Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix depency information for ddt_parse.yy.c (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
6 IF(FLEX_EXE)
7         set(HAVE_FLEX 1)
8         exec_program("${FLEX_EXE} --version" OUTPUT_VARIABLE FLEX_VERSION)
9         string(REGEX MATCH "[0-9]+[.]+[0-9]+[.]+[0-9]+" FLEX_VERSION "${FLEX_VERSION}")
10         string(REGEX MATCH "^[0-9]+" FLEX_MAJOR_VERSION "${FLEX_VERSION}")
11         string(REGEX MATCH "[0-9]+[.]+[0-9]+$" FLEX_VERSION "${FLEX_VERSION}")
12         string(REGEX MATCH "^[0-9]+" FLEX_MINOR_VERSION "${FLEX_VERSION}")
13         string(REGEX MATCH "[0-9]+$" FLEX_PATCH_VERSION "${FLEX_VERSION}")
14 ENDIF(FLEX_EXE)
15
16 IF(FLEXML_EXE)
17         set(HAVE_FLEXML 1)
18         exec_program("${FLEXML_EXE} --version" OUTPUT_VARIABLE FLEXML_VERSION)
19         string(REGEX MATCH "[0-9]+[.]+[0-9]+" FLEXML_VERSION "${FLEXML_VERSION}")
20         string(REGEX MATCH "^[0-9]*" FLEXML_MAJOR_VERSION "${FLEXML_VERSION}")
21         string(REGEX MATCH "[0-9]*$" FLEXML_MINOR_VERSION "${FLEXML_VERSION}")
22 ENDIF(FLEXML_EXE)
23
24 message(STATUS "Found flex: ${FLEX_EXE}")
25 message(STATUS "Found flexml: ${FLEXML_EXE}")
26 message(STATUS "Found sed: ${SED_EXE}")
27
28 if(HAVE_FLEXML AND HAVE_FLEX AND SED_EXE)
29
30 message(STATUS "Flex version: ${FLEX_MAJOR_VERSION}.${FLEX_MINOR_VERSION}.${FLEX_PATCH_VERSION}")
31 message(STATUS "Flexml version: ${FLEXML_MAJOR_VERSION}.${FLEXML_MINOR_VERSION}")
32
33 set(string1  "'s/extern  *\\([^ ]*[ \\*]*\\)/XBT_PUBLIC_DATA(\\1) /'")
34 set(string2  "'s/XBT_PUBLIC_DATA(\\([^)]*\\)) *\\([^(]*\\)(/XBT_PUBLIC(\\1) \\2(/'")
35 set(string3  "'s/extern  *\\([^ ]*[ \\*]*\\)/XBT_PUBLIC_DATA(\\1) /'")
36 set(string4  "'s/XBT_PUBLIC_DATA(\\([^)]*\\)) *\\([^(]*\\)(/XBT_PUBLIC(\\1) \\2(/'")
37 set(string5  "'s/SET(DOCTYPE)/SET(ROOT_dax__adag)/'")
38 set(string6  "'s/extern  *\\([^ ]*[ \\*]*\\)/XBT_PUBLIC_DATA(\\1) /'")
39 set(string7  "'s/XBT_PUBLIC_DATA(\\([^)]*\\)) *\\([^(]*\\)(/XBT_PUBLIC(\\1) \\2(/'")
40 set(string8  "'s/#if defined(_WIN32)/#if defined(_XBT_WIN32)/g'")
41 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'")
42 set(string10 "'s/#if defined(_WIN32)/#if defined(_XBT_WIN32)/g'")
43 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'")
44 set(string12 "'s/#if defined(_WIN32)/#if defined(_XBT_WIN32)/g'")
45 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'")
46 set(string14 "'\\!^ \\* Generated [0-9/]\\{10\\} [0-9:]\\{8\\}\\.$$!d'")
47 set(string15 "'s/FAIL(\"Premature EOF/if(!ETag_surfxml_include_state()) FAIL(\"Premature EOF/'")
48
49 ADD_CUSTOM_COMMAND(
50         OUTPUT  ${CMAKE_HOME_DIRECTORY}/include/surf/simgrid_dtd.h
51                         ${CMAKE_HOME_DIRECTORY}/include/xbt/graphxml.h
52                         ${CMAKE_HOME_DIRECTORY}/src/simdag/dax_dtd.h
53                         ${CMAKE_HOME_DIRECTORY}/src/surf/simgrid_dtd.c
54                         ${CMAKE_HOME_DIRECTORY}/src/xbt/graphxml.c
55                         ${CMAKE_HOME_DIRECTORY}/src/xbt/datadesc/ddt_parse.yy.c
56                         ${CMAKE_HOME_DIRECTORY}/src/simdag/dax_dtd.c
57                         
58         DEPENDS ${CMAKE_HOME_DIRECTORY}/src/surf/simgrid.dtd
59                         ${CMAKE_HOME_DIRECTORY}/src/xbt/graphxml.dtd
60                         ${CMAKE_HOME_DIRECTORY}/src/xbt/datadesc/ddt_parse.yy.l
61                         ${CMAKE_HOME_DIRECTORY}/src/simdag/dax.dtd
62                                         
63         #${CMAKE_HOME_DIRECTORY}/src/surf/simgrid_dtd.l: ${CMAKE_HOME_DIRECTORY}/src/surf/simgrid.dtd
64         COMMAND ${FLEXML_EXE} --root-tags platform -b 1000000 -P surfxml --sysid=http://simgrid.gforge.inria.fr/simgrid.dtd -S src/surf/simgrid_dtd.l -L src/surf/simgrid.dtd
65         COMMAND ${SED_EXE} -i ${string14} src/surf/simgrid_dtd.l
66         COMMAND ${CMAKE_COMMAND} -E echo "src/surf/simgrid_dtd.l"
67
68         #${CMAKE_HOME_DIRECTORY}/src/xbt/graphxml.l: ${CMAKE_HOME_DIRECTORY}/src/xbt/graphxml.dtd
69         COMMAND ${FLEXML_EXE} -b 1000000 -P graphxml --sysid=graphxml.dtd -S src/xbt/graphxml.l -L src/xbt/graphxml.dtd
70         COMMAND ${SED_EXE} -i ${string14} src/xbt/graphxml.l
71         COMMAND ${CMAKE_COMMAND} -E echo "src/xbt/graphxml.l"
72
73         #${CMAKE_HOME_DIRECTORY}/src/simdag/dax_dtd.l: ${CMAKE_HOME_DIRECTORY}/src/simdag/dax.dtd
74         COMMAND ${FLEXML_EXE} -b 1000000 --root-tags adag -P dax_ --sysid=dax.dtd -S src/simdag/dax_dtd.l -L src/simdag/dax.dtd
75         COMMAND ${SED_EXE} -i ${string5} src/simdag/dax_dtd.l
76         COMMAND ${SED_EXE} -i ${string14} src/simdag/dax_dtd.l
77         COMMAND ${CMAKE_COMMAND} -E echo "src/simdag/dax_dtd.l"
78         
79         #${CMAKE_HOME_DIRECTORY}/include/surf/simgrid_dtd.h: ${CMAKE_HOME_DIRECTORY}/src/surf/simgrid.dtd
80         COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/include/surf/simgrid.h
81         COMMAND ${FLEXML_EXE} --root-tags platform -P surfxml --sysid=http://simgrid.gforge.inria.fr/simgrid.dtd -H include/surf/simgrid_dtd.h -L src/surf/simgrid.dtd
82         COMMAND ${SED_EXE} -i ${string1} include/surf/simgrid_dtd.h
83         COMMAND ${SED_EXE} -i ${string2} include/surf/simgrid_dtd.h     
84         COMMAND ${SED_EXE} -i ${string14} include/surf/simgrid_dtd.h
85         COMMAND ${CMAKE_COMMAND} -E echo "include/surf/simgrid_dtd.h"
86
87         #${CMAKE_HOME_DIRECTORY}/include/xbt/graphxml.h: ${CMAKE_HOME_DIRECTORY}/src/xbt/graphxml.dtd
88         COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/include/xbt/graphxml.h
89         COMMAND ${FLEXML_EXE} -P graphxml --sysid=graphxml.dtd -H include/xbt/graphxml.h -L src/xbt/graphxml.dtd
90         COMMAND ${SED_EXE} -i ${string3} include/xbt/graphxml.h 
91         COMMAND ${SED_EXE} -i ${string4} include/xbt/graphxml.h
92         COMMAND ${SED_EXE} -i ${string14} include/xbt/graphxml.h
93         COMMAND ${CMAKE_COMMAND} -E echo "include/xbt/graphxml.h"
94
95         #${CMAKE_HOME_DIRECTORY}/src/simdag/dax_dtd.h: ${CMAKE_HOME_DIRECTORY}/src/simdag/dax.dtd
96         COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/src/simdag/dax_dtd.h
97         COMMAND ${FLEXML_EXE} --root-tags adag -P dax_ --sysid=dax.dtd -H src/simdag/dax_dtd.h -L src/simdag/dax.dtd
98         COMMAND ${SED_EXE} -i ${string6} src/simdag/dax_dtd.h   
99         COMMAND ${SED_EXE} -i ${string7} src/simdag/dax_dtd.h
100         COMMAND ${SED_EXE} -i ${string14} src/simdag/dax_dtd.h
101         COMMAND ${CMAKE_COMMAND} -E echo "src/simdag/dax_dtd.h"
102         
103         #surf/simgrid_dtd.c: surf/simgrid_dtd.l
104         COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/src/surf/simgrid_dtd.c
105         COMMAND ${SED_EXE} -i ${string8} src/surf/simgrid_dtd.l
106         COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_HOME_DIRECTORY}/src/surf
107         COMMAND ${FLEX_EXE} -o src/surf/simgrid_dtd.c -Psurf_parse_ --noline src/surf/simgrid_dtd.l
108         COMMAND ${SED_EXE} -i ${string9} src/surf/simgrid_dtd.c
109         COMMAND ${SED_EXE} -i ${string15} src/surf/simgrid_dtd.c
110         COMMAND ${CMAKE_COMMAND} -E echo "surf/simgrid_dtd.c"
111
112         #xbt/graphxml.c: xbt/graphxml.l
113         COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/src/xbt/graphxml.c
114         COMMAND ${SED_EXE} -i ${string10} src/xbt/graphxml.l    
115         COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_HOME_DIRECTORY}/src/xbt
116         COMMAND ${FLEX_EXE} -o src/xbt/graphxml.c -Pxbt_graph_parse_ --noline src/xbt/graphxml.l
117         COMMAND ${SED_EXE} -i ${string11} src/xbt/graphxml.c
118         COMMAND ${CMAKE_COMMAND} -E echo "xbt/graphxml.c"
119
120         # src/xbt/datadesc/ddt_parse.yy.c: src/xbt/datadesc/ddt_parse.yy.l
121         COMMAND ${FLEX_EXE} -o src/xbt/datadesc/ddt_parse.yy.c -Pxbt_ddt_parse_ --noline src/xbt/datadesc/ddt_parse.yy.l
122         COMMAND ${CMAKE_COMMAND} -E echo "xbt/datadesc/ddt_parse.yy.c"
123
124         #simdag/dax_dtd.c: simdag/dax_dtd.l
125         COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/src/simdag/dax_dtd.c
126         COMMAND ${SED_EXE} -i ${string12} src/simdag/dax_dtd.l
127         COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_HOME_DIRECTORY}/src/simdag
128         COMMAND ${FLEX_EXE} -o src/simdag/dax_dtd.c -Pdax_ --noline src/simdag/dax_dtd.l
129         COMMAND ${SED_EXE} -i ${string13} src/simdag/dax_dtd.c
130         COMMAND ${CMAKE_COMMAND} -E echo "simdag/dax_dtd.c"
131         
132         WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}
133         COMMENT "Generating files in maintainer mode..."
134 )
135
136         add_custom_target(maintainer_files
137                                                 DEPENDS ${CMAKE_HOME_DIRECTORY}/include/surf/simgrid_dtd.h
138                                                                 ${CMAKE_HOME_DIRECTORY}/include/xbt/graphxml.h
139                                                                 ${CMAKE_HOME_DIRECTORY}/src/simdag/dax_dtd.h
140                                                                 ${CMAKE_HOME_DIRECTORY}/src/surf/simgrid_dtd.c
141                                                                 ${CMAKE_HOME_DIRECTORY}/src/xbt/graphxml.c
142                                                                 ${CMAKE_HOME_DIRECTORY}/src/xbt/datadesc/ddt_parse.yy.c
143                                                                 ${CMAKE_HOME_DIRECTORY}/src/simdag/dax_dtd.c
144                                                 )
145
146 else(HAVE_FLEXML AND HAVE_FLEX  AND SED_EXE)
147         if(NOT HAVE_FLEXML)
148                 message(STATUS "Error : Install flexml before use maintainer mode.")
149         endif(NOT HAVE_FLEXML)
150         if(NOT HAVE_FLEX)
151                 message(STATUS "Error : Install flex before use maintainer mode.")
152         endif(NOT HAVE_FLEX)
153         if(NOT SED_EXE)
154                 message(STATUS "Error : Install sed before use maintainer mode.")
155         endif(NOT SED_EXE)
156         
157         message(FATAL_ERROR STATUS "Error : Need to install all tools for maintainer mode !!!")
158 endif(HAVE_FLEXML AND HAVE_FLEX  AND SED_EXE)
159
160 endif(enable_maintainer_mode AND NOT WIN32)
161