Logo AND Algorithmique Numérique Distribuée

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