FIX: ParaView changed the format of the version string
[freefoam.git] / ThirdParty / scotch.patch
blob63a8a74a067967a0ec367cdaec1c9e663c0aef28
1 diff --git a/CMakeLists.txt b/CMakeLists.txt
2 new file mode 100644
3 index 0000000..963f2ce
4 --- /dev/null
5 +++ b/CMakeLists.txt
6 @@ -0,0 +1,197 @@
7 +#-------------------------------------------------------------------------------
8 +# ______ _ ____ __ __
9 +# | ____| _| |_ / __ \ /\ | \/ |
10 +# | |__ _ __ ___ ___ / \| | | | / \ | \ / |
11 +# | __| '__/ _ \/ _ ( (| |) ) | | |/ /\ \ | |\/| |
12 +# | | | | | __/ __/\_ _/| |__| / ____ \| | | |
13 +# |_| |_| \___|\___| |_| \____/_/ \_\_| |_|
15 +# FreeFOAM: The Cross-Platform CFD Toolkit
17 +# Copyright (C) 2008-2011 Michael Wild <themiwi@users.sf.net>
18 +# Gerber van der Graaf <gerber_graaf@users.sf.net>
19 +#-------------------------------------------------------------------------------
20 +# License
21 +# This file is part of FreeFOAM.
23 +# FreeFOAM is free software; you can redistribute it and/or modify it
24 +# under the terms of the GNU General Public License as published by the
25 +# Free Software Foundation; either version 2 of the License, or (at your
26 +# option) any later version.
28 +# FreeFOAM is distributed in the hope that it will be useful, but WITHOUT
29 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
30 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
31 +# for more details.
33 +# You should have received a copy of the GNU General Public License
34 +# along with FreeFOAM; if not, write to the Free Software Foundation,
35 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
36 +#-------------------------------------------------------------------------------
38 +cmake_minimum_required(VERSION 2.8)
39 +project(scotch)
40 +set(SCOTCH_VERSION 5.1.7-dfsg1-freefoam1)
42 +find_package(BISON REQUIRED)
43 +find_package(FLEX REQUIRED)
44 +find_package(Threads)
45 +find_package(ZLIB)
47 +find_library(RT_LIBRARY rt)
48 +mark_as_advanced(RT_LIBRARY)
50 +include(CheckFunctionExists)
51 +if(RT_LIBRARY)
52 + set(CMAKE_REQUIRED_LIBRARIES ${RT_LIBRARY})
53 +endif(RT_LIBRARY)
54 +check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
55 +set(CMAKE_REQUIRED_LIBRARIES)
56 +mark_as_advanced(HAVE_CLOCK_GETTIME)
58 +include(CheckCCompilerFlag)
59 +include(CheckCSourceCompiles)
61 +# check for -std=c99 and -c99 compiler flags
62 +check_c_compiler_flag(-std=c99 STDC99_FLAG_WORKS)
63 +if(STDC99_FLAG_WORKS)
64 + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
65 + add_definitions(-D_BSD_SOURCE -D_POSIX_C_SOURCE=199309L)
66 +else()
67 + check_c_compiler_flag(-c99 C99_FLAG_WORKS)
68 + if(C99_FLAG_WORKS)
69 + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -c99")
70 + add_definitions(-D_BSD_SOURCE -D_POSIX_C_SOURCE=199309L)
71 + endif()
72 +endif()
74 +# check whether the restrict keyword works
75 +set(RESTRICT_CHECK_SRC
76 + "typedef struct A_ { int a1; int * restrict a2; } A; int main() { A a; return 0; }"
77 + )
78 +check_c_source_compiles("${RESTRICT_CHECK_SRC}" HAVE_STD_RESTRICT_KEYWORD)
80 +if(NOT HAVE_STD_RESTRICT_KEYWORD)
81 + # check whether __restrict keyword works
82 + set(CMAKE_REQUIRED_DEFINITIONS -Drestrict=__restrict)
83 + check_c_source_compiles("${RESTRICT_CHECK_SRC}" HAVE_NOSTD_RESTRICT_KEYWORD)
84 + set(CMAKE_REQUIRED_DEFINITIONS)
85 + if(HAVE_NOSTD_RESTRICT_KEYWORD)
86 + add_definitions(-Drestrict=__restrict)
87 + else()
88 + add_definitions(-Drestrict)
89 + endif()
90 +endif()
92 +if(CMAKE_USE_PTHREADS_INIT OR CMAKE_HP_PTHREADS_INIT)
93 + option(SCOTCH_USE_COMPRESSION_PTHREADS
94 + "Use pthread in the (un)compression code of the scotch library" ON)
95 + mark_as_advanced(SCOTCH_USE_COMPRESSION_PTHREADS)
96 + if(SCOTCH_USE_COMPRESSION_PTHREADS)
97 + add_definitions(-DCOMMON_PTHREAD)
98 + endif(SCOTCH_USE_COMPRESSION_PTHREADS)
99 + option(SCOTCH_USE_PTHREADS
100 +"Use pthreads in the scotch and ptscotch libraries (requires thread-safe MPI)"
101 + ON)
102 + mark_as_advanced(SCOTCH_USE_PTHREADS)
103 + if(SCOTCH_USE_PHREADS)
104 + add_definitions(-DSCOTCH_PTHREAD)
105 + endif(SCOTCH_USE_PHREADS)
106 +endif(CMAKE_USE_PTHREADS_INIT OR CMAKE_HP_PTHREADS_INIT)
108 +if(ZLIB_FOUND)
109 + add_definitions(-DCOMMON_FILE_COMPRESS_GZ)
110 + list(APPEND SCOTCH_LINK_LIBRARIES ${ZLIB_LIBRARIES})
111 +endif()
113 +if(HAVE_CLOCK_GETTIME)
114 + if(RT_LIBRARY)
115 + list(APPEND SCOTCH_LINK_LIBRARIES ${RT_LIBRARY})
116 + endif(RT_LIBRARY)
117 +else(HAVE_CLOCK_GETTIME)
118 + add_definitions(-DCOMMON_TIMING_OLD)
119 +endif(HAVE_CLOCK_GETTIME)
121 +if(MINGW)
122 + add_definitions(
123 + -DCOMMON_RANDOM_RAND
124 + -DCOMMON_STUB_FORK
125 + -D"pipe(pfds)=_pipe(pfds,1024,0x8000)"
127 +endif(MINGW)
129 +add_definitions(
130 + -DSCOTCH_VERSION="${SCOTCH_VERSION}"
131 + -DCOMMON_RANDOM_FIXED_SEED
132 + -DSCOTCH_RENAME
135 +set(PARSER_LL_C ${CMAKE_BINARY_DIR}/parser_ll.c)
136 +set(PARSER_YY_C ${CMAKE_BINARY_DIR}/parser_yy.c)
137 +set(PARSER_LY_H ${CMAKE_BINARY_DIR}/parser_ly.h)
138 +flex_target(parser_ll src/libscotch/parser_ll.l ${PARSER_LL_C})
139 +bison_target(parser_yy src/libscotch/parser_yy.y
140 + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/parser_yy.c)
141 +add_custom_command(OUTPUT ${PARSER_YY_C} ${PARSER_LY_H}
142 + COMMAND ${CMAKE_COMMAND} -E copy_if_different
143 + ${BISON_parser_yy_OUTPUT_SOURCE} ${PARSER_YY_C}
144 + COMMAND ${CMAKE_COMMAND} -E copy_if_different
145 + ${BISON_parser_yy_OUTPUT_HEADER} ${PARSER_LY_H}
146 + DEPENDS ${BISON_parser_yy_OUTPUT_HEADER}
147 + VERBATIM
150 +foreach(COMMON_SRC_NAME common common_file common_file_compress
151 + common_file_uncompress common_integer common_memory common_stub)
152 + configure_file(common.c.in
153 + ${CMAKE_BINARY_DIR}/${COMMON_SRC_NAME}2.c
154 + @ONLY
156 +endforeach(COMMON_SRC_NAME)
158 +add_executable(scotch_dummysizes
159 + src/libscotch/dummysizes.c)
161 +add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/scotch.h
162 + COMMAND scotch_dummysizes ${CMAKE_SOURCE_DIR}/src/libscotch/library.h
163 + ${CMAKE_BINARY_DIR}/scotch.h
164 + DEPENDS src/libscotch/library.h
165 + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
166 + COMMENT "Generating ${CMAKE_BINARY_DIR}/scotch.h"
167 + VERBATIM
170 +add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/scotchf.h
171 + COMMAND scotch_dummysizes ${CMAKE_SOURCE_DIR}/src/libscotch/libraryf.h
172 + ${CMAKE_BINARY_DIR}/scotchf.h
173 + DEPENDS src/libscotch/libraryf.h
174 + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
175 + COMMENT "Generating ${CMAKE_BINARY_DIR}/scotchf.h"
176 + VERBATIM
179 +include(files.cmake)
181 +include_directories(
182 + ${CMAKE_SOURCE_DIR}/src/libscotch
183 + ${CMAKE_BINARY_DIR}
184 + ${ZLIB_INCLUDE_DIR}
188 +add_library(foam_scotch ${SRCS}
189 + ${PARSER_LY_H} ${CMAKE_BINARY_DIR}/scotch.h ${CMAKE_BINARY_DIR}/scotchf.h)
191 +target_link_libraries(foam_scotch ${SCOTCH_LINK_LIBRARIES})
193 +install(TARGETS foam_scotch
194 + LIBRARY DESTINATION lib
195 + ARCHIVE DESTINATION lib
196 + RUNTIME DESTINATION bin
199 +install(FILES ${CMAKE_BINARY_DIR}/scotch.h
200 + DESTINATION include
203 +# ------------------------- vim: set sw=2 sts=2 et: --------------- end-of-file
204 diff --git a/common.c.in b/common.c.in
205 new file mode 100644
206 index 0000000..73792d7
207 --- /dev/null
208 +++ b/common.c.in
209 @@ -0,0 +1,5 @@
210 +/* AUTOMATICALLY GENERATED! DO NOT EDIT! */
212 +#define SCOTCH_COMMON_RENAME
213 +#include "module.h"
214 +#include "@COMMON_SRC_NAME@.c"
215 diff --git a/files.cmake b/files.cmake
216 new file mode 100644
217 index 0000000..3d62cd5
218 --- /dev/null
219 +++ b/files.cmake
220 @@ -0,0 +1,193 @@
221 +#-------------------------------------------------------------------------------
222 +# ______ _ ____ __ __
223 +# | ____| _| |_ / __ \ /\ | \/ |
224 +# | |__ _ __ ___ ___ / \| | | | / \ | \ / |
225 +# | __| '__/ _ \/ _ ( (| |) ) | | |/ /\ \ | |\/| |
226 +# | | | | | __/ __/\_ _/| |__| / ____ \| | | |
227 +# |_| |_| \___|\___| |_| \____/_/ \_\_| |_|
229 +# FreeFOAM: The Cross-Platform CFD Toolkit
231 +# Copyright (C) 2008-2011 Michael Wild <themiwi@users.sf.net>
232 +# Gerber van der Graaf <gerber_graaf@users.sf.net>
233 +#-------------------------------------------------------------------------------
234 +# License
235 +# This file is part of FreeFOAM.
237 +# FreeFOAM is free software; you can redistribute it and/or modify it
238 +# under the terms of the GNU General Public License as published by the
239 +# Free Software Foundation; either version 2 of the License, or (at your
240 +# option) any later version.
242 +# FreeFOAM is distributed in the hope that it will be useful, but WITHOUT
243 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
244 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
245 +# for more details.
247 +# You should have received a copy of the GNU General Public License
248 +# along with FreeFOAM; if not, write to the Free Software Foundation,
249 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
250 +#-------------------------------------------------------------------------------
252 +set(SRCS
253 + src/libscotch/arch.c
254 + src/libscotch/arch_build.c
255 + src/libscotch/arch_cmplt.c
256 + src/libscotch/arch_cmpltw.c
257 + src/libscotch/arch_deco.c
258 + src/libscotch/arch_hcub.c
259 + src/libscotch/arch_mesh.c
260 + src/libscotch/arch_tleaf.c
261 + src/libscotch/arch_torus.c
262 + src/libscotch/arch_vcmplt.c
263 + src/libscotch/arch_vhcub.c
264 + src/libscotch/bgraph.c
265 + src/libscotch/bgraph_bipart_bd.c
266 + src/libscotch/bgraph_bipart_df.c
267 + src/libscotch/bgraph_bipart_ex.c
268 + src/libscotch/bgraph_bipart_fm.c
269 + src/libscotch/bgraph_bipart_gg.c
270 + src/libscotch/bgraph_bipart_gp.c
271 + src/libscotch/bgraph_bipart_ml.c
272 + src/libscotch/bgraph_bipart_st.c
273 + src/libscotch/bgraph_bipart_zr.c
274 + src/libscotch/bgraph_check.c
275 + src/libscotch/bgraph_store.c
276 + src/libscotch/gain.c
277 + src/libscotch/geom.c
278 + src/libscotch/graph.c
279 + src/libscotch/graph_base.c
280 + src/libscotch/graph_check.c
281 + src/libscotch/graph_coarsen.c
282 + src/libscotch/graph_induce.c
283 + src/libscotch/graph_io.c
284 + src/libscotch/graph_io_chac.c
285 + src/libscotch/graph_io_habo.c
286 + src/libscotch/graph_io_mmkt.c
287 + src/libscotch/graph_io_scot.c
288 + src/libscotch/graph_list.c
289 + src/libscotch/hall_order_hd.c
290 + src/libscotch/hall_order_hf.c
291 + src/libscotch/hall_order_hx.c
292 + src/libscotch/hgraph.c
293 + src/libscotch/hgraph_check.c
294 + src/libscotch/hgraph_induce.c
295 + src/libscotch/hgraph_order_bl.c
296 + src/libscotch/hgraph_order_cp.c
297 + src/libscotch/hgraph_order_gp.c
298 + src/libscotch/hgraph_order_hd.c
299 + src/libscotch/hgraph_order_hf.c
300 + src/libscotch/hgraph_order_hx.c
301 + src/libscotch/hgraph_order_nd.c
302 + src/libscotch/hgraph_order_si.c
303 + src/libscotch/hgraph_order_st.c
304 + src/libscotch/hmesh.c
305 + src/libscotch/hmesh_check.c
306 + src/libscotch/hmesh_hgraph.c
307 + src/libscotch/hmesh_induce.c
308 + src/libscotch/hmesh_mesh.c
309 + src/libscotch/hmesh_order_bl.c
310 + src/libscotch/hmesh_order_cp.c
311 + src/libscotch/hmesh_order_gr.c
312 + src/libscotch/hmesh_order_gp.c
313 + src/libscotch/hmesh_order_hd.c
314 + src/libscotch/hmesh_order_hf.c
315 + src/libscotch/hmesh_order_hx.c
316 + src/libscotch/hmesh_order_nd.c
317 + src/libscotch/hmesh_order_si.c
318 + src/libscotch/hmesh_order_st.c
319 + src/libscotch/kgraph.c
320 + src/libscotch/kgraph_map_rb.c
321 + src/libscotch/kgraph_map_rb_map.c
322 + src/libscotch/kgraph_map_rb_part.c
323 + src/libscotch/kgraph_map_st.c
324 + src/libscotch/library_arch.c
325 + src/libscotch/library_arch_f.c
326 + src/libscotch/library_arch_build.c
327 + src/libscotch/library_arch_build_f.c
328 + src/libscotch/library_geom.c
329 + src/libscotch/library_geom_f.c
330 + src/libscotch/library_graph.c
331 + src/libscotch/library_graph_f.c
332 + src/libscotch/library_graph_base.c
333 + src/libscotch/library_graph_base_f.c
334 + src/libscotch/library_graph_check.c
335 + src/libscotch/library_graph_check_f.c
336 + src/libscotch/library_graph_io_chac.c
337 + src/libscotch/library_graph_io_chac_f.c
338 + src/libscotch/library_graph_io_habo.c
339 + src/libscotch/library_graph_io_habo_f.c
340 + src/libscotch/library_graph_io_mmkt.c
341 + src/libscotch/library_graph_io_mmkt_f.c
342 + src/libscotch/library_graph_io_scot.c
343 + src/libscotch/library_graph_io_scot_f.c
344 + src/libscotch/library_graph_map.c
345 + src/libscotch/library_graph_map_f.c
346 + src/libscotch/library_graph_map_view.c
347 + src/libscotch/library_graph_map_view_f.c
348 + src/libscotch/library_graph_order.c
349 + src/libscotch/library_graph_order_f.c
350 + src/libscotch/library_mesh.c
351 + src/libscotch/library_mesh_f.c
352 + src/libscotch/library_mesh_graph.c
353 + src/libscotch/library_mesh_graph_f.c
354 + src/libscotch/library_mesh_io_habo.c
355 + src/libscotch/library_mesh_io_habo_f.c
356 + src/libscotch/library_mesh_io_scot.c
357 + src/libscotch/library_mesh_io_scot_f.c
358 + src/libscotch/library_mesh_order.c
359 + src/libscotch/library_mesh_order_f.c
360 + src/libscotch/library_parser.c
361 + src/libscotch/library_parser_f.c
362 + src/libscotch/library_random.c
363 + src/libscotch/library_random_f.c
364 + src/libscotch/mapping.c
365 + src/libscotch/mapping_io.c
366 + src/libscotch/mesh.c
367 + src/libscotch/mesh_check.c
368 + src/libscotch/mesh_coarsen.c
369 + src/libscotch/mesh_graph.c
370 + src/libscotch/mesh_induce_sepa.c
371 + src/libscotch/mesh_io.c
372 + src/libscotch/mesh_io_habo.c
373 + src/libscotch/mesh_io_scot.c
374 + src/libscotch/order.c
375 + src/libscotch/order_check.c
376 + src/libscotch/order_io.c
377 + src/libscotch/parser.c
378 + src/libscotch/vgraph.c
379 + src/libscotch/vgraph_check.c
380 + src/libscotch/vgraph_separate_bd.c
381 + src/libscotch/vgraph_separate_es.c
382 + src/libscotch/vgraph_separate_fm.c
383 + src/libscotch/vgraph_separate_gg.c
384 + src/libscotch/vgraph_separate_gp.c
385 + src/libscotch/vgraph_separate_ml.c
386 + src/libscotch/vgraph_separate_st.c
387 + src/libscotch/vgraph_separate_th.c
388 + src/libscotch/vgraph_separate_vw.c
389 + src/libscotch/vgraph_separate_zr.c
390 + src/libscotch/vgraph_store.c
391 + src/libscotch/vmesh.c
392 + src/libscotch/vmesh_check.c
393 + src/libscotch/vmesh_separate_fm.c
394 + src/libscotch/vmesh_separate_gg.c
395 + src/libscotch/vmesh_separate_gr.c
396 + src/libscotch/vmesh_separate_ml.c
397 + src/libscotch/vmesh_separate_zr.c
398 + src/libscotch/vmesh_separate_st.c
399 + src/libscotch/vmesh_store.c
400 + ${PARSER_LL_C}
401 + ${PARSER_YY_C}
402 + common2.c
403 + common_file2.c
404 + common_file_compress2.c
405 + common_file_uncompress2.c
406 + common_integer2.c
407 + common_memory2.c
408 + common_stub2.c
409 + # HACK add the error handling directly to the scotch library
410 + src/libscotch/library_error_exit.c
413 +# ------------------------- vim: set sw=2 sts=2 et: --------------- end-of-file
414 diff --git a/src/libscotch/parser_yy.y b/src/libscotch/parser_yy.y
415 index 1a81615..87b8994 100644
416 --- a/src/libscotch/parser_yy.y
417 +++ b/src/libscotch/parser_yy.y
418 @@ -91,6 +91,11 @@ static StratParamTab * parserparamcurr = NULL; /* Pointer to current parame
420 extern unsigned int parsermethtokentab[]; /* Pre-definition for stupid compilers */
422 +/* HACK my Bison does not declare yyerror, so do that here.
423 + yyerror is defined to stratParserError. */
424 +static int stratParserError (const char * const errstr);
425 +/* END HACK */
429 %union {