Logo AND Algorithmique Numérique Distribuée

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