thread safe polylib configuration
[polylib.git] / configure.in
blob69b14d35b08a0ea51b2be2a896663d02e6f4a126
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 Location of the GMP Distribution], 
166         gmp_package=$withval, gmp_package=no)
167 if test "x$gmp_package" = "xno"; then
168         AC_MSG_RESULT(no)
169 else
170         AC_MSG_RESULT(yes)
171         if test "x$gmp_package" != "xyes"; then
172             GMP_DIR=$gmp_package
173             if test ! -d "$GMP_DIR"; then
174                 AC_ERROR(Directory given for GMP Distribution is not a directory)
175             fi
176             CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
177             LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
178         fi
179         AC_CHECK_HEADER(gmp.h,
180                 [AC_CHECK_LIB(gmp,main,
181                     [poly_cv_gmpfatal="no"],
182                     [poly_cv_gmpfatal="yes"])],
183                 [poly_cv_gmpfatal="yes"])
184         if test "$poly_cv_gmpfatal" = "yes"; then
185                 AC_MSG_ERROR([GMP not found])
186         else
187                 AC_CHECK_DECLS(mp_get_memory_functions,[],[
188                         AC_LIBOBJ(mp_get_memory_functions)
189                 ],[#include <gmp.h>])
190         fi
192         lib_type=gmp
193         BITS=`expr gmp`
194         LIBS="-lgmp $LIBS"
195         polylibs="libpolylib$BITS.la $polylibs"
196         ALL_BITS="$BITS $ALL_BITS"
199 if test "X$lib_type" = "X"; then
200     AC_MSG_CHECKING(what the LONG representation is)
201     if test "$ac_cv_sizeof_long_long_int" -gt "$ac_cv_sizeof_int"; then
202         AC_MSG_RESULT([long long int])
203         lib_type=longlongint
204         bits=`expr $ac_cv_sizeof_long_long_int \* 8`
205         polylibs="libpolylib$bits.la $polylibs"
206         ALL_BITS="$bits $ALL_BITS"
207     elif test "$ac_cv_sizeof_long_int" -gt "$ac_cv_sizeof_int"; then
208         AC_MSG_RESULT([long int])
209         lib_type=longint
210         bits=`expr $ac_cv_sizeof_long_int \* 8`
211         polylibs="libpolylib$bits.la $polylibs"
212         ALL_BITS="$bits $ALL_BITS"
213     else
214         AC_MSG_RESULT([NONE!])
215         lib_type=int
216         bits=`expr $ac_cv_sizeof_int \* 8`
217         polylibs="libpolylib$bits.la $polylibs"
218         ALL_BITS="$bits $ALL_BITS"
219     fi
222 case "$lib_type" in
223         int)
224             BITS=`expr $ac_cv_sizeof_int \* 8`
225             ;;
226         longint)
227             BITS=`expr $ac_cv_sizeof_long_int \* 8`
228             ;;
229         longlongint)
230             BITS=`expr $ac_cv_sizeof_long_long_int \* 8`
231             ;;
232 esac
235 AC_SUBST(polylib)
236 polylib="libpolylib$BITS.la"
238 dnl extra indirection to avoid automake getting confused
239 AC_SUBST(multi_bin_programs)
240 AC_SUBST(multi_noinst_programs)
241 for pl_bit in $ALL_BITS ; do
242         multi_bin_programs="$multi_bin_programs \$(multi_bin_programs_${pl_bit})"
243         multi_noinst_programs="$multi_noinst_programs \$(no_inst_programs_${pl_bit})"
244 done
246 dnl /*****************************************************************************/
247 AC_ARG_ENABLE(extra-suffix,
248         [  --enable-extra-suffix   Add bits size suffix to executables],
249         [ if test "$enableval" = yes; then
250                 program_transform_name="s/\$\$/$BITS/;$program_transform_name"
251     fi ] )
253 dnl /********************************************************************/
254 dnl Check for DOXYGEN package
255 AC_ARG_WITH(doxygen, [  --with-doxygen          DIR Location of the Doxygen Distribution (http://www.doxygen.org)], doxygen_package=$withval)
257 dnl AC_MSG_CHECKING(for Doxygen program)
258 AC_CHECK_PROG(DOXYGEN,doxygen,doxygen,test,[$PATH:$doxygen_package/bin:/usr/local/bin])
259 dnl AC_MSG_RESULT($DOXYGEN)
262 dnl AC_CHECK_LIB(pthread, pthread_create)
263 ACX_PTHREAD()
264 AC_ARG_ENABLE(threadsafe,
265         [  --enable-threadsafe     threadsafe polylib (enabled by default if a threading library is found))],
266         [
267                 if test "$enable_threadsafe" = "yes" -a "X$PTHREAD_CC" = "X"; then
268                         AC_MSG_ERROR([pthread library not found])
269                 fi
270         ] )
272 if test "X$PTHREAD_CC" = "X" ; then
273         AC_MSG_WARN([No pthread library found, PolyLib will not be threadsafe])
274 elif test "X$PTHREAD_CC" != "X" ; then
275         LIBS="$LIBS $PTHREAD_LIBS"
276         CFLAGS="$CFLAGS $PTHREAD_CFLAGS -DTHREAD_SAFE_POLYLIB"
277         CC="$PTHREAD_CC"
278         AC_MSG_NOTICE([Will build a threadsafe library])
281 AC_SUBST(LIBS)
282 AC_SUBST(CFLAGS)
283 AC_SUBST(CC)
285 dnl long/int bits and compilation flags
286 AC_SUBST(BITS)
288 dnl Used with doxygen
289 AC_SUBST(DOXYGEN)
291 dnl Currently, we only create one .pc file
292 dnl Creating one for each configured version is a bit complicated
293 PACKAGE_NAME=polylib$BITS
294 AX_CREATE_PKGCONFIG_INFO
296 AC_CONFIG_HEADERS(config.h)
297 AC_OUTPUT(Makefile
298           include/Makefile
299           include/polylib/Makefile
300           include/polylib/polylib.h
301           Test/Makefile
302           Test/Zpolytest/Makefile
303           Test/ehrhart/Makefile
304           Test/ehrhart_union/Makefile
305           Test/ranking/Makefile
306           Test/general/Makefile
307           Test/pp/Makefile
308           polylib.doxygen
309         )
312 echo "---------------------------------------------------"
313 echo "Polylib will be built with " $ALL_BITS "integer size(s)"
314 echo "You can proceed with:"
315 echo "make               :to build the libs and the executables"
316 echo "make tests         :to test the library"
317 echo "make install       :to install them (to $prefix)"
318 echo "---------------------------------------------------"