Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Generate files in good order.
[simgrid.git] / buildtools / Cmake / src / CMakeFLEXml.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
9 message("  FLEX :       ${FLEX_EXE}")
10 message("FLEXML :       ${FLEXML_EXE}")
11 message("   SED :       ${SED_EXE}\n")
12
13 set(top_srcdir "${PROJECT_DIRECTORY}")
14 set(srcdir "${PROJECT_DIRECTORY}/src")
15
16 IF(FLEX_EXE)
17         set(HAVE_FLEX 1)
18 ENDIF(FLEX_EXE)
19
20 IF(FLEXML_EXE)
21         set(HAVE_FLEXML 1)
22 ENDIF(FLEXML_EXE)
23
24 if(HAVE_FLEXML AND HAVE_FLEX AND SED_EXE)
25
26 #surf/simgrid_dtd.l: $(srcdir)/surf/simgrid.dtd
27 exec_program("mkdir -p surf")
28 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/")
29
30 #$(top_srcdir)/include/surf/simgrid_dtd.h: $(srcdir)/surf/simgrid.dtd
31 file(REMOVE "${top_srcdir}/include/surf/simgrid.h") 
32 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/")
33
34 if(EXISTS ${top_srcdir}/include/surf/simgrid.h)
35         #mv ${top_srcdir}/include/surf/simgrid.h ${top_srcdir}/include/surf/simgrid_dtd.h 
36 endif(EXISTS ${top_srcdir}/include/surf/simgrid.h)
37 set(CHAINE "'s/extern  *\\([^ ]*[ \\*]*\\)/XBT_PUBLIC_DATA(\\1) /'")
38 exec_program("${SED_EXE} ${CHAINE} -i ${top_srcdir}/include/surf/simgrid_dtd.h" "${PROJECT_DIRECTORY}/src/")
39 set(CHAINE "'s/XBT_PUBLIC_DATA(\\([^)]*\\)) *\\([^(]*\\)(/XBT_PUBLIC(\\1) \\2(/'")      
40 exec_program("${SED_EXE} ${CHAINE} -i ${top_srcdir}/include/surf/simgrid_dtd.h" "${PROJECT_DIRECTORY}/src/")
41
42 #xbt/graphxml.l: $(srcdir)/xbt/graphxml.dtd
43 exec_program("${FLEXML_EXE} -b 1000000 -P graphxml --sysid=graphxml.dtd -S xbt/graphxml.l -L ${srcdir}/xbt/graphxml.dtd" "${PROJECT_DIRECTORY}/src/")
44
45 #$(top_srcdir)/include/xbt/graphxml.h: $(srcdir)/xbt/graphxml.dtd
46 exec_program("${FLEXML_EXE} -P graphxml --sysid=graphxml.dtd -H ${top_srcdir}/include/xbt/graphxml.h -L ${srcdir}/xbt/graphxml.dtd" "${PROJECT_DIRECTORY}/src/")
47 set(CHAINE "'s/extern  *\\([^ ]*[ \\*]*\\)/XBT_PUBLIC_DATA(\\1) /'")
48 exec_program("${SED_EXE} ${CHAINE} -i ${top_srcdir}/include/xbt/graphxml.h" "${PROJECT_DIRECTORY}/src/")
49 set(CHAINE "'s/XBT_PUBLIC_DATA(\\([^)]*\\)) *\\([^(]*\\)(/XBT_PUBLIC(\\1) \\2(/'")
50 exec_program("${SED_EXE} ${CHAINE} -i ${top_srcdir}/include/xbt/graphxml.h" "${PROJECT_DIRECTORY}/src/")
51
52 #simdag/dax_dtd.l: simdag/dax.dtd
53 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/")
54 set(CHAINE "'s/SET(DOCTYPE)/SET(ROOT_dax__adag)/'")
55 exec_program("${SED_EXE} -i ${CHAINE} simdag/dax_dtd.l" "${PROJECT_DIRECTORY}/src/") # DOCTYPE not mandatory
56
57 #simdag/dax_dtd.h: simdag/dax.dtd
58 exec_program("${FLEXML_EXE} --root-tags adag -P dax_ --sysid=dax.dtd -H simdag/dax_dtd.h -L simdag/dax.dtd" "${PROJECT_DIRECTORY}/src/")
59 set(CHAINE "'s/extern  *\\([^ ]*[ \\*]*\\)/XBT_PUBLIC_DATA(\\1) /'")
60 exec_program("${SED_EXE} ${CHAINE} -i simdag/dax_dtd.h" "${PROJECT_DIRECTORY}/src/")
61 set(CHAINE "'s/XBT_PUBLIC_DATA(\\([^)]*\\)) *\\([^(]*\\)(/XBT_PUBLIC(\\1) \\2(/'")      
62 exec_program("${SED_EXE} ${CHAINE} -i simdag/dax_dtd.h" "${PROJECT_DIRECTORY}/src/")
63
64 exec_program("${FLEX_EXE} -o gras/DataDesc/ddt_parse.yy.c -Pgras_ddt_parse_ --noline gras/DataDesc/ddt_parse.yy.l" "${PROJECT_DIRECTORY}/src/")
65
66 #surf/simgrid_dtd.c: surf/simgrid_dtd.l
67 exec_program("mkdir -p `dirname surf/simgrid_dtd.c`" "${PROJECT_DIRECTORY}/src/")
68 exec_program("${FLEX_EXE} -o surf/simgrid_dtd.c -Psurf_parse_ --noline surf/simgrid_dtd.l" "${PROJECT_DIRECTORY}/src/")
69 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")      
70 exec_program("${SED_EXE} ${CHAINE}" "${PROJECT_DIRECTORY}/src/")
71
72 #xbt/graphxml.c: xbt/graphxml.l
73 exec_program("mkdir -p `dirname xbt/graphxml.c`" "${PROJECT_DIRECTORY}/src/")
74 exec_program("${FLEX_EXE} -o xbt/graphxml.c -Pxbt_graph_parse_ --noline xbt/graphxml.l" "${PROJECT_DIRECTORY}/src/")
75 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")                  
76 exec_program("${SED_EXE} ${CHAINE}" "${PROJECT_DIRECTORY}/src/")
77
78 #simdag/dax_dtd.c: simdag/dax_dtd.l
79 exec_program("mkdir -p `dirname simdag/dax_dtd.c`" "${PROJECT_DIRECTORY}/src/")
80 exec_program("${FLEX_EXE} -o simdag/dax_dtd.c -Pdax_ --noline simdag/dax_dtd.l" "${PROJECT_DIRECTORY}/src/")
81 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")        
82 exec_program("${SED_EXE} ${CHAINE}" "${PROJECT_DIRECTORY}/src/")
83
84 elseif(HAVE_FLEXML AND HAVE_FLEX  AND SED_EXE)
85         message("  FLEX :       ${FLEX_EXE}")
86         message("FLEXML :       ${FLEXML_EXE}")
87         message("   SED :       ${SED_EXE}")
88         message(FATAL_ERROR "Install flex or flexml or sed before use maintainer mode")
89 endif(HAVE_FLEXML AND HAVE_FLEX  AND SED_EXE)
90
91 #include $(top_srcdir)/acmacro/dist-files.mk
92
93 message("")
94 message("________________________________________________________________________________")
95 message("________________________________________________________________________________ FLEXML END")
96 endif(enable_maintainer_mode)
97