+##
+## 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
+ ./mk_supernovae.sh supernovae_sg.c $(filter-out $(simgrid_fragile_sources),$(simgrid_sources))
+supernovae_gras.c: Makefile.am
+ ./mk_supernovae.sh supernovae_gras.c $(filter-out $(gras_fragile_sources),$(gras_sources))
+supernovae_smpi.c: Makefile.am
+ ./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
+
+