Logo AND Algorithmique Numérique Distribuée

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