version : 5.11 (vincent)
[polylib.git] / configure.in
blob4837771ca7c78af9c7617909cf9bbab45665e1ee
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.
32 define([AC_CACHE_LOAD], )dnl
33 define([AC_CACHE_SAVE], )dnl
34 AC_INIT(include/polylib/polylib.h)
36 VERSION=5.11
38 dnl Checks for typedefs, structures, and compiler characteristics.
39 AC_CANONICAL_SYSTEM 
41 dnl Checks for programs.
42 AC_PROG_CC
43 AC_PROG_LN_S
44 AC_PROG_RANLIB
45 AC_PROG_INSTALL
47 dnl Checks for typedefs, structures, and compiler characteristics.
48 AC_C_CONST
50 dnl Checks for header files.
51 AC_HEADER_STDC
52 AC_CHECK_HEADERS(limits.h unistd.h)
55 case "$target" in
56   *hpux*)  
57         LD="ld";        
58         SHEXT="sl" ; 
59         EXEC_SUFFIX=    
60         SHAREDLIB_FLAG="-Wl,-B,immediate,-B,nonfatal,-B,verbose";     
61         LDCONFIG=
62         INSTALL_LIB="install-static install-shared" ;;
63   i*-*-linux-gnu)  
64         LD="gcc"
65         SHEXT="so" ; 
66         EXEC_SUFFIX=
67         SHAREDLIB_FLAG="-shared"
68         LDCONFIG=ldconfig
69         INSTALL_LIB="install-static install-shared" ;;
70   *-sun-solaris*)  
71         LD="gcc"
72         SHEXT="so" 
73         EXEC_SUFFIX=    
74         SHAREDLIB_FLAG="-G"
75         LDCONFIG=
76         prefix="$(PWD)"
77         INSTALL_LIB="install-static" ;;
78  *-pc-solaris*)  
79         LD="gcc"
80         SHEXT="so" 
81         EXEC_SUFFIX=    
82         SHAREDLIB_FLAG="-G"
83         LDCONFIG=
84         INSTALL_LIB="install-static" ;;
85  i*-pc-cygwin)   
86         LD="ld -r"
87         SHEXT="dll"
88         SHAREDLIB_FLAG=""
89         LIBS="$LIBS -lcygwin -lkernel32 -lcrtdll"
90         prefix="$(PWD)"
91         EXEC_SUFFIX=.exe        
92         LDCONFIG=
93         EXTRA_FLAGS="-DCYGWIN"
94         INSTALL_LIB="install-static" ;;
95     *) AC_MSG_ERROR([ARCH "$target" is not supported]) ;;
96 esac
99 dnl /*****************************************************************************/
100 dnl See if the only goal is to create an 'int', 'longint', or 'longlongint' library
102 AC_CHECK_SIZEOF(int,1)
103 case "$target" in
104  i*-pc-cygwin)
105         echo "... sorry 4"
106         ac_cv_sizeof_int=4;;
107 esac
108 AC_CHECK_SIZEOF(long int,1)
109 case "$target" in
110  i*-pc-cygwin)
111         echo "... sorry 4"
112         ac_cv_sizeof_long_int=4;;
113 esac
114 AC_CHECK_SIZEOF(long long int,1)
115 case "$target" in
116  i*-pc-cygwin)
117         echo "... sorry 8"
118         ac_cv_sizeof_long_long_int=8;;
119 esac
122 AC_ARG_ENABLE(int-lib,[ --enable-int-lib         Enable that only an int library is constructed], only_int_lib=$enableval,only_int_lib=no)
123 AC_ARG_ENABLE(longint-lib,[ --enable-longint-lib     Enable that only a long int library is constructed (default)], only_longint_lib=$enableval,only_longint_lib=no)
124 AC_ARG_ENABLE(longlongint-lib,[ --enable-longlongint-lib Enable that only a long long int library is constructed], only_longlongint_lib=$enableval,only_longlongint_lib=no)
125 AC_ARG_ENABLE(gmpint-lib,[ --enable-gmpint-lib Enable that only a gmp int library is constructued], only_gmpint_lib=$enableval,only_gmpint_lib=no)
126 AC_ARG_ENABLE(allint-lib,[ --enable-allint-lib Enable that 32, 64 and gmp int library is constructued], allint_lib=$enableval,allint_lib=no)
128 INT_BITS=`expr $ac_cv_sizeof_int \* 8`
129 INT_AFLAGS=-DLINEAR_VALUE_IS_INT
131 LONG_BITS=`expr $ac_cv_sizeof_long_long_int \* 8`
132 LONG_AFLAGS="-DLINEAR_VALUE_IS_LONGLONG -DLINEAR_VALUE_PROTECT_MULTIPLY\
133                         -DLINEAR_VALUE_ASSUME_SOFTWARE_IDIV"
135 GMP_BITS=`expr gmp`
136 GMP_AFLAGS="-DGNUMP"
139 if test "$only_int_lib" = "yes"; then
140         no_long=yes
141 elif test "$only_longint_lib" = "yes"; then
142 dnl /* type "long int" is built using INT_AFLAGS.
143         INT_BITS=`expr $ac_cv_sizeof_long_int \* 8`
144         INT_AFLAGS="-DLINEAR_VALUE_IS_LONG -DLINEAR_VALUE_PROTECT_MULTIPLY\
145                         -DLINEAR_VALUE_ASSUME_SOFTWARE_IDIV"
146         no_long=yes
147 elif test "$only_longlongint_lib" = "yes"; then
148         no_long=no
149 elif test "$only_gmpint_lib" = "yes"; then
150         no_long=no
151 else
153 dnl /******************************************************************/
154 dnl Check the size of the int's.
155 dnl three sizes library can be constructed: size = INT, LONG, or GMP.
156 dnl have to compute [size]BITS and [size]AFLAGS
158 AC_MSG_CHECKING(what the LONG representation is)
159 no_long=no
160 if test "$ac_cv_sizeof_long_long_int" -gt "$ac_cv_sizeof_int"; then
161         LONG_BITS=`expr $ac_cv_sizeof_long_long_int \* 8`
162         AC_MSG_RESULT([long long int, $LONG_BITS bits])
163 elif test "$ac_cv_sizeof_long_int" -gt "$ac_cv_sizeof_int"; then
164         LONG_BITS=`expr $ac_cv_sizeof_long_int \* 8`
165         AC_MSG_RESULT([long int, $LONG_BITS bits])
166 else
167         AC_MSG_RESULT([NONE!])
168         no_long=yes
172 case "$target" in
173  i*-pc-cygwin)
174            no_long=yes
175 esac
177 if test "$no_long" = "yes"; then
178         LIBS_TO_BUILD=$INT_BITS
179         EXEC_TO_BUILD=$INT_BITS
180         DEFAULT_INT_BITS=$INT_BITS
181         DEFAULT_AFLAGS=$INT_AFLAGS
182 elif test "$only_longlongint_lib" = "yes"; then
183         LIBS_TO_BUILD=$LONG_BITS
184         EXEC_TO_BUILD=$LONG_BITS
185         DEFAULT_INT_BITS=$LONG_BITS
186         DEFAULT_AFLAGS=$LONG_AFLAGS
187 elif test "$only_gmpint_lib" = "yes"; then
188         LIBS_TO_BUILD=$GMP_BITS
189         EXEC_TO_BUILD=$GMP_BITS
190         DEFAULT_INT_BITS=$GMP_BITS
191         DEFAULT_AFLAGS=$GMP_AFLAGS
192         usegmp=yes
193 elif test "$allint_lib" = "yes"; then
194         LIBS_TO_BUILD="$INT_BITS $LONG_BITS $GMP_BITS"
195         EXEC_TO_BUILD="$LONG_BITS"
196         DEFAULT_INT_BITS=$INT_BITS
197         DEFAULT_AFLAGS=$INT_AFLAGS
198         usegmp=yes
199 else
200         LIBS_TO_BUILD="$LONG_BITS"
201         EXEC_TO_BUILD="$LONG_BITS"
202         DEFAULT_INT_BITS=$LONG_BITS
203         DEFAULT_AFLAGS=$LONG_AFLAGS
206 AC_ARG_ENABLE(short-exec,[ --enable-short-exec      Enable that the int library is used by the executables (by default, the long library is used if built)],[ if test "$enableval" = yes; then
207                 EXEC_TO_BUILD=$INT_BITS
208                 DEFAULT_INT_BITS=$INT_BITS
209                 DEFAULT_AFLAGS=$INT_AFLAGS
211     fi ] )
213 dnl /*****************************************************************************/
214 EXEC_EXTRA_SUFFIX=$EXEC_SUFFIX
215 AC_ARG_ENABLE(extra-suffix,[ --enable-extra-suffix    Enable that the executables take an extra suffix depending on the library size],[ if test "$enableval" = yes; then
216                 EXEC_EXTRA_SUFFIX="\$(BITS)$EXEC_SUFFIX"
217     fi ] )
218 AC_ARG_ENABLE(all-exec,[ --enable-all-exec        Enable that all sized libraries are used to build the executables of each, which take an extra suffix depending on the library (by default, only the long library is used)],[ if test "$enableval" = yes; then
219                 EXEC_TO_BUILD="$LIBS_TO_BUILD"
220                 DEFAULT_INT_BITS=$INT_BITS
221                 DEFAULT_AFLAGS=$INT_AFLAGS
222                 EXEC_EXTRA_SUFFIX="\$(BITS)$EXEC_SUFFIX"
223     fi ] )
225 dnl /*****************************************************************************/
226 dnl install static/shared/none libraries (default : see below)
227 EXEC_EXTRA_LIBS="-lpolylib\$(BITS)"
228 dnl See if the only goal is to create a shared library
229 AC_ARG_ENABLE(onlyshared,[ --enable-onlyshared      Enable that only a shared library is constructued], only_shared=$enableval,only_shared=no)
230 if test "$only_shared" = "yes"; then
231         INSTALL_LIB="install-shared"
233 dnl See if the only goal is to create a static library
234 AC_ARG_ENABLE(onlystatic,[ --enable-onlystatic      Enable that only a static library is constructued], only_static=$enableval,only_static=no)
235 if test "$only_static" = "yes"; then
236         INSTALL_LIB="install-static"
238 dnl See if the user does not want to create any library
239 AC_ARG_ENABLE(install-lib,[ --disable-install-lib    Disable installation of the library],
240         [if test "$enableval" = "no"; then
241                 INSTALL_LIB=""
242                 EXEC_EXTRA_LIBS="-L\$(OBJ_DIR) $EXEC_EXTRA_LIBS"
243         fi], EXEC_EXTRA_LIBS="-L$libdir $EXEC_EXTRA_LIBS" )
245 AC_ARG_WITH(ldconfig-cache, [ --with-ldconfig-cache=FILE Run ldconfig -C <FILE>],
246         [if test "x$LDCONFIG" = "xldconfig"; then
247                 LDCONFIG="$LDCONFIG -C $withval"
248         fi])
251 dnl /*****************************************************************************/
252 dnl Check for GMP library
253 AC_ARG_WITH(libgmp, [ --with-libgmp            DIR Location of the GMP Distribution], gmp_package=$withval,gmp_package=yes)
255 EXTRA_LIBS=
256 EXTRA_INCLUDE=
258 dnl if test "x$usegmp" = "xyes"; then
259         AC_MSG_CHECKING(for GMP)
260         if test "x$gmp_package" = "xno"; then
261                 AC_MSG_RESULT(no)
262         else
263                 if test "x$gmp_package" = "xyes"; then
264                         AC_CHECK_HEADER(gmp.h,
265                                 AC_CHECK_LIB(gmp,main,
266                                         [ EXTRA_LIBS="-lgmp $EXTRA_LIBS"]))
267                 else
268         dnl Check if the GMP directory is a valid location
269                         GMP_DIR=$gmp_package
270                         if test ! -d "$GMP_DIR"; then
271                         AC_ERROR(Directory given for GMP Distribution is not a directory)
272                         else
273                                 GMP_INC=$GMP_DIR/include
274                                 GMP_LIB=$GMP_DIR/lib
275                                 if test ! -f $GMP_INC/gmp.h; then
276                                 AC_ERROR(Can't find $GMP_INC/gmp.h)
277                                 elif test -f $GMP_LIB/libgmp.so -o -f $GMP_LIB/libgmp.a -o -f $GMP_LIB/libgmp.$SHEXT; then
278                                         EXTRA_INCLUDES="-I$GMP_INC"
279                                         EXTRA_LIBS="-L$GMP_LIB -lgmp $EXTRA_LIBS"
280                                         AC_MSG_RESULT(yes)
281                                 else
282                                 AC_ERROR(Can't find $GMP_LIB/libgmp.so nor $GMP_LIB/libgmp.a nor $GMP_LIB/libgmp.$SHEXT)
283                                 fi
284                         fi
285                 fi
286         fi
287 dnl fi
289 echo "Polylib will be built with " $LIBS_TO_BUILD "integer size" 
290 echo "---------------------------------------------------"
291 echo "You can choose either:"
292 echo "make:              to build the libs,  and build the executables"
293 echo "make libs:         to build only the libraries"
294 echo "make install-libs: to install them somewhere (default /usr/local)"
295 echo "make install:      to build and install everything somewhere (default /usr/local)"
296 echo "---------------------------------------------------"
299 AC_SUBST(VERSION)
301 AC_SUBST(LD)
302 AC_SUBST(SHEXT)
303 AC_SUBST(SHAREDLIB_FLAG)
304 AC_SUBST(LIBS)
305 AC_SUBST(INSTALL_LIB)
306 AC_SUBST(LDCONFIG)
308 dnl define variants of polylib to build
309 AC_SUBST(LIBS_TO_BUILD)
310 AC_SUBST(EXEC_TO_BUILD)
312 dnl long/int bits and compilation flags
313 AC_SUBST(INT_BITS)
314 AC_SUBST(INT_AFLAGS)
315 AC_SUBST(LONG_BITS)
316 AC_SUBST(LONG_AFLAGS)
317 AC_SUBST(GMP_BITS)
318 AC_SUBST(GMP_AFLAGS)
320 AC_SUBST(DEFAULT_INT_BITS)
321 AC_SUBST(DEFAULT_AFLAGS)
323 dnl Used with GMP is selected
324 AC_SUBST(EXTRA_INCLUDES)
325 AC_SUBST(EXTRA_LIBS)
327 AC_SUBST(EXEC_EXTRA_SUFFIX)
328 AC_SUBST(EXEC_EXTRA_LIBS)
330 dnl Used with CYGWIN platform
331 AC_SUBST(EXTRA_FLAGS)
334 AC_OUTPUT(vars.mk)