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