updated INSTALL and doc/INSTALL
[polylib.git] / configure.in
blobbe9cba2b4d463254d9e54562509d4213f9c9cb9d
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.2)
34 AM_INIT_AUTOMAKE
35 AC_CONFIG_SRCDIR(include/polylib/polylib.h.in)
37 AC_PREREQ(2.60)
39 AC_SUBST(versioninfo)
40 versioninfo=6:1:2
42 if test "x$prefix" != "xNONE"; then
43     prefix_wd=`cd $prefix && pwd`
44     srcdir_wd=`cd $srcdir && pwd`
45     wd=`pwd`
46     if test "x$prefix_wd" = "x$srcdir_wd"; then
47         AC_MSG_ERROR(Installation in source directory not supported)
48     fi
49     if test "x$prefix_wd" = "x$wd"; then
50         AC_MSG_ERROR(Installation in build directory not supported)
51     fi
54 dnl Checks for programs.
55 AC_PROG_CC
56 AC_PROG_LN_S
57 AC_PROG_INSTALL
58 AC_PROG_LIBTOOL
60 dnl Checks for typedefs, structures, and compiler characteristics.
61 AC_C_CONST
63 dnl Checks for header files.
64 AC_HEADER_STDC
65 AC_CHECK_HEADERS(limits.h unistd.h)
66 AC_CHECK_HEADERS(getopt.h)
69 dnl /*****************************************************************************/
70 dnl See if the only goal is to create an 'int', 'longint', or 'longlongint' library
72 AC_CHECK_SIZEOF(int,1)
73 AC_CHECK_SIZEOF(long int,1)
74 AC_CHECK_SIZEOF(long long int,1)
76 AC_SUBST(polylib32_defs)
77 AC_SUBST(polylib64_defs)
78 AC_SUBST(polylib128_defs)
80 for type in long_long_int long_int int; do
81     case "$type" in
82         int)
83             bits=`expr $ac_cv_sizeof_int \* 8`
84             defs="#define LINEAR_VALUE_IS_INT"
85             ;;
86         long_int)
87             bits=`expr $ac_cv_sizeof_long_int \* 8`
88             defs="#define LINEAR_VALUE_IS_LONG
89                    #define LINEAR_VALUE_PROTECT_MULTIPLY"
90             ;;
91         long_long_int)
92             bits=`expr $ac_cv_sizeof_long_long_int \* 8`
93             defs="#define LINEAR_VALUE_IS_LONGLONG
94                    #define LINEAR_VALUE_PROTECT_MULTIPLY
95                    #define LINEAR_VALUE_ASSUME_SOFTWARE_IDIV"
96             ;;
97     esac
98     case "$bits" in
99         32)
100             polylib32_defs=$defs
101             ;;
102         64)
103             polylib64_defs=$defs
104             ;;
105         128)
106             polylib128_defs=$defs
107             ;;
108     esac
109 done
111 dnl extra indirection to avoid automake getting confused
112 AC_SUBST(multi_bin_programs)
113 AC_SUBST(multi_noinst_programs)
114 multi_bin_programs="\$(multi_bin_programs)"
115 multi_noinst_programs="\$(multi_noinst_programs)"
117 AC_SUBST(polylibs)
118 AC_SUBST(ALL_BITS)
120 AC_ARG_ENABLE(int-lib,
121         [  --enable-int-lib        Build an int library], 
122         [lib_type=int
123          bits=`expr $ac_cv_sizeof_int \* 8`
124          polylibs="libpolylib$bits.la $polylibs"
125          ALL_BITS="$bits $ALL_BITS"
126         ])
127 AC_ARG_ENABLE(longint-lib,
128         [  --enable-longint-lib    Build a long int library], 
129         [lib_type=longint
130          bits=`expr $ac_cv_sizeof_long_int \* 8`
131          polylibs="libpolylib$bits.la $polylibs"
132          ALL_BITS="$bits $ALL_BITS"
133         ])
134 AC_ARG_ENABLE(longlongint-lib,
135         [  --enable-longlongint-lib Build a long long int library], 
136         [lib_type=longlongint
137          bits=`expr $ac_cv_sizeof_long_long_int \* 8`
138          polylibs="libpolylib$bits.la $polylibs"
139          ALL_BITS="$bits $ALL_BITS"
140         ])
142 dnl Check for GMP library
143 AC_MSG_CHECKING(whether to use GMP)
144 AC_ARG_WITH(libgmp, 
145         [  --with-libgmp           DIR Location of the GMP Distribution], 
146         gmp_package=$withval, gmp_package=no)
147 if test "x$gmp_package" = "xno"; then
148         AC_MSG_RESULT(no)
149 else
150         AC_MSG_RESULT(yes)
151         if test "x$gmp_package" != "xyes"; then
152             GMP_DIR=$gmp_package
153             if test ! -d "$GMP_DIR"; then
154                 AC_ERROR(Directory given for GMP Distribution is not a directory)
155             fi
156             CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
157             LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
158         fi
159         AC_CHECK_HEADER(gmp.h,
160                 [AC_CHECK_LIB(gmp,main,
161                     [poly_cv_gmpfatal="no"],
162                     [poly_cv_gmpfatal="yes"])],
163                 [poly_cv_gmpfatal="yes"])
164         if test "$poly_cv_gmpfatal" = "yes"; then
165                 AC_MSG_ERROR([GMP not found])
166         else
167                 AC_CHECK_DECLS(mp_get_memory_functions,[],[
168                         AC_LIBOBJ(mp_get_memory_functions)
169                 ],[#include <gmp.h>])
170         fi
172         lib_type=gmp
173         BITS=`expr gmp`
174         LIBS="-lgmp $LIBS"
175         polylibs="libpolylib$BITS.la $polylibs"
176         ALL_BITS="$BITS $ALL_BITS"
179 if test "X$lib_type" = "X"; then
180     AC_MSG_CHECKING(what the LONG representation is)
181     if test "$ac_cv_sizeof_long_long_int" -gt "$ac_cv_sizeof_int"; then
182         AC_MSG_RESULT([long long int])
183         lib_type=longlongint
184         bits=`expr $ac_cv_sizeof_long_long_int \* 8`
185         polylibs="libpolylib$bits.la $polylibs"
186         ALL_BITS="$bits $ALL_BITS"
187     elif test "$ac_cv_sizeof_long_int" -gt "$ac_cv_sizeof_int"; then
188         AC_MSG_RESULT([long int])
189         lib_type=longint
190         bits=`expr $ac_cv_sizeof_long_int \* 8`
191         polylibs="libpolylib$bits.la $polylibs"
192         ALL_BITS="$bits $ALL_BITS"
193     else
194         AC_MSG_RESULT([NONE!])
195         lib_type=int
196         bits=`expr $ac_cv_sizeof_int \* 8`
197         polylibs="libpolylib$bits.la $polylibs"
198         ALL_BITS="$bits $ALL_BITS"
199     fi
202 case "$lib_type" in
203         int)
204             BITS=`expr $ac_cv_sizeof_int \* 8`
205             ;;
206         longint)
207             BITS=`expr $ac_cv_sizeof_long_int \* 8`
208             ;;
209         longlongint)
210             BITS=`expr $ac_cv_sizeof_long_long_int \* 8`
211             ;;
212 esac
215 AC_SUBST(polylib)
216 polylib="libpolylib$BITS.la"
218 dnl /*****************************************************************************/
219 AC_ARG_ENABLE(extra-suffix,
220         [  --enable-extra-suffix   Add bits size suffix to executables],
221         [ if test "$enableval" = yes; then
222                 program_transform_name="s/\$\$/$BITS/;$program_transform_name"
223     fi ] )
225 dnl /********************************************************************/
226 dnl Check for DOXYGEN package
227 AC_ARG_WITH(doxygen, [  --with-doxygen          DIR Location of the Doxygen Distribution (http://www.doxygen.org)], doxygen_package=$withval)
229 dnl AC_MSG_CHECKING(for Doxygen program)
230 AC_CHECK_PROG(DOXYGEN,doxygen,doxygen,test,[$PATH:$doxygen_package/bin:/usr/local/bin])
231 dnl AC_MSG_RESULT($DOXYGEN)
234 AC_SUBST(LIBS)
236 dnl long/int bits and compilation flags
237 AC_SUBST(BITS)
239 dnl Used with doxygen
240 AC_SUBST(DOXYGEN)
242 dnl Currently, we only create one .pc file
243 dnl Creating one for each configured version is a bit complicated
244 PACKAGE_NAME=polylib$BITS
245 AX_CREATE_PKGCONFIG_INFO
247 AC_CONFIG_HEADERS(config.h)
248 AC_OUTPUT(Makefile
249           include/Makefile
250           include/polylib/Makefile
251           include/polylib/polylib.h
252           Test/Makefile
253           Test/Zpolytest/Makefile
254           Test/ehrhart/Makefile
255           Test/ehrhart_union/Makefile
256           Test/ranking/Makefile
257           Test/general/Makefile
258           Test/pp/Makefile
259           polylib.doxygen
260         )
263 echo "Polylib will be built with " $ALL_BITS "integer size(s)"
264 echo "---------------------------------------------------"
265 echo "You can proceed with:"
266 echo "make               :to build the libs and the executables"
267 echo "make tests         :to test the library"
268 echo "make install       :to install them (to $prefix)"
269 echo "---------------------------------------------------"