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