Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Optimisation of get_route.
[simgrid.git] / buildtools / Cmake / Distrib.cmake
1 #########################################
2 ### Fill in the "make install" target ###
3 #########################################
4           
5 # doc
6 if(NOT EXISTS ${CMAKE_HOME_DIRECTORY}/doc/html/)
7         file(MAKE_DIRECTORY ${CMAKE_HOME_DIRECTORY}/doc/html/)
8 endif(NOT EXISTS ${CMAKE_HOME_DIRECTORY}/doc/html/)
9 install(DIRECTORY "${CMAKE_HOME_DIRECTORY}/doc/html/"
10   DESTINATION "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/doc/simgrid/html/"
11   PATTERN ".svn" EXCLUDE 
12   PATTERN ".git" EXCLUDE 
13   PATTERN "*.o" EXCLUDE
14   PATTERN "*~" EXCLUDE
15 )
16
17 #### Generate the manpages
18 if( NOT MANPAGE_DIR )
19         set( MANPAGE_DIR $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/share/man/share/man/man1 )
20 endif( NOT MANPAGE_DIR)
21
22 add_custom_target(TARGET install
23         COMMAND ${CMAKE_COMMAND} -E make_directory ${MANPAGE_DIR}
24         COMMAND pod2man tools/simgrid_update_xml.pl > ${MANPAGE_DIR}/simgrid_update_xml.1
25         COMMENT "Generating manpages"
26 )
27
28 # binaries
29 install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/smpicc
30                  ${CMAKE_BINARY_DIR}/bin/smpif2c
31                  ${CMAKE_BINARY_DIR}/bin/smpiff
32                  ${CMAKE_BINARY_DIR}/bin/smpirun
33                 DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/)
34
35 install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/tesh
36 DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/)
37
38 install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/graphicator
39 DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/)
40         
41 install(PROGRAMS ${CMAKE_HOME_DIRECTORY}/tools/MSG_visualization/colorize.pl
42         DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/
43                 RENAME simgrid-colorizer)
44                 
45 add_custom_target(simgrid-colorizer ALL
46 COMMENT "Install ${CMAKE_BINARY_DIR}/bin/colorize"
47 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/tools/MSG_visualization/colorize.pl ${CMAKE_BINARY_DIR}/bin/colorize
48 )
49                                 
50 install(PROGRAMS ${CMAKE_HOME_DIRECTORY}/tools/simgrid_update_xml.pl
51                 DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/
52                 RENAME simgrid_update_xml)
53                 
54 add_custom_target(simgrid_update_xml ALL
55 COMMENT "Install ${CMAKE_BINARY_DIR}/bin/simgrid_update_xml"
56 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/tools/simgrid_update_xml.pl ${CMAKE_BINARY_DIR}/bin/simgrid_update_xml
57 )
58                 
59 install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/gras_stub_generator
60                 DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/)
61
62 # libraries
63 install(TARGETS simgrid gras 
64         DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/)
65         
66 if(enable_smpi) 
67   install(TARGETS smpi
68           DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/)
69 endif(enable_smpi)
70
71 if(enable_lib_static AND NOT WIN32)
72         install(TARGETS simgrid_static 
73                 DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/)
74         if(enable_smpi) 
75                 install(TARGETS smpi_static
76                         DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/)
77         endif(enable_smpi)
78 endif(enable_lib_static AND NOT WIN32)
79
80 # include files
81 set(HEADERS
82     ${install_HEADERS}
83     ${GENERATE_HEADERS}
84     )
85 foreach(file ${HEADERS})
86   get_filename_component(location ${file} PATH)
87   string(REPLACE "${CMAKE_CURRENT_BINARY_DIR}/" "" location "${location}")
88   install(FILES ${file}
89           DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${location})
90 endforeach(file ${HEADERS})
91
92 # example files
93 foreach(file ${examples_to_install_in_doc})
94   string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/examples/" "" file ${file})
95   get_filename_component(location ${file} PATH)
96   install(FILES "examples/${file}"
97           DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/doc/simgrid/examples/${location})
98 endforeach(file ${examples_to_install_in_doc})
99
100 # bindings cruft
101
102 if(HAVE_LUA)
103         file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/lib/lua/5.1")
104         add_custom_target(simgrid_lua ALL
105                 DEPENDS simgrid 
106                                 ${CMAKE_BINARY_DIR}/lib/lua/5.1/simgrid.${LIB_EXE}
107                 )
108         add_custom_command(
109                 OUTPUT ${CMAKE_BINARY_DIR}/lib/lua/5.1/simgrid.${LIB_EXE}
110                 COMMAND ${CMAKE_COMMAND} -E create_symlink ../../libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/lib/lua/5.1/simgrid.${LIB_EXE}
111         )
112         install(FILES ${CMAKE_BINARY_DIR}/lib/lua/5.1/simgrid.${LIB_EXE}
113                 DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/lua/5.1
114                 )
115 endif(HAVE_LUA)
116
117 ###########################################
118 ### Fill in the "make uninstall" target ###
119 ###########################################
120
121 add_custom_target(uninstall
122 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/doc/simgrid
123 COMMAND ${CMAKE_COMMAND} -E     echo "uninstall doc ok"
124 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/lib/libgras*
125 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/lib/libsimgrid*
126 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/lib/libsmpi*
127 COMMAND ${CMAKE_COMMAND} -E     echo "uninstall lib ok"
128 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpicc
129 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpif2c
130 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpiff
131 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpirun
132 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/tesh
133 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/simgrid-colorizer
134 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/simgrid_update_xml
135 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/gras_stub_generator
136 COMMAND ${CMAKE_COMMAND} -E     echo "uninstall bin ok"
137 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/amok
138 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/gras
139 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/instr
140 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/msg 
141 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/simdag
142 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/smpi
143 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/surf
144 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/xbt
145 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/mc
146 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/include/simgrid_config.h
147 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/include/gras.h 
148 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/include/xbt.h
149 COMMAND ${CMAKE_COMMAND} -E     echo "uninstall include ok"
150 WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
151 )
152
153 if(HAVE_LUA)
154         add_custom_command(TARGET uninstall
155         COMMAND ${CMAKE_COMMAND} -E echo "uninstall binding lua ok"
156         COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_INSTALL_PREFIX}/lib/lua/5.1/simgrid.${LIB_EXE}
157         WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}/"
158         )
159 endif(HAVE_LUA)
160
161 ################################################################
162 ## Build a sain "make dist" target to build a source package ###
163 ##   containing only the files that I explicitely state      ###
164 ##   (instead of any cruft laying on my disk as CPack does)  ###
165 ################################################################
166
167 ##########################################
168 ### Fill in the "make dist-dir" target ###
169 ##########################################
170
171 add_custom_target(dist-dir
172   COMMENT "Generating the distribution directory"
173   COMMAND test -e simgrid-${release_version}/ && chmod -R a+w simgrid-${release_version}/ || true
174   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/
175   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}
176   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/doc/html/
177   COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_HOME_DIRECTORY}/doc/html/ simgrid-${release_version}/doc/html/
178 )
179 add_dependencies(dist-dir simgrid_documentation)
180
181 set(dirs_in_tarball "")
182 foreach(file ${source_to_pack})
183   #message(${file})
184   # This damn prefix is still set somewhere (seems to be in subdirs)
185   string(REPLACE "${CMAKE_HOME_DIRECTORY}/" "" file "${file}")
186   
187   # Create the directory on need
188   get_filename_component(file_location ${file} PATH)
189   string(REGEX MATCH ";${file_location};" OPERATION "${dirs_in_tarball}")
190   if(NOT OPERATION)
191        set(dirs_in_tarball "${dirs_in_tarball};${file_location};")
192        add_custom_command(
193          TARGET dist-dir
194          COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/${file_location}/
195        )       
196    endif(NOT OPERATION)
197    
198    # Actually copy the file
199    add_custom_command(
200      TARGET dist-dir
201      COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/${file} simgrid-${release_version}/${file_location}/
202    )
203    
204    add_custom_command(
205      TARGET dist-dir
206      COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Makefile.default simgrid-${release_version}/Makefile
207    )
208 endforeach(file ${source_to_pack})
209
210 ######################################
211 ### Fill in the "make dist" target ###
212 ######################################
213
214 add_custom_target(dist
215   DEPENDS ${CMAKE_BINARY_DIR}/simgrid-${release_version}.tar.gz
216 )
217 add_custom_command(
218         OUTPUT ${CMAKE_BINARY_DIR}/simgrid-${release_version}.tar.gz    
219         COMMENT "Compressing the archive from the distribution directory"
220         COMMAND ${CMAKE_COMMAND} -E tar cf simgrid-${release_version}.tar simgrid-${release_version}/
221         COMMAND gzip -9v simgrid-${release_version}.tar
222         COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/
223 )
224 add_dependencies(dist dist-dir)
225
226 ###########################################
227 ### Fill in the "make distcheck" target ###
228 ###########################################
229
230 # Allow to test the "make dist"
231 add_custom_target(distcheck
232   COMMAND ${CMAKE_COMMAND} -E echo "XXX remove old copy"
233   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}.cpy 
234   COMMAND ${CMAKE_COMMAND} -E echo "XXX copy again the source tree"
235   COMMAND ${CMAKE_COMMAND} -E copy_directory simgrid-${release_version}/ simgrid-${release_version}.cpy 
236   COMMAND ${CMAKE_COMMAND} -E echo "XXX create build and install subtrees"
237   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/_build
238   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/_inst
239  
240   # This stupid cmake creates a directory in source, killing the purpose of the chmod
241   # (tricking around)
242   COMMAND ${CMAKE_COMMAND} -E echo "XXX change the modes of directories"
243   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/CMakeFiles 
244   COMMAND chmod -R a-w simgrid-${release_version}/ # FIXME: we should pass without commenting that line
245   COMMAND chmod -R a+w simgrid-${release_version}/_build
246   COMMAND chmod -R a+w simgrid-${release_version}/_inst
247   COMMAND chmod -R a+w simgrid-${release_version}/CMakeFiles
248   
249   COMMAND ${CMAKE_COMMAND} -E echo "XXX Configure"
250   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build ${CMAKE_COMMAND} build ..  -DCMAKE_INSTALL_PREFIX=../_inst -Wno-dev -Denable_doc=OFF
251 #  COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build make dist-dir
252   COMMAND ${CMAKE_COMMAND} -E echo "XXX Build"
253   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build make VERBOSE=1
254   
255   # This fails, unfortunately, because GRAS is broken for now
256   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build ctest -j5 --output-on-failure
257
258   COMMAND ${CMAKE_COMMAND} -E echo "XXX Check that cleaning works"
259   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build make clean
260   COMMAND ${CMAKE_COMMAND} -E echo "XXX Display what is remaining after make clean"
261   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build ls -lR
262   COMMAND ${CMAKE_COMMAND} -E echo "XXX Remove _build and _inst directories"
263   COMMAND chmod a+w simgrid-${release_version}/
264   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/_build
265   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/_inst
266   COMMAND ${CMAKE_COMMAND} -E echo "XXX The output of the diff follows"
267   COMMAND diff -ruN simgrid-${release_version}.cpy simgrid-${release_version}
268   COMMAND ${CMAKE_COMMAND} -E echo "XXX end of the diff, random cleanups now"
269   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}.cpy 
270   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}
271 )
272 add_dependencies(distcheck dist-dir)
273
274 #######################################
275 ### Fill in the "make check" target ###
276 #######################################
277
278 if(enable_memcheck)
279         add_custom_target(check
280         COMMAND ctest -D ExperimentalMemCheck
281         )
282 else(enable_memcheck)
283         add_custom_target(check
284         COMMAND make test
285         )
286 endif(enable_memcheck)
287
288 #######################################
289 ### Fill in the "make xxx-clean" target ###
290 #######################################
291
292 add_custom_target(maintainer-clean
293 COMMAND ${CMAKE_COMMAND} -E remove -f src/config_unit.c
294 COMMAND ${CMAKE_COMMAND} -E remove -f src/cunit_unit.c
295 COMMAND ${CMAKE_COMMAND} -E remove -f src/dict_unit.c
296 COMMAND ${CMAKE_COMMAND} -E remove -f src/dynar_unit.c
297 COMMAND ${CMAKE_COMMAND} -E remove -f src/ex_unit.c
298 COMMAND ${CMAKE_COMMAND} -E remove -f src/set_unit.c
299 COMMAND ${CMAKE_COMMAND} -E remove -f src/simgrid_units_main.c
300 COMMAND ${CMAKE_COMMAND} -E remove -f src/swag_unit.c
301 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_sha_unit.c
302 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_str_unit.c
303 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_strbuff_unit.c
304 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_synchro_unit.c
305 WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}"
306 )
307
308 add_custom_target(supernovae-clean
309 COMMAND ${CMAKE_COMMAND} -E remove -f src/supernovae_gras.c
310 COMMAND ${CMAKE_COMMAND} -E remove -f src/supernovae_sg.c
311 COMMAND ${CMAKE_COMMAND} -E remove -f src/supernovae_smpi.c
312 WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}"
313 )
314
315 #############################################
316 ### Fill in the "make sync-gforge" target ###
317 #############################################
318
319 add_custom_target(sync-gforge-doc
320 COMMAND chmod g+rw -R doc/
321 COMMAND chmod a+rX -R doc/
322 COMMAND rsync --verbose --cvs-exclude --compress --delete --delete-excluded --rsh=ssh --ignore-times --recursive --links --perms --times --omit-dir-times doc/html/ scm.gforge.inria.fr:/home/groups/simgrid/htdocs/doc/ || true
323 COMMAND scp doc/index.php doc/webcruft/robots.txt scm.gforge.inria.fr:/home/groups/simgrid/htdocs/
324 COMMAND scp doc/html/simgrid_modules2.png doc/html/simgrid_modules.png doc/webcruft/simgrid_logo.png doc/webcruft/fish.gif doc/webcruft/simgrid_logo_small.png scm.gforge.inria.fr:/home/groups/simgrid/htdocs/
325 WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}"
326 )
327 add_custom_target(sync-gforge-dtd
328 COMMAND scp src/surf/simgrid.dtd scm.gforge.inria.fr:/home/groups/simgrid/htdocs/
329 WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}"
330 )
331
332
333 include(CPack)