Logo AND Algorithmique Numérique Distribuée

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