+SIMDAG_SRC= simdag/sd_global.c simdag/sd_link.c simdag/sd_task.c simdag/sd_workstation.c
+
+GRAS_COMMON_SRC= \
+ gras/gras.c \
+ gras/Transport/transport.c gras/Transport/transport_private.h \
+ gras/Msg/gras_msg_mod.c gras/Msg/gras_msg_types.c \
+ gras/Msg/gras_msg_exchange.c gras/Msg/gras_msg_listener.c \
+ gras/Msg/rpc.c gras/Msg/timer.c \
+ gras/Msg/msg_interface.h gras/Msg/msg_private.h \
+ \
+ gras/Virtu/process.c gras/Virtu/gras_module.c \
+ \
+ gras/DataDesc/ddt_create.c \
+ gras/DataDesc/ddt_convert.c gras/DataDesc/ddt_exchange.c \
+ gras/DataDesc/cbps.c gras/DataDesc/datadesc.c \
+ gras/DataDesc/datadesc_interface.h gras/DataDesc/datadesc_private.h \
+ gras/DataDesc/ddt_parse.c gras/DataDesc/ddt_parse.yy.c gras/DataDesc/ddt_parse.yy.h
+
+GRAS_RL_SRC= \
+ gras/rl_stubs.c xbt/xbt_os_thread.c \
+ \
+ gras/Transport/rl_transport.c \
+ gras/Transport/transport_plugin_file.c gras/Transport/transport_plugin_tcp.c \
+ \
+ gras/Virtu/rl_emul.c \
+ gras/Virtu/rl_process.c \
+ gras/Virtu/rl_dns.c\
+ \
+ gras/Msg/rl_msg.c
+
+GRAS_RL_SRC+=$(XBT_RL_SRC)
+
+GRAS_SG_SRC= gras/Transport/sg_transport.c gras/Transport/transport_plugin_sg.c \
+ \
+ gras/Virtu/sg_emul.c \
+ gras/Virtu/sg_process.c \
+ gras/Virtu/sg_dns.c\
+ \
+ gras/Msg/sg_msg.c
+
+GRAS_SG_SRC+=$(XBT_SG_SRC)
+
+AMOK_SRC= \
+ amok/amok_base.c \
+ amok/Bandwidth/bandwidth.c amok/Bandwidth/saturate.c \
+ amok/PeerManagement/peermanagement.c
+
+##############################
+# Deal with optional modules #
+##############################
+
+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)