Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Redo messages while all needed tools are none install for maintainer mode .
[simgrid.git] / buildtools / Cmake / MaintainerMode.cmake
1 if(enable_maintainer_mode AND NOT WIN32)
2 find_program(FLEX_EXE NAMES flex)
3 find_program(FLEXML_EXE NAMES flexml)
4 find_program(SED_EXE NAMES sed)
5 find_program(PERL_EXE NAMES perl)
6
7 IF(FLEX_EXE)
8         set(HAVE_FLEX 1)
9         exec_program("${FLEX_EXE} --version" OUTPUT_VARIABLE FLEX_VERSION)
10         string(REGEX MATCH "[0-9]+[.]+[0-9]+[.]+[0-9]+" FLEX_VERSION "${FLEX_VERSION}")
11         string(REGEX MATCH "^[0-9]+" FLEX_MAJOR_VERSION "${FLEX_VERSION}")
12         string(REGEX MATCH "[0-9]+[.]+[0-9]+$" FLEX_VERSION "${FLEX_VERSION}")
13         string(REGEX MATCH "^[0-9]+" FLEX_MINOR_VERSION "${FLEX_VERSION}")
14         string(REGEX MATCH "[0-9]+$" FLEX_PATCH_VERSION "${FLEX_VERSION}")
15 ENDIF(FLEX_EXE)
16
17 IF(FLEXML_EXE)
18         set(HAVE_FLEXML 1)
19         exec_program("${FLEXML_EXE} --version" OUTPUT_VARIABLE FLEXML_VERSION)
20         string(REGEX MATCH "[0-9]+[.]+[0-9]+" FLEXML_VERSION "${FLEXML_VERSION}")
21         string(REGEX MATCH "^[0-9]*" FLEXML_MAJOR_VERSION "${FLEXML_VERSION}")
22         string(REGEX MATCH "[0-9]*$" FLEXML_MINOR_VERSION "${FLEXML_VERSION}")
23 ENDIF(FLEXML_EXE)
24
25 if(HAVE_FLEXML AND HAVE_FLEX AND SED_EXE)
26 set(string1  "'s/extern  *\\([^ ]*[ \\*]*\\)/XBT_PUBLIC_DATA(\\1) /'")
27 set(string2  "'s/XBT_PUBLIC_DATA(\\([^)]*\\)) *\\([^(]*\\)(/XBT_PUBLIC(\\1) \\2(/'")
28 set(string3  "'s/extern  *\\([^ ]*[ \\*]*\\)/XBT_PUBLIC_DATA(\\1) /'")
29 set(string4  "'s/XBT_PUBLIC_DATA(\\([^)]*\\)) *\\([^(]*\\)(/XBT_PUBLIC(\\1) \\2(/'")
30 set(string5  "'s/SET(DOCTYPE)/SET(ROOT_dax__adag)/'")
31 set(string6  "'s/extern  *\\([^ ]*[ \\*]*\\)/XBT_PUBLIC_DATA(\\1) /'")
32 set(string7  "'s/XBT_PUBLIC_DATA(\\([^)]*\\)) *\\([^(]*\\)(/XBT_PUBLIC(\\1) \\2(/'")
33 set(string8  "'s/#if defined(_WIN32)/#if defined(_XBT_WIN32)/g'")
34 set(string9  "'s/#include <unistd.h>/#if defined(_XBT_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'")
35 set(string10 "'s/#if defined(_WIN32)/#if defined(_XBT_WIN32)/g'")
36 set(string11 "'s/#include <unistd.h>/#if defined(_XBT_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'")
37 set(string12 "'s/#if defined(_WIN32)/#if defined(_XBT_WIN32)/g'")
38 set(string13 "'s/#include <unistd.h>/#if defined(_XBT_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'")
39
40 ADD_CUSTOM_COMMAND(
41         OUTPUT  ${PROJECT_DIRECTORY}/include/surf/simgrid_dtd.h
42                         ${PROJECT_DIRECTORY}/include/xbt/graphxml.h
43                         ${PROJECT_DIRECTORY}/src/simdag/dax_dtd.h
44                         ${PROJECT_DIRECTORY}/src/surf/simgrid_dtd.c
45                         ${PROJECT_DIRECTORY}/src/xbt/graphxml.c
46                         ${PROJECT_DIRECTORY}/src/simdag/dax_dtd.c
47                         
48         DEPENDS ${PROJECT_DIRECTORY}/src/surf/simgrid.dtd
49                         ${PROJECT_DIRECTORY}/src/xbt/graphxml.dtd
50                         ${PROJECT_DIRECTORY}/src/simdag/dax.dtd
51                                         
52         #${PROJECT_DIRECTORY}/src/surf/simgrid_dtd.l: ${PROJECT_DIRECTORY}/src/surf/simgrid.dtd
53         COMMAND ${FLEXML_EXE} --root-tags platform -b 1000000 -P surfxml --sysid=simgrid.dtd -S src/surf/simgrid_dtd.l -L src/surf/simgrid.dtd
54         COMMAND ${CMAKE_COMMAND} -E echo "src/surf/simgrid_dtd.l"
55         #${PROJECT_DIRECTORY}/src/xbt/graphxml.l: ${PROJECT_DIRECTORY}/src/xbt/graphxml.dtd
56         COMMAND ${FLEXML_EXE} -b 1000000 -P graphxml --sysid=graphxml.dtd -S src/xbt/graphxml.l -L src/xbt/graphxml.dtd
57         COMMAND ${CMAKE_COMMAND} -E echo "src/xbt/graphxml.l"
58         #${PROJECT_DIRECTORY}/src/simdag/dax_dtd.l: ${PROJECT_DIRECTORY}/src/simdag/dax.dtd
59         COMMAND ${FLEXML_EXE} -b 1000000 --root-tags adag -P dax_ --sysid=dax.dtd -S ${PROJECT_DIRECTORY}/src/simdag/dax_dtd.l -L ${PROJECT_DIRECTORY}/src/simdag/dax.dtd
60         COMMAND ${SED_EXE} -i'' ${string5} src/simdag/dax_dtd.l
61         COMMAND ${CMAKE_COMMAND} -E echo "src/simdag/dax_dtd.l"
62         
63         #${PROJECT_DIRECTORY}/include/surf/simgrid_dtd.h: ${PROJECT_DIRECTORY}/src/surf/simgrid.dtd
64         COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/include/surf/simgrid.h
65         COMMAND ${FLEXML_EXE} --root-tags platform -P surfxml --sysid=simgrid.dtd -H include/surf/simgrid_dtd.h -L src/surf/simgrid.dtd
66         COMMAND ${SED_EXE} -i'' ${string1} include/surf/simgrid_dtd.h
67         COMMAND ${SED_EXE} -i'' ${string2} include/surf/simgrid_dtd.h   
68         COMMAND ${CMAKE_COMMAND} -E echo "include/surf/simgrid_dtd.h"
69         #${PROJECT_DIRECTORY}/include/xbt/graphxml.h: ${PROJECT_DIRECTORY}/src/xbt/graphxml.dtd
70         COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/include/xbt/graphxml.h
71         COMMAND ${FLEXML_EXE} -P graphxml --sysid=graphxml.dtd -H include/xbt/graphxml.h -L src/xbt/graphxml.dtd
72         COMMAND ${SED_EXE} -i'' ${string3} include/xbt/graphxml.h       
73         COMMAND ${SED_EXE} -i'' ${string4} include/xbt/graphxml.h
74         COMMAND ${CMAKE_COMMAND} -E echo "include/xbt/graphxml.h"
75         #${PROJECT_DIRECTORY}/src/simdag/dax_dtd.h: ${PROJECT_DIRECTORY}/src/simdag/dax.dtd
76         COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/simdag/dax_dtd.h
77         COMMAND ${FLEXML_EXE} --root-tags adag -P dax_ --sysid=dax.dtd -H src/simdag/dax_dtd.h -L src/simdag/dax.dtd
78         COMMAND ${SED_EXE} -i'' ${string6} src/simdag/dax_dtd.h 
79         COMMAND ${SED_EXE} -i'' ${string7} src/simdag/dax_dtd.h
80         COMMAND ${FLEX_EXE} -o src/gras/DataDesc/ddt_parse.yy.c -Pgras_ddt_parse_ --noline src/gras/DataDesc/ddt_parse.yy.l
81         COMMAND ${CMAKE_COMMAND} -E echo "src/simdag/dax_dtd.h"
82         
83         #surf/simgrid_dtd.c: surf/simgrid_dtd.l
84         COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/surf/simgrid_dtd.c
85         COMMAND ${SED_EXE} -i'' ${string8} src/surf/simgrid_dtd.l
86         COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_DIRECTORY}/src/surf
87         COMMAND ${FLEX_EXE} -o src/surf/simgrid_dtd.c -Psurf_parse_ --noline src/surf/simgrid_dtd.l
88         COMMAND ${SED_EXE} -i'' ${string9} src/surf/simgrid_dtd.c
89         COMMAND ${CMAKE_COMMAND} -E echo "surf/simgrid_dtd.c"
90         #xbt/graphxml.c: xbt/graphxml.l
91         COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/xbt/graphxml.c
92         COMMAND ${SED_EXE} -i'' ${string10} src/xbt/graphxml.l  
93         COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_DIRECTORY}/src/xbt
94         COMMAND ${FLEX_EXE} -o src/xbt/graphxml.c -Pxbt_graph_parse_ --noline src/xbt/graphxml.l
95         COMMAND ${SED_EXE} -i'' ${string11} src/xbt/graphxml.c
96         COMMAND ${CMAKE_COMMAND} -E echo "xbt/graphxml.c"
97         #simdag/dax_dtd.c: simdag/dax_dtd.l
98         COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/simdag/dax_dtd.c
99         COMMAND ${SED_EXE} -i'' ${string12} src/simdag/dax_dtd.l
100         COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_DIRECTORY}/src/simdag
101         COMMAND ${FLEX_EXE} -o src/simdag/dax_dtd.c -Pdax_ --noline src/simdag/dax_dtd.l
102         COMMAND ${SED_EXE} -i'' ${string13} src/simdag/dax_dtd.c
103         COMMAND ${CMAKE_COMMAND} -E echo "simdag/dax_dtd.c"
104         
105         WORKING_DIRECTORY ${PROJECT_DIRECTORY}
106         COMMENT "Generating files in maintainer mode..."
107 )
108
109         add_custom_target(maintainer_files
110                                                 DEPENDS ${PROJECT_DIRECTORY}/include/surf/simgrid_dtd.h
111                                                                 ${PROJECT_DIRECTORY}/include/xbt/graphxml.h
112                                                                 ${PROJECT_DIRECTORY}/src/simdag/dax_dtd.h
113                                                                 ${PROJECT_DIRECTORY}/src/surf/simgrid_dtd.c
114                                                                 ${PROJECT_DIRECTORY}/src/xbt/graphxml.c
115                                                                 ${PROJECT_DIRECTORY}/src/simdag/dax_dtd.c
116                                                 )
117
118 else(HAVE_FLEXML AND HAVE_FLEX  AND SED_EXE)
119         message("  FLEX :       ${FLEX_EXE}")
120         message("FLEXML :       ${FLEXML_EXE}")
121         message("   SED :       ${SED_EXE}")
122         
123         if(NOT HAVE_FLEXML)
124                 message("Install flexml before use maintainer mode.")
125         endif(NOT HAVE_FLEXML)
126         if(NOT HAVE_FLEX)
127                 message("Install flex before use maintainer mode.")
128         endif(NOT HAVE_FLEX)
129         if(NOT SED_EXE)
130                 message("Install sed before use maintainer mode.")
131         endif(NOT SED_EXE)
132         
133         message(FATAL_ERROR "Need to install all tools for maintainer mode !!!")
134 endif(HAVE_FLEXML AND HAVE_FLEX  AND SED_EXE)
135
136 if(PERL_EXE)
137         
138         ADD_CUSTOM_COMMAND(
139         OUTPUT  ${PROJECT_DIRECTORY}/src/cunit_unit.c
140                         ${PROJECT_DIRECTORY}/src/ex_unit.c
141                         ${PROJECT_DIRECTORY}/src/dynar_unit.c
142                         ${PROJECT_DIRECTORY}/src/dict_unit.c
143                         ${PROJECT_DIRECTORY}/src/set_unit.c
144                         ${PROJECT_DIRECTORY}/src/swag_unit.c
145                         ${PROJECT_DIRECTORY}/src/xbt_str_unit.c
146                         ${PROJECT_DIRECTORY}/src/xbt_strbuff_unit.c
147                         ${PROJECT_DIRECTORY}/src/xbt_sha_unit.c
148                         ${PROJECT_DIRECTORY}/src/config_unit.c
149                         ${PROJECT_DIRECTORY}/src/xbt_synchro_unit.c
150                         
151         DEPENDS ${PROJECT_DIRECTORY}/tools/sg_unit_extractor.pl
152                         ${PROJECT_DIRECTORY}/src/xbt/cunit.c
153                         ${PROJECT_DIRECTORY}/src/xbt/ex.c
154                         ${PROJECT_DIRECTORY}/src/xbt/dynar.c
155                         ${PROJECT_DIRECTORY}/src/xbt/dict.c
156                         ${PROJECT_DIRECTORY}/src/xbt/set.c
157                         ${PROJECT_DIRECTORY}/src/xbt/swag.c
158                         ${PROJECT_DIRECTORY}/src/xbt/xbt_str.c
159                         ${PROJECT_DIRECTORY}/src/xbt/xbt_strbuff.c
160                         ${PROJECT_DIRECTORY}/src/xbt/xbt_sha.c
161                         ${PROJECT_DIRECTORY}/src/xbt/config.c
162                         ${PROJECT_DIRECTORY}/src/xbt/xbt_synchro.c
163         
164         COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/simgrid_units_main.c
165         COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/cunit_unit.c
166         COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/ex_unit.c
167         COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/dynar_unit.c
168         COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/dict_unit.c
169         COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/set_unit.c
170         COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/swag_unit.c
171         COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/xbt_str_unit.c
172         COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/xbt_strbuff_unit.c
173         COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/xbt_sha_unit.c
174         COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/config_unit.c
175         COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/xbt_synchro_unit.c
176         
177         COMMAND chmod a=rwx ${PROJECT_DIRECTORY}/tools/sg_unit_extractor.pl
178         
179         #$(TEST_UNITS): $(TEST_CFILES)
180         COMMAND ${PROJECT_DIRECTORY}/tools/sg_unit_extractor.pl xbt/cunit.c
181         COMMAND ${PROJECT_DIRECTORY}/tools/sg_unit_extractor.pl xbt/ex.c
182         COMMAND ${PROJECT_DIRECTORY}/tools/sg_unit_extractor.pl xbt/dynar.c
183         COMMAND ${PROJECT_DIRECTORY}/tools/sg_unit_extractor.pl xbt/dict.c
184         COMMAND ${PROJECT_DIRECTORY}/tools/sg_unit_extractor.pl xbt/set.c
185         COMMAND ${PROJECT_DIRECTORY}/tools/sg_unit_extractor.pl xbt/swag.c
186         COMMAND ${PROJECT_DIRECTORY}/tools/sg_unit_extractor.pl xbt/xbt_str.c
187         COMMAND ${PROJECT_DIRECTORY}/tools/sg_unit_extractor.pl xbt/xbt_strbuff.c
188         COMMAND ${PROJECT_DIRECTORY}/tools/sg_unit_extractor.pl xbt/xbt_sha.c
189         COMMAND ${PROJECT_DIRECTORY}/tools/sg_unit_extractor.pl xbt/config.c
190         COMMAND ${PROJECT_DIRECTORY}/tools/sg_unit_extractor.pl xbt/xbt_synchro.c
191         
192         #@builddir@/simgrid_units_main.c: $(TEST_UNITS)
193         COMMAND ${PROJECT_DIRECTORY}/tools/sg_unit_extractor.pl xbt/cunit.c
194         
195         WORKING_DIRECTORY ${PROJECT_DIRECTORY}/src
196         
197         COMMENT "Generating *_units files for testall..."
198         )
199         
200         add_custom_target(units_files
201                                                 DEPENDS ${PROJECT_DIRECTORY}/src/cunit_unit.c
202                                                                 ${PROJECT_DIRECTORY}/src/ex_unit.c
203                                                                 ${PROJECT_DIRECTORY}/src/dynar_unit.c
204                                                                 ${PROJECT_DIRECTORY}/src/dict_unit.c
205                                                                 ${PROJECT_DIRECTORY}/src/set_unit.c
206                                                                 ${PROJECT_DIRECTORY}/src/swag_unit.c
207                                                                 ${PROJECT_DIRECTORY}/src/xbt_str_unit.c
208                                                                 ${PROJECT_DIRECTORY}/src/xbt_strbuff_unit.c
209                                                                 ${PROJECT_DIRECTORY}/src/xbt_sha_unit.c
210                                                                 ${PROJECT_DIRECTORY}/src/config_unit.c
211                                                                 ${PROJECT_DIRECTORY}/src/xbt_synchro_unit.c
212                                                 )
213         
214 else(PERL_EXE)
215         message(FATAL_ERROR "Install perl before use maintainer mode")
216 endif(PERL_EXE)
217
218 endif(enable_maintainer_mode AND NOT WIN32)
219