configure.ac 12.4 KB
Newer Older
Erick's avatar
Erick committed
1 2 3 4
### configure.in for STklos
###
###           Author: Erick Gallesio [eg@unice.fr]
###    Creation date: 28-Dec-1999 21:19 (eg)
Erick's avatar
Erick committed
5
### Last file update: 28-Aug-2011 23:45 (eg)
Erick's avatar
Erick committed
6 7

AC_PREREQ(2.64)
8
AC_INIT([stklos], [1.10])
Erick's avatar
Erick committed
9 10 11 12 13
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR(src/stklos.c)
AC_CONFIG_HEADERS(src/stklosconf.h)

### Checks for programs.
eg's avatar
eg committed
14
AC_PROG_CC
Erick's avatar
Erick committed
15 16 17 18 19
AC_PROG_CPP
AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
eg's avatar
eg committed
20
AC_PROG_RANLIB
Erick's avatar
Erick committed
21 22
AC_PROG_LEX
AC_PROG_MKDIR_P
23
AC_CHECK_PROG(PKGCONFIG, pkg-config, "pkg-config", "false")
24

Erick's avatar
Erick committed
25
### Checks for header files.
26
AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h malloc.h memory.h netdb.h netinet/in.h nlist.h stdlib.h string.h strings.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h])
eg's avatar
eg committed
27

Erick's avatar
Erick committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
### Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T

### Checks for library functions.
AC_FUNC_ALLOCA
AC_FUNC_ERROR_AT_LINE
AC_FUNC_FORK
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_MALLOC
AC_FUNC_MKTIME
AC_FUNC_REALLOC
AC_FUNC_STRCOLL
AC_FUNC_STRTOD
45
AC_CHECK_FUNCS([atexit dup2 endpwent floor getcwd gethostbyaddr gethostbyname gethostname getpass gettimeofday glob inet_ntoa isascii memchr memmove memset mkdir modf putenv rmdir select socket sqrt strcasecmp strchr strerror strrchr strstr strtoul])
Erick's avatar
Erick committed
46

Erick's avatar
Erick committed
47 48 49 50
### ======================================================================
### Various stuff done by hand
### ======================================================================

Erick's avatar
Erick committed
51
### Initialize prefix
eg's avatar
eg committed
52 53
if test X$prefix = XNONE ;then  prefix=$ac_default_prefix; fi

Erick's avatar
Erick committed
54 55
### use -O3 if user has not specified something else and we are using GCC
USER_CFLAGS=$CFLAGS
Erick Gallesio's avatar
.  
Erick Gallesio committed
56
if test "X$USER_CFLAGS" = "X" -a "$CC" = "gcc"
eg's avatar
eg committed
57 58 59 60
then
  CFLAGS="-O3 -fomit-frame-pointer"
fi

Erick's avatar
Erick committed
61 62 63 64
### Determine the options necessary for dynamic loading (even if disbaled later)
eval `CC=$CC /bin/sh ./utils/shlib-options`

case $OS_NAME_VERSION in
65
  SUNOS*)
Erick's avatar
Erick committed
66 67 68 69 70
    CFLAGS="$CFLAGS -DSOLARIS";
    LIBS="$LIBS -lsocket -lrt -lnsl -lpthread"
    ;;
  DARWIN_10)
     GCINC="GCINC -D_XOPEN_SOURCE"
71
     EXTRA_COMP_FLAGS="-I/opt/local/include"
Erick's avatar
Erick committed
72 73 74 75 76 77 78
     ;;
  UNKNOWN*)
    echo ""
    echo "**** STklos has no support for your system (`uname -s`)"
    echo "**** Please modify the script \"utils/shlib-options\" to add"
    echo "**** support for your system (it's easy) and restart installation process."
    echo "**** Thanks for sending your modifications to <bugs _at_ stklos.net>"
79
    exit 1
Erick's avatar
Erick committed
80 81 82 83 84 85 86 87 88 89 90 91 92
    ;;
esac


### Initilize the extra conf file in src
SCMDIR=$prefix/share/$PACKAGE/$VERSION
EXECDIR=$prefix/lib/$PACKAGE/$VERSION
PREFIX=$prefix

### Determine the kind of the machine which is running this script
BUILD_OS=$os-$version
BUILD_ARCH=`uname -m`
OS_NAME=$OS
93 94
case $OS in
   LINUX)
