removed compiler warning
[polylib.git] / configure.ac
bloba700471762547edd247fbb7f7027a691fcce7d7d
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.6])
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.71])
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 LT_INIT
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 m4_warn([obsolete],
69 [The preprocessor macro `STDC_HEADERS' is obsolete.
70   Except in unusual embedded environments, you can safely include all
71   ISO C90 headers unconditionally.])dnl
72 # Autoupdate added the next two lines to ensure that your configure
73 # script's behavior did not change.  They are probably safe to remove.
74 AC_CHECK_INCLUDES_DEFAULT
75 AC_PROG_EGREP
77 AC_CHECK_HEADERS(limits.h unistd.h)
78 AC_CHECK_HEADERS(getopt.h)
81 dnl /*****************************************************************************/
82 dnl See if the only goal is to create an 'int', 'longint', or 'longlongint' library
84 AC_CHECK_SIZEOF(int,1)
85 AC_CHECK_SIZEOF(long int,1)
86 AC_CHECK_SIZEOF(long long int,1)
88 AC_SUBST(polylib32_defs)
89 AC_SUBST(polylib64_defs)
90 AC_SUBST(polylib128_defs)
92 for type in long_long_int long_int int; do
93     case "$type" in
94         int)
95             bits=`expr $ac_cv_sizeof_int \* 8`
96             defs="#define LINEAR_VALUE_IS_INT"
97             ;;
98         long_int)
99             bits=`expr $ac_cv_sizeof_long_int \* 8`
100             defs="#define LINEAR_VALUE_IS_LONG
101 #define LINEAR_VALUE_PROTECT_MULTIPLY"
102             ;;
103         long_long_int)
104             bits=`expr $ac_cv_sizeof_long_long_int \* 8`
105             defs="#define LINEAR_VALUE_IS_LONGLONG
106 #define LINEAR_VALUE_PROTECT_MULTIPLY
107 #define LINEAR_VALUE_ASSUME_SOFTWARE_IDIV"
108             ;;
109     esac
110     case "$bits" in
111         32)
112             polylib32_defs=$defs
113             ;;
114         64)
115             polylib64_defs=$defs
116             ;;
117         128)
118             polylib128_defs=$defs
119             ;;
120     esac
121 done
124 AC_SUBST(polylibs)
125 AC_SUBST(ALL_BITS)
127 AC_ARG_ENABLE(int-lib,
128         [  --enable-int-lib        Build an int library], 
129         [lib_type=int
130          bits=`expr $ac_cv_sizeof_int \* 8`
131          polylibs="libpolylib$bits.la $polylibs"
132          ALL_BITS=" $bits $ALL_BITS"
133         ])
134 AC_ARG_ENABLE(longint-lib,
135         [  --enable-longint-lib    Build a long int library], 
136         [lib_type=longint
137          bits=`expr $ac_cv_sizeof_long_int \* 8`
138          case "$ALL_BITS" in
139            *' '$bits' '*) ;;
140            *) polylibs="libpolylib$bits.la $polylibs"
141               ALL_BITS=" $bits $ALL_BITS" ;;
142          esac
143         ])
144 AC_ARG_ENABLE(longlongint-lib,
145         [  --enable-longlongint-lib Build a long long int library], 
146         [lib_type=longlongint
147          bits=`expr $ac_cv_sizeof_long_long_int \* 8`
148          case "$ALL_BITS" in
149            *' '$bits' '*) ;;
150            *) polylibs="libpolylib$bits.la $polylibs"
151               ALL_BITS=" $bits $ALL_BITS" ;;
152          esac
153         ])
155 dnl Check for GMP library
156 AC_MSG_CHECKING(whether to use GMP)
157 AC_ARG_WITH(libgmp, 
158         [  --with-libgmp[=DIR]     Build a GMP polylib using the GMP library], 
159         gmp_package=$withval, gmp_package=notuserdefined)
160 if test "x$gmp_package" = "xno"; then
161         # user choice: don't use gmp
162         AC_MSG_RESULT([no])
163 elif test "x$gmp_package" = "xnotuserdefined"; then
164         # check if we find gmp or not... Don't fail if not
165         AC_MSG_RESULT(system)
166         AC_CHECK_HEADER(gmp.h,
167                 [AC_CHECK_LIB(gmp,main,
168                     [poly_cv_gmpfatal="no"],
169                     [poly_cv_gmpfatal="yes"])],
170                 [poly_cv_gmpfatal="yes"])
171         if test "$poly_cv_gmpfatal" = "yes"; then
172                 AC_MSG_RESULT([GMP not found])
173                 gmp_package=no
174         else
175                 AC_CHECK_DECLS(mp_get_memory_functions,[],[
176                         AC_LIBOBJ(mp_get_memory_functions)
177                 ],[#include <gmp.h>])
178         fi
179 else
180         # user choice: use gmp
181         AC_MSG_RESULT(yes)
182         if test "x$gmp_package" != "xyes"; then
183             GMP_DIR=$gmp_package
184             if test ! -d "$GMP_DIR"; then
185                 AC_MSG_ERROR(Directory given for GMP Distribution is not a directory)
186             fi
187             CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
188             LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
189         fi
190         AC_CHECK_HEADER(gmp.h,
191                 [AC_CHECK_LIB(gmp,main,
192                     [poly_cv_gmpfatal="no"],
193                     [poly_cv_gmpfatal="yes"])],
194                 [poly_cv_gmpfatal="yes"])
195         if test "$poly_cv_gmpfatal" = "yes"; then
196                 AC_MSG_ERROR([GMP not found])
197         else
198                 AC_CHECK_DECLS(mp_get_memory_functions,[],[
199                         AC_LIBOBJ(mp_get_memory_functions)
200                 ],[#include <gmp.h>])
201         fi
203         lib_type=gmp
204         BITS=`expr gmp`
205         LIBS="-lgmp $LIBS"
206         polylibs="libpolylib$BITS.la $polylibs"
207         ALL_BITS="$BITS $ALL_BITS"
210 # no default libtype defined. Let's try to build all of them.
211 if test "X$lib_type" = "X"; then
212         AC_MSG_RESULT(no default type given by user:)
213         bits=`expr $ac_cv_sizeof_int \* 8`
214         AC_MSG_RESULT([ Adding 'int' ($bits) representation])
215         lib_type=int
216         polylibs="libpolylib$bits.la $polylibs"
217         ALL_BITS="$bits $ALL_BITS"
219         if test "$ac_cv_sizeof_long_int" -gt "$ac_cv_sizeof_int"; then
220                 bits=`expr $ac_cv_sizeof_long_int \* 8`
221                 AC_MSG_RESULT([Adding 'long int' ($bits)representation])
222                 lib_type=longint
223                 polylibs="libpolylib$bits.la $polylibs"
224                 ALL_BITS="$ALL_BITS $bits"
225         fi
226         if test "$ac_cv_sizeof_long_long_int" -gt "$ac_cv_sizeof_long_int"; then
227                 bits=`expr $ac_cv_sizeof_long_long_int \* 8`
228                 AC_MSG_RESULT([ Adding 'long long int' ($bits) representation])
229                 lib_type=longlongint
230                 polylibs="libpolylib$bits.la $polylibs"
231                 ALL_BITS="$ALL_BITS $bits"
232         fi
233         if test "x$gmp_package" != "xno"; then
234                 AC_MSG_RESULT([ Adding 'gmp' representation])
235                 lib_type=gmp
236                 BITS=`expr gmp`
237                 LIBS="-lgmp $LIBS"
238                 polylibs="libpolylib$BITS.la $polylibs"
239                 ALL_BITS="$ALL_BITS $BITS"
240         fi
243 case "$lib_type" in
244         int)
245             BITS=`expr $ac_cv_sizeof_int \* 8`
246             ;;
247         longint)
248             BITS=`expr $ac_cv_sizeof_long_int \* 8`
249             ;;
250         longlongint)
251             BITS=`expr $ac_cv_sizeof_long_long_int \* 8`
252             ;;
253 esac
256 AC_SUBST(polylib)
257 polylib="libpolylib$BITS.la"
259 dnl extra indirection to avoid automake getting confused
260 AC_SUBST(multi_bin_programs)
261 AC_SUBST(multi_noinst_programs)
262 for pl_bit in $ALL_BITS ; do
263         multi_bin_programs="$multi_bin_programs \$(multi_bin_programs_${pl_bit})"
264         multi_noinst_programs="$multi_noinst_programs \$(no_inst_programs_${pl_bit})"
265 done
267 dnl /*****************************************************************************/
268 AC_ARG_ENABLE(extra-suffix,
269         [  --enable-extra-suffix   Add bits size suffix to executables],
270         [ if test "$enableval" = yes; then
271                 program_transform_name="s/\$\$/$BITS/;$program_transform_name"
272     fi ] )
274 dnl /********************************************************************/
275 dnl Check for DOXYGEN package
276 AC_ARG_WITH(doxygen, [  --with-doxygen          DIR Location of the Doxygen Distribution (http://www.doxygen.org)], doxygen_package=$withval)
278 dnl AC_MSG_CHECKING(for Doxygen program)
279 AC_CHECK_PROG(DOXYGEN,doxygen,doxygen,test,[$PATH:$doxygen_package/bin:/usr/local/bin])
280 dnl AC_MSG_RESULT($DOXYGEN)
283 dnl AC_CHECK_LIB(pthread, pthread_create)
284 ACX_PTHREAD()
285 AC_ARG_ENABLE(threadsafe,
286         [  --enable-threadsafe     threadsafe polylib (enabled by default if a threading library is found)],
287         [
288                 if test "$enable_threadsafe" = "yes" -a "X$PTHREAD_CC" = "X"; then
289                         AC_MSG_ERROR([pthread library not found])
290                 fi
291         ] )
293 if test "X$PTHREAD_CC" = "X" ; then
294         AC_MSG_WARN([No pthread library found, PolyLib will not be threadsafe])
295 elif test "X$PTHREAD_CC" != "X" ; then
296         LIBS="$LIBS $PTHREAD_LIBS"
297         CFLAGS="$CFLAGS $PTHREAD_CFLAGS -DTHREAD_SAFE_POLYLIB"
298         CC="$PTHREAD_CC"
299         AC_MSG_NOTICE([Will build a threadsafe library])
302 AC_SUBST(LIBS)
303 AC_SUBST(CFLAGS)
304 AC_SUBST(CC)
306 dnl long/int bits and compilation flags
307 AC_SUBST(BITS)
309 dnl Used with doxygen
310 AC_SUBST(DOXYGEN)
312 dnl Currently, we only create one .pc file
313 dnl Creating one for each configured version is a bit complicated
314 PACKAGE_NAME=polylib$BITS
315 AX_CREATE_PKGCONFIG_INFO
317 AC_CONFIG_HEADERS(config.h)
318 AC_CONFIG_FILES([Makefile
319           include/Makefile
320           include/polylib/Makefile
321           include/polylib/polylib.h
322           Test/Makefile
323           Test/Zpolytest/Makefile
324           Test/ehrhart/Makefile
325           Test/ehrhart_union/Makefile
326           Test/ranking/Makefile
327           Test/general/Makefile
328           Test/pp/Makefile
329           polylib.doxygen
330         ])
331 AC_OUTPUT
334 echo "---------------------------------------------------"
335 echo "Polylib will be built with" $ALL_BITS "integer size(s)"
336 echo "You can proceed with:"
337 echo "make               :to build the libs and the executables"
338 echo "make tests         :to test the library"
339 echo "make install       :to install them (to $prefix)"
340 echo "---------------------------------------------------"