configure: replace --enable-*-version with --with-bits
[piplib.git] / configure.in
blobeabdc72664e7fd4779b4bcda60dc67a16c83a423
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.4.0)
23 AC_SUBST(versioninfo)
24 versioninfo=3:0:1
26 dnl /**************************************************************************
27 dnl  *                              Checking                                  *
28 dnl  **************************************************************************/
31 if test "x$prefix" != "xNONE"; then
32     prefix_wd=`cd $prefix && pwd`
33     srcdir_wd=`cd $srcdir && pwd`
34     wd=`pwd`
35     if test "x$prefix_wd" = "x$srcdir_wd"; then
36         AC_MSG_ERROR(Installation in source directory not supported)
37     fi
38     if test "x$prefix_wd" = "x$wd"; then
39         AC_MSG_ERROR(Installation in build directory not supported)
40     fi
43 dnl Checks for programs.
44 AC_PROG_CC
45 AC_PROG_LN_S
46 AC_PROG_MAKE_SET
47 AC_CHECK_PROG(CD, cd)
48 dnl Configure needs an empty install.sh file with this, i HATE that...
49 AC_PROG_INSTALL
50 AC_CANONICAL_HOST
51 AC_PROG_LIBTOOL
52 AC_CHECK_PROG(TEXI2DVI, texi2dvi, texi2dvi, [])
53 AM_CONDITIONAL(HAVE_TEXI2DVI, test -n "$TEXI2DVI")
55 AX_CC_MAXOPT
57 dnl Checks for typedefs, structures, and compiler characteristics.
58 AC_C_CONST
59 AC_TYPE_SIZE_T
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.
68 AC_HEADER_STDC
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.
82 PIP="pip"
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
87 MP_BITS="MP"
88 MP_DFLAGS=-DLINEAR_VALUE_IS_MP
89 NEED_MP="no"
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...
96 gmp_package="yes"
97 gmp_include_package="yes"
98 gmp_library_package="yes"
101 dnl Options.
102 dnl --with-pip=yes, --with-pip=no or --without-pip
103 AC_ARG_WITH(pip,
104         [  --without-pip           disable the compilation of pip],
105         [ echo "Package pip : $withval" &&
106           if test "$withval"="no" ; then        
107                 PIP=""
108           fi ])
110 AC_ARG_WITH(gmp,
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 &&
116           NEED_MP="yes"])
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 &&
123           NEED_MP="yes"])
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 &&
130           NEED_MP="yes"])
132 AC_ARG_WITH(bits,
133         [AS_HELP_STRING([--with-bits=32,64,gmp,all],
134                         [integer type version(s) to build (default is all)])])
136 TEST_MP="yes"
137 TO_BUILD="32 64"
139 case "$with_bits" in
140 *all*|"")
141         ;;
143         TO_BUILD=""
144         TEST_MP="no"
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
148         ;;
149 esac
152 dnl /**************************************************************************
153 dnl  *                            Where is GMP?                               *
154 dnl  **************************************************************************/
157 dnl Checking for gmp
158 if test "$gmp_package" = "no"; then
159   echo "GMP package not defined"
160 else
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)"
165       GMP_DIR=$gmp_package
166       GMP_LIB=$GMP_DIR/lib
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"
172     fi
173     
174     if test "$gmp_include_package" != "yes" ; then
175       CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
176     fi
177     
178     if test "$gmp_library_package" != "yes" ; then
179       EXTRA_LIBS="$EXTRA_LIBS -L$GMP_LIB"
180       LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
181     fi
182      
183     gmp_found=no
184     AC_CHECK_HEADER(gmp.h, [
185         AC_CHECK_LIB(gmp, __gmpz_init,
186                      [gmp_found=yes],
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"
192     else
193         if test $NEED_MP = yes; then
194                 AC_MSG_ERROR([gmp not found])
195         fi
196     fi
198     AC_MSG_CHECKING(whether gmp works)
199     AC_MSG_RESULT($gmp_found)
200   fi
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)"
213     fi
214     examples="$examples example$tb\$(EXEEXT)"
215 done
217 AC_SUBST(GIT_INDEX)
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.
228 AC_SUBST(examples)
229 AC_SUBST(piplibs)
230 AC_SUBST(pips)
231 AC_SUBST(EXTRA_LIBS)
233 dnl compilation flags
234 AC_SUBST(DFLAGS32)
235 AC_SUBST(DFLAGS64)
236 AC_SUBST(MP_DFLAGS)
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])
242 AC_OUTPUT
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)."