Erick's avatar
Erick committed
95 96 97 98 99 100 101 102 103 104
      v=`echo $version | sed -e 's/\([[0-9]]*\)\.\([[0-9\]]*\).*/\1_\2/'`
      OS_NAME_VERSION=LINUX_$v
      ;;
   DARWIN)
      case $version in
         9*)  OS_NAME_VERSION=DARWIN_9;;
	 10*) OS_NAME_VERSION=DARWIN_10;;
	 *)   OS_NAME_VERSION=DARWIN_OLD;;
      esac
      ;;
105
  *)
Erick's avatar
Erick committed
106
      v=`echo $version | sed -e 's/[[^0-9]]/_/g'`
107
      OS_NAME_VERSION=$OS\_$v;
Erick's avatar
Erick committed
108 109
esac

eg's avatar
eg committed
110

Erick's avatar
Erick committed
111 112 113
###
### Checks for libraries.
###
Erick's avatar
Erick committed
114 115 116
SYST_LIBS=""
COMP_LIBS=""

Erick's avatar
Erick committed
117 118

### Check for dynamic loading
eg's avatar
eg committed
119 120 121 122
AC_CHECK_FUNC(dlopen, HAVE_DLOPEN="yes", AC_CHECK_LIB(dl, dlopen, LIBS="-ldl $LIBS"&&HAVE_DLOPEN="yes"))

if test "X$HAVE_DLOPEN" = "Xyes"
then
Erick's avatar
Erick committed
123
  AC_DEFINE(HAVE_DLOPEN, 1, [System provides flopen])
eg's avatar
eg committed
124 125
fi

Erick's avatar
Erick committed
126 127 128 129

###
### To thread or not to thread ?
###
130 131
AC_CHECK_LIB(pthread, pthread_create, deflt_threads=pthreads, deflt_threads=none)

132
AC_ARG_ENABLE(threads,
Erick's avatar
Erick committed
133
  [AS_HELP_STRING([--enable-threads=TYPE],[choose threading package (none,pthreads)])],
134
  THREADS=$enableval,
135
  THREADS=$deflt_threads)
136 137

AC_LANG(C)
138

Erick's avatar
Erick committed
139
### Now look at what threads we want
140 141 142 143 144 145
case "$THREADS" in
 no | none | single)
   THREADS=none
   AC_DEFINE(THREADS_NONE, [], [No thread support])
   ;;
 posix | pthreads)
Erick's avatar
Erick committed
146
   ### Check for pthreads
147
   AC_CHECK_LIB(pthread, pthread_create, LIBS="-lpthread $LIBS",
148 149 150 151 152 153 154 155
                [AC_MSG_ERROR([Missing PThread library])])
   THREADS=pthreads
   AC_DEFINE(THREADS_PTHREADS, [], [PThread support])
   ;;
 *)
   AC_MSG_ERROR([Unknown thread system: $THREADS])
   ;;
esac
156

157

Erick's avatar
Erick committed
158
### Add the options _REENTRANT and GC_LINUX_THREADS if we are on Linux
159 160 161
case "$THREADS" in
  none) true ;;
  *) case `uname -s` in
162
        Linux*) STKCFLAGS="-D_REENTRANT=1 -DGC_LINUX_THREADS=1";;
163 164 165 166 167
     esac
esac



168 169


Erick's avatar
Erick committed
170
### Automake nightmare
171 172
AM_CONDITIONAL(PTHREADS, test "$THREADS" = pthreads)
AM_CONDITIONAL(NO_THREAD, test "$THREADS" = none)
eg's avatar
eg committed
173

174
# ----------------------------------------------------------------------
175
# GC support
176 177 178 179 180
# ----------------------------------------------------------------------
echo "*****"
echo "***** GC support"
echo "*****"

181
# Try to determine if libgc is installed
182
if ${PKGCONFIG} --exists bdw-gc ;then
183
   HAVE_GC="yes"
184
else
185 186
   AC_CHECK_LIB(gc, GC_malloc, HAVE_GC="yes", HAVE_GC="no", $LIBS)
fi
187 188 189

# Test if the user want to force with our GC lib
AC_ARG_WITH(provided-gc,
Erick's avatar
Erick committed
190
       [  --with-provided-gc	  use the provided Boehm GC library],
191
       PROV_GC="$withval", PROV_GC="no")
192 193

if test "$HAVE_GC" = "no" -o "$PROV_GC" = "yes"
194
then
195
     echo "... Configuring libgc"
