Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
install java from the simgrid-java, not make project
[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 if(HAVE_FLEXML AND HAVE_FLEX AND SED_EXE)
25 set(string1  "'s/extern  *\\([^ ]*[ \\*]*\\)/XBT_PUBLIC_DATA(\\1) /'")
26 set(string2  "'s/XBT_PUBLIC_DATA(\\([^)]*\\)) *\\([^(]*\\)(/XBT_PUBLIC(\\1) \\2(/'")
27 set(string3  "'s/extern  *\\([^ ]*[ \\*]*\\)/XBT_PUBLIC_DATA(\\1) /'")
28 set(string4  "'s/XBT_PUBLIC_DATA(\\([^)]*\\)) *\\([^(]*\\)(/XBT_PUBLIC(\\1) \\2(/'")
29 set(string5  "'s/SET(DOCTYPE)/SET(ROOT_dax__adag)/'")
30 set(string6  "'s/extern  *\\([^ ]*[ \\*]*\\)/XBT_PUBLIC_DATA(\\1) /'")
31 set(string7  "'s/XBT_PUBLIC_DATA(\\([^)]*\\)) *\\([^(]*\\)(/XBT_PUBLIC(\\1) \\2(/'")
32 set(string8  "'s/#if defined(_WIN32)/#if defined(_XBT_WIN32)/g'")
33 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'")
34 set(string10 "'s/#if defined(_WIN32)/#if defined(_XBT_WIN32)/g'")
35 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'")
36 set(string12 "'s/#if defined(_WIN32)/#if defined(_XBT_WIN32)/g'")
37 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'")
38
39 ADD_CUSTOM_COMMAND(
40         OUTPUT  ${CMAKE_HOME_DIRECTORY}/include/surf/simgrid_dtd.h
41                         ${CMAKE_HOME_DIRECTORY}/include/xbt/graphxml.h
42                         ${CMAKE_HOME_DIRECTORY}/src/simdag/dax_dtd.h
43                         ${CMAKE_HOME_DIRECTORY}/src/surf/simgrid_dtd.c
44                         ${CMAKE_HOME_DIRECTORY}/src/xbt/graphxml.c
45                         ${CMAKE_HOME_DIRECTORY}/src/simdag/dax_dtd.c
46                         
47         DEPENDS ${CMAKE_HOME_DIRECTORY}/src/surf/simgrid.dtd
48                         ${CMAKE_HOME_DIRECTORY}/src/xbt/graphxml.dtd
49                         ${CMAKE_HOME_DIRECTORY}/src/simdag/dax.dtd
50                                         
51         #${CMAKE_HOME_DIRECTORY}/src/surf/simgrid_dtd.l: ${CMAKE_HOME_DIRECTORY}/src/surf/simgrid.dtd
52         COMMAND ${FLEXML_EXE} --root-tags platform -b 1000000 -P surfxml --sysid=simgrid.dtd -S src/surf/simgrid_dtd.l -L src/surf/simgrid.dtd
53         COMMAND ${CMAKE_COMMAND} -E echo "src/surf/simgrid_dtd.l"
54         #${CMAKE_HOME_DIRECTORY}/src/xbt/graphxml.l: ${CMAKE_HOME_DIRECTORY}/src/xbt/graphxml.dtd
55         COMMAND ${FLEXML_EXE} -b 1000000 -P graphxml --sysid=graphxml.dtd -S src/xbt/graphxml.l -L src/xbt/graphxml.dtd
56         COMMAND ${CMAKE_COMMAND} -E echo "src/xbt/graphxml.l"
57         #${CMAKE_HOME_DIRECTORY}/src/simdag/dax_dtd.l: ${CMAKE_HOME_DIRECTORY}/src/simdag/dax.dtd
58         COMMAND ${FLEXML_EXE} -b 1000000 --root-tags adag -P dax_ --sysid=dax.dtd -S ${CMAKE_HOME_DIRECTORY}/src/simdag/dax_dtd.l -L ${CMAKE_HOME_DIRECTORY}/src/simdag/dax.dtd
59         COMMAND ${SED_EXE} -i ${string5} src/simdag/dax_dtd.l
60         COMMAND ${CMAKE_COMMAND} -E echo "src/simdag/dax_dtd.l"
61         
62         #${CMAKE_HOME_DIRECTORY}/include/surf/simgrid_dtd.h: ${CMAKE_HOME_DIRECTORY}/src/surf/simgrid.dtd
63         COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/include/surf/simgrid.h
64         COMMAND ${FLEXML_EXE} --root-tags platform -P surfxml --sysid=simgrid.dtd -H include/surf/simgrid_dtd.h -L src/surf/simgrid.dtd
65         COMMAND ${SED_EXE} -i ${string1} include/surf/simgrid_dtd.h
66         COMMAND ${SED_EXE} -i ${string2} include/surf/simgrid_dtd.h     
67         COMMAND ${CMAKE_COMMAND} -E echo "include/surf/simgrid_dtd.h"
68         #${CMAKE_HOME_DIRECTORY}/include/xbt/graphxml.h: ${CMAKE_HOME_DIRECTORY}/src/xbt/graphxml.dtd
69         COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/include/xbt/graphxml.h
70         COMMAND ${FLEXML_EXE} -P graphxml --sysid=graphxml.dtd -H include/xbt/graphxml.h -L src/xbt/graphxml.dtd
71         COMMAND ${SED_EXE} -i ${string3} include/xbt/graphxml.h 
72         COMMAND ${SED_EXE} -i ${string4} include/xbt/graphxml.h
73         COMMAND ${CMAKE_COMMAND} -E echo "include/xbt/graphxml.h"
74         #${CMAKE_HOME_DIRECTORY}/src/simdag/dax_dtd.h: ${CMAKE_HOME_DIRECTORY}/src/simdag/dax.dtd
75         COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/src/simdag/dax_dtd.h
76         COMMAND ${FLEXML_EXE} --root-tags adag -P dax_ --sysid=dax.dtd -H src/simdag/dax_dtd.h -L src/simdag/dax.dtd
77         COMMAND ${SED_EXE} -i ${string6} src/simdag/dax_dtd.h   
78         COMMAND ${SED_EXE} -i ${string7} src/simdag/dax_dtd.h
79         COMMAND ${FLEX_EXE} -o src/gras/DataDesc/ddt_parse.yy.c -Pgras_ddt_parse_ --noline src/gras/DataDesc/ddt_parse.yy.l
80         COMMAND ${CMAKE_COMMAND} -E echo "src/simdag/dax_dtd.h"
81         
82         #surf/simgrid_dtd.c: surf/simgrid_dtd.l
83         COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/src/surf/simgrid_dtd.c
84         COMMAND ${SED_EXE} -i ${string8} src/surf/simgrid_dtd.l
85         COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_HOME_DIRECTORY}/src/surf
86         COMMAND ${FLEX_EXE} -o src/surf/simgrid_dtd.c -Psurf_parse_ --noline src/surf/simgrid_dtd.l
87         COMMAND ${SED_EXE} -i ${string9} src/surf/simgrid_dtd.c
88         COMMAND ${CMAKE_COMMAND} -E echo "surf/simgrid_dtd.c"
89         #xbt/graphxml.c: xbt/graphxml.l
90         COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/src/xbt/graphxml.c
91         COMMAND ${SED_EXE} -i ${string10} src/xbt/graphxml.l    
92         COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_HOME_DIRECTORY}/src/xbt
93         COMMAND ${FLEX_EXE} -o src/xbt/graphxml.c -Pxbt_graph_parse_ --noline src/xbt/graphxml.l
94         COMMAND ${SED_EXE} -i ${string11} src/xbt/graphxml.c
95         COMMAND ${CMAKE_COMMAND} -E echo "xbt/graphxml.c"
96         #simdag/dax_dtd.c: simdag/dax_dtd.l
97         COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/src/simdag/dax_dtd.c
98         COMMAND ${SED_EXE} -i ${string12} src/simdag/dax_dtd.l
99         COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_HOME_DIRECTORY}/src/simdag
100         COMMAND ${FLEX_EXE} -o src/simdag/dax_dtd.c -Pdax_ --noline src/simdag/dax_dtd.l
101         COMMAND ${SED_EXE} -i ${string13} src/simdag/dax_dtd.c
102         COMMAND ${CMAKE_COMMAND} -E echo "simdag/dax_dtd.c"
103         
104         WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}
105         COMMENT "Generating files in maintainer mode..."
106 )
107
108         add_custom_target(maintainer_files
109                                                 DEPENDS ${CMAKE_HOME_DIRECTORY}/include/surf/simgrid_dtd.h
110                                                                 ${CMAKE_HOME_DIRECTORY}/include/xbt/graphxml.h
111                                                                 ${CMAKE_HOME_DIRECTORY}/src/simdag/dax_dtd.h
112                                                                 ${CMAKE_HOME_DIRECTORY}/src/surf/simgrid_dtd.c
113                                                                 ${CMAKE_HOME_DIRECTORY}/src/xbt/graphxml.c
114                                                                 ${CMAKE_HOME_DIRECTORY}/src/simdag/dax_dtd.c
115                                                 )
116
117 else(HAVE_FLEXML AND HAVE_FLEX  AND SED_EXE)
118         message("  FLEX :       ${FLEX_EXE}")
119         message("FLEXML :       ${FLEXML_EXE}")
120         message("   SED :       ${SED_EXE}")
121         
122         if(NOT HAVE_FLEXML)
123                 message("Install flexml before use maintainer mode.")
124         endif(NOT HAVE_FLEXML)
125         if(NOT HAVE_FLEX)
126                 message("Install flex before use maintainer mode.")
127         endif(NOT HAVE_FLEX)
128         if(NOT SED_EXE)
129                 message("Install sed before use maintainer mode.")
130         endif(NOT SED_EXE)
131         
132         message(FATAL_ERROR "Need to install all tools for maintainer mode !!!")
133 endif(HAVE_FLEXML AND HAVE_FLEX  AND SED_EXE)
134
135
136 endif(enable_maintainer_mode AND NOT WIN32)
137