Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
This is needed during make dist, which may occure before make all. So explicit our...
[simgrid.git] / tools / gras / stub_generator.c
index fde4e0f..f6445cf 100644 (file)
@@ -8,10 +8,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include"xbt/sysdep.h"
-#include"xbt/dict.h"
-#include"xbt/dynar.h"
-#include"xbt/error.h"
+#include "xbt/sysdep.h"
 #include "surf/surf_parse.h"
 #include "surf/surf.h"
 
@@ -67,23 +64,6 @@ const char *SIM_PREEMBULE =
 "  return retcode;\n" \
 "}\n"
 
-#define SIM_MAIN_PREEMBULE \
-"int main (int argc,char *argv[]) {\n" \
-"  int i,j;\n" \
-"\n" \
-"  /*  Simulation setup */\n" \
-"  MSG_global_init_args(&argc,argv);\n" \
-"  if (argc != 3) {\n" \
-"    fprintf(stderr, \"Usage: %%s platform_file application_description.txt [--gras-log=...]\\n\",argv[0]);\n" \
-"    exit(1);\n" \
-"  }\n" \
-"\n" \
-"  MSG_paje_output(\"%s.trace\");\n" \
-"  MSG_set_channel_number(10); /* Using at most 10 channel (ports) per host. Change it here if needed */\n" \
-"  MSG_create_environment(argv[1]);\n" \
-"\n" \
-"  /*  Application deployment */\n"
-
 const char *SIM_MAIN_POSTEMBULE = "\n"
 "\n"
 "  MSG_launch_application(argv[2]);\n"
@@ -181,7 +161,23 @@ static void generate_sim(char *project)
   }
   fprintf(OUT, "\n%s\n",warning);
 
-  fprintf(OUT, SIM_MAIN_PREEMBULE, project);
+  fprintf(OUT, "%s", "int main (int argc,char *argv[]) {\n" 
+                     "  int i,j;\n" 
+                     "\n" 
+                    "  /*  Simulation setup */\n" 
+                     "  MSG_global_init_args(&argc,argv);\n" 
+                     "  if (argc != 3) {\n" 
+                     "    fprintf(stderr, \"Usage: %s platform_file application_description.txt [--gras-log=...]\\n\",argv[0]);\n" 
+                     "    exit(1);\n" 
+                     "  }\n"
+                     "\n");
+   fprintf(OUT, 
+          "  MSG_paje_output(\"%s.trace\");\n" 
+          "  MSG_set_channel_number(10); /* Using at most 10 channel (ports) per host. Change it here if needed */\n" 
+          "  MSG_create_environment(argv[1]);\n" 
+          "\n" 
+          "  /*  Application deployment */\n",
+          project);
   xbt_dict_foreach(process_function_set,cursor,key,data) {
     fprintf(OUT,"  MSG_function_register(\"%s\", launch_%s);\n",key,key);
   }
@@ -316,7 +312,7 @@ static void generate_makefile_local(char *project, char *deployment)
   fprintf(OUT, 
          "DISTDIR=gras-$(PROJECT_NAME)\n\n"
          "GRAS_ROOT?= $(shell echo \"\\\"<<<< GRAS_ROOT undefined !!! >>>>\\\"\")\n"
-         "CFLAGS = -O3 -w\n"
+         "CFLAGS = -O3 -w -g\n"
          "INCLUDES = -I$(GRAS_ROOT)/include\n"
          "LIBS_SIM = -lm  -L$(GRAS_ROOT)/lib/ -lsimgrid\n"
          "LIBS_RL = -lm  -L$(GRAS_ROOT)/lib/ -lgras\n"
@@ -366,15 +362,22 @@ static void generate_makefile_local(char *project, char *deployment)
          "\n"
          "dist: clean distdir\n"
          "\ttar c $(DISTDIR) | gzip -c > $(DISTDIR).tar.gz\n"
-         "\n"
+         "\n", project, project);
+
+  fprintf(OUT,
          "clean:\n"
-         "\trm -f $(BIN_FILES) $(OBJ_FILES) *~\n"
+         "\trm -f $(BIN_FILES) $(OBJ_FILES) *~ %s.o " SIM_OBJNAME, project, project);
+  xbt_dict_foreach(process_function_set,cursor,key,data) {
+     fprintf(OUT, " " RL_OBJNAME, project, key);
+  }
+  fprintf(OUT,   
+         "\n"
          "\trm -rf $(DISTDIR)\n"
          "\n"
          ".SUFFIXES:\n"
          ".PHONY : clean\n"
-         "\n", project, project);
-
+         "\n");
+   
   fprintf(OUT, "############ REMOTE COMPILING #########\n");
   fprintf(OUT, 
          "MACHINES ?= ");