Logo AND Algorithmique Numérique Distribuée

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