forked from harenome/polylib
-
Notifications
You must be signed in to change notification settings - Fork 4
/
configure.ac
343 lines (304 loc) · 9.88 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
dnl This file is an input file used by the GNU "autoconf" program to
dnl generate the file "configure", which is run to configure the
dnl Makefile in this directory.
# Authors: Bart Kienhuis, Vincent Loechner, T. Risset
# Copyright (c) 2000 The Regents of the University of California.
# All rights reserved.
#
# Permission is hereby granted, without written agreement and without
# license or royalty fees, to use, copy, modify, and distribute this
# software and its documentation for any purpose, provided that the
# above copyright notice and the following two paragraphs appear in all
# copies of this software.
#
# IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
# ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
# THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
# PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
# CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
# ENHANCEMENTS, OR MODIFICATIONS.
#
# PT_COPYRIGHT_VERSION_2
# COPYRIGHTENDKEY
dnl Process this file with autoconf to produce a configure script.
AC_INIT([polylib],[5.22.7])
AC_CONFIG_AUX_DIR([.])
# AM_INIT_AUTOMAKE([gnu])
AM_INIT_AUTOMAKE([gnu])
AC_CONFIG_SRCDIR(include/polylib/polylib.h.in)
AC_CONFIG_MACRO_DIR([m4])
AC_PREREQ([2.60])
AC_SUBST(versioninfo)
versioninfo=10:0:2
if test "x$prefix" != "xNONE"; then
prefix_wd=`cd $prefix && pwd`
srcdir_wd=`cd $srcdir && pwd`
wd=`pwd`
if test "x$prefix_wd" = "x$srcdir_wd"; then
AC_MSG_ERROR(Installation in source directory not supported)
fi
if test "x$prefix_wd" = "x$wd"; then
AC_MSG_ERROR(Installation in build directory not supported)
fi
fi
dnl Checks for programs.
AC_LANG(C)
AC_PROG_CC
AC_PROG_LN_S
AC_PROG_INSTALL
LT_INIT
AM_PROG_CC_C_O
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
dnl Checks for header files.
m4_warn([obsolete],
[The preprocessor macro `STDC_HEADERS' is obsolete.
Except in unusual embedded environments, you can safely include all
ISO C90 headers unconditionally.])dnl
# Autoupdate added the next two lines to ensure that your configure
# script's behavior did not change. They are probably safe to remove.
#AC_CHECK_INCLUDES_DEFAULT
#AC_PROG_EGREP
AC_CHECK_HEADERS(limits.h unistd.h)
AC_CHECK_HEADERS(getopt.h)
dnl /*****************************************************************************/
dnl See if the only goal is to create an 'int', 'longint', or 'longlongint' library
AC_CHECK_SIZEOF(int,1)
AC_CHECK_SIZEOF(long int,1)
AC_CHECK_SIZEOF(long long int,1)
AC_SUBST(polylib32_defs)
AC_SUBST(polylib64_defs)
AC_SUBST(polylib128_defs)
for type in long_long_int long_int int; do
case "$type" in
int)
bits=`expr $ac_cv_sizeof_int \* 8`
defs="#define LINEAR_VALUE_IS_INT"
;;
long_int)
bits=`expr $ac_cv_sizeof_long_int \* 8`
defs="#define LINEAR_VALUE_IS_LONG
#define LINEAR_VALUE_PROTECT_MULTIPLY"
;;
long_long_int)
bits=`expr $ac_cv_sizeof_long_long_int \* 8`
defs="#define LINEAR_VALUE_IS_LONGLONG
#define LINEAR_VALUE_PROTECT_MULTIPLY
#define LINEAR_VALUE_ASSUME_SOFTWARE_IDIV"
;;
esac
case "$bits" in
32)
polylib32_defs=$defs
;;
64)
polylib64_defs=$defs
;;
128)
polylib128_defs=$defs
;;
esac
done
AC_SUBST(polylibs)
AC_SUBST(ALL_BITS)
AC_ARG_ENABLE(int-lib,
[ --enable-int-lib Build an int library],
[lib_type=int
bits=`expr $ac_cv_sizeof_int \* 8`
polylibs="libpolylib$bits.la $polylibs"
ALL_BITS=" $bits $ALL_BITS"
])
AC_ARG_ENABLE(longint-lib,
[ --enable-longint-lib Build a long int library],
[lib_type=longint
bits=`expr $ac_cv_sizeof_long_int \* 8`
case "$ALL_BITS" in
*' '$bits' '*) ;;
*) polylibs="libpolylib$bits.la $polylibs"
ALL_BITS=" $bits $ALL_BITS" ;;
esac
])
AC_ARG_ENABLE(longlongint-lib,
[ --enable-longlongint-lib Build a long long int library],
[lib_type=longlongint
bits=`expr $ac_cv_sizeof_long_long_int \* 8`
case "$ALL_BITS" in
*' '$bits' '*) ;;
*) polylibs="libpolylib$bits.la $polylibs"
ALL_BITS=" $bits $ALL_BITS" ;;
esac
])
dnl Check for GMP library
AC_MSG_CHECKING(whether to use GMP)
AC_ARG_WITH(libgmp,
[ --with-libgmp[=DIR] Build a GMP polylib using the GMP library],
gmp_package=$withval, gmp_package=notuserdefined)
if test "x$gmp_package" = "xno"; then
# user choice: don't use gmp
AC_MSG_RESULT([no])
elif test "x$gmp_package" = "xnotuserdefined"; then
# check if we find gmp or not... Don't fail if not
AC_MSG_RESULT(system)
AC_CHECK_HEADER(gmp.h,
[AC_CHECK_LIB(gmp,main,
[poly_cv_gmpfatal="no"],
[poly_cv_gmpfatal="yes"])],
[poly_cv_gmpfatal="yes"])
if test "$poly_cv_gmpfatal" = "yes"; then
AC_MSG_RESULT([GMP not found])
gmp_package=no
else
AC_CHECK_DECLS(mp_get_memory_functions,[],[
AC_LIBOBJ(mp_get_memory_functions)
],[#include <gmp.h>])
fi
else
# user choice: use gmp
AC_MSG_RESULT(yes)
if test "x$gmp_package" != "xyes"; then
GMP_DIR=$gmp_package
if test ! -d "$GMP_DIR"; then
AC_MSG_ERROR(Directory given for GMP Distribution is not a directory)
fi
CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
fi
AC_CHECK_HEADER(gmp.h,
[AC_CHECK_LIB(gmp,main,
[poly_cv_gmpfatal="no"],
[poly_cv_gmpfatal="yes"])],
[poly_cv_gmpfatal="yes"])
if test "$poly_cv_gmpfatal" = "yes"; then
AC_MSG_ERROR([GMP not found])
else
AC_CHECK_DECLS(mp_get_memory_functions,[],[
AC_LIBOBJ(mp_get_memory_functions)
],[#include <gmp.h>])
fi
lib_type=gmp
BITS=`expr gmp`
LIBS="-lgmp $LIBS"
polylibs="libpolylib$BITS.la $polylibs"
ALL_BITS="$BITS $ALL_BITS"
fi
# no default libtype defined. Let's try to build all of them.
if test "X$lib_type" = "X"; then
AC_MSG_RESULT(no default type given by user:)
bits=`expr $ac_cv_sizeof_int \* 8`
AC_MSG_RESULT([ Adding 'int' ($bits) representation])
lib_type=int
polylibs="libpolylib$bits.la $polylibs"
ALL_BITS="$bits $ALL_BITS"
if test "$ac_cv_sizeof_long_int" -gt "$ac_cv_sizeof_int"; then
bits=`expr $ac_cv_sizeof_long_int \* 8`
AC_MSG_RESULT([Adding 'long int' ($bits)representation])
lib_type=longint
polylibs="libpolylib$bits.la $polylibs"
ALL_BITS="$ALL_BITS $bits"
fi
if test "$ac_cv_sizeof_long_long_int" -gt "$ac_cv_sizeof_long_int"; then
bits=`expr $ac_cv_sizeof_long_long_int \* 8`
AC_MSG_RESULT([ Adding 'long long int' ($bits) representation])
lib_type=longlongint
polylibs="libpolylib$bits.la $polylibs"
ALL_BITS="$ALL_BITS $bits"
fi
if test "x$gmp_package" != "xno"; then
AC_MSG_RESULT([ Adding 'gmp' representation])
lib_type=gmp
BITS=`expr gmp`
LIBS="-lgmp $LIBS"
polylibs="libpolylib$BITS.la $polylibs"
ALL_BITS="$ALL_BITS $BITS"
fi
fi
case "$lib_type" in
int)
BITS=`expr $ac_cv_sizeof_int \* 8`
;;
longint)
BITS=`expr $ac_cv_sizeof_long_int \* 8`
;;
longlongint)
BITS=`expr $ac_cv_sizeof_long_long_int \* 8`
;;
esac
AC_SUBST(polylib)
polylib="libpolylib$BITS.la"
dnl extra indirection to avoid automake getting confused
AC_SUBST(multi_bin_programs)
AC_SUBST(multi_noinst_programs)
for pl_bit in $ALL_BITS ; do
multi_bin_programs="$multi_bin_programs \$(multi_bin_programs_${pl_bit})"
multi_noinst_programs="$multi_noinst_programs \$(no_inst_programs_${pl_bit})"
done
dnl /*****************************************************************************/
AC_ARG_ENABLE(extra-suffix,
[ --enable-extra-suffix Add bits size suffix to executables],
[ if test "$enableval" = yes; then
program_transform_name="s/\$\$/$BITS/;$program_transform_name"
fi ] )
dnl /********************************************************************/
dnl Check for DOXYGEN package
AC_ARG_WITH(doxygen, [ --with-doxygen DIR Location of the Doxygen Distribution (http://www.doxygen.org)], doxygen_package=$withval)
dnl AC_MSG_CHECKING(for Doxygen program)
AC_CHECK_PROG(DOXYGEN,doxygen,doxygen,test,[$PATH:$doxygen_package/bin:/usr/local/bin])
dnl AC_MSG_RESULT($DOXYGEN)
dnl AC_CHECK_LIB(pthread, pthread_create)
ACX_PTHREAD()
AC_ARG_ENABLE(threadsafe,
[ --enable-threadsafe threadsafe polylib (enabled by default if a threading library is found)],
[
if test "$enable_threadsafe" = "yes" -a "X$PTHREAD_CC" = "X"; then
AC_MSG_ERROR([pthread library not found])
fi
] )
if test "X$PTHREAD_CC" = "X" ; then
AC_MSG_WARN([No pthread library found, PolyLib will not be threadsafe])
elif test "X$enable_threadsafe" = "Xno"; then
AC_MSG_NOTICE([Will NOT build a threadsafe library (as requested)])
else
LIBS="$LIBS $PTHREAD_LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS -DTHREAD_SAFE_POLYLIB"
CC="$PTHREAD_CC"
AC_MSG_NOTICE([Will build a threadsafe library])
fi
AC_SUBST(LIBS)
AC_SUBST(CFLAGS)
AC_SUBST(CC)
dnl long/int bits and compilation flags
AC_SUBST(BITS)
dnl Used with doxygen
AC_SUBST(DOXYGEN)
dnl Currently, we only create one .pc file
dnl Creating one for each configured version is a bit complicated
PACKAGE_NAME=polylib$BITS
AX_CREATE_PKGCONFIG_INFO
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_FILES([Makefile
include/Makefile
include/polylib/Makefile
include/polylib/polylib.h
Test/Makefile
Test/Zpolytest/Makefile
Test/ehrhart/Makefile
Test/ehrhart_union/Makefile
Test/ranking/Makefile
Test/general/Makefile
Test/pp/Makefile
polylib.doxygen
])
AC_OUTPUT
echo "---------------------------------------------------"
echo "Polylib will be built with" $ALL_BITS "integer size(s)"
echo "You can proceed with:"
echo "make :to build the libs and the executables"
echo "make tests :to test the library"
echo "make install :to install them (to $prefix)"
echo "---------------------------------------------------"