Logo AND Algorithmique Numérique Distribuée

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