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