Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Be sure we can execute this script.
[simgrid.git] / buildtools / Cmake / src / CMakeMaintainerMode.txt
1 if(enable_maintainer_mode)
2 message("")
3 message("________________________________________________________________________________")
4 message("________________________________________________________________________________ FLEXMl")
5 find_program(FLEX_EXE NAMES flex)
6 find_program(FLEXML_EXE NAMES flexml)
7 find_program(SED_EXE NAMES sed)
8 find_program(PERL_EXE NAMES perl)
9
10 message("  FLEX :       ${FLEX_EXE}")
11 message("FLEXML :       ${FLEXML_EXE}")
12 message("   SED :       ${SED_EXE}\n")
13
14 set(top_srcdir "${PROJECT_DIRECTORY}")
15 set(srcdir "${PROJECT_DIRECTORY}/src")
16
17 IF(FLEX_EXE)
18         set(HAVE_FLEX 1)
19 ENDIF(FLEX_EXE)
20
21 IF(FLEXML_EXE)
22         set(HAVE_FLEXML 1)
23 ENDIF(FLEXML_EXE)
24
25 if(HAVE_FLEXML AND HAVE_FLEX AND SED_EXE)
26
27 foreach(file ${script_to_install})
28         exec_program("chmod a=rwx ${file}" OUTPUT_VARIABLE "OKITOKI")
29 endforeach(file ${script_to_install})
30
31 #surf/simgrid_dtd.l: $(srcdir)/surf/simgrid.dtd
32 exec_program("mkdir -p surf")
33 exec_program("${FLEXML_EXE} --root-tags platform -b 1000000 -P surfxml --sysid=simgrid.dtd -S surf/simgrid_dtd.l -L ${srcdir}/surf/simgrid.dtd"  "${PROJECT_DIRECTORY}/src/")
34
35 #$(top_srcdir)/include/surf/simgrid_dtd.h: $(srcdir)/surf/simgrid.dtd
36 file(REMOVE "${top_srcdir}/include/surf/simgrid.h") 
37 exec_program("${FLEXML_EXE} --root-tags platform -P surfxml --sysid=simgrid.dtd -H ${top_srcdir}/include/surf/simgrid_dtd.h -L ${srcdir}/surf/simgrid.dtd" "${PROJECT_DIRECTORY}/src/")
38
39 if(EXISTS ${top_srcdir}/include/surf/simgrid.h)
40         #mv ${top_srcdir}/include/surf/simgrid.h ${top_srcdir}/include/surf/simgrid_dtd.h 
41 endif(EXISTS ${top_srcdir}/include/surf/simgrid.h)
42 set(CHAINE "'s/extern  *\\([^ ]*[ \\*]*\\)/XBT_PUBLIC_DATA(\\1) /'")
43 exec_program("${SED_EXE} ${CHAINE} -i ${top_srcdir}/include/surf/simgrid_dtd.h" "${PROJECT_DIRECTORY}/src/")
44 set(CHAINE "'s/XBT_PUBLIC_DATA(\\([^)]*\\)) *\\([^(]*\\)(/XBT_PUBLIC(\\1) \\2(/'")      
45 exec_program("${SED_EXE} ${CHAINE} -i ${top_srcdir}/include/surf/simgrid_dtd.h" "${PROJECT_DIRECTORY}/src/")
46
47 #xbt/graphxml.l: $(srcdir)/xbt/graphxml.dtd
48 exec_program("${FLEXML_EXE} -b 1000000 -P graphxml --sysid=graphxml.dtd -S xbt/graphxml.l -L ${srcdir}/xbt/graphxml.dtd" "${PROJECT_DIRECTORY}/src/")
49
50 #$(top_srcdir)/include/xbt/graphxml.h: $(srcdir)/xbt/graphxml.dtd
51 exec_program("${FLEXML_EXE} -P graphxml --sysid=graphxml.dtd -H ${top_srcdir}/include/xbt/graphxml.h -L ${srcdir}/xbt/graphxml.dtd" "${PROJECT_DIRECTORY}/src/")
52 set(CHAINE "'s/extern  *\\([^ ]*[ \\*]*\\)/XBT_PUBLIC_DATA(\\1) /'")
53 exec_program("${SED_EXE} ${CHAINE} -i ${top_srcdir}/include/xbt/graphxml.h" "${PROJECT_DIRECTORY}/src/")
54 set(CHAINE "'s/XBT_PUBLIC_DATA(\\([^)]*\\)) *\\([^(]*\\)(/XBT_PUBLIC(\\1) \\2(/'")
55 exec_program("${SED_EXE} ${CHAINE} -i ${top_srcdir}/include/xbt/graphxml.h" "${PROJECT_DIRECTORY}/src/")
56
57 #simdag/dax_dtd.l: simdag/dax.dtd
58 exec_program("${FLEXML_EXE} -b 1000000 --root-tags adag -P dax_ --sysid=dax.dtd -S simdag/dax_dtd.l -L simdag/dax.dtd" "${PROJECT_DIRECTORY}/src/")
59 set(CHAINE "'s/SET(DOCTYPE)/SET(ROOT_dax__adag)/'")
60 exec_program("${SED_EXE} -i ${CHAINE} simdag/dax_dtd.l" "${PROJECT_DIRECTORY}/src/") # DOCTYPE not mandatory
61
62 #simdag/dax_dtd.h: simdag/dax.dtd
63 exec_program("${FLEXML_EXE} --root-tags adag -P dax_ --sysid=dax.dtd -H simdag/dax_dtd.h -L simdag/dax.dtd" "${PROJECT_DIRECTORY}/src/")
64 set(CHAINE "'s/extern  *\\([^ ]*[ \\*]*\\)/XBT_PUBLIC_DATA(\\1) /'")
65 exec_program("${SED_EXE} ${CHAINE} -i simdag/dax_dtd.h" "${PROJECT_DIRECTORY}/src/")
66 set(CHAINE "'s/XBT_PUBLIC_DATA(\\([^)]*\\)) *\\([^(]*\\)(/XBT_PUBLIC(\\1) \\2(/'")      
67 exec_program("${SED_EXE} ${CHAINE} -i simdag/dax_dtd.h" "${PROJECT_DIRECTORY}/src/")
68
69 exec_program("${FLEX_EXE} -o gras/DataDesc/ddt_parse.yy.c -Pgras_ddt_parse_ --noline gras/DataDesc/ddt_parse.yy.l" "${PROJECT_DIRECTORY}/src/")
70
71 #surf/simgrid_dtd.c: surf/simgrid_dtd.l
72 exec_program("mkdir -p `dirname surf/simgrid_dtd.c`" "${PROJECT_DIRECTORY}/src/")
73 exec_program("${FLEX_EXE} -o surf/simgrid_dtd.c -Psurf_parse_ --noline surf/simgrid_dtd.l" "${PROJECT_DIRECTORY}/src/")
74 set(CHAINE "'s/#include <unistd.h>/#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)\\n#  ifndef __STRICT_ANSI__\\n#    include <io.h>\\n#    include <process.h>\\n#  endif\\n#else\\n#  include <unistd.h>\\n#endif/g' -i surf/simgrid_dtd.c")      
75 exec_program("${SED_EXE} ${CHAINE}" "${PROJECT_DIRECTORY}/src/")
76
77 #xbt/graphxml.c: xbt/graphxml.l
78 exec_program("mkdir -p `dirname xbt/graphxml.c`" "${PROJECT_DIRECTORY}/src/")
79 exec_program("${FLEX_EXE} -o xbt/graphxml.c -Pxbt_graph_parse_ --noline xbt/graphxml.l" "${PROJECT_DIRECTORY}/src/")
80 set(CHAINE "'s/#include <unistd.h>/#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)\\n#  ifndef __STRICT_ANSI__\\n#    include <io.h>\\n#    include <process.h>\\n#  endif\\n#else\\n#  include <unistd.h>\\n#endif/g' -i xbt/graphxml.c")                  
81 exec_program("${SED_EXE} ${CHAINE}" "${PROJECT_DIRECTORY}/src/")
82
83 #simdag/dax_dtd.c: simdag/dax_dtd.l
84 exec_program("mkdir -p `dirname simdag/dax_dtd.c`" "${PROJECT_DIRECTORY}/src/")
85 exec_program("${FLEX_EXE} -o simdag/dax_dtd.c -Pdax_ --noline simdag/dax_dtd.l" "${PROJECT_DIRECTORY}/src/")
86 set(CHAINE "'s/#include <unistd.h>/#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)\\n#  ifndef __STRICT_ANSI__\\n#    include <io.h>\\n#    include <process.h>\\n#  endif\\n#else\\n#  include <unistd.h>\\n#endif/g' -i simdag/dax_dtd.c")        
87 exec_program("${SED_EXE} ${CHAINE}" "${PROJECT_DIRECTORY}/src/")
88
89 elseif(HAVE_FLEXML AND HAVE_FLEX  AND SED_EXE)
90         message("  FLEX :       ${FLEX_EXE}")
91         message("FLEXML :       ${FLEXML_EXE}")
92         message("   SED :       ${SED_EXE}")
93         message(FATAL_ERROR "Install flex or flexml or sed before use maintainer mode")
94 endif(HAVE_FLEXML AND HAVE_FLEX  AND SED_EXE)
95
96 #include $(top_srcdir)/acmacro/dist-files.mk
97
98 message("")
99 message("________________________________________________________________________________")
100 message("________________________________________________________________________________ FLEXML END")
101
102 message("")
103 message("________________________________________________________________________________")
104 message("________________________________________________________________________________ SG_UNIT_EXTRACTOR")
105
106 if(PERL_EXE)
107         message("   PERL :      ${PERL_EXE}\n")
108         exec_program("rm -f simgrid_units_main.c *_unit.c ${PROJECT_DIRECTORY}/src/simgrid_units_main.c ${PROJECT_DIRECTORY}/src/*_unit.c" "${PROJECT_DIRECTORY}/src/" OUTPUT_VARIABLE OKITOKI)
109
110         #$(TEST_UNITS): $(TEST_CFILES)
111         string(REPLACE ";" " " USE_TEST_CFILES "${TEST_CFILES}")
112         exec_program("chmod a=rwx ${PROJECT_DIRECTORY}/tools/sg_unit_extractor.pl" "${PROJECT_DIRECTORY}/src/")
113         exec_program("${PROJECT_DIRECTORY}/tools/sg_unit_extractor.pl ${USE_TEST_CFILES}" "${PROJECT_DIRECTORY}/src/")
114
115         #@builddir@/simgrid_units_main.c: $(TEST_UNITS)
116         exec_program("${PROJECT_DIRECTORY}/tools/sg_unit_extractor.pl ${PROJECT_DIRECTORY}/src/xbt/cunit.c" "${PROJECT_DIRECTORY}/src/")
117
118 else(PERL_EXE)
119         message(FATAL_ERROR "Install perl before use maintainer mode")
120 endif(PERL_EXE)
121 message("")
122 message("________________________________________________________________________________")
123 message("________________________________________________________________________________ SG_UNIT_EXTRACTOR END")
124
125 #Those lines permit to remake a cmake configure if "sources to look" have been changed
126 foreach(file ${SRC_TO_LOOK})
127         configure_file(${file} ${file} COPYONLY)
128 endforeach(file ${SRC_TO_LOOK})
129 endif(enable_maintainer_mode)
130