Logo AND Algorithmique Numérique Distribuée

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