Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
af1dae66f6a00478fcb03c410affae3979d61320
[simgrid.git] / buildtools / Cmake / src / doc / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2 SET(PROJECT_NAME "Simgrid_doc")
3 find_program(PWD_EXE NAMES pwd)
4 find_path(FIG2DEV_PATH  NAMES fig2dev   PATHS NO_DEFAULT_PATHS)
5 find_path(DOXYGEN_PATH  NAMES doxygen   PATHS NO_DEFAULT_PATHS)
6 find_path(BIBTOOL_PATH  NAMES bibtool   PATHS NO_DEFAULT_PATHS)
7
8 ### AUTO DETECT THE PROJECT_DIRECTORY
9 exec_program("${PWD_EXE}" OUTPUT_VARIABLE PROJECT_DIRECTORY)
10 #message("PROJECT_DIRECTORY = ${PROJECT_DIRECTORY}")
11 string(REPLACE "/buildtools/Cmake/src/doc" "" PROJECT_DIRECTORY "${PROJECT_DIRECTORY}")
12 #message("PROJECT_DIRECTORY = ${PROJECT_DIRECTORY}")
13
14 if(NOT EXISTS "${PROJECT_DIRECTORY}/bibtex2html-1.02/src/bibtex2html")
15         write_file("${PROJECT_DIRECTORY}/buildtools/Cmake/bibtex2html_install.sh"
16         "#! /bin/sh
17         cd ${PROJECT_DIRECTORY}
18         wget ftp://ftp-sop.inria.fr/epidaure/Softs/bibtex2html/bibtex2html-1.02.tar.gz
19         rm -rf bibtex2html-1.02
20         tar -xvf bibtex2html-1.02.tar.gz
21         rm bibtex2html-1.02.tar.gz
22         cd bibtex2html-1.02/src
23         make"
24         )
25         exec_program("chmod a=rwx ${PROJECT_DIRECTORY}/buildtools/Cmake/bibtex2html_install.sh")
26         exec_program("${PROJECT_DIRECTORY}/buildtools/Cmake/bibtex2html_install.sh" OUTPUT_VARIABLE OKITOKI)
27         exec_program("rm ${PROJECT_DIRECTORY}/buildtools/Cmake/bibtex2html_install.sh" OUTPUT_VARIABLE OKITOKI)
28
29         if(EXISTS "${PROJECT_DIRECTORY}/bibtex2html-1.02/src/bibtex2html")
30         set(BIBTEX2HTML_PATH ${PROJECT_DIRECTORY}/bibtex2html-1.02/src)
31         else(EXISTS "${PROJECT_DIRECTORY}/bibtex2html-1.02/src/bibtex2html")
32         set(BIBTEX2HTML_PATH NOT_FOUND)
33         endif(EXISTS "${PROJECT_DIRECTORY}/bibtex2html-1.02/src/bibtex2html")
34
35 else(NOT EXISTS "${PROJECT_DIRECTORY}/bibtex2html-1.02/src/bibtex2html")
36         set(BIBTEX2HTML_PATH ${PROJECT_DIRECTORY}/bibtex2html-1.02/src)
37 endif(NOT EXISTS "${PROJECT_DIRECTORY}/bibtex2html-1.02/src/bibtex2html")
38
39 find_path(ICONV_PATH    NAMES iconv     PATHS NO_DEFAULT_PATHS)
40 find_path(MAKE_PATH     NAMES make      PATHS NO_DEFAULT_PATHS)
41
42 exec_program("rm -rf ${PROJECT_DIRECTORY}/doc/html"  "${PROJECT_DIRECTORY}/doc/")
43 exec_program("mkdir -p ${PROJECT_DIRECTORY}/doc/html"  "${PROJECT_DIRECTORY}/doc/")
44 exec_program("find ${PROJECT_DIRECTORY}/tools/gras  ${PROJECT_DIRECTORY}/src ${PROJECT_DIRECTORY}/include -name \"*.[chl]\"" OUTPUT_VARIABLE LISTE_UNE)
45 exec_program("find ${PROJECT_DIRECTORY} -name \"*.doc\" |grep -v logcategories.doc"  "${PROJECT_DIRECTORY}/doc/" OUTPUT_VARIABLE LISTE_DEUX)
46
47
48 set(DOCSSOURCES "${LISTE_UNE}\n${LISTE_DEUX}")
49 string(REPLACE "\n" ";" DOCSSOURCES ${DOCSSOURCES})
50
51 set(FIGS
52 ${PROJECT_DIRECTORY}/doc/fig/simgrid_modules.fig
53 ${PROJECT_DIRECTORY}/doc/fig/simgrid_modules2.fig
54 ${PROJECT_DIRECTORY}/doc/fig/amok_bw_test.fig
55 ${PROJECT_DIRECTORY}/doc/fig/amok_bw_sat.fig
56 ${PROJECT_DIRECTORY}/doc/fig/gras_comm.fig
57 )
58
59 string(REPLACE ".fig" ".png\n" LISTE_TROIS ${FIGS})
60
61 set(PNGS 
62 ${PROJECT_DIRECTORY}/doc/webcruft/simgrid_logo.png
63 ${PROJECT_DIRECTORY}/doc/webcruft/simgrid_logo_small.png
64 ${PROJECT_DIRECTORY}/doc/webcruft/poster_thumbnail.png
65 )
66
67 SET(PRINT false)
68
69 if(PRINT)
70
71 message("${DOXYGEN_PATH}/doxygen")
72 message("${FIG2DEV_PATH}/fig2dev")
73 message("${BIBTOOL_PATH}/bibtool")
74 message("${BIBTEX2HTML_PATH}/bibtex2html")
75 message("${ICONV_PATH}/iconv")
76 message("\n")
77
78 endif(PRINT)
79
80 if(DOXYGEN_PATH AND FIG2DEV_PATH)
81
82         exec_program("${FIG2DEV_PATH}/fig2dev -Lmap ${PROJECT_DIRECTORY}/doc/fig/simgrid_modules.fig | grep -e IMG -e MAP -e AREA | sed 's/imagemap/simgrid_modules/g' | sed 's/\\.gif/.png/' | sed 's/<IMG /<IMG style=\"border:0px \"/g' | sed 's/\\.gif/.png/' > ${PROJECT_DIRECTORY}/doc/simgrid_modules.map"  "${PROJECT_DIRECTORY}/doc/")
83
84         foreach(file ${FIGS})
85                 string(REPLACE ".fig" ".png" tmp_file ${file})
86                 string(REPLACE "${PROJECT_DIRECTORY}/doc/fig/" "${PROJECT_DIRECTORY}/doc/html/" tmp_file ${tmp_file})
87                 exec_program("${FIG2DEV_PATH}/fig2dev -Lpng ${file} > ${tmp_file}"  "${PROJECT_DIRECTORY}/doc/")
88         endforeach(file ${FIGS})
89
90
91         exec_program("touch ${PROJECT_DIRECTORY}/doc/index-API.doc ${PROJECT_DIRECTORY}/doc/.FAQ.doc.toc ${PROJECT_DIRECTORY}/doc/.index.doc.toc ${PROJECT_DIRECTORY}/doc/.contrib.doc.toc ${PROJECT_DIRECTORY}/doc/.history.doc.toc"  "${PROJECT_DIRECTORY}/doc/")
92         exec_program("test -e ${PROJECT_DIRECTORY}/doc/html || mkdir ${PROJECT_DIRECTORY}/doc/html"  "${PROJECT_DIRECTORY}/doc/")
93
94         foreach(file ${PNGS})
95                 exec_program("cp ${file} ${PROJECT_DIRECTORY}/doc/html/"  "${PROJECT_DIRECTORY}/doc/")
96         endforeach(file ${PNGS})
97
98         exec_program("cp ${PROJECT_DIRECTORY}/doc/webcruft/Paje_MSG_screenshot_thn.jpg ${PROJECT_DIRECTORY}/doc/webcruft/Paje_MSG_screenshot.jpg ${PROJECT_DIRECTORY}/doc/html/"  "${PROJECT_DIRECTORY}/doc/")
99         exec_program("cp ${PROJECT_DIRECTORY}/doc/simgrid.css ${PROJECT_DIRECTORY}/doc/html/"  "${PROJECT_DIRECTORY}/doc/") 
100
101         set(top_srcdir "..")
102         set(WARNING "This file is generated, do not edit")
103         set(srcdir ".")
104         configure_file(${PROJECT_DIRECTORY}/doc/Doxyfile.in ${PROJECT_DIRECTORY}/doc/Doxyfile @ONLY)
105 # First pass
106         exec_program("${DOXYGEN_PATH}/doxygen ${PROJECT_DIRECTORY}/doc/Doxyfile" "${PROJECT_DIRECTORY}/doc/")
107
108         exec_program("${PROJECT_DIRECTORY}/tools/doxygen/index_create.pl" "${PROJECT_DIRECTORY}/doc/"
109         ARGS simgrid.tag index-API.doc)
110         exec_program("${PROJECT_DIRECTORY}/tools/doxygen/toc_create.pl" "${PROJECT_DIRECTORY}/doc/"
111         ARGS FAQ.doc index.doc contrib.doc gtut-introduction.doc history.doc)
112 # Second pass
113         exec_program("${DOXYGEN_PATH}/doxygen ${PROJECT_DIRECTORY}/doc/Doxyfile" "${PROJECT_DIRECTORY}/doc/")
114 # Post-processing
115         exec_program("rm -f ${PROJECT_DIRECTORY}/doc/html/dir*"  "${PROJECT_DIRECTORY}/doc/")
116         exec_program("${PROJECT_DIRECTORY}/tools/doxygen/index_php.pl""${PROJECT_DIRECTORY}/doc/"
117         ARGS index.php.in html/index.html index.php)
118         exec_program("${PROJECT_DIRECTORY}/tools/doxygen/doxygen_postprocesser.pl"  "${PROJECT_DIRECTORY}/doc/")
119
120 #html/gras.html:
121         exec_program("echo \"<html><META HTTP-EQUIV='Refresh' content='0;URL=http://simgrid.gforge.inria.fr/doc/group__GRAS__API.html'>\" > ${PROJECT_DIRECTORY}/doc/html/gras.html"  "${PROJECT_DIRECTORY}/doc/")
122         exec_program("echo \"<center><h2><br><a href='http://simgrid.gforge.inria.fr/doc/group__GRAS__API.html'>Grid Reality And Simulation.</a></h2></center></html>\" >> ${PROJECT_DIRECTORY}/doc/html/gras.html"  "${PROJECT_DIRECTORY}/doc/")
123 #html/amok.html:
124         exec_program("echo \"<html><META HTTP-EQUIV='Refresh' content='0;URL=http://simgrid.gforge.inria.fr/doc/group__AMOK__API.html'>\" > ${PROJECT_DIRECTORY}/doc/html/amok.html"  "${PROJECT_DIRECTORY}/doc/")
125         exec_program("echo \"<center><h2><br><a href='http://simgrid.gforge.inria.fr/doc/group__AMOK__API.html'>Advanced Metacomputing Overlay Kit.</a></h2></center></html>\" >> ${PROJECT_DIRECTORY}/doc/html/amok.html"  "${PROJECT_DIRECTORY}/doc/")
126 #html/msg.html:
127         exec_program("echo \"<html><META HTTP-EQUIV='Refresh' content='0;URL=http://simgrid.gforge.inria.fr/doc/group__MSG__API.html'>\" > ${PROJECT_DIRECTORY}/doc/html/msg.html"  "${PROJECT_DIRECTORY}/doc/")
128         exec_program("echo \"<center><h2><br><a href='http://simgrid.gforge.inria.fr/doc/group__MSG__API.html'>Meta SimGrid.</a></h2></center></html>\" >> ${PROJECT_DIRECTORY}/doc/html/msg.html"  "${PROJECT_DIRECTORY}/doc/")
129 #html/simdag.html:
130         exec_program("echo \"<html><META HTTP-EQUIV='Refresh' content='0;URL=http://simgrid.gforge.inria.fr/doc/group__SD__API.html'>\" > ${PROJECT_DIRECTORY}/doc/html/simdag.html"  "${PROJECT_DIRECTORY}/doc/")
131         exec_program("echo \"<center><h2><br><a href='http://simgrid.gforge.inria.fr/doc/group__SD__API.html'>DAG Simulator.</a></h2></center></html>\" >> ${PROJECT_DIRECTORY}/doc/html/simdag.html"  "${PROJECT_DIRECTORY}/doc/")
132
133 if(BIBTOOL_PATH AND BIBTEX2HTML_PATH AND ICONV_PATH)
134
135 #publis_count.html: all.bib
136         exec_program("${PROJECT_DIRECTORY}/tools/doxygen/bibtex2html_table_count.pl < ${PROJECT_DIRECTORY}/doc/all.bib > ${PROJECT_DIRECTORY}/doc/publis_count.html"  "${PROJECT_DIRECTORY}/doc/")
137
138 #publis_core.bib: all.bib 
139         exec_program("${BIBTOOL_PATH}/bibtool -- 'select.by.string={category \"core\"}' -- 'preserve.key.case={on}' -- 'preserve.keys={on}' ${PROJECT_DIRECTORY}/doc/all.bib -o ${PROJECT_DIRECTORY}/doc/publis_core.bib"  "${PROJECT_DIRECTORY}/doc/")
140
141 #publis_extern.bib: all.bib 
142         exec_program("${BIBTOOL_PATH}/bibtool -- 'select.by.string={category \"extern\"}' -- 'preserve.key.case={on}' -- 'preserve.keys={on}' ${PROJECT_DIRECTORY}/doc/all.bib -o ${PROJECT_DIRECTORY}/doc/publis_extern.bib"  "${PROJECT_DIRECTORY}/doc/")
143
144 #publis_intra.bib: all.bib 
145         exec_program("${BIBTOOL_PATH}/bibtool -- 'select.by.string={category \"intra\"}' -- 'preserve.key.case={on}' -- 'preserve.keys={on}' ${PROJECT_DIRECTORY}/doc/all.bib -o ${PROJECT_DIRECTORY}/doc/publis_intra.bib"  "${PROJECT_DIRECTORY}/doc/")
146
147 #%_bib.latin1.html: %.bib
148         exec_program("find ${PROJECT_DIRECTORY}/doc/ -name \"*.bib\""  "${PROJECT_DIRECTORY}/doc/" OUTPUT_VARIABLE LISTE_QUATRE)
149         string(REPLACE "\n" ";" LISTE_QUATRE ${LISTE_QUATRE})
150         foreach(file ${LISTE_QUATRE})
151                 string(REPLACE ".bib" "_bib.latin1.html" file_tmp "${file}")
152                 string(REPLACE ".html" ".html.tmp" file_tmp2 "${file_tmp}")
153                 exec_program("${BIBTEX2HTML_PATH}/bibtex2html -single-output -nv -force -sort year -copy-icons ${file} -output ${file_tmp2} 2>&1 | grep -v 'WARNING: unknown field type'"  "${PROJECT_DIRECTORY}/doc/")
154                 exec_program("${PROJECT_DIRECTORY}/tools/doxygen/bibtex2html_postprocessor.pl < ${file_tmp2} > ${file_tmp}"  "${PROJECT_DIRECTORY}/doc/")
155                 #message("file ${file}\nfile_tmp ${file_tmp}")
156         endforeach(file ${LISTE_QUATRE})
157
158
159 #%_bib.html: %_bib.latin1.html
160         exec_program("find ${PROJECT_DIRECTORY}/doc/ -name \"*_bib.latin1.html\""  "${PROJECT_DIRECTORY}/doc/" OUTPUT_VARIABLE LISTE_CINQ)
161         string(REPLACE "\n" ";" LISTE_CINQ ${LISTE_CINQ})
162         foreach(file ${LISTE_CINQ})
163                 string(REPLACE "_bib.latin1.html" "_bib.html" file_tmp "${file}")
164                 exec_program("${ICONV_PATH}/iconv --from-code latin1 --to-code utf8 ${file} --output ${file_tmp}"  "${PROJECT_DIRECTORY}/doc/")
165                 #message("file ${file}\nfile_tmp ${file_tmp}")
166         endforeach(file ${LISTE_CINQ})
167 endif(BIBTOOL_PATH AND BIBTEX2HTML_PATH AND ICONV_PATH)
168
169 endif(DOXYGEN_PATH AND FIG2DEV_PATH)
170
171 file(WRITE ${PROJECT_DIRECTORY}/doc/logcategories.sh    "\#! /bin/sh")  
172 file(APPEND ${PROJECT_DIRECTORY}/doc/logcategories.sh   "\npwd=`pwd`")
173 file(APPEND ${PROJECT_DIRECTORY}/doc/logcategories.sh   "\nrm -f $pwd/logcategories.doc")
174 file(APPEND ${PROJECT_DIRECTORY}/doc/logcategories.sh   "\nset -e")
175 file(APPEND ${PROJECT_DIRECTORY}/doc/logcategories.sh   "\necho \"/* Generated file, do not edit */\"     > $pwd/logcategories.doc")
176 file(APPEND ${PROJECT_DIRECTORY}/doc/logcategories.sh   "\necho \"/** \\addtogroup XBT_log_cats\"          >> $pwd/logcategories.doc")
177 file(APPEND ${PROJECT_DIRECTORY}/doc/logcategories.sh   "\necho \"    @{\"                                >> $pwd/logcategories.doc")
178 file(APPEND ${PROJECT_DIRECTORY}/doc/logcategories.sh   "\ncd ${PROJECT_DIRECTORY}/src")
179 file(APPEND ${PROJECT_DIRECTORY}/doc/logcategories.sh   "\n${PROJECT_DIRECTORY}/tools/doxygen/xbt_log_extract_hierarchy.pl      >> $pwd/logcategories.doc")
180 file(APPEND ${PROJECT_DIRECTORY}/doc/logcategories.sh   "\necho \"@}*/\"                                 >> $pwd/logcategories.doc")
181
182 exec_program("chmod a=rwx ${PROJECT_DIRECTORY}/doc/logcategories.sh"  "${PROJECT_DIRECTORY}/doc/")
183 exec_program("${PROJECT_DIRECTORY}/doc/logcategories.sh" "${PROJECT_DIRECTORY}/doc/"
184 ARGS ${DOCSSOURCES})
185
186
187 file(WRITE ${PROJECT_DIRECTORY}/doc/realtoc.sh  "\#! /bin/sh")  
188 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\n\necho \"Check individual TOCs\"")
189 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\nfor n in gtut-tour-*.doc ; do")
190 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\n  sed -n '/Table of Contents/,/hr/p' $n|grep ref > tmp.curtoc;")
191 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\n  grep -E '\\\\s?u?b?section' $n | grep -v _toc | sed -e 's/\\\\section //' -e 's/\\\\subsection /subsection/' -e 's/ .*//' | sed -e 's/^/ - \\\\ref /' -e 's/- \\\\ref subsection/   - \\\\ref /' > tmp.realtoc;")
192 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\n  if ! diff -q tmp.curtoc tmp.realtoc >/dev/null; then")
193 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\n    echo \"Wrong toc for $n. Should be ;\"")
194 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\n    cat tmp.realtoc;")
195 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\n  fi ;")
196 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\ndone")
197 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\n\nrm tmp.realtoc tmp.curtoc")
198 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\necho \"Check main TOC\"")
199 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\nfor n in gtut-tour-*doc; do")
200 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\n  grep @page $n | sed -e 's/@page //' -e 's/ .*//' -e 's/^/ - \\\\ref /' >>tmp.realtoc;")
201 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\n  sed -n -e '/Table of Contents/,/hr/p' $n|sed -e 's/^/   /'| grep -v toc|grep -v '<hr>'|grep [^[:blank:]] >>tmp.realtoc;")
202 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\ndone")
203 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\ngrep ' *- \\\\ref' gtut-tour.doc > tmp.curtoc")
204 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\nif ! diff -b -u tmp.curtoc tmp.realtoc ; then")
205 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\n  echo \"Wrong toc for gtut-tour.doc Right one is in tmp.realtoc\";")
206 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\nelse")
207 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\n  rm tmp.realtoc;")
208 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\nfi ;")
209 file(APPEND ${PROJECT_DIRECTORY}/doc/realtoc.sh "\nrm tmp.curtoc")
210
211 exec_program("chmod a=rwx ${PROJECT_DIRECTORY}/doc/realtoc.sh"  "${PROJECT_DIRECTORY}/doc/")
212 exec_program("${PROJECT_DIRECTORY}/doc/realtoc.sh" "${PROJECT_DIRECTORY}/doc/")