version 5.22.5
[polylib.git] / configure.in
blob1a176322f9093b231f6d49666e120c3209870981
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.5)
49 AM_INIT_AUTOMAKE([gnu])
50 AC_CONFIG_SRCDIR(include/polylib/polylib.h.in)
51 AC_CONFIG_MACRO_DIR([m4])
53 AC_PREREQ(2.60)
55 AC_SUBST(versioninfo)
56 versioninfo=9:0:1
58 if test "x$prefix" != "xNONE"; then
59     prefix_wd=`cd $prefix && pwd`
60     srcdir_wd=`cd $srcdir && pwd`
61     wd=`pwd`
62     if test "x$prefix_wd" = "x$srcdir_wd"; then
63         AC_MSG_ERROR(Installation in source directory not supported)
64     fi
65     if test "x$prefix_wd" = "x$wd"; then
66         AC_MSG_ERROR(Installation in build directory not supported)
67     fi
70 dnl Checks for programs.
71 AC_PROG_CC
72 AC_PROG_LN_S
73 AC_PROG_INSTALL
74 AC_PROG_LIBTOOL
75 AM_PROG_CC_C_O
77 dnl Checks for typedefs, structures, and compiler characteristics.
78 AC_C_CONST
80 dnl Checks for header files.
81 AC_HEADER_STDC
82 AC_CHECK_HEADERS(limits.h unistd.h)
83 AC_CHECK_HEADERS(getopt.h)
86 dnl /*****************************************************************************/
87 dnl See if the only goal is to create an 'int', 'longint', or 'longlongint' library
89 AC_CHECK_SIZEOF(int,1)
90 AC_CHECK_SIZEOF(long int,1)
91 AC_CHECK_SIZEOF(long long int,1)
93 AC_SUBST(polylib32_defs)
94 AC_SUBST(polylib64_defs)
95 AC_SUBST(polylib128_defs)
97 for type in long_long_int long_int int; do
98     case "$type" in
99         int)
100             bits=`expr $ac_cv_sizeof_int \* 8`
101             defs="#define LINEAR_VALUE_IS_INT"
102             ;;
103         long_int)
104             bits=`expr $ac_cv_sizeof_long_int \* 8`
105             defs="#define LINEAR_VALUE_IS_LONG
106 #define LINEAR_VALUE_PROTECT_MULTIPLY"
107             ;;
108         long_long_int)
109             bits=`expr $ac_cv_sizeof_long_long_int \* 8`
110             defs="#define LINEAR_VALUE_IS_LONGLONG
111 #define LINEAR_VALUE_PROTECT_MULTIPLY
112 #define LINEAR_VALUE_ASSUME_SOFTWARE_IDIV"
113             ;;
114     esac
115     case "$bits" in
116         32)
117             polylib32_defs=$defs
118             ;;
119         64)
120             polylib64_defs=$defs
121             ;;
122         128)
123             polylib128_defs=$defs
124             ;;
125     esac
126 done
129 AC_SUBST(polylibs)
130 AC_SUBST(ALL_BITS)
132 AC_ARG_ENABLE(int-lib,
133         [  --enable-int-lib        Build an int library], 
134         [lib_type=int
135          bits=`expr $ac_cv_sizeof_int \* 8`
136          polylibs="libpolylib$bits.la $polylibs"
137          ALL_BITS="$bits $ALL_BITS"
138         ])
139 AC_ARG_ENABLE(longint-lib,
140         [  --enable-longint-lib    Build a long int library], 
141         [lib_type=longint
142          bits=`expr $ac_cv_sizeof_long_int \* 8`
143          polylibs="libpolylib$bits.la $polylibs"
144          ALL_BITS="$bits $ALL_BITS"
145         ])
146 AC_ARG_ENABLE(longlongint-lib,
147         [  --enable-longlongint-lib Build a long long int library], 
148         [lib_type=longlongint
149          bits=`expr $ac_cv_sizeof_long_long_int \* 8`
150          polylibs="libpolylib$bits.la $polylibs"
151          ALL_BITS="$bits $ALL_BITS"
152         ])
154 dnl Check for GMP library
155 AC_MSG_CHECKING(whether to use GMP)
156 AC_ARG_WITH(libgmp, 
157         [  --with-libgmp           DIR Location of the GMP Distribution], 
158         gmp_package=$withval, gmp_package=no)
159 if test "x$gmp_package" = "xno"; then
160         AC_MSG_RESULT(no)
161 else
162         AC_MSG_RESULT(yes)
163         if test "x$gmp_package" != "xyes"; then
164             GMP_DIR=$gmp_package
165             if test ! -d "$GMP_DIR"; then
166                 AC_ERROR(Directory given for GMP Distribution is not a directory)
167             fi
168             CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
169             LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
170         fi
171         AC_CHECK_HEADER(gmp.h,
172                 [AC_CHECK_LIB(gmp,main,
173                     [poly_cv_gmpfatal="no"],
174                     [poly_cv_gmpfatal="yes"])],
175                 [poly_cv_gmpfatal="yes"])
176         if test "$poly_cv_gmpfatal" = "yes"; then
177                 AC_MSG_ERROR([GMP not found])
178         else
179                 AC_CHECK_DECLS(mp_get_memory_functions,[],[
180                         AC_LIBOBJ(mp_get_memory_functions)
181                 ],[#include <gmp.h>])
182         fi
184         lib_type=gmp
185         BITS=`expr gmp`
186         LIBS="-lgmp $LIBS"
187         polylibs="libpolylib$BITS.la $polylibs"
188         ALL_BITS="$BITS $ALL_BITS"
191 if test "X$lib_type" = "X"; then
192     AC_MSG_CHECKING(what the LONG representation is)
193     if test "$ac_cv_sizeof_long_long_int" -gt "$ac_cv_sizeof_int"; then
194         AC_MSG_RESULT([long long int])
195         lib_type=longlongint
196         bits=`expr $ac_cv_sizeof_long_long_int \* 8`
197         polylibs="libpolylib$bits.la $polylibs"
198         ALL_BITS="$bits $ALL_BITS"
199     elif test "$ac_cv_sizeof_long_int" -gt "$ac_cv_sizeof_int"; then
200         AC_MSG_RESULT([long int])
201         lib_type=longint
202         bits=`expr $ac_cv_sizeof_long_int \* 8`
203         polylibs="libpolylib$bits.la $polylibs"
204         ALL_BITS="$bits $ALL_BITS"
205     else
206         AC_MSG_RESULT([NONE!])
207         lib_type=int
208         bits=`expr $ac_cv_sizeof_int \* 8`
209         polylibs="libpolylib$bits.la $polylibs"
210         ALL_BITS="$bits $ALL_BITS"
211     fi
214 case "$lib_type" in
215         int)
216             BITS=`expr $ac_cv_sizeof_int \* 8`
217             ;;
218         longint)
219             BITS=`expr $ac_cv_sizeof_long_int \* 8`
220             ;;
221         longlongint)
222             BITS=`expr $ac_cv_sizeof_long_long_int \* 8`
223             ;;
224 esac
227 AC_SUBST(polylib)
228 polylib="libpolylib$BITS.la"
230 dnl extra indirection to avoid automake getting confused
231 AC_SUBST(multi_bin_programs)
232 AC_SUBST(multi_noinst_programs)
233 for pl_bit in $ALL_BITS ; do
234         multi_bin_programs="$multi_bin_programs \$(multi_bin_programs_${pl_bit})"
235         multi_noinst_programs="$multi_noinst_programs \$(no_inst_programs_${pl_bit})"
236 done
238 dnl /*****************************************************************************/
239 AC_ARG_ENABLE(extra-suffix,
240         [  --enable-extra-suffix   Add bits size suffix to executables],
241         [ if test "$enableval" = yes; then
242                 program_transform_name="s/\$\$/$BITS/;$program_transform_name"
243     fi ] )
245 dnl /********************************************************************/
246 dnl Check for DOXYGEN package
247 AC_ARG_WITH(doxygen, [  --with-doxygen          DIR Location of the Doxygen Distribution (http://www.doxygen.org)], doxygen_package=$withval)
249 dnl AC_MSG_CHECKING(for Doxygen program)
250 AC_CHECK_PROG(DOXYGEN,doxygen,doxygen,test,[$PATH:$doxygen_package/bin:/usr/local/bin])
251 dnl AC_MSG_RESULT($DOXYGEN)
254 AC_SUBST(LIBS)
256 dnl long/int bits and compilation flags
257 AC_SUBST(BITS)
259 dnl Used with doxygen
260 AC_SUBST(DOXYGEN)
262 dnl Currently, we only create one .pc file
263 dnl Creating one for each configured version is a bit complicated
264 PACKAGE_NAME=polylib$BITS
265 AX_CREATE_PKGCONFIG_INFO
267 AC_CONFIG_HEADERS(config.h)
268 AC_OUTPUT(Makefile
269           include/Makefile
270           include/polylib/Makefile
271           include/polylib/polylib.h
272           Test/Makefile
273           Test/Zpolytest/Makefile
274           Test/ehrhart/Makefile
275           Test/ehrhart_union/Makefile
276           Test/ranking/Makefile
277           Test/general/Makefile
278           Test/pp/Makefile
279           polylib.doxygen
280         )
283 echo "Polylib will be built with " $ALL_BITS "integer size(s)"
284 echo "---------------------------------------------------"
285 echo "You can proceed with:"
286 echo "make               :to build the libs and the executables"
287 echo "make tests         :to test the library"
288 echo "make install       :to install them (to $prefix)"
289 echo "---------------------------------------------------"