configure: replace --with-gmp-{include,library} with --with-gmp-{,exec-}prefix
[piplib.git] / configure.in
blob78021d1c4af5820ce15107091880f5b3e70a8d90
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"
92 dnl Options.
93 dnl --with-pip=yes, --with-pip=no or --without-pip
94 AC_ARG_WITH(pip,
95         [  --without-pip           disable the compilation of pip],
96         [ echo "Package pip : $withval" &&
97           if test "$withval"="no" ; then        
98                 PIP=""
99           fi ])
101 AC_ARG_WITH(gmp,
102             [AS_HELP_STRING([--with-gmp],
103                             [Build gmp version])])
104 if test "x$with_gmp" = "x"; then
105         with_gmp=yes
107 AC_ARG_WITH(gmp_prefix,
108             [AS_HELP_STRING([--with-gmp-prefix=DIR],
109                             [Prefix of gmp installation])])
110 AC_ARG_WITH(gmp_exec_prefix,
111             [AS_HELP_STRING([--with-gmp-exec-prefix=DIR],
112                             [Exec prefix of gmp installation])])
114 if test "x$with_gmp_prefix" != "x" -o "x$with_gmp_exec_prefix" != "x"; then
115         with_gmp=yes
118 if test "x$with_gmp" = "xyes"; then
119         NEED_MP="yes"
122 if test "x$with_gmp_prefix" != "x" -a "x$with_gmp_exec_prefix" = "x"; then
123         with_gmp_exec_prefix=$with_gmp_prefix
126 AC_ARG_WITH(bits,
127         [AS_HELP_STRING([--with-bits=32,64,gmp,all],
128                         [integer type version(s) to build (default is all)])])
130 TEST_MP="yes"
131 TO_BUILD="32 64"
133 case "$with_bits" in
134 *all*|"")
135         ;;
137         TO_BUILD=""
138         TEST_MP="no"
139         case "$with_bits" in *32*) TO_BUILD="$TO_BUILD 32" ;; esac
140         case "$with_bits" in *64*) TO_BUILD="$TO_BUILD 64" ;; esac
141         case "$with_bits" in *gmp*) TEST_MP="yes"; NEED_MP="yes" ;; esac
142         ;;
143 esac
146 dnl /**************************************************************************
147 dnl  *                            Where is GMP?                               *
148 dnl  **************************************************************************/
151 dnl Checking for gmp
152 if test "$with_gmp" = "no"; then
153   echo "GMP package not defined"
154 else
155   if test "$TEST_MP" != "no"; then
156     if test "x$with_gmp_prefix" != "x" ; then
157       CPPFLAGS="-I$with_gmp_prefix/include $CPPFLAGS"
158     fi
159     
160     if test "x$with_gmp_exec_prefix" != "x" ; then
161       EXTRA_LIBS="$EXTRA_LIBS -L$with_gmp_exec_prefix/lib"
162       LDFLAGS="-L$with_gmp_exec_prefix/lib $LDFLAGS"
163     fi
164      
165     gmp_found=no
166     AC_CHECK_HEADER(gmp.h, [
167         AC_CHECK_LIB(gmp, __gmpz_init,
168                      [gmp_found=yes],
169                      [AC_MSG_WARN(Can't find gmp library.)])
170     ], [AC_MSG_WARN(Can't find gmp headers.)])
171     if test $gmp_found = yes; then
172         EXTRA_LIBS="$EXTRA_LIBS -lgmp"
173         TO_BUILD="$TO_BUILD MP"
174     else
175         if test $NEED_MP = yes; then
176                 AC_MSG_ERROR([gmp not found])
177         fi
178     fi
180     AC_MSG_CHECKING(whether gmp works)
181     AC_MSG_RESULT($gmp_found)
182   fi
186 dnl /**************************************************************************
187 dnl  *                       Packages to actually build                       *
188 dnl  **************************************************************************/
191 for tb in $TO_BUILD; do
192     piplibs="$piplibs libpiplib$tb.la"
193     if test "x$PIP" != "x"; then
194         pips="$pips pip$tb\$(EXEEXT)"
195     fi
196     examples="$examples example$tb\$(EXEEXT)"
197 done
199 AC_SUBST(GIT_INDEX)
200 if test -f $srcdir/.git/HEAD; then
201     GIT_INDEX="\$(top_srcdir)/.git/index"
204 dnl /**************************************************************************
205 dnl  *                            Substitutions                               *
206 dnl  **************************************************************************/
209 dnl Substitutions to do in Makefile.in.
210 AC_SUBST(examples)
211 AC_SUBST(piplibs)
212 AC_SUBST(pips)
213 AC_SUBST(EXTRA_LIBS)
215 dnl compilation flags
216 AC_SUBST(DFLAGS32)
217 AC_SUBST(DFLAGS64)
218 AC_SUBST(MP_DFLAGS)
220 AC_CONFIG_FILES(Makefile example/Makefile test/Makefile doc/Makefile)
221 AC_CONFIG_FILES([genversion.sh], [chmod +x genversion.sh])
222 AC_CONFIG_COMMANDS([version.h],
223     [echo '#define PIPLIB_HEAD "'`./genversion.sh`'"' > version.h])
224 AC_OUTPUT
227 echo "             /*-----------------------------------------------*"
228 echo "              *         PIP/PipLib configuration is OK        *"
229 echo "              *-----------------------------------------------*/"
230 echo "It appears that your system is OK to start PIP/PipLib compilation. You"
231 echo "need now to type \"make uninstall\" if your are upgrading an old version."
232 echo "Next, type \"make\" to build the program. Lastly type \"make install\" to"
233 echo "install it on your system (log as root if necessary)."