+
+###
+### Declare the library content
+###
+
+lib_LTLIBRARIES= libsimgrid.la libgras.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
+
+##
+## Java cruft
+
+if HAVE_JAVA
+lib_LTLIBRARIES += libsimgrid4java.la
+
+libsimgrid4java_la_SOURCES = $(XBT_SRC) $(SURF_SRC) $(GTNETS_USED) $(SDP_SRC) \
+ $(SIMIX_SRC) $(JCTX_SRC) \
+ $(JMSG_C_SRC) $(MSG_SRC) \
+ $(GRAS_COMMON_SRC) $(GRAS_SG_SRC) $(AMOK_SRC)
+libsimgrid4java_la_LDFLAGS = -no-undefined $(VERSION_INFO) @SIMGRID_DEP@ @LD_DYNAMIC_FLAGS@ -lm
+libsimgrid4java_la_GCJFLAGS = -fjni
+
+clean-local:
+ -rm -rf .classes
+
+jardir = $(prefix)/jar
+jar_DATA = simgrid.jar
+
+simgrid.jar: $(JMSG_JAVA_SRC)
+ [ -e .classes ] || mkdir .classes
+ $(JAVAC) -sourcepath java -d .classes $(JMSG_JAVA_SRC)
+ $(JAR) cvf simgrid.jar -C .classes .;
+else
+EXTRA_DIST += $(JCTX_SRC) $(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/config.c
+TEST_UNITS= ./cunit_unit.c ./ex_unit.c \
+ ./dynar_unit.c ./dict_unit.c ./set_unit.c ./swag_unit.c \
+ ./xbt_str_unit.c \
+ ./config_unit.c
+
+BUILT_SOURCES=../include/surf/surfxml.h surf/surfxml.c \
+ ../include/xbt/graphxml.h xbt/graphxml.c \
+ gras/DataDesc/ddt_parse.yy.c \
+ $(TEST_UNITS) simgrid_units_main.c
+
+testall_SOURCES= $(TEST_UNITS) simgrid_units_main.c
+testall_LDADD=libgras.la
+TESTS=testall
+TESTS_ENVIRONMENT=$(SG_TEST_EXENV)
+
+EXTRA_DIST+=$(testall_SOURCES)
+
+if MAINTAINER_MODE
+./cunit_unit.c: xbt/cunit.c
+ @top_srcdir@/tools/sg_unit_extractor.pl $^
+./ex_unit.c: xbt/ex.c
+ @top_srcdir@/tools/sg_unit_extractor.pl $^
+./xbt_str_unit.c: xbt/xbt_str.c
+ @top_srcdir@/tools/sg_unit_extractor.pl $^
+./dynar_unit.c: xbt/dynar.c
+ @top_srcdir@/tools/sg_unit_extractor.pl $^
+./dict_unit.c: xbt/dict.c
+ @top_srcdir@/tools/sg_unit_extractor.pl $^
+./set_unit.c: xbt/set.c
+ @top_srcdir@/tools/sg_unit_extractor.pl $^
+./swag_unit.c: xbt/swag.c
+ @top_srcdir@/tools/sg_unit_extractor.pl $^
+./config_unit.c: xbt/config.c
+ @top_srcdir@/tools/sg_unit_extractor.pl $^
+
+simgrid_units_main.c: $(TEST_UNITS)
+ @top_srcdir@/tools/sg_unit_extractor.pl xbt/cunit.c
+
+clean-units:
+ rm -f simgrid_units_main.c *_unit.c
+
+else
+
+$(TEST_UNITS) simgrid_units_main.c clean-units:
+ @echo "ERROR: Test units not generated."
+ @echo "ERROR: If you are using a CVS checkout, configure with the --enable-maintainer-mode flag"
+ @echo "ERROR: If not, please report the bug to the simgrid-devel mailing list."
+ @exit 1
+
+endif
+
+###
+### Regenerate what needs to with flex & flexml
+###
+
+
+gras/DataDesc/ddt_parse.yy.c: gras/DataDesc/ddt_parse.yy.l
+ set -e;@LEX@ -o$@ -Pgras_ddt_parse_ --noline $^
+
+if MAINTAINER_MODE
+surf/surfxml.c: surf/surfxml.l
+ set -e;mkdir -p `dirname $@`; @LEX@ -o$@ -Psurf_parse_ --noline $^
+xbt/graphxml.c: xbt/graphxml.l
+ set -e;mkdir -p `dirname $@`; @LEX@ -o$@ -Pxbt_graph_parse_ --noline $^
+
+if HAVE_FLEXML
+surf/surfxml.l: $(srcdir)/surf/surfxml.dtd
+ set -e; mkdir -p surf; flexml -b 1000000 -P surfxml --sysid=surfxml.dtd -S $@ -L $^
+$(top_srcdir)/include/surf/surfxml.h: $(srcdir)/surf/surfxml.dtd
+ set -e; flexml -P surfxml --sysid=surfxml.dtd -H $@ -L $^
+
+xbt/graphxml.l: $(srcdir)/xbt/graphxml.dtd
+ set -e; flexml -b 1000000 -P graphxml --sysid=graphxml.dtd -S $@ -L $^
+$(top_srcdir)/include/xbt/graphxml.h: $(srcdir)/xbt/graphxml.dtd
+ set -e; flexml -P graphxml --sysid=graphxml.dtd -H $@ -L $^
+else
+
+$(top_srcdir)/include/surf/surfxml.h surf/surfxml.l: $(top_srcdir)/src/surf/surfxml.dtd
+ @echo "ERROR: src/surf/surfxml.dtd was modified, but the flexml program was not detected"
+ @echo "ERROR: Please install it, or if you didn't modify this file, try this:"
+ @echo "ERROR: touch include/surf/surfxml.h src/surf/surfxml.l"
+ @exit 1
+$(top_srcdir)/include/xbt/graphxml.h xbt/graphxml.l: $(top_srcdir)/src/xbt/graphxml.dtd
+ @echo "ERROR: src/xbt/graphxml.dtd was modified, but the flexml program was not detected"
+ @echo "ERROR: Please install it, or if you didn't modify this file, try this:"
+ @echo "ERROR: touch include/xbt/graphxml.h src/xbt/graphxml.l"
+ @exit 1
+endif
+endif
+endif
+
+include $(top_srcdir)/acmacro/dist-files.mk