+if HAVE_GTNETS
+ GTNETS_USED=$(GTNETS_SRC)
+else
+ GTNETS_USED=
+ EXTRA_DIST+=$(GTNETS_SRC)
+endif
+
+if HAVE_SDP
+ SDP_SRC= surf/sdp.c
+else
+ SDP_SRC=
+ EXTRA_DIST+=surf/sdp.c
+endif
+
+###
+### Declare the library content
+###
+
+lib_LTLIBRARIES= libsimgrid.la libgras.la libsmpi.la
+
+libgras_la_SOURCES= $(XBT_SRC) $(GRAS_COMMON_SRC) $(GRAS_RL_SRC) $(AMOK_SRC)
+libgras_la_LDFLAGS = -no-undefined $(VERSION_INFO) @GRAS_DEP@ @LD_DYNAMIC_FLAGS@ -lm
+
+libsimgrid_la_SOURCES = $(XBT_SRC) $(SURF_SRC) $(GTNETS_USED) $(SDP_SRC) \
+ $(SIMIX_SRC) $(CTX_SRC) \
+ $(MSG_SRC) $(SIMDAG_SRC) \
+ $(GRAS_COMMON_SRC) $(GRAS_SG_SRC) $(AMOK_SRC)
+libsimgrid_la_LDFLAGS = -no-undefined $(VERSION_INFO) @SIMGRID_DEP@ @LD_DYNAMIC_FLAGS@ -lm
+# -Wl,--entry -Wl,simgrid_version
+
+# Please do not add -no-undefined to libsmpi_la_LDFLAGS:
+# smpi_simulated_main is indeed defined in user code, and undef in the
+# library (no idea why it works under linux, but it fails under windows)
+libsmpi_la_LIBADD = libsimgrid.la
+libsmpi_la_SOURCES = $(SMPI_SRC)
+libsmpi_la_LDFLAGS = $(VERSION_INFO) @SMPI_DEP@ @LD_DYNAMIC_FLAGS@ -lm
+
+# Windows users (at least, MSVC ones) need a def file.
+if IS_WINDOWS
+libgras_la_LDFLAGS += -Wl,--output-def,libgras.def
+libsimgrid_la_LDFLAGS += -Wl,--output-def,libsimgrid.def
+libsmpi_la_LDFLAGS += -Wl,--output-def,libsmpi.def
+endif
+
+##
+## Java cruft
+
+EXTRA_DIST+=$(JMSG_JAVA_SRC)
+
+if HAVE_JAVA
+libsimgrid_la_SOURCES += $(JMSG_C_SRC) # add the binding support to the library
+
+clean-local:
+ -rm -rf .classes
+
+jardir = $(prefix)/jar
+jar_DATA = simgrid.jar
+
+simgrid.jar: $(JMSG_JAVA_SRC) $(srcdir)/surf/simgrid.dtd
+ [ -e .classes ] || mkdir .classes
+ $(JAVAC) -d .classes $(foreach file,$(JMSG_JAVA_SRC),$(srcdir)/$(file))
+ [ -e .classes/surf ] || mkdir .classes/surf
+ cp $(srcdir)/surf/simgrid.dtd .classes/surf
+ $(JAR) cvf simgrid.jar -C .classes .
+else
+EXTRA_DIST+=$(JMSG_C_SRC) $(MSG_SRC)
+endif
+
+if GRAMINE_MODE
+else
+###
+### Testing infrastructure
+###
+
+# Test files must be added both to the TEST_CFILES and TEST_UNITS because
+# if I compute TEST_UNITS from TEST_CFILES, automake fails to note that they
+# are generated. Sorry about that.
+
+# If you add a test unit, you should regenerate simgrid_units_main.c from scratch:
+# make clean-units ; make testall
+
+# Suites and tests run in the given order.
+
+noinst_PROGRAMS=testall
+TEST_CFILES=xbt/cunit.c xbt/ex.c \
+ xbt/dynar.c xbt/dict.c xbt/set.c xbt/swag.c \
+ xbt/xbt_str.c xbt/xbt_sha.c \
+ xbt/config.c
+TEST_UNITS= @builddir@/cunit_unit.c @builddir@/ex_unit.c \
+ @builddir@/dynar_unit.c @builddir@/dict_unit.c @builddir@/set_unit.c @builddir@/swag_unit.c \
+ @builddir@/xbt_str_unit.c @builddir@/xbt_strbuff_unit.c @builddir@/xbt_sha_unit.c\
+ @builddir@/config_unit.c
+
+BUILT_SOURCES=../include/surf/simgrid_dtd.h surf/simgrid_dtd.c \
+ ../include/xbt/graphxml.h xbt/graphxml.c \
+ gras/DataDesc/ddt_parse.yy.c \
+ $(TEST_UNITS) @builddir@/simgrid_units_main.c
+
+testall_SOURCES= $(TEST_UNITS) @builddir@/simgrid_units_main.c
+testall_LDADD=libgras.la
+TESTS=testall
+TESTS_ENVIRONMENT=$(SG_TEST_EXENV)
+
+EXTRA_DIST+=$(testall_SOURCES)