Logo AND Algorithmique Numérique Distribuée

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