+MC_SRC= \
+ mc/mc_memory.c mc/mc_checkpoint.c \
+ mc/memory_map.c mc/mc_global.c \
+ mc/mc_dfs.c mc/mc_dpor.c \
+ mc/mc_transition.c
+
+##############################
+# Deal with optional modules #
+##############################
+
+if HAVE_GTNETS
+ GTNETS_USED=$(GTNETS_SRC)
+else
+ GTNETS_USED=
+ EXTRA_DIST+=$(GTNETS_SRC)
+endif
+
+###
+### Declare the library content
+###
+
+lib_LTLIBRARIES= libsimgrid.la libgras.la libsmpi.la
+
+gras_sources=$(XBT_SRC) $(GRAS_COMMON_SRC) $(GRAS_RL_SRC) $(AMOK_SRC)
+simgrid_sources=$(XBT_SRC) $(SURF_SRC) $(GTNETS_USED) \
+ $(SIMIX_SRC) $(MC_SRC) $(MSG_SRC) $(SIMDAG_SRC) \
+ $(GRAS_COMMON_SRC) $(GRAS_SG_SRC) $(AMOK_SRC) \
+ $(TRACING_SRC)
+
+
+libgras_la_LDFLAGS = -no-undefined $(VERSION_INFO) @GRAS_DEP@ @LD_DYNAMIC_FLAGS@ -lm
+
+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
+
+if HAVE_RUBY
+lib_LTLIBRARIES += simgrid_ruby.la
+simgrid_ruby_la_LIBADD = libsimgrid.la
+simgrid_ruby_la_SOURCES = bindings/ruby/simgrid_ruby.c
+simgrid_ruby_la_LDFLAGS = $(VERSION_INFO) @LD_DYNAMIC_FLAGS@ -lm -module
+endif
+
+# Windows users (at least, MSVC ones) need a def file. (and JNI dont like @ cruft added to symbols)
+if IS_WINDOWS
+libgras_la_LDFLAGS += -Wl,--output-def,libgras.def
+libsimgrid_la_LDFLAGS += -Wl,--output-def,libsimgrid.def -Wl,--kill-at
+libsmpi_la_LDFLAGS += -Wl,--output-def,libsmpi.def
+endif
+
+##
+## Java cruft
+
+EXTRA_DIST+=$(JMSG_JAVA_SRC)
+
+if HAVE_JAVA
+simgrid_sources += $(JMSG_C_SRC) # add the binding support to the library
+
+clean-local:
+ -rm -rf .classes simgrid.jar
+
+jardir = $(prefix)/jar
+jar_DATA = simgrid.jar
+
+simgrid.jar: $(JMSG_JAVA_SRC)
+ [ -e .classes ] || mkdir .classes
+ $(JAVAC) -d .classes -source 6 $(foreach file,$(JMSG_JAVA_SRC),$(srcdir)/$(file))
+ [ -e .classes/surf ] || mkdir .classes/surf
+ $(JAR) cvf simgrid.jar -C .classes .
+else
+EXTRA_DIST+=$(JMSG_C_SRC) $(JMSG_JAVA_SRC) $(MSG_SRC) $(TRACING_SRC)
+endif
+
+LUA_SRC= simix/smx_context_lua.c bindings/lua/simgrid_lua.c #bindings/lua/Msglua.c
+if HAVE_LUA
+ simgrid_sources += $(LUA_SRC)
+else
+ EXTRA_DIST += $(LUA_SRC)
+endif
+
+RUBY_SRC= simix/smx_context_ruby.c \
+ bindings/ruby/rb_msg_process.c \
+ bindings/ruby/rb_msg_host.c \
+ bindings/ruby/rb_msg_task.c \
+ bindings/ruby/rb_application_handler.c
+if HAVE_RUBY
+ simgrid_sources += $(RUBY_SRC)
+else
+ EXTRA_DIST += $(RUBY_SRC)
+endif
+##
+## Compile the libs
+CLEANFILES=supernovae_sg.c supernovae_gras.c supernovae_smpi.c
+BUILT_SOURCES=
+
+# Cannot let automake autocompute the content of dist from
+# lib*_la_SOURCES variables since it would include supernovae files,
+# which are only generated sometimes, not always.
+# So, use nodist_lib*_la_SOURCES variables and add stuff to EXTRA_DIST manually
+
+EXTRA_DIST+=$(simgrid_sources) $(gras_sources)
+
+if SUPERNOVAE_MODE
+simgrid_fragile_sources=gras/DataDesc/ddt_parse.yy.c surf/surfxml_parse.c xbt/graphxml_parse.c simdag/sd_daxloader.c
+gras_fragile_sources=gras/DataDesc/ddt_parse.yy.c xbt/graphxml_parse.c
+BUILT_SOURCES+=supernovae_sg.c supernovae_gras.c supernovae_smpi.c
+
+supernovae_sg.c: Makefile.am
+ @top_srcdir@/src/mk_supernovae.sh supernovae_sg.c $(filter-out $(simgrid_fragile_sources),$(simgrid_sources))
+supernovae_gras.c: Makefile.am
+ @top_srcdir@/src/mk_supernovae.sh supernovae_gras.c $(filter-out $(gras_fragile_sources),$(gras_sources))
+supernovae_smpi.c: Makefile.am
+ @top_srcdir@/src/mk_supernovae.sh supernovae_smpi.c $(filter-out $(smpi_fragile_sources),$(smpi_sources))
+
+nodist_libsimgrid_la_SOURCES = supernovae_sg.c $(simgrid_fragile_sources)
+nodist_libgras_la_SOURCES = supernovae_gras.c $(gras_fragile_sources)
+else
+nodist_libsimgrid_la_SOURCES = $(simgrid_sources)
+nodist_libgras_la_SOURCES = $(gras_sources)
+endif
+
+