piplib 1.3.3
[piplib.git] / configure.in
blob2b117c16f3583efabf5ec8897f0304ed344102ff
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.
13 AC_PREREQ(2.13)
14 AC_INIT(./source/piplib.c)
15 VERSION="1.3.3"
17 TO_BUILD_32="32"
18 TO_BUILD_64="64"
19 TO_BUILD_MP="MP"
21 dnl /**************************************************************************
22 dnl  *                              Checking                                  *
23 dnl  **************************************************************************/
26 dnl Checks for typedefs, structures, and compiler characteristics.
27 AC_CANONICAL_SYSTEM
29 dnl Checks for programs.
30 AC_PROG_CC
31 AC_PROG_LN_S
32 AC_PROG_RANLIB
33 AC_PROG_MAKE_SET
34 AC_CHECK_PROG(CD, cd)
35 dnl Configure needs an empty install.sh file with this, i HATE that...
36 AC_PROG_INSTALL
38 dnl Checks for typedefs, structures, and compiler characteristics.
39 AC_C_CONST
40 AC_TYPE_SIZE_T
43 dnl Checks for libraries.
44 dnl Replace `main' with a function in -lc:
45 dnl AC_CHECK_LIB(c, main)
48 dnl Checks for header files.
49 AC_HEADER_STDC
52 dnl Set some system dependant values.
53 case "$target" in
54   i*-pc-cygwin)
55         SHEXT="dll"
56         EXEC_SUFFIX=".exe"      
57         EXTRA_FLAGS="-DCYGWIN"
58         EXTRA_LIBS="-lcygwin -lkernel32"
59         TO_BUILD_64=""
60         PIPLIB="piplibstatic"
61         INSTALL_PIPLIB="install_piplibstatic" ;;
62   *)
63         SHEXT="so"
64         EXEC_SUFFIX=""
65         EXTRA_FLAGS=""
66         EXTRA_LIBS=""
67         PIPLIB="piplibshared piplibstatic"
68         INSTALL_PIPLIB="install_piplibshared install_piplibstatic" ;;
69 esac
72 dnl Checks sizeof the two supported cases.
73 AC_CHECK_SIZEOF(int,1)
74 AC_CHECK_SIZEOF(long long int,1)
77 dnl /**************************************************************************
78 dnl  *                             Option setting                             *
79 dnl  **************************************************************************/
82 dnl The different packages that can be built and installed.
83 PIP="pip"
84 INSTALL_PIP="install_pip"
85 INT_BITS=`expr $ac_cv_sizeof_int \* 8`
86 INT_DFLAGS=-DLINEAR_VALUE_IS_INT
87 LONG_BITS=`expr $ac_cv_sizeof_long_long_int \* 8`
88 LONG_DFLAGS=-DLINEAR_VALUE_IS_LONGLONG
89 MP_BITS="MP"
90 MP_DFLAGS=-DLINEAR_VALUE_IS_MP
91 NEED_MP="no"
92 GMP_INC="/usr/local/include"
93 GMP_LIB="/usr/local/lib"
95 dnl Options.
96 dnl --with-pip=yes, --with-pip=no ou --without-pip
97 dnl --with-lib=yes, --with-lib=no ou --without-lib
98 AC_ARG_WITH(pip,
99         [  --without-pip           disable the compilation of pip],
100         [ echo "Package pip : $withval" &&
101           if test "$withval"="no" ; then        
102                 PIP=""
103                 INSTALL_PIP="" 
104           fi ])
106 AC_ARG_WITH(lib,
107         [  --without-lib           disable the compilation of libs],
108         [ echo "Package lib : $withval" &&
109           if test "$withval"="no" ; then        
110                 PIPLIB=""
111                 INSTALL_PIPLIB=""
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           if test "$enableval"="no" ; then      
140                 TO_BUILD_32="32"
141                 TO_BUILD_64=""
142                 TO_BUILD_MP=""
143           fi ])
145 AC_ARG_ENABLE(llint-version,
146         [  --enable-llint-version  Only 'long long int' version is built],
147         [ echo "Package long long int : $enableval" &&
148           if test "$enableval"="no" ; then      
149                 TO_BUILD_32=""
150                 TO_BUILD_64="64"
151                 TO_BUILD_MP=""
152           fi ])
154 AC_ARG_ENABLE(mp-version,
155         [  --enable-mp-version     Only 'MP' version is built],
156         [ echo "Package mp : $enableval" &&
157           if test "$enableval"="no" ; then      
158                 TO_BUILD_32=""
159                 TO_BUILD_64=""
160                 TO_BUILD_MP="MP"
161                 NEED_MP="yes"
162           fi ])
164 dnl Packages to build.
165 PACKAGES="$PIPLIB $PIP"
166 TO_INSTALL="$INSTALL_PIPLIB $INSTALL_PIP"
169 dnl /**************************************************************************
170 dnl  *                            Where is GMP?                               *
171 dnl  **************************************************************************/
174 dnl Checking for gmp
175 AC_MSG_CHECKING(whether gmp works)
176 if test "$gmp_package" = "no"; then
177   AC_MSG_RESULT(no)
178   TO_BUILD_MP=""
179 else
180   if test "$NEED_MP" = "no"; then
181     echo "Mode normal GMP"
182     AC_CHECK_HEADER(gmp.h,
183                     [AC_CHECK_LIB(gmp,
184                                   __gmpz_init,
185                                   [EXTRA_LIBS="-lgmp $EXTRA_LIBS"],
186                                   [echo "Can't find gmp library." &&
187                                    echo "MP version will not be builded." &&
188                                    TO_BUILD_MP=""])],
189                     [echo "Can't find gmp headers." &&
190                      echo "MP version will not be builded." &&
191                      TO_BUILD_MP=""])
192   else
193     if test "$gmp_package" = "yes" ; then
194       AC_CHECK_HEADER(gmp.h,
195                       [],
196                       [AC_MSG_ERROR(Can't find gmp headers.)])
197       AC_CHECK_LIB(gmp,
198                    __gmpz_init,
199                    [EXTRA_LIBS="-lgmp $EXTRA_LIBS"],
200                    [AC_MSG_ERROR(Can't find gmp library.)])
201     else
202       if test ! -d "$GMP_INC" ; then
203         AC_MSG_ERROR(Directory given for gmp include does not exist.)
204       fi
205       if test ! -d "$GMP_LIB" ; then
206         AC_MSG_ERROR(Directory given for gmp library does not exist.)
207       fi
208       
209       if test ! -f $GMP_INC/gmp.h; then
210         AC_MSG_ERROR(Can't find $GMP_INC/gmp.h)
211       else
212         if test -f $GMP_LIB/libgmp.so -o -f $GMP_LIB/libgmp.a ; then
213           EXTRA_INC="-I$GMP_INC"
214           EXTRA_LIBS="-L$GMP_LIB -lgmp $EXTRA_LIBS"
215           TO_BUILD="$TO_BUILD MP"
216           AC_MSG_RESULT(yes)
217         else
218           AC_MSG_ERROR(Can't find $GMP_LIB/libgmp{.so or .a})
219         fi
220       fi
221     fi
222   fi
226 dnl /**************************************************************************
227 dnl  *                       Packages to actually build                       *
228 dnl  **************************************************************************/
231 TO_BUILD="$TO_BUILD_32 $TO_BUILD_64 $TO_BUILD_MP"
234 dnl /**************************************************************************
235 dnl  *                            Substitutions                               *
236 dnl  **************************************************************************/
239 dnl Substitutions to do in Makefile.in.
240 AC_SUBST(VERSION)
241 AC_SUBST(TO_BUILD)
242 AC_SUBST(target)
243 AC_SUBST(CC)
244 AC_SUBST(LN_S)
245 AC_SUBST(RANLIB)
246 AC_SUBST(SHEXT)
247 AC_SUBST(EXEC_SUFFIX)
248 AC_SUBST(EXTRA_FLAGS)
249 AC_SUBST(EXTRA_LIBS)
250 AC_SUBST(EXTRA_INC)
252 dnl int/long bits and compilation flags
253 AC_SUBST(INT_BITS)
254 AC_SUBST(INT_DFLAGS)
255 AC_SUBST(LONG_BITS)
256 AC_SUBST(LONG_DFLAGS)
257 AC_SUBST(MP_BITS)
258 AC_SUBST(MP_DFLAGS)
260 AC_SUBST(prefix)
261 AC_SUBST(exec_prefix)
262 AC_SUBST(INSTALL)
263 AC_SUBST(PACKAGES)
264 AC_SUBST(TO_INSTALL)
266 dnl Makefile creation.
267 AC_OUTPUT(Makefile)
270 echo "             /*-----------------------------------------------*"
271 echo "              *         PIP/PipLib configuration is OK        *"
272 echo "              *-----------------------------------------------*/"
273 echo "It appears that your system is OK to start PIP/PipLib compilation. You"
274 echo "need now to type \"make uninstall\" if your are upgrading an old version."
275 echo "Next, type \"make\" to build the program. Lastly type \"make install\" to"
276 echo "install it on your system (log as root if necessary)."