2 dnl /**-------------------------------------------------------------------**
4 dnl **-------------------------------------------------------------------**
6 dnl **-------------------------------------------------------------------**
7 dnl ** First version: august 11th 2001 **
8 dnl **-------------------------------------------------------------------**/
10 dnl Input file for autoconf to build a configuration shellscript.
11 dnl To build the configure script from the PipLib's top-level directory, use
12 dnl autoconf -I autoconf -o configure autoconf/configure.in
13 dnl for older versions of autoconf use -l instead
14 dnl autoconf -l autoconf autoconf/configure.in > configure
15 dnl chmod +x configure
19 AC_INIT(source/piplib.c)
20 AC_CONFIG_AUX_DIR(autoconf)
21 AC_CONFIG_MACRO_DIR([m4])
22 AM_INIT_AUTOMAKE(piplib, 1.4.0)
26 dnl /**************************************************************************
28 dnl **************************************************************************/
31 if test "x$prefix" != "xNONE"; then
32 prefix_wd=`cd $prefix && pwd`
33 srcdir_wd=`cd $srcdir && pwd`
35 if test "x$prefix_wd" = "x$srcdir_wd"; then
36 AC_MSG_ERROR(Installation in source directory not supported)
38 if test "x$prefix_wd" = "x$wd"; then
39 AC_MSG_ERROR(Installation in build directory not supported)
43 dnl Checks for programs.
48 dnl Configure needs an empty install.sh file with this, i HATE that...
52 AC_CHECK_PROG(TEXI2DVI, texi2dvi, texi2dvi, [])
53 AM_CONDITIONAL(HAVE_TEXI2DVI, test -n "$TEXI2DVI")
57 dnl Checks for typedefs, structures, and compiler characteristics.
62 dnl Checks for libraries.
63 dnl Replace `main' with a function in -lc:
64 dnl AC_CHECK_LIB(c, main)
67 dnl Checks for header files.
71 dnl Checks sizeof the two supported cases.
72 AC_CHECK_SIZEOF(int,1)
73 AC_CHECK_SIZEOF(long long int,1)
76 dnl /**************************************************************************
77 dnl * Option setting *
78 dnl **************************************************************************/
81 dnl The different packages that can be built and installed.
83 INT_BITS=`expr $ac_cv_sizeof_int \* 8`
84 eval DFLAGS$INT_BITS=-DLINEAR_VALUE_IS_INT
85 LONG_BITS=`expr $ac_cv_sizeof_long_long_int \* 8`
86 eval DFLAGS$LONG_BITS=-DLINEAR_VALUE_IS_LONGLONG
88 MP_DFLAGS=-DLINEAR_VALUE_IS_MP
90 GMP_INC="/usr/local/include"
91 GMP_LIB="/usr/local/lib"
94 dnl Some default values cause I'm not sure whether autoconf set them, while
95 dnl documentation says it does...
97 gmp_include_package="yes"
98 gmp_library_package="yes"
102 dnl --with-pip=yes, --with-pip=no or --without-pip
104 [ --without-pip disable the compilation of pip],
105 [ echo "Package pip : $withval" &&
106 if test "$withval"="no" ; then
111 [ --with-gmp=DIR DIR where the gmp package is installed],
112 [ echo "Package gmp : $withval" &&
113 gmp_package=$withval &&
114 GMP_INC=$gmp_package/include &&
115 GMP_LIB=$gmp_package/lib &&
118 AC_ARG_WITH(gmp_include,
119 [ --with-gmp-include=DIR DIR where gmp.h is installed],
120 [ echo "Package gmp-include : $withval" &&
121 gmp_include_package=$withval &&
122 GMP_INC=$gmp_include_package &&
125 AC_ARG_WITH(gmp_library,
126 [ --with-gmp-library=DIR DIR where the gmp library is installed],
127 [ echo "Package gmp-library : $withval" &&
128 gmp_library_package=$withval &&
129 GMP_LIB=$gmp_library_package &&
133 [AS_HELP_STRING([--with-bits=32,64,gmp,all],
134 [integer type version(s) to build (default is all)])])
145 case "$with_bits" in *32*) TO_BUILD="$TO_BUILD 32" ;; esac
146 case "$with_bits" in *64*) TO_BUILD="$TO_BUILD 64" ;; esac
147 case "$with_bits" in *gmp*) TEST_MP="yes"; NEED_MP="yes" ;; esac
152 dnl /**************************************************************************
153 dnl * Where is GMP? *
154 dnl **************************************************************************/
158 if test "$gmp_package" = "no"; then
159 echo "GMP package not defined"
161 if test "$TEST_MP" != "no"; then
162 dnl Default given by --with-X is "yes", --without-X is "no".
163 if test "$gmp_package" != "yes" ; then
164 echo "(GMP path has been set by user)"
167 GMP_INC=$GMP_DIR/include
168 EXTRA_LIBS="$EXTRA_LIBS -L$GMP_LIB"
169 dnl Useful for AC_CHECK_X to find what we want.
170 CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
171 LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
174 if test "$gmp_include_package" != "yes" ; then
175 CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
178 if test "$gmp_library_package" != "yes" ; then
179 EXTRA_LIBS="$EXTRA_LIBS -L$GMP_LIB"
180 LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
184 AC_CHECK_HEADER(gmp.h, [
185 AC_CHECK_LIB(gmp, __gmpz_init,
187 [AC_MSG_WARN(Can't find gmp library.)])
188 ], [AC_MSG_WARN(Can't find gmp headers.)])
189 if test $gmp_found = yes; then
190 EXTRA_LIBS="$EXTRA_LIBS -lgmp"
191 TO_BUILD="$TO_BUILD MP"
193 if test $NEED_MP = yes; then
194 AC_MSG_ERROR([gmp not found])
198 AC_MSG_CHECKING(whether gmp works)
199 AC_MSG_RESULT($gmp_found)
204 dnl /**************************************************************************
205 dnl * Packages to actually build *
206 dnl **************************************************************************/
209 for tb in $TO_BUILD; do
210 piplibs="$piplibs libpiplib$tb.la"
211 if test "x$PIP" != "x"; then
212 pips="$pips pip$tb\$(EXEEXT)"
214 examples="$examples example$tb\$(EXEEXT)"
218 if test -f $srcdir/.git/HEAD; then
219 GIT_INDEX="$srcdir/.git/index"
222 dnl /**************************************************************************
223 dnl * Substitutions *
224 dnl **************************************************************************/
227 dnl Substitutions to do in Makefile.in.
233 dnl compilation flags
238 AC_CONFIG_FILES(Makefile example/Makefile test/Makefile doc/Makefile)
239 AC_CONFIG_FILES([genversion.sh], [chmod +x genversion.sh])
240 AC_CONFIG_COMMANDS([version.h],
241 [echo '#define PIPLIB_HEAD "'`./genversion.sh`'"' > version.h])
245 echo " /*-----------------------------------------------*"
246 echo " * PIP/PipLib configuration is OK *"
247 echo " *-----------------------------------------------*/"
248 echo "It appears that your system is OK to start PIP/PipLib compilation. You"
249 echo "need now to type \"make uninstall\" if your are upgrading an old version."
250 echo "Next, type \"make\" to build the program. Lastly type \"make install\" to"
251 echo "install it on your system (log as root if necessary)."