autoconf warning missing files
[polylib.git] / configure.ac
blob3997c8e7c3d2203bc37ad018ba65ada84f4fa140
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.
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.
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.
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.
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.7])
34 AC_CONFIG_AUX_DIR([.])
35 # AM_INIT_AUTOMAKE([gnu])
36 AM_INIT_AUTOMAKE([gnu subdir-objects])
37 AC_CONFIG_SRCDIR(include/polylib/polylib.h.in)
38 AC_CONFIG_MACRO_DIR([m4])
40 AC_PREREQ([2.60])
42 AC_SUBST(versioninfo)
43 versioninfo=10:0:2
45 if test "x$prefix" != "xNONE"; then
46     prefix_wd=`cd $prefix && pwd`
47     srcdir_wd=`cd $srcdir && pwd`
48     wd=`pwd`
49     if test "x$prefix_wd" = "x$srcdir_wd"; then
50         AC_MSG_ERROR(Installation in source directory not supported)
51     fi
52     if test "x$prefix_wd" = "x$wd"; then
53         AC_MSG_ERROR(Installation in build directory not supported)
54     fi
57 dnl Checks for programs.
58 AC_LANG(C)
59 AC_PROG_CC
60 AC_PROG_LN_S
61 AC_PROG_INSTALL
62 LT_INIT
63 AM_PROG_CC_C_O
65 dnl Checks for typedefs, structures, and compiler characteristics.
66 AC_C_CONST
68 dnl Checks for header files.
69 m4_warn([obsolete],
70 [The preprocessor macro `STDC_HEADERS' is obsolete.
71   Except in unusual embedded environments, you can safely include all
72   ISO C90 headers unconditionally.])dnl
73 # Autoupdate added the next two lines to ensure that your configure
74 # script's behavior did not change.  They are probably safe to remove.
75 #AC_CHECK_INCLUDES_DEFAULT
76 #AC_PROG_EGREP
78 AC_CHECK_HEADERS(limits.h unistd.h)
79 AC_CHECK_HEADERS(getopt.h)
82 dnl /*****************************************************************************/
83 dnl See if the only goal is to create an 'int', 'longint', or 'longlongint' library
85 AC_CHECK_SIZEOF(int,1)
86 AC_CHECK_SIZEOF(long int,1)
87 AC_CHECK_SIZEOF(long long int,1)
89 AC_SUBST(polylib32_defs)
90 AC_SUBST(polylib64_defs)
91 AC_SUBST(polylib128_defs)
93 for type in long_long_int long_int int; do
94     case "$type" in
95         int)
96             bits=`expr $ac_cv_sizeof_int \* 8`
97             defs="#define LINEAR_VALUE_IS_INT"
98             ;;
99         long_int)
100             bits=`expr $ac_cv_sizeof_long_int \* 8`
101             defs="#define LINEAR_VALUE_IS_LONG
102 #define LINEAR_VALUE_PROTECT_MULTIPLY"
103             ;;
104         long_long_int)
105             bits=`expr $ac_cv_sizeof_long_long_int \* 8`
106             defs="#define LINEAR_VALUE_IS_LONGLONG
107 #define LINEAR_VALUE_PROTECT_MULTIPLY
108 #define LINEAR_VALUE_ASSUME_SOFTWARE_IDIV"
109             ;;
110     esac
111     case "$bits" in
112         32)
113             polylib32_defs=$defs
114             ;;
115         64)
116             polylib64_defs=$defs
117             ;;
118         128)
119             polylib128_defs=$defs
120             ;;
121     esac
122 done
125 AC_SUBST(polylibs)
126 AC_SUBST(ALL_BITS)
128 AC_ARG_ENABLE(int-lib,
129         [  --enable-int-lib        Build an int library],
130         [lib_type=int
131          bits=`expr $ac_cv_sizeof_int \* 8`
132          polylibs="libpolylib$bits.la $polylibs"
133          ALL_BITS=" $bits $ALL_BITS"
134         ])
135 AC_ARG_ENABLE(longint-lib,
136         [  --enable-longint-lib    Build a long int library],
137         [lib_type=longint
138          bits=`expr $ac_cv_sizeof_long_int \* 8`
139          case "$ALL_BITS" in
140            *' '$bits' '*) ;;
141            *) polylibs="libpolylib$bits.la $polylibs"
142               ALL_BITS=" $bits $ALL_BITS" ;;
143          esac
144         ])
145 AC_ARG_ENABLE(longlongint-lib,
146         [  --enable-longlongint-lib Build a long long int library],
147         [lib_type=longlongint
148          bits=`expr $ac_cv_sizeof_long_long_int \* 8`
149          case "$ALL_BITS" in
150            *' '$bits' '*) ;;
151            *) polylibs="libpolylib$bits.la $polylibs"
152               ALL_BITS=" $bits $ALL_BITS" ;;
153          esac
154         ])
156 dnl Check for GMP library
157 AC_MSG_CHECKING(whether to use GMP)
158 AC_ARG_WITH(libgmp,
159         [  --with-libgmp[=DIR]     Build a GMP polylib using the GMP library],
160         gmp_package=$withval, gmp_package=notuserdefined)
161 if test "x$gmp_package" = "xno"; then
162         # user choice: don't use gmp
163         AC_MSG_RESULT([no])
164 elif test "x$gmp_package" = "xnotuserdefined"; then
165         # check if we find gmp or not... Don't fail if not
166         AC_MSG_RESULT(system)
167         AC_CHECK_HEADER(gmp.h,
168                 [AC_CHECK_LIB(gmp,main,
169                     [poly_cv_gmpfatal="no"],
170                     [poly_cv_gmpfatal="yes"])],
171                 [poly_cv_gmpfatal="yes"])
172         if test "$poly_cv_gmpfatal" = "yes"; then
173                 AC_MSG_RESULT([GMP not found])
174                 gmp_package=no
175         else
176                 AC_CHECK_DECLS(mp_get_memory_functions,[],[
177                         AC_LIBOBJ(mp_get_memory_functions)
178                 ],[#include <gmp.h>])
179         fi
180 else
181         # user choice: use gmp
182         AC_MSG_RESULT(yes)
183         if test "x$gmp_package" != "xyes"; then
184             GMP_DIR=$gmp_package
185             if test ! -d "$GMP_DIR"; then
186                 AC_MSG_ERROR(Directory given for GMP Distribution is not a directory)
187             fi
188             CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
189             LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
190         fi
191         AC_CHECK_HEADER(gmp.h,
192                 [AC_CHECK_LIB(gmp,main,
193                     [poly_cv_gmpfatal="no"],
194                     [poly_cv_gmpfatal="yes"])],
195                 [poly_cv_gmpfatal="yes"])
196         if test "$poly_cv_gmpfatal" = "yes"; then
197                 AC_MSG_ERROR([GMP not found])
198         else
199                 AC_CHECK_DECLS(mp_get_memory_functions,[],[
200                         AC_LIBOBJ(mp_get_memory_functions)
201                 ],[#include <gmp.h>])
202         fi
204         lib_type=gmp
205         BITS=`expr gmp`
206         LIBS="-lgmp $LIBS"
207         polylibs="libpolylib$BITS.la $polylibs"
208         ALL_BITS="$BITS $ALL_BITS"
211 # no default libtype defined. Let's try to build all of them.
212 if test "X$lib_type" = "X"; then
213         AC_MSG_RESULT(no default type given by user:)
214         bits=`expr $ac_cv_sizeof_int \* 8`
215         AC_MSG_RESULT([ Adding 'int' ($bits) representation])
216         lib_type=int
217         polylibs="libpolylib$bits.la $polylibs"
218         ALL_BITS="$bits $ALL_BITS"
220         if test "$ac_cv_sizeof_long_int" -gt "$ac_cv_sizeof_int"; then
221                 bits=`expr $ac_cv_sizeof_long_int \* 8`
222                 AC_MSG_RESULT([Adding 'long int' ($bits)representation])
223                 lib_type=longint
224                 polylibs="libpolylib$bits.la $polylibs"
225                 ALL_BITS="$ALL_BITS $bits"
226         fi
227         if test "$ac_cv_sizeof_long_long_int" -gt "$ac_cv_sizeof_long_int"; then
228                 bits=`expr $ac_cv_sizeof_long_long_int \* 8`
229                 AC_MSG_RESULT([ Adding 'long long int' ($bits) representation])
230                 lib_type=longlongint
231                 polylibs="libpolylib$bits.la $polylibs"
232                 ALL_BITS="$ALL_BITS $bits"
233         fi
234         if test "x$gmp_package" != "xno"; then
235                 AC_MSG_RESULT([ Adding 'gmp' representation])
236                 lib_type=gmp
237                 BITS=`expr gmp`
238                 LIBS="-lgmp $LIBS"
239                 polylibs="libpolylib$BITS.la $polylibs"
240                 ALL_BITS="$ALL_BITS $BITS"
241         fi
244 case "$lib_type" in
245         int)
246             BITS=`expr $ac_cv_sizeof_int \* 8`
247             ;;
248         longint)
249             BITS=`expr $ac_cv_sizeof_long_int \* 8`
250             ;;
251         longlongint)
252             BITS=`expr $ac_cv_sizeof_long_long_int \* 8`
253             ;;
254 esac
257 AC_SUBST(polylib)
258 polylib="libpolylib$BITS.la"
260 dnl extra indirection to avoid automake getting confused
261 AC_SUBST(multi_bin_programs)
262 AC_SUBST(multi_noinst_programs)
263 for pl_bit in $ALL_BITS ; do
264         multi_bin_programs="$multi_bin_programs \$(multi_bin_programs_${pl_bit})"
265         multi_noinst_programs="$multi_noinst_programs \$(no_inst_programs_${pl_bit})"
266 done
268 dnl /*****************************************************************************/
269 AC_ARG_ENABLE(extra-suffix,
270         [  --enable-extra-suffix   Add bits size suffix to executables],
271         [ if test "$enableval" = yes; then
272                 program_transform_name="s/\$\$/$BITS/;$program_transform_name"
273     fi ] )
275 dnl /********************************************************************/
276 dnl Check for DOXYGEN package
277 AC_ARG_WITH(doxygen, [  --with-doxygen          DIR Location of the Doxygen Distribution (http://www.doxygen.org)], doxygen_package=$withval)
279 dnl AC_MSG_CHECKING(for Doxygen program)
280 AC_CHECK_PROG(DOXYGEN,doxygen,doxygen,test,[$PATH:$doxygen_package/bin:/usr/local/bin])
281 dnl AC_MSG_RESULT($DOXYGEN)
284 dnl AC_CHECK_LIB(pthread, pthread_create)
285 ACX_PTHREAD()
286 AC_ARG_ENABLE(threadsafe,
287         [  --enable-threadsafe     threadsafe polylib (enabled by default if a threading library is found)],
288         [
289                 if test "$enable_threadsafe" = "yes" -a "X$PTHREAD_CC" = "X"; then
290                         AC_MSG_ERROR([pthread library not found])
291                 fi
292         ] )
294 if test "X$PTHREAD_CC" = "X" ; then
295         AC_MSG_WARN([No pthread library found, PolyLib will not be threadsafe])
296 elif test "X$enable_threadsafe" = "Xno"; then
297         AC_MSG_NOTICE([Will NOT build a threadsafe library (as requested)])
298 else
299         LIBS="$LIBS $PTHREAD_LIBS"
300         CFLAGS="$CFLAGS $PTHREAD_CFLAGS -DTHREAD_SAFE_POLYLIB"
301         CC="$PTHREAD_CC"
302         AC_MSG_NOTICE([Will build a threadsafe library])
305 AC_SUBST(LIBS)
306 AC_SUBST(CFLAGS)
307 AC_SUBST(CC)
309 dnl long/int bits and compilation flags
310 AC_SUBST(BITS)
312 dnl Used with doxygen
313 AC_SUBST(DOXYGEN)
315 dnl Currently, we only create one .pc file
316 dnl Creating one for each configured version is a bit complicated
317 PACKAGE_NAME=polylib$BITS
318 AX_CREATE_PKGCONFIG_INFO
320 AC_CONFIG_HEADERS(config.h)
321 AC_CONFIG_FILES([Makefile
322           include/Makefile
323           include/polylib/Makefile
324           include/polylib/polylib.h
325           Test/Makefile
326           Test/Zpolytest/Makefile
327           Test/ehrhart/Makefile
328           Test/ehrhart_union/Makefile
329           Test/ranking/Makefile
330           Test/general/Makefile
331           Test/pp/Makefile
332           polylib.doxygen
333         ])
334 AC_OUTPUT
337 echo "---------------------------------------------------"
338 echo "Polylib will be built with" $ALL_BITS "integer size(s)"
339 echo "You can proceed with:"
340 echo "make               :to build the libs and the executables"
341 echo "make tests         :to test the library"
342 echo "make install       :to install them (to $prefix)"
343 echo "---------------------------------------------------"