genversion.sh: rename GIT_HEAD_ID to PIPLIB_HEAD and drop "piplib-" prefix
[piplib.git] / configure.in
blob88ea749f8a27e1bd04278dc6375330f031617a13
2 dnl /**-------------------------------------------------------------------**
3 dnl  **                              PIPLIB                               **
4 dnl  **-------------------------------------------------------------------**
5 dnl  **                           configure.in                            **
6 dnl  **-------------------------------------------------------------------**
7 dnl  **                   First version: august 11th  2001                **
8 dnl  **-------------------------------------------------------------------**/
9 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
18 AC_PREREQ(2.13)
19 AC_INIT(source/piplib.c)
20 AC_CONFIG_AUX_DIR(autoconf)
21 AC_CONFIG_MACRO_DIR([m4])
22 AM_INIT_AUTOMAKE(piplib, 1.3.6)
23 AC_SUBST(versioninfo)
24 versioninfo=2:0:0
26 TO_BUILD_32="32"
27 TO_BUILD_64="64"
28 TO_BUILD_MP="MP"
30 dnl /**************************************************************************
31 dnl  *                              Checking                                  *
32 dnl  **************************************************************************/
35 if test "x$prefix" != "xNONE"; then
36     prefix_wd=`cd $prefix && pwd`
37     srcdir_wd=`cd $srcdir && pwd`
38     wd=`pwd`
39     if test "x$prefix_wd" = "x$srcdir_wd"; then
40         AC_MSG_ERROR(Installation in source directory not supported)
41     fi
42     if test "x$prefix_wd" = "x$wd"; then
43         AC_MSG_ERROR(Installation in build directory not supported)
44     fi
47 dnl Checks for programs.
48 AC_PROG_CC
49 AC_PROG_LN_S
50 AC_PROG_MAKE_SET
51 AC_CHECK_PROG(CD, cd)
52 dnl Configure needs an empty install.sh file with this, i HATE that...
53 AC_PROG_INSTALL
54 AC_CANONICAL_HOST
55 AC_PROG_LIBTOOL
56 AC_CHECK_PROG(TEXI2DVI, texi2dvi, texi2dvi, [])
57 AM_CONDITIONAL(HAVE_TEXI2DVI, test -n "$TEXI2DVI")
59 AX_CC_MAXOPT
61 dnl Checks for typedefs, structures, and compiler characteristics.
62 AC_C_CONST
63 AC_TYPE_SIZE_T
66 dnl Checks for libraries.
67 dnl Replace `main' with a function in -lc:
68 dnl AC_CHECK_LIB(c, main)
71 dnl Checks for header files.
72 AC_HEADER_STDC
75 dnl Checks sizeof the two supported cases.
76 AC_CHECK_SIZEOF(int,1)
77 AC_CHECK_SIZEOF(long long int,1)
80 dnl /**************************************************************************
81 dnl  *                             Option setting                             *
82 dnl  **************************************************************************/
85 dnl The different packages that can be built and installed.
86 PIP="pip"
87 INT_BITS=`expr $ac_cv_sizeof_int \* 8`
88 eval DFLAGS$INT_BITS=-DLINEAR_VALUE_IS_INT
89 LONG_BITS=`expr $ac_cv_sizeof_long_long_int \* 8`
90 eval DFLAGS$LONG_BITS=-DLINEAR_VALUE_IS_LONGLONG
91 MP_BITS="MP"
92 MP_DFLAGS=-DLINEAR_VALUE_IS_MP
93 NEED_MP="no"
94 GMP_INC="/usr/local/include"
95 GMP_LIB="/usr/local/lib"
98 dnl Some default values cause I'm not sure whether autoconf set them, while
99 dnl documentation says it does...
100 gmp_package="yes"
101 gmp_include_package="yes"
102 gmp_library_package="yes"
105 dnl Options.
106 dnl --with-pip=yes, --with-pip=no or --without-pip
107 AC_ARG_WITH(pip,
108         [  --without-pip           disable the compilation of pip],
109         [ echo "Package pip : $withval" &&
110           if test "$withval"="no" ; then        
111                 PIP=""
112           fi ])
114 AC_ARG_WITH(gmp,
115         [  --with-gmp=DIR          DIR where the gmp package is installed],
116         [ echo "Package gmp : $withval" &&
117           gmp_package=$withval &&
118           GMP_INC=$gmp_package/include &&
119           GMP_LIB=$gmp_package/lib &&
120           NEED_MP="yes"])
122 AC_ARG_WITH(gmp_include,
123         [  --with-gmp-include=DIR  DIR where gmp.h is installed],
124         [ echo "Package gmp-include : $withval" &&
125           gmp_include_package=$withval &&
126           GMP_INC=$gmp_include_package &&
127           NEED_MP="yes"])
129 AC_ARG_WITH(gmp_library,
130         [  --with-gmp-library=DIR  DIR where the gmp library is installed],
131         [ echo "Package gmp-library : $withval" &&
132           gmp_library_package=$withval &&
133           GMP_LIB=$gmp_library_package &&
134           NEED_MP="yes"])
136 AC_ARG_ENABLE(int-version,
137         [  --enable-int-version    Only 'int' version is built],
138         [ echo "Package int : $enableval" &&
139           TO_BUILD_32="32" &&
140           TO_BUILD_64="" &&
141           TO_BUILD_MP=""])
143 AC_ARG_ENABLE(llint-version,
144         [  --enable-llint-version  Only 'long long int' version is built],
145         [ echo "Package long long int : $enableval" &&
146           TO_BUILD_32="" &&
147           TO_BUILD_64="64" &&
148           TO_BUILD_MP=""])
150 AC_ARG_ENABLE(mp-version,
151         [  --enable-mp-version     Only 'MP' version is built],
152         [ echo "Package mp : $enableval" &&
153           TO_BUILD_32="" &&
154           TO_BUILD_64="" &&
155           TO_BUILD_MP="MP" &&
156           NEED_MP="yes"])
159 dnl /**************************************************************************
160 dnl  *                            Where is GMP?                               *
161 dnl  **************************************************************************/
164 dnl Checking for gmp
165 AC_MSG_CHECKING(whether gmp works)
166 if test "$gmp_package" = "no"; then
167   echo "GMP package not defined"
168   AC_MSG_RESULT(no)
169   TO_BUILD_MP=""
170 else
171   if test "$NEED_MP" = "no"; then
172     echo "Mode normal GMP"
173     AC_CHECK_HEADER(gmp.h,
174                     [AC_CHECK_LIB(gmp,
175                                   __gmpz_init,
176                                   [EXTRA_LIBS="$EXTRA_LIBS -lgmp"],
177                                   [echo "Can't find gmp library." &&
178                                    echo "MP version will not be builded." &&
179                                    TO_BUILD_MP=""])],
180                     [echo "Can't find gmp headers." &&
181                      echo "MP version will not be builded." &&
182                      TO_BUILD_MP=""])
183   else
184     dnl Default given by --with-X is "yes", --without-X is "no".
185     if test "$gmp_package" != "yes" ; then
186       echo "(GMP path has been set by user)"
187       GMP_DIR=$gmp_package
188       GMP_LIB=$GMP_DIR/lib
189       GMP_INC=$GMP_DIR/include
190       EXTRA_LIBS="$EXTRA_LIBS -L$GMP_LIB"
191       dnl Useful for AC_CHECK_X to find what we want.
192       CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
193       LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
194     fi
195     
196     if test "$gmp_include_package" != "yes" ; then
197       CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
198     fi
199     
200     if test "$gmp_library_package" != "yes" ; then
201       EXTRA_LIBS="$EXTRA_LIBS -L$GMP_LIB"
202       LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
203     fi
204      
205     AC_CHECK_HEADER(gmp.h,
206                     [],
207                     [AC_MSG_ERROR(Can't find gmp headers.)])
208     AC_CHECK_LIB(gmp,
209                  __gmpz_init,
210                  [EXTRA_LIBS="$EXTRA_LIBS -lgmp"],
211                  [AC_MSG_ERROR(Can't find gmp library.)])
212     
213     AC_MSG_RESULT(yes)
214   fi
218 dnl /**************************************************************************
219 dnl  *                       Packages to actually build                       *
220 dnl  **************************************************************************/
223 TO_BUILD="$TO_BUILD_32 $TO_BUILD_64 $TO_BUILD_MP"
224 for tb in $TO_BUILD; do
225     piplibs="$piplibs libpiplib$tb.la"
226     if test "x$PIP" != "x"; then
227         pips="$pips pip$tb\$(EXEEXT)"
228     fi
229     examples="$examples example$tb\$(EXEEXT)"
230 done
232 AC_SUBST(GIT_INDEX)
233 if test -f $srcdir/.git/HEAD; then
234     GIT_INDEX="$srcdir/.git/index"
237 dnl /**************************************************************************
238 dnl  *                            Substitutions                               *
239 dnl  **************************************************************************/
242 dnl Substitutions to do in Makefile.in.
243 AC_SUBST(examples)
244 AC_SUBST(piplibs)
245 AC_SUBST(pips)
246 AC_SUBST(EXTRA_LIBS)
248 dnl compilation flags
249 AC_SUBST(DFLAGS32)
250 AC_SUBST(DFLAGS64)
251 AC_SUBST(MP_DFLAGS)
253 AC_CONFIG_FILES(Makefile example/Makefile test/Makefile doc/Makefile)
254 AC_CONFIG_FILES([genversion.sh], [chmod +x genversion.sh])
255 AC_CONFIG_COMMANDS([version.h],
256     [echo '#define PIPLIB_HEAD "'`./genversion.sh`'"' > version.h])
257 AC_OUTPUT
260 echo "             /*-----------------------------------------------*"
261 echo "              *         PIP/PipLib configuration is OK        *"
262 echo "              *-----------------------------------------------*/"
263 echo "It appears that your system is OK to start PIP/PipLib compilation. You"
264 echo "need now to type \"make uninstall\" if your are upgrading an old version."
265 echo "Next, type \"make\" to build the program. Lastly type \"make install\" to"
266 echo "install it on your system (log as root if necessary)."