Erick's avatar
Erick committed
196 197

     case $OS_NAME_VERSION in
198
       DARWIN_10)
Erick's avatar
Erick committed
199 200 201 202 203
          cflags="${CFLAGS} -D_XOPEN_SOURCE";;
       *)
          cflags="${CFLAGS}";;
     esac
     (cd gc; CC=${CC} CFLAGS=${cflags} ./configure --prefix=$prefix \
204 205 206 207
              --includedir=$prefix/include/stklos \
	      --enable-threads=$THREADS) || { echo "Cannot configure the GC"; exit; }
     GC=gc
     GCINC="-I../gc/include"
208
     GCLIB="../gc/.libs/libgc.a"
Erick's avatar
Erick committed
209
     COMP_LIBS="libgc $COMP_LIBS"
eg's avatar
eg committed
210
else
211 212
     echo "... Using system libgc library"
     GC=""
213
     if $PKGCONFIG --exists bdw-gc ;then
214 215 216 217 218 219
        GCINC=$(pkg-config  bdw-gc --cflags)
        GCLIB=$(pkg-config  bdw-gc --libs)
     else
        GCINC=""
        GCLIB="-lgc"
     fi
220
     AC_DEFINE(HAVE_GC, 1, [Use system GC])
Erick's avatar
Erick committed
221 222 223 224 225
     SYST_LIBS="libgc $SYST_LIBS"
fi


# ----------------------------------------------------------------------
226
# GMP support
Erick's avatar
Erick committed
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
# ----------------------------------------------------------------------
echo "*****"
echo "***** GMP support"
echo "*****"

# Try to determine if libgmp is installed
# No pkg-config for gmp yet

# check for GMP pre-version 3.0
AC_CHECK_LIB(gmp, mpz_init_set, HAVE_GMP="yes", HAVE_GMP="no")

# check for GMP version post 3.0
if test "$HAVE_GMP" = "no" ;then
  AC_CHECK_LIB(gmp, __gmpz_init_set, HAVE_GMP="yes", HAVE_GMP="no")
fi

243
# Test if the user want to force with our GMP lib
Erick's avatar
Erick committed
244 245 246
# (2 names available for that  --with-provided-bignum or (legacy) --with-gmp-light
AC_ARG_WITH(provided-bignum,
       [  --with-provided-bignum  use the provided Bignum (GMPlite) library],
247
       PROV_GMP="$withval", PROV_GMP="no")
Erick's avatar
Erick committed
248

249 250 251
if test "$PROV_GMP" = "no" ;then
  AC_ARG_WITH(gmp-light,
         [  --with-gmp-light	  a synonym for --with-provided-bignum],
252
         PROV_GMP="$withval", PROV_GMP="no")
253
fi
Erick's avatar
Erick committed
254 255

if test "$HAVE_GMP" = "no" -o "$PROV_GMP" = "yes"
256
then
Erick's avatar
Erick committed
257 258 259 260 261 262 263 264 265 266 267 268 269 270
     echo "... Configuring libgmp"
     (cd gmp; CC=${CC} CFLAGS="${cflags} -I../src -DFOR_STKLOS=1" ./configure \
     	      --prefix=$prefix) || { echo "Cannot configure the GMP"; exit; }
     GMP=gmp
     GMPINC="-I../gmp"
     GMPLIB="../gmp/.libs/libgmp.a"
     COMP_LIBS="libgmp $COMP_LIBS"
else
     echo "... Using system libgmp library"
     GMP=""
     GMPINC=""
     GMPLIB="-lgmp"
     AC_DEFINE(HAVE_GMP, 1, [Use system GMP])
     SYST_LIBS="libgmp $SYST_LIBS"
eg's avatar
eg committed
271 272 273
fi


274
# ----------------------------------------------------------------------
275
# PCRE support
276 277 278 279 280
# ----------------------------------------------------------------------
echo "*****"
echo "***** Regexp support"
echo "*****"

281
# Try to determine if libpcre is installed
282
if ${PKGCONFIG} --exists libpcre ;then
283
   HAVE_PCRE="yes"
284
   PCREPKG="present"
285
else
286 287
   AC_CHECK_LIB(pcre, pcre_fullinfo, HAVE_PCRE="yes", HAVE_PCRE="no", $LIBS)
fi
288 289 290

