FIX: test log file anaylsis was broken
[freefoam.git] / ThirdParty / metis.patch
blobabf2973cd5b3e3b90c63e92f152450b6bd1f309e
1 diff --git a/CMakeLists.txt b/CMakeLists.txt
2 new file mode 100644
3 index 0000000..abdca7e
4 --- /dev/null
5 +++ b/CMakeLists.txt
6 @@ -0,0 +1,160 @@
7 +#-------------------------------------------------------------------------------
8 +# ______ _ ____ __ __
9 +# | ____| _| |_ / __ \ /\ | \/ |
10 +# | |__ _ __ ___ ___ / \| | | | / \ | \ / |
11 +# | __| '__/ _ \/ _ ( (| |) ) | | |/ /\ \ | |\/| |
12 +# | | | | | __/ __/\_ _/| |__| / ____ \| | | |
13 +# |_| |_| \___|\___| |_| \____/_/ \_\_| |_|
15 +# FreeFOAM: The Cross-Platform CFD Toolkit
17 +# Copyright (C) 2008-2010 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
37 +#-------------------------------------------------------------------------------
39 +cmake_minimum_required(VERSION 2.8)
40 +project(METIS)
42 +find_package(Threads REQUIRED)
44 +# do we have mallinfo() and struct mallinfo? this is a bit tedious...
45 +include(CheckFunctionExists)
46 +check_function_exists(mallinfo HAVE_MALLINFO)
47 +mark_as_advanced(HAVE_MALLINFO)
48 +if(HAVE_MALLINFO AND NOT DEFINED MALLINFO_FIELD_TYPE)
49 + # output is:
50 + # sizeof(int);sizeof(size_t);sizeof(mallinfo.arena);signedness of mallinfo.arena
51 + set(__mallinfo_src
52 + "#include <malloc.h>
53 + #include <stdio.h>
54 + int main(int argc, char* argv[]){
55 + struct mallinfo mi = mallinfo();
56 + mi.arena = -1;
57 + printf(\"%d;%d;%d;%d\\n\",sizeof(int),sizeof(size_t),sizeof(mi.arena),mi.arena<0);
58 + return 0;
59 + }"
60 + )
61 + file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
62 + "${__mallinfo_src}\n"
63 + )
64 + try_run(__mallinfo_runs __mallinfo_compiles
65 + ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
66 + RUN_OUTPUT_VARIABLE __mallinfo_output
67 + )
68 + set(__mallinfo_usable FALSE)
69 + if(__mallinfo_compiles AND __mallinfo_runs)
70 + set(__mallinfo_output ${__mallinfo_output})
71 + list(GET __mallinfo_output 0 __sizeof_int)
72 + list(GET __mallinfo_output 1 __sizeof_size_t)
73 + list(GET __mallinfo_output 2 __sizeof_mallinfo_arena)
74 + list(GET __mallinfo_output 3 __mallinfo_arena_signed)
75 + if(CMAKE_SIZEOF_VOID_P EQUAL 4)
76 + # 32 bit, only look out for signedness
77 + if(__mallinfo_arena_signed)
78 + set(__default_mallinfo_field_type int)
79 + else()
80 + set(__default_mallinfo_field_type size_t)
81 + endif()
82 + # success
83 + set(__mallinfo_usable TRUE)
84 + elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
85 + # 64 bit, more complicated...
86 + if(__sizeof_mallinfo_arena EQUAL ${__sizeof_int})
87 + # it is of int size
88 + if(__mallinfo_arena_signed)
89 + set(__default_mallinfo_field_type unsigned)
90 + else()
91 + set(__default_mallinfo_field_type int)
92 + endif()
93 + # success
94 + set(__mallinfo_usable TRUE)
95 + elseif(__sizeof_mallinfo_arena EQUAL ${__sizeof_size_t})
96 + # it is of long int size (i.e. size_t)
97 + if(__mallinfo_arena_signed)
98 + set(__default_mallinfo_field_type size_t)
99 + else()
100 + set(__default_mallinfo_field_type "long int")
101 + endif()
102 + # success
103 + set(__mallinfo_usable TRUE)
104 + endif()
105 + endif()
106 + endif()
107 + # was above code succesful?
108 + if(NOT __mallinfo_usable)
109 + set(HAVE_MALLINFO FALSE CACHE BOOL "Failed to run simple code using mallinfo." FORCE)
110 + message(STATUS "mallinfo not usable")
111 + endif()
112 +endif()
113 +if(NOT DEFINED __default_mallinfo_field_type)
114 + # default
115 + set(__default_mallinfo_field_type size_t)
116 +endif()
117 +# let the user override
118 +set(MALLINFO_FIELD_TYPE "${__default_mallinfo_field_type}" CACHE STRING "Type of the fields in the mallinfo struct")
119 +mark_as_advanced(MALLINFO_FIELD_TYPE)
121 +# set up platform specific defines
122 +if(APPLE)
123 + execute_process(
124 + COMMAND arch
125 + OUTPUT_VARIABLE ARCH_NAME
126 + OUTPUT_STRIP_TRAILING_WHITESPACE
128 + if(ARCH_NAME MATCHES ppc)
129 + add_definitions(-DDARWINPPC)
130 + else()
131 + add_definitions(-DDARWIN)
132 + endif()
133 +elseif(WIN32)
134 + add_definitions(-DWIN32 -DMSC -D_CRT_SECURE_NO_DEPRECATE)
135 +elseif(UNIX)
136 + add_definitions(-DUNIX)
137 + if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
138 + add_definitions(-DLINUX)
139 + endif()
140 +endif()
142 +configure_file(metis_config.h.in ${CMAKE_BINARY_DIR}/metis_config.h)
144 +include(files.cmake)
146 +include_directories(
147 + include
148 + GKlib/trunk
149 + libmetis
150 + ${CMAKE_BINARY_DIR}
152 +add_library(foam_metis ${GKLIB_SRCS} ${METIS_SRCS})
154 +target_link_libraries(foam_metis ${CMAKE_THREAD_LIBS_INIT})
156 +install(TARGETS foam_metis
157 + LIBRARY DESTINATION lib
158 + ARCHIVE DESTINATION lib
159 + RUNTIME DESTINATION bin
162 +install(FILES include/metis.h
163 + DESTINATION include
166 +# ------------------------- vim: set sw=2 sts=2 et: --------------- end-of-file
167 diff --git a/GKlib/trunk/gk_dlmalloc.h b/GKlib/trunk/gk_dlmalloc.h
168 index f194285..0f0a6ff 100644
169 --- a/GKlib/trunk/gk_dlmalloc.h
170 +++ b/GKlib/trunk/gk_dlmalloc.h
171 @@ -24,6 +24,7 @@
172 \version\verbatim $Id: gk_dlmalloc.h 1421 2007-04-06 14:37:41Z karypis $\endverbatim
175 +#include "metis_config.h"
177 /**********************************************************************
178 * These are the compile-time options that are enabled by GKlib
179 @@ -691,9 +692,9 @@ MAX_RELEASE_CHECK_RATE default: 255 unless not HAVE_MMAP
181 /* #define HAVE_USR_INCLUDE_MALLOC_H */
183 -#ifdef HAVE_USR_INCLUDE_MALLOC_H
184 -#include "/usr/include/malloc.h"
185 -#else /* HAVE_USR_INCLUDE_MALLOC_H */
186 +#ifdef HAVE_MALLINFO
187 +#include <stdlib.h>
188 +#else /* HAVE_MALLINFO */
190 struct mallinfo {
191 MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */
192 @@ -708,7 +709,7 @@ struct mallinfo {
193 MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */
196 -#endif /* HAVE_USR_INCLUDE_MALLOC_H */
197 +#endif /* HAVE_MALLINFO */
198 #endif /* NO_MALLINFO */
201 diff --git a/files.cmake b/files.cmake
202 new file mode 100644
203 index 0000000..eb9d70c
204 --- /dev/null
205 +++ b/files.cmake
206 @@ -0,0 +1,114 @@
207 +#-------------------------------------------------------------------------------
208 +# ______ _ ____ __ __
209 +# | ____| _| |_ / __ \ /\ | \/ |
210 +# | |__ _ __ ___ ___ / \| | | | / \ | \ / |
211 +# | __| '__/ _ \/ _ ( (| |) ) | | |/ /\ \ | |\/| |
212 +# | | | | | __/ __/\_ _/| |__| / ____ \| | | |
213 +# |_| |_| \___|\___| |_| \____/_/ \_\_| |_|
215 +# FreeFOAM: The Cross-Platform CFD Toolkit
217 +# Copyright (C) 2008-2010 Michael Wild <themiwi@users.sf.net>
218 +# Gerber van der Graaf <gerber_graaf@users.sf.net>
219 +#-------------------------------------------------------------------------------
220 +# License
221 +# This file is part of FreeFOAM.
223 +# FreeFOAM is free software; you can redistribute it and/or modify it
224 +# under the terms of the GNU General Public License as published by the
225 +# Free Software Foundation; either version 2 of the License, or (at your
226 +# option) any later version.
228 +# FreeFOAM is distributed in the hope that it will be useful, but WITHOUT
229 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
230 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
231 +# for more details.
233 +# You should have received a copy of the GNU General Public License
234 +# along with FreeFOAM; if not, write to the Free Software Foundation,
235 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
236 +#-------------------------------------------------------------------------------
238 +set(METIS_SRCS
239 + libmetis/balance.c
240 + libmetis/bucketsort.c
241 + libmetis/ccgraph.c
242 + libmetis/checkgraph.c
243 + libmetis/cmetis.c
244 + libmetis/coarsen.c
245 + libmetis/compress.c
246 + libmetis/debug.c
247 + libmetis/estmem.c
248 + libmetis/fm.c
249 + libmetis/fortran.c
250 + libmetis/frename.c
251 + libmetis/graph.c
252 + libmetis/initpart.c
253 + libmetis/kmetis.c
254 + libmetis/kvmetis.c
255 + libmetis/kwayfm.c
256 + libmetis/kwayrefine.c
257 + libmetis/kwayvolfm.c
258 + libmetis/kwayvolrefine.c
259 + libmetis/match.c
260 + libmetis/mbalance2.c
261 + libmetis/mbalance.c
262 + libmetis/mcoarsen.c
263 + libmetis/memory.c
264 + libmetis/mesh.c
265 + libmetis/meshpart.c
266 + libmetis/mfm2.c
267 + libmetis/mfm.c
268 + libmetis/mincover.c
269 + libmetis/minitpart2.c
270 + libmetis/minitpart.c
271 + libmetis/mkmetis.c
272 + libmetis/mkwayfmh.c
273 + libmetis/mkwayrefine.c
274 + libmetis/mmatch.c
275 + libmetis/mmd.c
276 + libmetis/mpmetis.c
277 + libmetis/mrefine2.c
278 + libmetis/mrefine.c
279 + libmetis/mrkmetis.c
280 + libmetis/mutil.c
281 + libmetis/myqsort.c
282 + libmetis/ometis.c
283 + libmetis/parmetis.c
284 + libmetis/pmetis.c
285 + libmetis/pqueue.c
286 + libmetis/refine.c
287 + libmetis/rkmetis.c
288 + libmetis/separator.c
289 + libmetis/sfm.c
290 + libmetis/srefine.c
291 + libmetis/stat.c
292 + libmetis/streamio.c
293 + libmetis/subdomains.c
294 + libmetis/timing.c
295 + libmetis/util.c
298 +set(GKLIB_SRCS
299 + GKlib/trunk/b64.c
300 + GKlib/trunk/blas.c
301 + GKlib/trunk/dfkvkselect.c
302 + GKlib/trunk/dlmalloc.c
303 + GKlib/trunk/error.c
304 + GKlib/trunk/fs.c
305 + GKlib/trunk/getopt.c
306 + GKlib/trunk/htable.c
307 + GKlib/trunk/io.c
308 + GKlib/trunk/memory.c
309 + GKlib/trunk/omp.c
310 + GKlib/trunk/pdb.c
311 + GKlib/trunk/pqueue.c
312 + GKlib/trunk/seq.c
313 + GKlib/trunk/sort.c
314 + GKlib/trunk/string.c
315 + GKlib/trunk/timers.c
316 + GKlib/trunk/tokenizer.c
317 + GKlib/trunk/util.c
320 +# ------------------------- vim: set sw=2 sts=2 et: --------------- end-of-file
321 diff --git a/metis_config.h.in b/metis_config.h.in
322 new file mode 100644
323 index 0000000..e3cc712
324 --- /dev/null
325 +++ b/metis_config.h.in
326 @@ -0,0 +1,34 @@
327 +/* AUTOMATICALLY GENERATED. DO NOT EDIT! */
329 +#ifndef _METIS_CONFIG_H
330 +#define _METIS_CONFIG_H
332 +/* MALLINFO_FIELD_TYPE default: size_t
333 + * The type of the fields in the mallinfo struct. This was originally
334 + * defined as "int" in SVID etc, but is more usefully defined as
335 + * size_t. The value is used only if HAVE_MALLINFO is not set
336 + */
337 +#define MALLINFO_FIELD_TYPE @MALLINFO_FIELD_TYPE@
339 +/* This version of malloc supports the standard SVID/XPG mallinfo
340 + routine that returns a struct containing usage properties and
341 + statistics. It should work on any system that has a
342 + /usr/include/malloc.h defining struct mallinfo. The main
343 + declaration needed is the mallinfo struct that is returned (by-copy)
344 + by mallinfo(). The malloinfo struct contains a bunch of fields that
345 + are not even meaningful in this version of malloc. These fields are
346 + are instead filled by mallinfo() with other numbers that might be of
347 + interest.
349 + HAVE_MALLINFO should be set if you have a /usr/include/malloc.h file that
350 + includes a declaration of struct mallinfo. If so, it is included; else a
351 + compliant version is declared below. These must be precisely the same for
352 + mallinfo() to work. The original SVID version of this struct, defined on
353 + most systems with mallinfo, declares all fields as ints. But some others
354 + define as unsigned long. If your system defines the fields using a type of
355 + different width than listed here, you MUST #include your system version and
356 + #define HAVE_MALLINFO.
358 +#cmakedefine HAVE_MALLINFO
360 +#endif // _METIS_CONFIG_H