Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Changes to test gras_simix.
[simgrid.git] / tools / gras / stub_generator.c
1 /*      $Id$     */
2
3 /* gras_stub_generator - creates the main() to use a GRAS program           */
4
5 /* Copyright (c) 2003-2007 Martin Quinson, Arnaud Legrand, Malek Cherier.   */
6 /* All rights reserved.                                                     */
7
8 /* This program is free software; you can redistribute it and/or modify it
9  * under the terms of the license (GNU LGPL) which comes with this package. */
10
11 /* specific to Borland Compiler */
12 #ifdef __BORLANDDC__
13 #pragma hdrstop
14 #endif
15
16 #include <stdio.h>
17 #include "xbt/sysdep.h"
18 #include "xbt/function_types.h"
19 #include "xbt/log.h"
20 #include "surf/surfxml_parse.h"
21 #include "surf/surf.h"
22
23 #include <stdarg.h>
24
25
26
27 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(stubgen,gras,"Stub generator");
28
29 #ifdef _WIN32
30
31 /* tabulation level (used to indent the lines of the borland project file */
32 static unsigned int level = 0;
33
34
35
36 /* the gras.h header directory */
37 static char* __gras_path = NULL;
38
39
40 #ifndef MAX_PATH
41 #define MAX_PATH 260
42 #endif
43
44 /*
45  * A structure which represents a borland project file.
46  */
47 typedef struct s_borland_project
48 {
49     const char* xml_version;/* the xml version used to write the borland project file                   */
50     const char* encoding;   /* the encoding used to write the borland project file                      */
51     const char* comment;    /* the xml comment to write at the begining of the borland project file     */
52         char* name;                     /* the name of the borland project file                                                                         */
53         FILE* stream;                   /* the stream to the borland project file                                                                       */
54         const char* version;    /* the builder version of the borland project file                                                      */
55         char* bin_dir;          /* the directory used to store the generated program                                            */
56         char* obj_dir;          /* the directory used to store the generated object files                                       */
57         char* lib_dir;          /* the directory used to store the librairies used in the borland project       */
58         char* src_dir;          /* the directory use to store the source files of the project                           */
59 }s_borland_project_t,* borland_project_t;
60
61
62 /*
63  * A structure which represents a visual C++ project file.
64  */
65 typedef struct s_dsp
66 {
67         FILE* stream;
68         char* lib_dir;
69         char* src_dir;
70         char* name;
71 }s_dsp_t,* dsp_t;
72
73 /*
74  * Write tabs in a borland project file.
75  * @param project The project concerned by the operation.
76  * @param count The count tab to write
77  */
78 void
79 borland_project_write_tabs(borland_project_t project,unsigned int count);
80
81 /*
82  * Write the begin of an xml node in the borland project file.
83  * @param project The borland project concerned by this operation.
84  * @param name The name of the node.
85  */
86 void
87 borland_project_begin_xml_node(borland_project_t project, const char* name);
88
89
90 /*
91  * Write the end of an xml node in the borland project file.
92  * @param project The borland project concerned by this operation.
93  * @param name The name of the node.
94  */
95 void
96 borland_project_end_xml_node(borland_project_t project, const char* name);
97
98 /*
99  * Write an xml element in a borland project file.
100  * @param project The borland project concerned by this operation.
101  * @param name The name of the element to write
102  * @param value The value of the element  
103  */
104 void
105 borland_project_write_xml_element(borland_project_t project,const char* name,const char* value);
106
107 /*
108  * Write a FILE xml element in the borland project file.
109  * @param project The borland project concerned by this operation.
110  * @param file_name The value of the attribute FILENAME.
111  * @param form_name The value of the attribute FORMNAME.
112  * @param unit_name The value of the attribute UNITNAME.
113  * @param container_id The value of the attribute CONTAINERID.
114  * @param design_claas The value of the attribute DESIGNCLASS.
115  * @param local_command The value of the attribute LOCALCOMMAND.
116  */
117 void
118 borland_project_write_file_element(     borland_project_t project,
119                                                                         const char* file_name,
120                                                                         const char* form_name,
121                                                                         const char* unit_name,
122                                                                         const char* container_id,
123                                                                         const char* design_class,
124                                                                         const char* local_command);
125 /*
126  * Write all options of the IDE of the Borland Builder C++ compiler.
127  * @ param project The project concerned by this operation.
128  */
129
130 void
131 borland_project_write_ide_options(borland_project_t project);
132
133 /*
134  * Write the xml header of the xml document.
135  * @param project The project concerned by the operation.
136  */
137 void
138 borland_project_write_xml_header(borland_project_t project);
139
140 /*
141  * Write an xml comment in a borland project file
142  * @param project The project concerned by this operation.
143  */
144 void
145 borland_project_write_xml_comment(borland_project_t project);
146
147 /*
148  * Create a bpf file used by a borland project file.
149  * @param name The name of the bpf file to create.
150  */
151 void
152 borland_project_create_main_file(const char* name);
153
154 /*
155  * Create a borland project file.
156  * @param project The project concerned by this operation.
157  */
158 void
159 borland_project_create(borland_project_t project);
160
161 /*
162  * Close a borland project file.
163  * @param project the borland project file to close.
164  */
165 void
166 borland_project_close(borland_project_t project);
167
168
169 /*
170  * Generate a borland simulation poject file.
171  * @param name The name of the simulation project
172  */
173 void
174 generate_borland_simulation_project(const char* name);
175
176 /*
177  * Generate a borland project file for real life.
178  * @param name The name of the project to create.
179  */
180 void
181 generate_borland_real_life_project(const char* name);
182
183 /*
184  * Generate a borland project file.
185  * @param project The borland project to generate.
186  */
187 void
188 generate_borland_project(borland_project_t project,int is_rl,const char* name);
189
190 /*
191  * Find the path of a file.
192  * @param file_name The file name to find.
193  * @path path If founded this parameter will contain the path of file.
194  * @return If successful the function returns 1. Otherwise the function
195  *  retruns 0;
196  */
197 int
198 find_file_path(const char* root_dir,const char* file_name,char* path);
199
200
201 /*
202  * Functions used to create a Microsoft Visual C++ project file (*.dsp).
203  */
204
205 /*
206  * Create the Microsoft visual C++ file project for the simulation.
207  */
208 int
209 generate_simulation_dsp_file(const char* project_name);
210
211 /*
212  * Create the Microsoft visual C++ real life project file.
213  */
214 int
215 generate_real_live_dsp_file(const char* project_name);
216
217 /*
218  * generate a Microsoft Visual project file*/
219 void
220 generate_dsp_project(dsp_t project,int is_rl,const char* name);
221
222 #endif
223
224
225
226 #define WARN "/***********\n * DO NOT EDIT! THIS FILE HAS BEEN AUTOMATICALLY GENERATED FROM %s BY gras_stub_generator\n ***********/\n"
227 #define SIM_SOURCENAME  "_%s_simulator.c"
228 #define SIM_OBJNAME  "_%s_simulator.o"
229 #define SIM_BINARYNAME  "%s_simulator"
230 #define SIM_SOURCENAME_LDADD  "%s_simulator_LDADD"
231 #define SIM_SOURCENAME_SOURCES  "%s_simulator_SOURCES"
232 #define RL_SOURCENAME  "_%s_%s.c"
233 #define RL_OBJNAME  "_%s_%s.o"
234 #define RL_BINARYNAME  "%s_%s"
235 #define RL_SOURCENAME_LDADD  "%s_%s_LDADD"
236 #define RL_SOURCENAME_SOURCES  "%s_%s_SOURCES"
237 #define MAKEFILE_FILENAME_AM  "%s.Makefile.am"
238 #define MAKEFILE_FILENAME_LOCAL  "%s.mk"
239 #define MAKEFILE_FILENAME_REMOTE  "%s.Makefile.remote"
240 #define DEPLOYMENT  "%s.deploy.sh"
241
242 char *warning = NULL;
243
244 /**********************************************/
245 /**** Generate the file for the simulator *****/
246 /**********************************************/
247
248 const char *SIM_PREEMBULE =
249 "/* specific to Borland Compiler */\n"
250 "#ifdef __BORLANDC__\n"
251 "#pragma hdrstop\n"
252 "#endif\n\n"
253 "#include <stdlib.h>\n"
254 "#include <stdio.h>\n"
255 "#include \"msg/msg.h\"\n"
256 "#include <gras.h>\n"
257 "\n"
258 "char *gras_log=NULL;\n";
259
260
261 #define SIM_LAUNCH_FUNC  \
262 "int launch_%s(int argc, char **argv) {\n" \
263 "  char **myargv=argv;\n" \
264 "  int myargc=argc;\n" \
265 "  int i;\n" \
266 "  int retcode;\n"\
267 "    \n"\
268 "  if (gras_log) {\n"\
269 "    myargv=malloc((argc+1) * sizeof(char**));\n" \
270 "    for (i=0; i<argc; i++)\n" \
271 "      myargv[i] = argv[i];\n" \
272 "    myargv[myargc++] = gras_log;\n" \
273 "  }\n" \
274 "  retcode = %s(myargc,myargv);\n" \
275 "  if (myargv != argv)\n" \
276 "    free(myargv);\n" \
277 "  return retcode;\n" \
278 "}\n"
279
280 const char *SIM_MAIN_POSTEMBULE = "\n"
281 "\n"
282 "  gras_launch_application(argv[2]);\n"
283 "\n"
284 "  /*  Run the simulation */\n"
285 "  gras_main();\n"
286 "\n"
287 "  /* cleanup the place */\n"
288 "  gras_clean();\n"
289 "  if (gras_log)\n"
290 "    free(gras_log);\n"
291 "  return 0;\n"
292 "}\n";
293
294
295
296 /**********************************************/
297 /********* Parse XML deployment file **********/
298 /**********************************************/
299 xbt_dict_t process_function_set = NULL;
300 xbt_dynar_t process_list = NULL;
301 xbt_dict_t machine_set = NULL;
302
303 typedef struct s_process_t {
304   int argc;
305   char **argv;
306   char *host;
307 } s_process_t;
308
309 static void s_process_free(void *process)
310 {
311   int i;
312   for(i=0;i<((s_process_t*)process)->argc; i++)
313     free(((s_process_t*)process)->argv[i]);
314   free(((s_process_t*)process)->host);
315 }
316
317 static s_process_t process;
318
319 /*
320  * Création de deux dictionnaires
321  */
322 static void parse_process_init(void)
323 {
324   xbt_dict_set(process_function_set, A_surfxml_process_function, NULL, NULL);
325   xbt_dict_set(machine_set, A_surfxml_process_host, NULL, NULL);
326   process.argc = 1 ;
327   process.argv = xbt_new(char*,1);
328   process.argv[0] = xbt_strdup(A_surfxml_process_function);
329   process.host=strdup(A_surfxml_process_host);
330   /*VERB1("Function: %s",A_surfxml_process_function);*/
331 }
332
333 static void parse_argument(void)
334 {
335   process.argc++;
336   process.argv = xbt_realloc(process.argv, (process.argc) * sizeof(char *));
337   process.argv[(process.argc) - 1] = xbt_strdup(A_surfxml_argument_value);
338 }
339
340 static void parse_process_finalize(void)
341 {
342   xbt_dynar_push(process_list,&process);
343   /*VERB1("Function: %s",process.argv[0]);*/
344 }
345
346 static void generate_sim(char *project)
347 {
348         xbt_dict_cursor_t cursor=NULL;
349         char *key = NULL;
350         void *data = NULL;
351         char *filename = NULL;
352         FILE *OUT = NULL;
353         
354         /* 
355          * Creation d'un fichier nommé : <projet>_simulator.c 
356          */
357  
358
359         filename = xbt_new(char,strlen(project) + strlen(SIM_SOURCENAME));
360         sprintf(filename,SIM_SOURCENAME,project);
361         
362         OUT=fopen(filename,"w");
363         
364         
365         xbt_assert1(OUT, "Unable to open %s for writing",filename);
366         
367         /*
368          * Ecriture du message d'avertissement.
369          */
370         fprintf(OUT, "%s\n",warning);
371         
372         /*
373          * Ecriture du préambule (inclusion de certains fichiers d'en-tête
374          */
375         fprintf(OUT, "%s", SIM_PREEMBULE);
376         
377         /*
378          * Déclaration des fonction int <process>(int argc,char *argv[]);
379          */
380         xbt_dict_foreach(process_function_set,cursor,key,data) {
381                 fprintf(OUT,"int %s(int argc,char *argv[]);\n",key);
382         }
383         
384         fprintf(OUT,"\n");
385         
386         /*
387          * Déclaration des fonction int launch_<process>(int argc,char *argv[]);
388          */
389         xbt_dict_foreach(process_function_set,cursor,key,data) {
390         fprintf(OUT,"int launch_%s(int argc,char *argv[]);\n",key);
391         }
392         
393         /*
394          * Ecriture du message d'avertissement.
395          */
396         fprintf(OUT, "\n%s\n",warning);
397
398         xbt_dict_foreach(process_function_set,cursor,key,data) {
399                 fprintf(OUT,SIM_LAUNCH_FUNC,key,key);
400         }
401         fprintf(OUT, "\n%s\n",warning);
402
403     fprintf(OUT,"%s", "/* specific to Borland Compiler */\n"
404     "#ifdef __BORLANDDC__\n"
405     "#pragma argsused\n"
406     "#endif\n\n");
407         
408         fprintf(OUT, "%s", "int main (int argc,char *argv[]) {\n"
409         "\n" 
410         "  /*  Simulation setup */\n" 
411         "  gras_global_init(&argc,argv);\n" 
412         "  if (argc != 3) {\n" 
413         "    fprintf(stderr, \"Usage: %s platform.xml deployment.xml [--gras-log=...]\\n\",argv[0]);\n" 
414         "    exit(1);\n" 
415         "  }\n"
416         "\n");
417         fprintf(OUT, 
418         "  //MSG_paje_output(\"%s.trace\");\n" 
419         "  //MSG_set_channel_number(XBT_MAX_CHANNEL); /* Using at most 10 channel (ports) per host. Change it here if needed */\n" 
420         "  gras_create_environment(argv[1]);\n" 
421         "\n" 
422         "  /*  Application deployment */\n",
423         project);
424         xbt_dict_foreach(process_function_set,cursor,key,data) {
425                 fprintf(OUT,"  gras_function_register(\"%s\", launch_%s);\n",key,key);
426         }
427         fprintf(OUT, "%s", SIM_MAIN_POSTEMBULE);
428         fclose(OUT);
429         free(filename);
430 }
431
432 /**********************************************/
433 /**** Generate the file for the real life *****/
434 /**********************************************/
435 static void generate_rl(char *project)
436 {
437   xbt_dict_cursor_t cursor=NULL;
438   char *key = NULL;
439   void *data = NULL;
440   char *filename = NULL;
441   FILE *OUT = NULL;
442
443   xbt_dict_foreach(process_function_set,cursor,key,data) {
444     filename = xbt_new(char,strlen(project) + strlen(RL_SOURCENAME) + strlen(key));
445
446         sprintf(filename,RL_SOURCENAME,project,key);
447
448     OUT=fopen(filename,"w");
449     xbt_assert1(OUT, "Unable to open %s for writing",filename);
450
451     fprintf(OUT, "\n%s\n",warning);
452     fprintf(OUT, "/* specific to Borland Compiler */\n" \
453                  "#ifdef __BORLANDC__\n" \
454                  "#pragma hdrstop\n" \
455                  "#endif\n\n" \
456                  "#include <stdio.h>\n" \
457                  "#include <signal.h>\n" \
458                  "#include <gras.h>\n" \
459                  "\n" \
460                  "extern const char * XBT_PUBLIC_DATA _gras_procname;\n" \
461                  "/* user code */\n" \
462                  "int %s(int argc, char *argv[]);\n" \
463                  "\n" \
464                  "/* specific to Borland Compiler */\n" \
465                 "#ifdef __BORLANDC__\n" \
466                 "#pragma argsused\n" \
467                 "#endif\n\n" \
468                  "int main(int argc, char *argv[]){\n" \
469                  "  int errcode;\n" \
470                  "\n" \
471                  "  _gras_procname = \"%s\";\n" \
472                  "  errcode=%s(argc,argv);\n"\
473                  " \n" \
474                  "  return errcode;\n"\
475                  "}\n",
476             key,key,key);
477     fprintf(OUT, "\n%s\n",warning);
478     fclose(OUT);
479     free(filename);
480   }
481 }
482
483 static void generate_makefile_am(char *project, char *deployment)
484 {
485   xbt_dict_cursor_t cursor=NULL;
486   char *key = NULL;
487   void *data = NULL;
488   char *filename = NULL;
489   FILE *OUT = NULL;
490
491   filename = xbt_new(char,strlen(project) + strlen(MAKEFILE_FILENAME_AM));
492   sprintf(filename,MAKEFILE_FILENAME_AM, project);
493
494   OUT=fopen(filename,"w");
495   xbt_assert1(OUT, "Unable to open %s for writing",filename);
496
497   fprintf(OUT, "# AUTOMAKE variable definition\n");
498   fprintf(OUT, "INCLUDES= @CFLAGS_SimGrid@\n\n");
499   fprintf(OUT, "PROGRAMS=");
500   fprintf(OUT, SIM_BINARYNAME,project);
501
502   xbt_dict_foreach(process_function_set,cursor,key,data) {
503     fprintf(OUT, " ");
504     fprintf(OUT, RL_BINARYNAME, project, key);
505   }
506
507   fprintf(OUT, "\n\n");
508   fprintf(OUT, SIM_SOURCENAME_SOURCES,project);
509   fprintf(OUT, "=\t");
510   fprintf(OUT, SIM_SOURCENAME,project);
511   fprintf(OUT, " %s.c\n", project);
512   fprintf(OUT, SIM_SOURCENAME_LDADD, project);
513   fprintf(OUT, "=\tpath/to/libsimgrid.a\n\n");
514
515   xbt_dict_foreach(process_function_set,cursor,key,data) {
516     fprintf(OUT, RL_SOURCENAME_SOURCES, project,key);
517     fprintf(OUT, "=\t");
518     fprintf(OUT, RL_SOURCENAME, project,key);
519     fprintf(OUT, " %s.c\n", project);
520     fprintf(OUT, RL_SOURCENAME_LDADD, project, key);
521     fprintf(OUT, "=\tpath/to/libgras.a\n\n");
522   }
523
524   fprintf(OUT, "\n# cleanup temps\n");
525   fprintf(OUT, "CLEANFILES= ");
526   fprintf(OUT, SIM_SOURCENAME, project);
527   
528   xbt_dict_foreach(process_function_set,cursor,key,data) {
529     fprintf(OUT, " ");
530     fprintf(OUT, RL_SOURCENAME, project,key);
531   }
532   fprintf(OUT, "\n");
533
534   fprintf(OUT, "\n# generate temps\n");
535   fprintf(OUT, "\n# A rule to generate the source file each time the deployment file changes\n");
536
537   xbt_dict_foreach(process_function_set,cursor,key,data) {
538     fprintf(OUT, RL_SOURCENAME, project,key);
539     fprintf(OUT, " ");
540   }
541   fprintf(OUT, SIM_SOURCENAME, project);
542   fprintf(OUT, ": %s\n", deployment);
543   fprintf(OUT, "\tgras_stub_generator %s %s >/dev/null\n", project, deployment);
544   fclose(OUT);
545 }
546
547 static void generate_makefile_local(char *project, char *deployment)
548 {
549   xbt_dict_cursor_t cursor=NULL;
550   char *key = NULL;
551   void *data = NULL;
552   char *filename = NULL;
553   FILE *OUT = NULL;
554
555   filename = xbt_new(char,strlen(project) + strlen(MAKEFILE_FILENAME_LOCAL));
556   sprintf(filename,MAKEFILE_FILENAME_LOCAL, project);
557   
558   OUT=fopen(filename,"w");
559   xbt_assert1(OUT, "Unable to open %s for writing",filename);
560   free(filename);
561    
562   fprintf(OUT,
563           "\n"
564           "####\n"
565           "#### THIS FILE WAS GENERATED, DO NOT EDIT BEFORE RENAMING IT\n"
566           "####\n\n\n");
567
568   fprintf(OUT,"## Variable declarations\n"
569               "PROJECT_NAME=%s\n"
570               "DISTDIR=gras-$(PROJECT_NAME)\n\n"
571           ,project);
572    
573   fprintf(OUT,
574           "# Set the GRAS_ROOT environment variable to the path under which you installed SimGrid\n"
575           "# Compilation will fail if you don't do so\n" 
576           "GRAS_ROOT?= $(shell echo \"\\\"<<<< GRAS_ROOT undefined !!! >>>>\\\"\")\n\n"
577           "# You can fiddle the following to make it fit your taste\n"
578           "INCLUDES = -I$(GRAS_ROOT)/include\n"
579           "CFLAGS ?= -O3 -w -g\n"
580           "LIBS_SIM = -lm  -L$(GRAS_ROOT)/lib/ -lsimgrid\n"
581           "LIBS_RL = -lm  -L$(GRAS_ROOT)/lib/ -lgras\n"
582           "LIBS = \n"
583           "\n");
584
585   fprintf(OUT, "PRECIOUS_C_FILES ?= %s.c\n", project);
586
587   fprintf(OUT, "GENERATED_C_FILES = ");
588   fprintf(OUT, SIM_SOURCENAME" ",project);
589   xbt_dict_foreach(process_function_set,cursor,key,data) {
590     fprintf(OUT, RL_SOURCENAME " ",project, key);
591   }
592   fprintf(OUT, "\n");
593
594   fprintf(OUT,"OBJ_FILES = $(patsubst %%.c,%%.o,$(PRECIOUS_C_FILES))\n");
595
596   fprintf(OUT, "BIN_FILES = ");
597
598   fprintf(OUT, SIM_BINARYNAME " ",project);
599   xbt_dict_foreach(process_function_set,cursor,key,data) {
600     fprintf(OUT, RL_BINARYNAME " ", project, key);
601   }
602   fprintf(OUT, "\n");
603
604   fprintf(OUT,
605           "\n"
606           "## By default, build all the binaries\n"
607           "all: $(BIN_FILES)\n"
608           "\n");
609    
610   fprintf(OUT, "\n## generate temps: regenerate the source file each time the deployment file changes\n");
611   xbt_dict_foreach(process_function_set,cursor,key,data) {
612     fprintf(OUT, RL_SOURCENAME, project,key);
613     fprintf(OUT, " ");
614   }
615   fprintf(OUT, SIM_SOURCENAME, project);
616   fprintf(OUT, ": %s\n", deployment);
617   fprintf(OUT, "\tgras_stub_generator %s %s >/dev/null\n", project, deployment);
618
619   fprintf(OUT, "\n## Generate the binaries\n");
620   fprintf(OUT, SIM_BINARYNAME ": " SIM_OBJNAME " $(OBJ_FILES)\n",project, project);
621   fprintf(OUT, "\t$(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS_SIM) $(LIBS) $(LDADD) -o $@ \n");
622   xbt_dict_foreach(process_function_set,cursor,key,data) {
623     fprintf(OUT, RL_BINARYNAME " : " RL_OBJNAME " $(OBJ_FILES)\n", project, key, project, key);
624     fprintf(OUT, "\t$(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS_RL) $(LIBS) $(LDADD) -o $@ \n");
625   }  
626   fprintf(OUT, 
627           "\n"
628           "%%: %%.o\n"
629           "\t$(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@ \n"
630           "\n"
631           "%%.o: %%.c\n"
632           "\t$(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $<\n"
633           "\n");
634    
635   fprintf(OUT,
636           "## Rules for tarballs and cleaning\n"
637           "DIST_FILES= $(EXTRA_DIST) $(GENERATED_C_FILES) $(PRECIOUS_C_FILES) "MAKEFILE_FILENAME_LOCAL" " /*MAKEFILE_FILENAME_REMOTE*/"\n"
638           "distdir: $(DIST_FILES)\n"
639           "\trm -rf $(DISTDIR)\n"
640           "\tmkdir -p $(DISTDIR)\n"
641           "\tcp $^ $(DISTDIR)\n"
642           "\n"
643           "dist: clean distdir\n"
644           "\ttar c $(DISTDIR) | gzip -c9 > $(DISTDIR).tar.gz\n"
645           "\n", project /*, project*/);
646
647   fprintf(OUT,
648           "clean:\n"
649           "\trm -f $(BIN_FILES) $(OBJ_FILES) *~ %s.o " SIM_OBJNAME, project, project);
650   xbt_dict_foreach(process_function_set,cursor,key,data) {
651      fprintf(OUT, " " RL_OBJNAME, project, key);
652   }
653   fprintf(OUT,   
654           "\n"
655           "\trm -rf $(DISTDIR)\n"
656           "\n"
657           ".SUFFIXES:\n"
658           ".PHONY : clean\n"
659           "\n");
660   /* 
661   fprintf(OUT, "############ REMOTE COMPILING #########\n");
662   fprintf(OUT, 
663           "MACHINES ?= ");
664   xbt_dict_foreach(machine_set,cursor,key,data) {
665     fprintf(OUT, "%s ",key);
666   }
667   fprintf(OUT,"\n");
668
669   fprintf(OUT, 
670           "INSTALL_PATH ?='$$HOME/tmp/src' ### Has to be an absolute path !!! \n"
671           "GRAS_ROOT ?='$(INSTALL_PATH)' ### Has to be an absolute path !!! \n"
672           "SRCDIR ?= ./\n"
673           "SIMGRID_URL ?=http://gcl.ucsd.edu/simgrid/dl/\n"
674           "SIMGRID_VERSION ?=2.92\n"
675           "GRAS_PROJECT ?= %s\n"
676           "GRAS_PROJECT_URL ?= http://www-id.imag.fr/Laboratoire/Membres/Legrand_Arnaud/gras_test/\n"
677           "\n"
678           "remote:\n"
679           "\t@echo;echo \"----[ Compile the package on remote hosts ]----\"\n"
680           "\t@test -e $(SRCDIR)/buildlogs/ || mkdir -p $(SRCDIR)/buildlogs/\n"
681           "\t for site in $(MACHINES) ; do \\\n"
682           "\t   machine=`echo $$site |sed 's/^\\([^%%]*\\)%%.*$$/\\1/'`;\\\n"
683           "\t   machine2=`echo $$site |sed 's/^\\([^%%]*\\)%%\\(.*\\)$$/\\2/'`;\\\n"
684           "\t   cmd_mkdir=\"\\\"sh -c 'env INSTALL_PATH=$(INSTALL_PATH) GRAS_ROOT=$(GRAS_ROOT) \\\n"
685           "\t                        SIMGRID_URL=$(SIMGRID_URL) SIMGRID_VERSION=$(SIMGRID_VERSION) GRAS_PROJECT=$(GRAS_PROJECT) \\\n"
686           "\t                        GRAS_PROJECT_URL=$(GRAS_PROJECT_URL)  mkdir -p $(INSTALL_PATH) 2>&1'\\\"\";\\\n"
687           "\t   cmd_make=\"\\\"sh -c 'env INSTALL_PATH=$(INSTALL_PATH) GRAS_ROOT=$(GRAS_ROOT) \\\n"
688           "\t                        SIMGRID_URL=$(SIMGRID_URL) SIMGRID_VERSION=$(SIMGRID_VERSION) GRAS_PROJECT=$(GRAS_PROJECT) \\\n"
689           "\t                        GRAS_PROJECT_URL=$(GRAS_PROJECT_URL)  make -C $(INSTALL_PATH) -f "MAKEFILE_FILENAME_REMOTE" $(ACTION) 2>&1'\\\"\";\\\n"
690           "\t   if echo $$site | grep  '%%' >/dev/null ; then \\\n"
691           "\t     echo \"----[ Compile on $$machine2 (behind $$machine) ]----\";\\\n"
692           "\t   else \\\n"
693           "\t     machine=$$site;\\\n"
694           "\t     echo \"----[ Compile on $$machine ]----\";\\\n"
695           "\t   fi;\\\n"
696           "\t   if echo $$site | grep  '%%' >/dev/null ; then \\\n"
697           "\t     if ssh $$machine \"ssh -A $$machine2 $$cmd_mkdir\" 2>&1 > $(SRCDIR)/buildlogs/$$site.log;\\\n"
698           "\t     then true; else failed=1;echo \"Failed (check $(SRCDIR)/buildlogs/$$site.log)\"; fi;\\\n"
699           "\t   else \\\n"
700           "\t     if ssh $$machine \"eval $$cmd_mkdir\" 2>&1 > $(SRCDIR)/buildlogs/$$site.log ;\\\n"
701           "\t     then true; else failed=1;echo \"Failed (check $(SRCDIR)/buildlogs/$$site.log)\"; fi; \\\n"
702           "\t   fi;\\\n"
703           "\t   echo \"-- Copy the data over\"; \\\n"
704           "\t   scp "MAKEFILE_FILENAME_REMOTE" $$site:$(INSTALL_PATH) ;\\\n"
705           "\t   echo \"-- Compiling... (the output gets into $(SRCDIR)/buildlogs/$$site.log)\"; \\\n"
706           "\t   if echo $$site | grep  '%%' >/dev/null ; then \\\n"
707           "\t     if ssh $$machine \"ssh -A $$machine2 $$cmd_make\" 2>&1 >> $(SRCDIR)/buildlogs/$$site.log;\\\n"
708           "\t     then echo \"Sucessful\"; else failed=1;echo \"Failed (check $(SRCDIR)/buildlogs/$$site.log)\"; fi;echo; \\\n"
709           "\t   else \\\n"
710           "\t     if ssh $$machine \"eval $$cmd_make\" 2>&1 >> $(SRCDIR)/buildlogs/$$site.log ;\\\n"
711           "\t     then echo \"Sucessful\"; else failed=1;echo \"Failed (check $(SRCDIR)/buildlogs/$$site.log)\"; fi;echo; \\\n"
712           "\t   fi;\\\n"
713           "\t done;\n",project,project,project);
714 */
715   fclose(OUT);
716 }
717
718 static void generate_makefile_remote(char *project, char *deployment)
719 {
720   char *filename = NULL;
721   FILE *OUT = NULL;
722
723   filename = xbt_new(char,strlen(project) + strlen(MAKEFILE_FILENAME_REMOTE));
724   sprintf(filename,MAKEFILE_FILENAME_REMOTE, project);
725   
726   OUT=fopen(filename,"w");
727   xbt_assert1(OUT, "Unable to open %s for writing",filename);
728
729   fprintf(OUT, 
730           "INSTALL_PATH ?= $(shell pwd)\n"
731           "\n"
732           "compile-simgrid:\n"
733           "\tcd $$GRAS_ROOT ; \\\n"
734           "\tretrieved=`LANG=C;wget -N $(SIMGRID_URL)/simgrid-$(SIMGRID_VERSION).tar.gz 2>&1 | grep newer | sed 's/.*no newer.*/yes/'`; \\\n"
735           "\techo $$retrieved; \\\n"
736           "\tif test \"x$$retrieved\" = x; then \\\n"
737           "\t  tar zxf simgrid-$(SIMGRID_VERSION).tar.gz ; \\\n"
738           "\t  cd simgrid-$(SIMGRID_VERSION)/; \\\n"
739           "\t  ./configure --prefix=$$GRAS_ROOT ; \\\n"
740           "\t  make all install ;\\\n"
741            "\tfi\n"
742           "\n"
743           "compile-gras: compile-simgrid\n"
744           "\tnot_retrieved=`LANG=C;wget -N $(GRAS_PROJECT_URL)/gras-$(GRAS_PROJECT).tar.gz 2>&1 | grep newer | sed 's/.*no newer.*/yes/'`; \\\n"
745           "\techo $$not_retrieved; \\\n"
746           "\tif test \"x$$not_retrieved\" != xyes; then \\\n"
747           "\t  tar zxf gras-$(GRAS_PROJECT).tar.gz ; \\\n"
748           "\t  make -C gras-$(GRAS_PROJECT)/ -f $(GRAS_PROJECT).Makefile.local all ; \\\n"
749           "\tfi\n"
750           "\n"
751           "clean-simgrid:\n"
752           "\trm -rf simgrid-$(SIMGRID_VERSION)*\n"
753           "clean-gras clean-gras-$(GRAS_PROJECT):\n"
754           "\trm -rf gras-$(GRAS_PROJECT)*\n"
755           "clean: clean-simgrid clean-gras-$(GRAS_PROJECT)\n"
756           "\n"
757           ".PHONY: clean clean-simgrid clean-gras clean-gras-$(GRAS_PROJECT) \\\n"
758           "        compile-simgrid compile-gras\n"
759           );
760   fclose(OUT);
761 }
762
763
764 static void generate_deployment(char *project, char *deployment)
765 {
766   xbt_dict_cursor_t cursor=NULL;
767   char *key = NULL;
768   void *data = NULL;
769   char *filename = NULL;
770   FILE *OUT = NULL;
771
772   int cpt,i;
773   s_process_t proc;
774
775   filename = xbt_new(char,strlen(project) + strlen(DEPLOYMENT));
776   sprintf(filename,DEPLOYMENT, project);
777   
778   OUT=fopen(filename,"w");
779   xbt_assert1(OUT, "Unable to open %s for writing",filename);
780
781   fprintf(OUT, "#!/bin/sh\n");
782   fprintf(OUT, "############ DEPLOYMENT FILE #########\n");
783   fprintf(OUT,
784           "if test \"${MACHINES+set}\" != set; then \n"
785           "    export MACHINES='");
786   xbt_dict_foreach(machine_set,cursor,key,data) {
787     fprintf(OUT, "%s ",key);
788   }
789   fprintf(OUT,  
790           "';\n"
791           "fi\n"
792           "if test \"${INSTALL_PATH+set}\" != set; then \n"
793           "    export INSTALL_PATH='`echo $HOME`/tmp/src'\n"
794           "fi\n"
795           "if test \"${GRAS_ROOT+set}\" != set; then \n"
796           "    export GRAS_ROOT='`echo $INSTALL_PATH`'\n"
797           "fi\n"
798           "if test \"${SRCDIR+set}\" != set; then \n"
799           "    export SRCDIR=./\n"
800           "fi\n"
801           "if test \"${SIMGRID_URL+set}\" != set; then \n"
802           "    export SIMGRID_URL=http://gcl.ucsd.edu/simgrid/dl/\n"
803           "fi\n"
804           "if test \"${SIMGRID_VERSION+set}\" != set; then \n"
805           "    export SIMGRID_VERSION=2.91\n"
806           "fi\n"
807           "if test \"${GRAS_PROJECT+set}\" != set; then \n"
808           "    export GRAS_PROJECT=%s\n"
809           "fi\n"
810           "if test \"${GRAS_PROJECT_URL+set}\" != set; then \n"
811           "    export GRAS_PROJECT_URL=http://www-id.imag.fr/Laboratoire/Membres/Legrand_Arnaud/gras_test/\n"
812           "fi\n"
813           "\n"
814           "test -e runlogs/ || mkdir -p runlogs/\n",
815           project);
816
817   fprintf(OUT,  
818           "cmd_prolog=\"env INSTALL_PATH=$INSTALL_PATH GRAS_ROOT=$GRAS_ROOT \\\n"
819           "                 SIMGRID_URL=$SIMGRID_URL SIMGRID_VERSION=$SIMGRID_VERSION GRAS_PROJECT=$GRAS_PROJECT \\\n"
820           "                 GRAS_PROJECT_URL=$GRAS_PROJECT_URL LD_LIBRARY_PATH=$GRAS_ROOT/lib/ sh -c \";\n");
821
822   xbt_dynar_foreach (process_list,cpt,proc) {
823     fprintf(OUT,"cmd=\"\\$INSTALL_PATH/gras-%s/"RL_BINARYNAME" ",project,project,proc.argv[0]);
824     for(i=1;i<proc.argc;i++) {
825       fprintf(OUT,"%s ",proc.argv[i]);
826     }
827     fprintf(OUT,"\";\n");
828     fprintf(OUT,"ssh %s \"$cmd_prolog 'export LD_LIBRARY_PATH=\\$INSTALL_PATH/lib:\\$LD_LIBRARY_PATH; echo \\\"$cmd\\\" ; $cmd 2>&1'\" > runlogs/%s_%d.log &\n",proc.host,proc.host,cpt);
829   }
830
831   fclose(OUT);
832 }
833
834 static void print(void *p)
835 {
836   printf("%p",p);
837 }
838
839
840 #ifdef _WIN32
841 #include <windows.h>
842 #endif
843
844 /* specific to Borland Compiler */
845 #ifdef __BORLANDDC__
846 #pragma argsused
847 #endif
848
849 int main(int argc, char *argv[])
850 {
851   char *project_name = NULL;
852   char *deployment_file = NULL;
853   int i;
854    
855   surf_init(&argc, argv);
856
857   xbt_assert1((argc >= 3),"Usage: %s project_name deployment_file [deployment_file...]\n",argv[0]);
858
859   project_name = argv[1];
860
861   process_function_set = xbt_dict_new();
862   process_list = xbt_dynar_new(sizeof(s_process_t),s_process_free);
863   machine_set = xbt_dict_new();
864
865   STag_surfxml_process_fun = parse_process_init;
866   ETag_surfxml_argument_fun = parse_argument;
867   ETag_surfxml_process_fun = parse_process_finalize;
868   
869   for(i=2; i<argc; i++) {
870      deployment_file = argv[i];
871      surf_parse_open(deployment_file);
872      if(surf_parse()) 
873         xbt_assert1(0,"Parse error in %s",deployment_file);
874      
875      surf_parse_close();
876   }
877
878
879   warning = xbt_new(char,strlen(WARN)+strlen(deployment_file)+10);
880   sprintf(warning,WARN,deployment_file);
881
882   /*if(XBT_LOG_ISENABLED(stubgen, xbt_log_priority_debug)) {
883     xbt_dict_cursor_t cursor=NULL;
884     char *key = NULL;
885     void *data = NULL;
886
887     for (cursor=NULL, xbt_dict_cursor_first((process_function_set),&(cursor)) ;
888          xbt_dict_cursor_get_or_free(&(cursor),&(key),(void**)(&data));
889          xbt_dict_cursor_step(cursor) ) {
890       DEBUG1("Function %s", key);      
891     }
892     
893     xbt_dict_dump(process_function_set,print);
894   }*/
895
896   generate_sim(project_name);
897   generate_rl(project_name);
898   generate_makefile_local(project_name, deployment_file);
899   #ifdef _WIN32
900   generate_borland_simulation_project(project_name);
901   generate_borland_real_life_project(project_name);
902   generate_simulation_dsp_file(project_name);
903   generate_real_live_dsp_file(project_name);
904
905   if(__gras_path)
906     xbt_free(__gras_path);
907   
908
909   #endif
910 //  generate_makefile_remote(project_name, deployment_file);
911 //  generate_deployment(project_name, deployment_file);
912
913   free(warning);
914   surf_exit();
915   return 0;
916 }
917 #ifdef _WIN32
918 void
919 generate_borland_project(borland_project_t project,int is_rl,const char* name)
920 {
921         char* binary_path;      /* the path of the generated binary file                                */
922         char* obj_path;         /* the path of the generated object file                                */
923         char* lib_files;        /* a list of the libraries used in the borland project  */
924         char* main_source;      /* the name of the bpf file used by the borland project */
925         char* file_name;        /* the file name of the main source file                                */
926     char* include_path; /* the include path                                     */
927         char* buffer;
928
929     /* create the borland project file */
930     borland_project_create(project);
931
932     /* write the xml document header */
933     borland_project_write_xml_header(project);
934
935     /* write the xml comment to identify a borland project file */
936     borland_project_write_xml_comment(project);
937         
938         /* write the begin of the node PROJECT */
939         borland_project_begin_xml_node(project,"PROJECT");
940         
941         /* write the begin of node MACROS */
942         borland_project_begin_xml_node(project,"MACROS");
943         
944         /* write the borland project version */
945         borland_project_write_xml_element(project,"VERSION",project->version);
946         
947         /* construct and write the borland project binary path */
948         binary_path = xbt_new0(char,strlen(project->name) + strlen(project->bin_dir) + 6);
949         sprintf(binary_path,"%s\\%s.exe",project->bin_dir,project->name);
950         borland_project_write_xml_element(project,"PROJECT",binary_path);
951         xbt_free(binary_path);
952         
953         /* construct an write the object files to generate by the compiler */
954         obj_path = xbt_new0(char,strlen(project->name) + strlen(name) + (2*strlen(project->obj_dir)) + 11);
955         sprintf(binary_path,"%s\\%s.obj\n%s\\%s.obj",project->obj_dir,project->name,project->obj_dir,name);
956         borland_project_write_xml_element(project,"OBJFILES",obj_path);
957         xbt_free(obj_path);
958         
959         /* write the resource files used by the compiler (no resource file used) */
960         borland_project_write_xml_element(project,"RESFILES","");
961         
962         /* write the IDL files of the project (no IDL files used) */
963         borland_project_write_xml_element(project,"IDLFILES","");
964         
965         /* write the IDLGENFILES element (not used) */
966         borland_project_write_xml_element(project,"IDLGENFILES","");
967         
968         /* write the DEFFILE element (not used) */
969         borland_project_write_xml_element(project,"DEFFILE","");
970         
971         /* write the RESDEPEN element (not used, no resource file used) */
972         borland_project_write_xml_element(project,"RESDEPEN","$(RESFILES)");
973
974         /* construct and write the list of libraries used by the project */
975         /*
976     lib_files = xbt_new0(char,(2 * (strlen(project->lib_dir) + 1)) + strlen("simgrid.lib") + strlen("libgras.lib") + 3);
977         sprintf(lib_files,"%s\\simgrid.lib %s\\libgras.lib",project->lib_dir,project->lib_dir);
978     */
979         
980         if(is_rl){
981                 lib_files = xbt_new0(char,(2 * (strlen(project->lib_dir) + 1)) + strlen("libgras.lib") + 2);
982                 sprintf(lib_files,"%s\\libgras.lib",project->lib_dir);  
983         }else{
984         lib_files = xbt_new0(char,(2 * (strlen(project->lib_dir) + 1)) + strlen("simgrid.lib") + 2);
985                 sprintf(lib_files,"%s\\simgrid.lib",project->lib_dir);
986         }
987
988         borland_project_write_xml_element(project,"LIBFILES",lib_files);
989         xbt_free(lib_files);
990         
991         /* write the SPARELIBS element (not used) */
992         borland_project_write_xml_element(project,"SPARELIBS","");
993         
994         /* write the PACKAGES element (no package used) */
995         borland_project_write_xml_element(project,"PACKAGES","");
996         
997         /* write the PATHCPP element (the path of the source files of the project)*/
998         borland_project_write_xml_element(project,"PATHCPP",".;");
999         
1000         /* write the PATHPAS element (not used) */
1001         borland_project_write_xml_element(project,"PATHPAS","");
1002         
1003         /* write the PATHRC element (not used) */
1004         borland_project_write_xml_element(project,"PATHRC","");
1005         
1006         /* write the PATHASM element (not used) */
1007         borland_project_write_xml_element(project,"PATHASM","");
1008         
1009         /* write the DEBUGLIBPATH element (the path for debug) */
1010         borland_project_write_xml_element(project,"DEBUGLIBPATH","$(BCB)\\lib\\debug");
1011         
1012         /* write the RELEASELIBPATH element (the path for release) */
1013         borland_project_write_xml_element(project,"RELEASELIBPATH","$(BCB)\\lib\\release");
1014         
1015         /* specify the linker to use */
1016         borland_project_write_xml_element(project,"LINKER","ilink32");
1017         
1018         /* write the USERDEFINES element (user definitions (#define _DEBUG))*/
1019         borland_project_write_xml_element(project,"USERDEFINES","_DEBUG");
1020         
1021         /* write the SYSDEFINES element (use the system definitions, not used strict ANSI and no use the VCL)*/
1022         borland_project_write_xml_element(project,"SYSDEFINES","NO_STRICT;_NO_VCL");
1023
1024         /* construct and write the MAINSOURCE element */
1025         main_source = xbt_new0(char,strlen(project->name) + 5);
1026         sprintf(main_source,"%s.bpf",project->name);
1027     /* write the main source file to use in the borland project file */
1028         borland_project_write_xml_element(project,"MAINSOURCE",main_source);
1029
1030         /* create the bpf file used by the borland project */
1031         borland_project_create_main_file(main_source);
1032
1033         /* FIXME resolve the include path */
1034         /* write the INCLUDEPATH element  */
1035
1036     if(!__gras_path){
1037         buffer =xbt_new0(char,MAX_PATH);
1038         GetEnvironmentVariable("SG_INSTALL_DIR",buffer,MAX_PATH);
1039         
1040                 __gras_path = xbt_new0(char,MAX_PATH);
1041                 sprintf(__gras_path,"%s\\simgrid\\include",buffer);
1042                 free(buffer);
1043
1044         /*find_file_path("C:\\","gras.h",__gras_path);*/
1045     }
1046
1047     include_path = xbt_new0(char,strlen("$(BCB)\\include") + strlen(__gras_path) + 2);
1048     sprintf(include_path,"$(BCB)\\include;%s",__gras_path);
1049
1050         borland_project_write_xml_element(project,"INCLUDEPATH",include_path);
1051
1052     xbt_free(include_path);
1053
1054         /* write the LIBPATH element (no librarie paths specified)*/
1055         borland_project_write_xml_element(project,"LIBPATH","$(BCB)\\lib;$(BCB)\\lib\\obj");
1056
1057         /*
1058      * write the WARNINGS element :
1059      *  -w-sus (-w-8075) disabled the suspect conversion pointer warning
1060      *  -w-rvl (-w-8070) disabled the function must return warning
1061      *  -w-rch (-w-8066) disabled the warning which specify that we can't attain the code
1062      *  -w-pia (-w-8060) disabled the warning that detect a possible bad assignement
1063      *  -w-pch (-w-8058) disabled the warning throw when the compiler can't precompile a header file
1064      *  -w-par (-w-8057) disabled the warning that detect an unused variable
1065      *  -w-csu (-w-8012) disabled the warning that detect a comparison between a signed number and an unsigned number
1066      *  -w-ccc (-w-8008) disabled the warning that detect une conditon which is always true
1067      *  -w-aus (-w-8008) disabled the warning that detect an affected value which is never used
1068      */
1069         borland_project_write_xml_element(project,"WARNINGS","-w-sus -w-rvl -w-rch -w-pia -w-pch -w-par -w-csu -w-ccc -w-aus");
1070
1071         /* write the OTHERFILES element (no other files used used) */
1072         borland_project_write_xml_element(project,"OTHERFILES","");
1073
1074         /* write the end of the node MACROS */
1075         borland_project_end_xml_node(project,"MACROS");
1076
1077         /* write the begin of the node OPTIONS */
1078         borland_project_begin_xml_node(project,"OPTIONS");
1079
1080         /* FIXME check the idlcflags */
1081         /* write the IDLCFLAGS element */
1082         borland_project_write_xml_element(project,"IDLCFLAGS","");
1083
1084         /*
1085      * write the CFLAG1 element (compiler options ) :
1086      *
1087      *  -Od     this flag disable all compiler optimisation
1088      *  -H      this flag specify the name of the file which will contain the precompiled header
1089      *  -Hc     this flag specify to the compiler to cach the precompiled header
1090      *  -Vx     this flag specify to the compiler to allow the empty structures
1091      *  -Ve     this flag specify to the compiler to allow the empty base classes
1092      *  -X-     this flag activate the auto-depend informations of the compiler
1093      *  -r-     this flag disabled the use of the processor register
1094      *  -a1     this flag specify that the data must be aligned on one byte
1095      *  -b-     this flag specify that the enums are the smallest size of the integer
1096      *  -k      (used during debug)
1097      *  -y      this flag generate the line number for debug
1098      *  -v      this flag enabled the debugging of the source files
1099      *  -vi     check the expansion of the inline functions
1100      *  -tWC    specify that it's a console application
1101      *  -tWM-   specify that the application is not multithread
1102      *  -c      generate the object file, no link
1103      */
1104         borland_project_write_xml_element(project,"CFLAG1","-Od -H=$(BCB)\\lib\\vcl60.csm -Hc -Vx -Ve -X- -r- -a8 -b- -k -y -v -vi- -tWC -tWM- -c");
1105
1106         /* write the PFLAGS element */
1107         borland_project_write_xml_element(project,"PFLAGS","-N2obj -N0obj -$YD -$W -$O- -$A8 -v -JPHNE ");
1108
1109         /* write the RFLAGS element */
1110         borland_project_write_xml_element(project,"RFLAGS","");
1111
1112         /* write the AFLAGS element (assembler flags) :
1113      *
1114      *  /mx (not documented)
1115      *  /w2 (not documented)
1116      *  /zd (not documented)
1117      *
1118      */
1119         borland_project_write_xml_element(project,"AFLAGS","/mx /w2 /zd");
1120
1121         /* write the LFLAGS element (linker flags) :
1122      *
1123      *  -I      specify the output directory for object files
1124      *  -D      register the specified description (no description "")
1125      *  -ap     build a win32 console application
1126      *  -Tpe    generate a exe file
1127      *  -x      do not create the map file
1128      *  -Gn     do not generate the state file
1129      *  -v      include the complete debug informations  
1130      */
1131         borland_project_write_xml_element(project,"LFLAGS","-Iobj -D&quot;&quot; -ap -Tpe -x -Gn -v");
1132
1133         /* write the OTHERFILES element (not used)*/
1134         borland_project_write_xml_element(project,"OTHERFILES","");
1135
1136         /* write the end of the node OPTIONS */
1137         borland_project_end_xml_node(project,"OPTIONS");
1138
1139         /* write the begin of the node LINKER */
1140         borland_project_begin_xml_node(project,"LINKER");
1141
1142         /* write the ALLOBJ element */
1143         borland_project_write_xml_element(project,"ALLOBJ","c0x32.obj $(OBJFILES)");
1144
1145         /* write the ALLRES element (not used) */
1146         borland_project_write_xml_element(project,"ALLRES","");
1147
1148         /* write the ALLLIB element */
1149         borland_project_write_xml_element(project,"ALLLIB","$(LIBFILES) $(LIBRARIES) import32.lib cw32.lib");
1150
1151         /* write the OTHERFILES element (not used) */
1152         borland_project_write_xml_element(project,"OTHERFILES","");
1153
1154         /* write the end of the node LINKER */
1155         borland_project_end_xml_node(project,"LINKER");
1156
1157         /* write the begin of the node FILELIST */
1158         borland_project_begin_xml_node(project,"FILELIST");
1159         
1160         /* construct and write the list of file elements */
1161         
1162         /* add the bpf file to the list */
1163         borland_project_write_file_element(project,main_source,"",project->name,"BPF","","");
1164         xbt_free(main_source);
1165         
1166         /* FIXME : check the source file directory */
1167         /* add the generated source file to the list */
1168         
1169         file_name = xbt_new0(char,strlen(project->src_dir) + strlen(project->name) + 5);
1170         sprintf(file_name,"%s\\_%s.c",project->src_dir,project->name);
1171         borland_project_write_file_element(project,file_name,"",project->name,"CCompiler","","");
1172
1173         memset(file_name,0,strlen(project->src_dir) + strlen(project->name) + 4);
1174         sprintf(file_name,"%s\\%s.c",project->src_dir,name);
1175         borland_project_write_file_element(project,file_name,"",name,"CCompiler","","");
1176
1177         xbt_free(file_name);
1178
1179         /* FIXME : check the libraries directory */
1180         /* add the simgrid library to the list */
1181         
1182         if(is_rl){
1183                 file_name = xbt_new0(char,strlen(project->lib_dir) + strlen("libgras.lib") + 2);
1184                 sprintf(file_name,"%s\\libgras.lib",project->lib_dir);
1185                 borland_project_write_file_element(project,file_name,"","libgras.lib","LibTool","","");
1186         }else
1187         {
1188                 file_name = xbt_new0(char,strlen(project->lib_dir) + strlen("simgrid.lib") + 2);
1189                 sprintf(file_name,"%s\\simgrid.lib",project->lib_dir);
1190                 borland_project_write_file_element(project,file_name,"","simgrid.lib","LibTool","","");
1191         }
1192         
1193         
1194         xbt_free(file_name);
1195
1196         /* write the end of the node FILELIST */
1197         borland_project_end_xml_node(project,"FILELIST");
1198         
1199         /* write the begin of the node BUILDTOOLS (not used)*/
1200         borland_project_begin_xml_node(project,"BUILDTOOLS");
1201         
1202         /* write the end of the node BUILDTOOLS (not used)*/
1203         borland_project_end_xml_node(project,"BUILDTOOLS");
1204         
1205         /* write the begin of the node IDEOPTIONS */
1206         borland_project_begin_xml_node(project,"IDEOPTIONS");
1207         
1208         /* write all of the option of the IDE of Borland C++ Builder */
1209         borland_project_write_ide_options(project);
1210         
1211         /* write the end of the node IDEOPTIONS */
1212         borland_project_end_xml_node(project,"IDEOPTIONS");
1213
1214     /* write the end of the node PROJECT */
1215         borland_project_end_xml_node(project,"PROJECT");
1216
1217     /* close the borland project file */
1218     borland_project_close(project);
1219 }
1220
1221 void
1222 borland_project_write_tabs(borland_project_t project,unsigned int count)
1223 {
1224         unsigned int pos;
1225         
1226         for(pos = 0; pos < count; pos++)
1227                 fprintf(project->stream,"\t");          
1228 }
1229
1230 void
1231 borland_project_begin_xml_node(borland_project_t project, const char* name)
1232 {
1233         if(level)
1234                 borland_project_write_tabs(project,level);
1235                 
1236         fprintf(project->stream,"<%s>\n",name);
1237         
1238         level++;
1239 }
1240
1241 void
1242 borland_project_end_xml_node(borland_project_t project, const char* name)
1243 {
1244         level--;
1245         
1246         if(level)
1247                 borland_project_write_tabs(project,level);
1248         
1249         fprintf(project->stream,"</%s>\n",name);        
1250 }
1251
1252
1253 void
1254 borland_project_write_xml_element(borland_project_t project,const char* name,const char* value)
1255 {
1256         borland_project_write_tabs(project,level);
1257         fprintf(project->stream,"<%s value=\"%s\"/>\n",name,value);
1258 }
1259
1260 void
1261 borland_project_write_xml_header(borland_project_t project)
1262 {
1263     fprintf(project->stream,"<?xml version='%s' encoding='%s' ?>\n",project->xml_version, project->encoding);
1264 }
1265
1266 void
1267 borland_project_create_main_file(const char* name)
1268 {
1269         FILE* stream = fopen(name,"w+");
1270
1271         fprintf(stream,"Ce fichier est uniquement utilisé par le gestionnaire de projets et doit être traité comme le fichier projet\n\n\nmain\n");
1272
1273         fclose(stream);
1274 }
1275
1276 void
1277 borland_project_create(borland_project_t project)
1278 {
1279     char* file_name = xbt_new0(char,strlen(project->name ) + 5);
1280     sprintf(file_name,"%s.bpr",project->name);
1281     project->stream = fopen(file_name,"w+");
1282     xbt_free(file_name);
1283 }
1284
1285 void
1286 borland_project_write_xml_comment(borland_project_t project)
1287 {
1288     fprintf(project->stream,"<!-- %s -->\n",project->comment);
1289 }
1290 void
1291 borland_project_write_file_element(     borland_project_t project,
1292                                                                         const char* file_name,
1293                                                                         const char* form_name,
1294                                                                         const char* unit_name,
1295                                                                         const char* container_id,
1296                                                                         const char* design_class,
1297                                                                         const char* local_command)
1298 {
1299         borland_project_write_tabs(project,level);
1300
1301         fprintf(project->stream,"<FILE FILENAME=\"%s\" FORMNAME=\"%s\" UNITNAME=\"%s\" CONTAINERID=\"%s\" DESIGNCLASS=\"%s\" LOCALCOMMAND=\"%s\"/>\n",file_name,form_name,unit_name,container_id,design_class,local_command);
1302 }
1303
1304 void
1305 borland_project_write_ide_options(borland_project_t project)
1306 {
1307
1308         const char* ide_options =
1309         "[Version Info]\nIncludeVerInfo=0\nAutoIncBuild=0\nMajorVer=1\nMinorVer=0\nRelease=0\nBuild=0\nDebug=0\nPreRelease=0\nSpecial=0\nPrivate=0\nDLL=0\nLocale=1036\nCodePage=1252\n\n"  \
1310         "[Version Info Keys]\nCompanyName=\nFileDescription=\nFileVersion=1.0.0.0\nInternalName=\nLegalCopyright=\nLegalTrademarks=\nOriginalFilename=\nProductName=\nProductVersion=1.0.0.0\nComments=\n\n" \
1311         "[Excluded Packages]\n$(BCB)\\dclclxdb60.bpl=Composants BD CLX Borland\n$(BCB)\\Bin\\dclclxstd60.bpl=Composants Standard CLX Borland\n\n" \
1312         "[HistoryLists\\hlIncludePath]\nCount=1\nItem0=$(BCB)\\include;$(BCB)\\include\\vcl;\n\n" \
1313         "[HistoryLists\\hlLibraryPath]\nCount=1\nItem0=$(BCB)\\lib\\obj;$(BCB)\\lib\n\n" \
1314         "[HistoryLists\\hlDebugSourcePath]\nCount=1\nItem0=$(BCB)\\source\\vcl\\\n\n" \
1315         "[HistoryLists\\hlConditionals]\nCount=1\nItem0=_DEBUG\n\n" \
1316         "[HistoryLists\\hlIntOutputDir]\nCount=0\n\n" \
1317         "[HistoryLists\\hlFinalOutputDir]\nCount=0\n\n" \
1318         "[HistoryLists\\hIBPIOutputDir]\nCount=0\n\n" \
1319         "[Debugging]\nDebugSourceDirs=$(BCB)\\source\\vcl\n\n" \
1320         "[Parameters]\nRunParams=\nLauncher=\nUseLauncher=0\nDebugCWD=\nHostApplication=\nRemoteHost=\nRemotePath=\nRemoteLauncher=\nRemoteCWD=\nRemoteDebug=0\n\n" \
1321         "[Compiler]\nShowInfoMsgs=0\nLinkDebugVcl=0\nLinkCGLIB=0\n\n" \
1322         "[CORBA]\nAddServerUnit=1\nAddClientUnit=1\nPrecompiledHeaders=1\n\n" \
1323         "[Language]\nActiveLang=\nProjectLang=\nRootDir=\n";
1324
1325         fprintf(project->stream,ide_options);
1326 }
1327
1328 void
1329 borland_project_close(borland_project_t project)
1330 {
1331     fclose(project->stream);
1332 }
1333
1334 void
1335 generate_borland_simulation_project(const char* name)
1336 {
1337     char buffer[MAX_PATH] = {0};
1338
1339     HANDLE hDir;
1340     WIN32_FIND_DATA wfd = {0};
1341
1342     s_borland_project_t borland_project = {0};
1343     borland_project.xml_version = "1.0";
1344     borland_project.encoding ="utf-8";
1345     borland_project.comment ="C++Builder XML Project";
1346     borland_project.version = "BCB.06.00";
1347
1348     borland_project.lib_dir = xbt_new0(char,MAX_PATH);
1349
1350     
1351     GetEnvironmentVariable("LIB_SIMGRID_PATH",borland_project.lib_dir,MAX_PATH);
1352                 
1353
1354     GetCurrentDirectory(MAX_PATH,buffer);
1355
1356     borland_project.src_dir = xbt_new0(char,strlen(buffer) + 1);
1357
1358     strcpy(borland_project.src_dir,buffer);
1359
1360     borland_project.name = xbt_new0(char,strlen(name) + strlen("simulator") + 2);
1361     sprintf(borland_project.name,"%s_simulator",name);
1362
1363     borland_project.bin_dir = xbt_new0(char,strlen(buffer) + strlen("\\bin") + 1);
1364     sprintf(borland_project.bin_dir,"%s\\bin",buffer);
1365
1366     hDir = FindFirstFile(borland_project.bin_dir,&wfd);
1367
1368     if(!hDir)
1369         CreateDirectory(borland_project.bin_dir,NULL);
1370
1371     borland_project.obj_dir = xbt_new0(char,strlen(buffer) + strlen("\\obj") + 1);
1372     sprintf(borland_project.obj_dir,"%s\\obj",buffer);
1373
1374     hDir = FindFirstFile(borland_project.obj_dir,&wfd);
1375
1376     if(INVALID_HANDLE_VALUE == hDir)
1377         CreateDirectory(borland_project.obj_dir,NULL);
1378
1379     generate_borland_project(&borland_project,0,name);
1380
1381     xbt_free(borland_project.name);
1382     xbt_free(borland_project.src_dir);
1383     xbt_free(borland_project.bin_dir);
1384     xbt_free(borland_project.obj_dir);
1385     xbt_free(borland_project.lib_dir);
1386 }
1387
1388 void
1389 generate_borland_real_life_project(const char* name)
1390 {
1391     HANDLE hDir;
1392     WIN32_FIND_DATA wfd = {0};
1393     char buffer[MAX_PATH] = {0};
1394     xbt_dict_cursor_t cursor = NULL;
1395     char *key = NULL;
1396     void *data = NULL;
1397         s_borland_project_t borland_project = {0};
1398
1399         borland_project.xml_version = "1.0";
1400     borland_project.encoding ="utf-8";
1401     borland_project.comment ="C++Builder XML Project";
1402     borland_project.version = "BCB.06.00";
1403     borland_project.lib_dir = " ";
1404
1405     borland_project.lib_dir = xbt_new0(char,MAX_PATH);
1406
1407     GetEnvironmentVariable("LIB_GRAS_PATH",borland_project.lib_dir,MAX_PATH);
1408        
1409     GetCurrentDirectory(MAX_PATH,buffer);
1410
1411     borland_project.src_dir = xbt_new0(char,strlen(buffer) + 1);
1412
1413     strcpy(borland_project.src_dir,buffer);
1414
1415     borland_project.bin_dir = xbt_new0(char,strlen(buffer) + strlen("\\bin") + 1);
1416     sprintf(borland_project.bin_dir,"%s\\bin",buffer);
1417
1418     hDir = FindFirstFile(borland_project.bin_dir,&wfd);
1419
1420     if(INVALID_HANDLE_VALUE == hDir)
1421         CreateDirectory(borland_project.bin_dir,NULL);
1422
1423     borland_project.obj_dir = xbt_new0(char,strlen(buffer) + strlen("\\obj") + 1);
1424     sprintf(borland_project.obj_dir,"%s\\obj",buffer);
1425
1426     hDir = FindFirstFile(borland_project.obj_dir,&wfd);
1427
1428     if(!hDir)
1429         CreateDirectory(borland_project.obj_dir,NULL);
1430
1431
1432         xbt_dict_foreach(process_function_set,cursor,key,data) {
1433         borland_project.name = xbt_new0(char,strlen(name) + strlen(key) + 2);
1434
1435         sprintf(borland_project.name,"%s_%s",name,key);
1436
1437         generate_borland_project(&borland_project,1,name);
1438         xbt_free(borland_project.name);
1439     }
1440
1441     xbt_free(borland_project.src_dir);
1442     xbt_free(borland_project.bin_dir);
1443     xbt_free(borland_project.obj_dir);
1444     xbt_free(borland_project.lib_dir);
1445 }
1446 int
1447 find_file_path(const char* root_dir,const char* file_name,char* path)
1448 {
1449         HANDLE hFind;
1450         WIN32_FIND_DATA wfd;
1451         char* prev_dir = xbt_new(char,MAX_PATH);
1452         GetCurrentDirectory(MAX_PATH,prev_dir);
1453         SetCurrentDirectory(root_dir);
1454         
1455         // begining of the scan
1456         hFind=FindFirstFile ("*.*", &wfd);
1457         
1458         if(hFind!=INVALID_HANDLE_VALUE){
1459         
1460                 /* it's a file */
1461                 if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
1462                 
1463                         if(!strcmp(file_name,wfd.cFileName)){
1464                                 GetCurrentDirectory(MAX_PATH,path);
1465                                 SetCurrentDirectory(prev_dir);
1466                                 xbt_free(prev_dir);
1467                                 FindClose(hFind);
1468                                 return 1;
1469                         }
1470                 
1471                 }
1472                 /* it's a directory, scan it*/
1473                 else {
1474                 
1475                         if(strcmp(wfd.cFileName,".") && strcmp(wfd.cFileName,"..")){
1476                                 if(find_file_path(wfd.cFileName,file_name,path)){
1477                                         FindClose(hFind);
1478                                         SetCurrentDirectory(prev_dir);
1479                                         return 1;
1480                                 }
1481                         }
1482                 }
1483                 
1484                 /* next file or directory */
1485                 while(FindNextFile(hFind,&wfd))
1486                 {
1487                         /* it's a file */
1488                         if(!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
1489                         {
1490                                 if(!strcmp(file_name,wfd.cFileName)){
1491                                         GetCurrentDirectory(MAX_PATH,path);
1492                                         SetCurrentDirectory(prev_dir);
1493                                         xbt_free(prev_dir);
1494                                         FindClose(hFind);
1495                                         return 1;
1496                                 }
1497                         }
1498                         /* it's a file scan it */
1499                         else {
1500                 
1501                                 if(strcmp(wfd.cFileName,".") && strcmp(wfd.cFileName,"..")){
1502                 
1503                                         if(find_file_path(wfd.cFileName,file_name,path)){
1504                                                 SetCurrentDirectory(prev_dir);
1505                                                 FindClose(hFind);
1506                                                 return 1;
1507                                         }
1508                 
1509                                 }
1510                 
1511                         }
1512                 }
1513         }
1514         
1515         SetCurrentDirectory(prev_dir);
1516         xbt_free(prev_dir);
1517         FindClose (hFind);
1518         return 0;
1519 }
1520
1521 /* Implementation of the functions used to create a Visual C++ project.*/
1522
1523 int
1524 generate_simulation_dsp_file(const char* name)
1525 {
1526         char buffer[MAX_PATH] = {0};
1527     s_dsp_t dsp = {0};
1528     dsp.lib_dir = xbt_new0(char,MAX_PATH);
1529
1530     GetEnvironmentVariable("LIB_SIMGRID_PATH",dsp.lib_dir,MAX_PATH);
1531     GetCurrentDirectory(MAX_PATH,buffer);
1532
1533     dsp.src_dir = xbt_new0(char,strlen(buffer) + 1);
1534     strcpy(dsp.src_dir,buffer);
1535         dsp.name = xbt_new0(char,strlen(name) + strlen("simulator") + 2);
1536         sprintf(dsp.name,"%s_simulator",name);
1537
1538     generate_dsp_project(&dsp,0,name);
1539
1540     xbt_free(dsp.name);
1541     xbt_free(dsp.src_dir);
1542         xbt_free(dsp.lib_dir);
1543     
1544     return 0;           
1545 }
1546
1547 /*
1548  * Create the Microsoft visual C++ real life project file.
1549  */
1550 int
1551 generate_real_live_dsp_file(const char* name)
1552 {
1553         
1554     char buffer[MAX_PATH] = {0};
1555     xbt_dict_cursor_t cursor = NULL;
1556     char *key = NULL;
1557     void *data = NULL;
1558         s_dsp_t dsp = {0};
1559
1560         
1561     dsp.lib_dir = xbt_new0(char,MAX_PATH);
1562
1563     GetEnvironmentVariable("LIB_GRAS_PATH",dsp.lib_dir,MAX_PATH);
1564        
1565     GetCurrentDirectory(MAX_PATH,buffer);
1566
1567     dsp.src_dir = xbt_new0(char,strlen(buffer) + 1);
1568
1569     strcpy(dsp.src_dir,buffer);
1570
1571
1572         xbt_dict_foreach(process_function_set,cursor,key,data) {
1573         dsp.name = xbt_new0(char,strlen(name) + strlen(key) + 2);
1574
1575         sprintf(dsp.name,"%s_%s",name,key);
1576
1577         generate_dsp_project(&dsp,1,name);
1578         xbt_free(dsp.name);
1579     }
1580
1581     xbt_free(dsp.src_dir);
1582     xbt_free(dsp.lib_dir);
1583         return 0;
1584 }
1585
1586 void
1587 generate_dsp_project(dsp_t project,int is_rl,const char* name)
1588 {
1589         /* create the visual C++ project file */
1590         char* buffer;
1591         char* file_name = xbt_new0(char,strlen(project->name) + 5);
1592     sprintf(file_name,"%s.dsp",project->name);
1593     project->stream = fopen(file_name,"w+");
1594     xbt_free(file_name);
1595     
1596     if(!__gras_path)
1597         {
1598         buffer =xbt_new0(char,MAX_PATH);
1599         GetEnvironmentVariable("SG_INSTALL_DIR",buffer,MAX_PATH);
1600         
1601                 __gras_path = xbt_new0(char,MAX_PATH);
1602                 sprintf(__gras_path,"%s\\simgrid\\include",buffer);
1603                 free(buffer);
1604     }
1605     
1606     /* dsp file header */
1607     fprintf(project->stream,"# Microsoft Developer Studio Project File - Name=\"%s\" - Package Owner=<4>\n",project->name);
1608         fprintf(project->stream,"# Microsoft Developer Studio Generated Build File, Format Version 6.00\n");
1609         fprintf(project->stream,"# ** DO NOT EDIT **\n\n");
1610         
1611         /* target type is a win32 x86 console application */
1612         fprintf(project->stream,"# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\n\n");
1613         
1614         /* the current config is win32-debug */
1615         fprintf(project->stream,"CFG=%s - Win32 Debug\n",project->name);
1616         
1617         /* warning */
1618         fprintf(project->stream,"!MESSAGE This is not a valid makefile. To build this project using NMAKE,\n");
1619         
1620         /* NMAKE usage */
1621         fprintf(project->stream,"!MESSAGE use the Export Makefile command and run\n");
1622         fprintf(project->stream,"!MESSAGE\n");
1623         fprintf(project->stream,"!MESSAGE NMAKE /f \"%s.mak\".\n",project->name);
1624         fprintf(project->stream,"!MESSAGE\n");
1625         fprintf(project->stream,"!MESSAGE You can specify a configuration when running NMAKE\n");
1626         fprintf(project->stream,"!MESSAGE by defining the macro CFG on the command line. For example:\n");
1627         fprintf(project->stream,"!MESSAGE\n"); 
1628         fprintf(project->stream,"!MESSAGE NMAKE /f \"%s.mak\" CFG=\"%s - Win32 Debug\"\n",project->name,project->name);
1629         fprintf(project->stream,"!MESSAGE\n");
1630         fprintf(project->stream,"!MESSAGE Possible choices for configuration are:\n");
1631         fprintf(project->stream,"!MESSAGE\n"); 
1632         fprintf(project->stream,"!MESSAGE \"%s - Win32 Release\" (based on \"Win32 (x86) Console Application\")\n",project->name);
1633         fprintf(project->stream,"!MESSAGE \"%s - Win32 Debug\" (based on \"Win32 (x86) Console Application\")\n",project->name);
1634         fprintf(project->stream,"!MESSAGE\n\n"); 
1635         
1636         fprintf(project->stream,"# Begin Project\n\n");
1637         fprintf(project->stream,"# PROP AllowPerConfigDependencies 0\n");
1638         fprintf(project->stream,"# PROP Scc_ProjName\n");
1639         fprintf(project->stream,"# PROP Scc_LocalPath\n");
1640         fprintf(project->stream,"CPP=cl.exe\n");
1641         fprintf(project->stream,"RSC=rc.exe\n\n");
1642         
1643         fprintf(project->stream,"!IF  \"$(CFG)\" == \"%s - Win32 Release\"\n\n",project->name);
1644         
1645         fprintf(project->stream,"# PROP BASE Use_MFC 0\n");
1646         fprintf(project->stream,"# PROP BASE Use_Debug_Libraries 0\n");
1647         fprintf(project->stream,"# PROP BASE Output_Dir \"Release\"\n");
1648         fprintf(project->stream,"# PROP BASE Intermediate_Dir \"Release\"\n");
1649         fprintf(project->stream,"# PROP BASE Target_Dir \"\"\n");
1650         fprintf(project->stream,"# PROP Use_MFC 0\n");
1651         fprintf(project->stream,"# PROP Use_Debug_Libraries 0\n");
1652         fprintf(project->stream,"# PROP Output_Dir \"Release\"\n");
1653         fprintf(project->stream,"# PROP Intermediate_Dir \"Release\"\n");
1654         fprintf(project->stream,"# PROP Target_Dir \"\"\n");
1655         /* TODO : the include directory */
1656         /*fprintf(project->stream,"# ADD BASE CPP /nologo /W3 /GX /O2 /I \"./%s\" /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n",__gras_path);*/
1657         fprintf(project->stream,"# ADD BASE CPP /nologo /W3 /GX /O2 /I \"%s\" /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n",__gras_path);
1658         fprintf(project->stream,"# ADD CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n");
1659         fprintf(project->stream,"# ADD BASE RSC /l 0x40c /d \"NDEBUG\"\n");
1660         fprintf(project->stream,"# ADD RSC /l 0x40c /d \"NDEBUG\n");
1661         fprintf(project->stream,"BSC32=bscmake.exe\n");
1662         fprintf(project->stream,"# ADD BASE BSC32 /nologo\n");
1663         fprintf(project->stream,"# ADD BSC32 /nologo\n");
1664         fprintf(project->stream,"LINK32=link.exe\n");
1665         fprintf(project->stream,"# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\n");
1666         
1667         if(is_rl)
1668                 fprintf(project->stream,"# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libgras.lib /nologo /subsystem:console /machine:I386\n\n");
1669         else
1670                 fprintf(project->stream,"# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib simgrid.lib /nologo /subsystem:console /machine:I386\n\n");
1671                         
1672         fprintf(project->stream,"!ELSEIF  \"$(CFG)\" == \"%s - Win32 Debug\"\n",project->name);
1673
1674         fprintf(project->stream,"# PROP BASE Use_MFC 0\n");
1675         fprintf(project->stream,"# PROP BASE Use_Debug_Libraries 1\n");
1676         fprintf(project->stream,"# PROP BASE Output_Dir \"Debug\"\n");
1677         fprintf(project->stream,"# PROP BASE Intermediate_Dir \"Debug\"\n");
1678         fprintf(project->stream,"# PROP BASE Target_Dir \"\"\n");
1679         fprintf(project->stream,"# PROP Use_MFC 0\n");
1680         fprintf(project->stream,"# PROP Use_Debug_Libraries 1\n");
1681         fprintf(project->stream,"# PROP Output_Dir \"Debug\"\n");
1682         fprintf(project->stream,"# PROP Intermediate_Dir \"Debug\"\n");
1683         fprintf(project->stream,"# PROP Ignore_Export_Lib 0\n");
1684         fprintf(project->stream,"# PROP Target_Dir \"\"\n");
1685         /* TODO : the include directory */
1686         /*fprintf(project->stream,"# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od  /I \"./%s\" /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ  /c\n",__gras_path);*/
1687         fprintf(project->stream,"# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od  /I \"%s\" /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ  /c\n",__gras_path);
1688         fprintf(project->stream,"# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ  /c\n");
1689         fprintf(project->stream,"# ADD BASE RSC /l 0x40c /d \"_DEBUG\"\n");
1690         fprintf(project->stream,"# ADD RSC /l 0x40c /d \"_DEBUG\"\n");
1691         fprintf(project->stream,"BSC32=bscmake.exe\n");
1692         fprintf(project->stream,"# ADD BASE BSC32 /nologo\n");
1693         fprintf(project->stream,"# ADD BSC32 /nologo\n");
1694         fprintf(project->stream,"LINK32=link.exe\n");
1695         fprintf(project->stream,"# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n");
1696         
1697         if(is_rl)
1698                 fprintf(project->stream,"# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib simgrid.lib  libgras.lib  /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n\n");
1699         else
1700                 fprintf(project->stream,"# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib simgrid.lib  simgrid.lib  /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n\n");
1701                         
1702         fprintf(project->stream,"!ENDIF\n\n");
1703         
1704         fprintf(project->stream,"# Begin Target\n\n");
1705         fprintf(project->stream,"# Name \"%s - Win32 Release\"\n",project->name);
1706         fprintf(project->stream,"# Name \"%s - Win32 Debug\"\n",project->name);
1707         fprintf(project->stream,"# Begin Group \"Source Files\"\n\n");
1708         fprintf(project->stream,"# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\n\n");
1709         
1710         fprintf(project->stream,"# Begin Source File\n");
1711         fprintf(project->stream,"SOURCE=%s\\_%s.c\n",project->src_dir,project->name);
1712         fprintf(project->stream,"# End Source File\n\n");
1713         
1714         fprintf(project->stream,"# Begin Source File\n");
1715         fprintf(project->stream,"SOURCE=%s\\%s.c\n",project->src_dir,name);
1716         fprintf(project->stream,"# End Source File\n\n");
1717         
1718         fprintf(project->stream,"# End Group\n");
1719         fprintf(project->stream,"# Begin Group \"Header Files\"\n\n");
1720         fprintf(project->stream,"# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\n");
1721         fprintf(project->stream,"# End Group\n");
1722         fprintf(project->stream,"# Begin Group \"Resource Files\"\n\n");
1723         fprintf(project->stream,"# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\n");
1724         fprintf(project->stream,"# End Group\n");
1725         fprintf(project->stream,"# End Target\n");
1726         fprintf(project->stream,"# End Project\n");
1727         
1728 }
1729
1730 #endif
1731
1732
1733
1734
1735