# Test if the user want to force with our PCRE lib
AC_ARG_WITH(provided-regexp,
Erick's avatar
Erick committed
291
       [  --with-provided-regexp use the provided Regexp (PCRE) library],
292
       PROV_PCRE="$withval", PROV_PCRE="no")
Erick's avatar
Erick committed
293 294

if test "$HAVE_PCRE" = "no" -o "$PROV_PCRE" = "yes"
295
then
Erick's avatar
Erick committed
296 297 298 299
     echo "... Configuring libpcre"
     PCRE_FLAGS="-Dregexec=PCRE_regexec -Dregcomp=PCRE_regcomp \
                 -Dregerror=PCRE_regerror -Dregfree=PCRE_regfree"
     (cd pcre; CC=${CC} CFLAGS="${CFLAGS} $PCRE_FLAGS" ./configure \
300
           --enable-utf8 \
301 302
           --prefix=$prefix --disable-shared --disable-cpp) || \
	   { echo "Cannot configure PCRE"; exit; }
Erick's avatar
Erick committed
303 304
     PCRE=pcre
     PCREINC="-I../pcre"
305
     PCRELIB="../pcre/.libs/libpcreposix.a ../pcre/.libs/libpcre.a"
Erick's avatar
Erick committed
306
     DEF_PCRE=""
Erick's avatar
Erick committed
307
     COMP_LIBS="libpcre $COMP_LIBS"
Erick's avatar
Erick committed
308 309 310
else
     echo "... Using system libpcre library"
     PCRE=""
311
     if $PKGCONFIG --exists libpcre ;then
312 313
        PCREINC="$($PKGCONFIG --cflags libpcre)"
        PCRELIB="$($PKGCONFIG --libs libpcre) -lpcreposix"
314
     else
315 316
        PCREINC=""
        PCRELIB="-lpcre -lpcreposix"
317
     fi
Erick's avatar
Erick committed
318 319
     AC_DEFINE(HAVE_PCRE, 1 , [We use our version of pcre])
     SYST_LIBS="libpcre $SYST_LIBS"
Erick's avatar
Erick committed
320
fi
321 322 323


# ----------------------------------------------------------------------
324
# FFI support
325 326 327 328 329
# ----------------------------------------------------------------------
echo "*****"
echo "***** FFI support"
echo "*****"

330
# Try to determine if libffi is installed
331
if ${PKGCONFIG} --exists libffi ;then
332
   HAVE_FFI="yes"
333
else
334 335
  AC_CHECK_LIB(ffi, ffi_prep_cif, HAVE_FFI="yes", HAVE_FFI="no", $LIBS)
fi
336 337 338

# Test if the user want to force with our FFI lib
AC_ARG_WITH(provided-ffi,
Erick's avatar
Erick committed
339
       [  --with-provided-ffi    use the provided FFI library],
340
       PROV_FFI="$withval", PROV_FFI="no")
341

Erick's avatar
Erick committed
342
if test "$HAVE_FFI" = "no" -o "$PROV_FFI" = "yes"
343
then
Erick's avatar
Erick committed
344 345
     echo "... Configuring libffi"
     (cd ffi; CC=${CC} CFLAGS=${CFLAGS} ./configure \
346
           --disable-structs --disable-raw-api --disable-shared \
347
	   --prefix=$prefix) || { echo "Cannot configure libffi"; exit; }
Erick's avatar
Erick committed
348 349 350
     FFI="ffi"
     FFIINC="-I../ffi/include"
     FFILIB="../ffi/.libs/libffi.a"
Erick's avatar
Erick committed
351
     COMP_LIBS="libffi $COMP_LIBS"
352
else
Erick's avatar
Erick committed
353 354
     echo "... Using system libffi library"
     FFI=""
355
     if $PKGCONFIG --exists libffi ;then
356 357 358
       FFIINC=$($PKGCONFIG libffi --cflags)
       FFILIB=$($PKGCONFIG libffi --libs)
     else
359
       FFIINC="-I/usr/include/ffi"
360 361
       FFILIB="-lffi"
     fi
Erick's avatar
Erick committed
362
     SYST_LIBS="libffi $SYST_LIBS"
eg's avatar
eg committed
363
fi
Erick's avatar
Erick committed
364
# We always want FFI. Should be modifiable in the future
365
AC_DEFINE(HAVE_FFI, 1, [System provides FFI])
366

