Logo AND Algorithmique Numérique Distribuée

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