367 368 369 370 371 372 373 374
###
### See in what direction the stack grows (code stolen from Sawfish)
###
AC_TRY_RUN([ void inner (char *foo) { char bar; exit (!(foo >= &bar)); }
             void main () { char foo; inner (&foo); } ],
   [STACK_DIRECTION="DOWN"],
   [STACK_DIRECTION="UP"],
   echo "Stack direction is not detected when cross compiling for now")
375

eg's avatar
eg committed
376

377 378 379 380 381 382
###
### Finishing ...
###
LIB_SUMMARY="(:system ($SYST_LIBS) :compiled ($COMP_LIBS))"


383
### Output files
384
AC_SUBST(STKCFLAGS)
eg's avatar
eg committed
385 386 387 388 389 390 391 392 393 394 395 396
AC_SUBST(VERSION)
AC_SUBST(HAVE_DLOPEN)
AC_SUBST(OS_FLAVOUR)
AC_SUBST(GMP)
AC_SUBST(GMPLIB)
AC_SUBST(GMPINC)
AC_SUBST(PREFIX)
AC_SUBST(SCMDIR)
AC_SUBST(EXECDIR)
AC_SUBST(BUILD_OS)
AC_SUBST(BUILD_ARCH)
AC_SUBST(OS_NAME)
397
AC_SUBST(OS_NAME_VERSION)
398
AC_SUBST(EXTRA_COMP_FLAGS)
eg's avatar
eg committed
399 400 401 402
AC_SUBST(SH_COMP_FLAGS)
AC_SUBST(SH_LOAD_FLAGS)
AC_SUBST(SH_LOADER)
AC_SUBST(SH_SUFFIX)
403
AC_SUBST(SH_LIB_SUFFIX)
eg's avatar
eg committed
404 405 406 407 408 409
AC_SUBST(SH_MAIN_LOAD_FLAGS)
AC_SUBST(COMPOBJ)
AC_SUBST(COMPSRC)
AC_SUBST(STACK_DIRECTION)
AC_SUBST(HAVE_GNOME)
AC_SUBST(LDAP_LIB)
410 411 412 413
#GC
AC_SUBST(GC)
AC_SUBST(GCLIB)
AC_SUBST(GCINC)
Erick's avatar
Erick committed
414
# PCRE
eg's avatar
eg committed
415 416 417
AC_SUBST(PCRE)
AC_SUBST(PCRELIB)
AC_SUBST(PCREINC)
418
AC_SUBST(PCREPKG)
Erick's avatar
Erick committed
419 420 421 422 423
# FFI
AC_SUBST(FFI)
AC_SUBST(FFILIB)
AC_SUBST(FFIINC)

424
AC_SUBST(THREADS)
425
AC_SUBST(LIB_SUMMARY)
426

Erick's avatar
Erick committed
427
AC_CONFIG_FILES([Makefile src/Makefile src/extraconf.h doc/Makefile
428 429 430 431 432
          lib/Makefile utils/Makefile utils/stklos-config
	  utils/stklos-script examples/Makefile
	  lib/Match.d/Makefile lib/SILex.d/Makefile lib/Lalr.d/Makefile
	  lib/ScmPkg.d/Makefile tests/Makefile
	  doc/stklos.1 doc/stklos-config.1 doc/stklos-compile.1
433
	  doc/stklos-genlex.1 doc/stklos-pkg.1 doc/skb/stklos-version.stk
Erick's avatar
Erick committed
434 435
	  pkgman/Makefile])
AC_OUTPUT
eg's avatar
eg committed
436 437 438 439 440 441 442

chmod 0755 utils/stklos-config utils/stklos-script

echo " "
echo " "
echo "SUMMARY"
echo "*******"
Erick's avatar
Erick committed
443 444 445 446 447 448
echo "               System: " $BUILD_OS
echo "              OS nick: " $OS_NAME_VERSION
echo "              OS type: " $OS_FLAVOUR
echo "      Install prefix : " $prefix
echo "           C compiler: " $CC
echo "    Compilation flags: " $CFLAGS
449
echo "       Thread support: " $THREADS
Erick's avatar
Erick committed
450 451
echo "System libraries used: " $SYST_LIBS
echo "   Compiled libraries: " $COMP_LIBS
eg's avatar
eg committed
452
echo " "
453

eg's avatar
eg committed
454
echo "If this is correct, you can just type 'make' now at your shell prompt."
455
echo "Otherwise, re-run 'configure' with correct options."
eg's avatar
eg committed
456
echo " "
Erick's avatar
Erick committed
457