configure.ac 12.8 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)
5
### Last file update: 11-Jun-2018 15:02 (eg)
Erick's avatar
Erick committed
6

Erick's avatar
Erick committed
7 8
AC_PREREQ([2.69])
AC_INIT([stklos],[1.20])
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
      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;;
Erick's avatar
Erick committed
101 102 103
         10*) OS_NAME_VERSION=DARWIN_10;;
         11*) OS_NAME_VERSION=DARWIN_11;;
         *)   OS_NAME_VERSION=DARWIN_OLD;;
Erick's avatar
Erick committed
104 105
      esac
      ;;
106
  *)
Erick's avatar
Erick committed
107
      v=`echo $version | sed -e 's/[[^0-9]]/_/g'`
108
      OS_NAME_VERSION=$OS\_$v;
Erick's avatar
Erick committed
109 110
esac

eg's avatar
eg committed
111

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

Erick's avatar
Erick committed
118 119

### Check for dynamic loading
eg's avatar
eg committed
120 121 122 123
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
124
  AC_DEFINE(HAVE_DLOPEN, 1, [System provides flopen])
eg's avatar
eg committed
125 126
fi

Erick's avatar
Erick committed
127 128 129 130

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

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

AC_LANG(C)
139

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

158

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



169 170


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

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

182 183 184 185 186 187
# Patch code for OSX Lion
case $OS_NAME_VERSION in
     DARWIN_11)
       if test ! -f gc/stklos-patch-applied
       then
              echo "**** Patching GC library";
Erick's avatar
Erick committed
188 189
              patch -p1 < etc/lion.patch
              touch  gc/stklos-patch-applied
190 191 192 193 194
       fi
       ;;
esac


195
# Try to determine if libgc is installed
196
if ${PKGCONFIG} --exists bdw-gc ;then
197
   HAVE_GC="yes"
198
else
199 200
   AC_CHECK_LIB(gc, GC_malloc, HAVE_GC="yes", HAVE_GC="no", $LIBS)
fi
201 202 203

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

if test "$HAVE_GC" = "no" -o "$PROV_GC" = "yes"
208
then
209
     echo "... Configuring libgc"
Erick's avatar
Erick committed
210 211

     case $OS_NAME_VERSION in
212
       DARWIN_10)
Erick's avatar
Erick committed
213 214 215 216 217
          cflags="${CFLAGS} -D_XOPEN_SOURCE";;
       *)
          cflags="${CFLAGS}";;
     esac
     (cd gc; CC=${CC} CFLAGS=${cflags} ./configure --prefix=$prefix \
218
              --includedir=$prefix/include/stklos \
Erick's avatar
Erick committed
219
              --enable-threads=$THREADS) || { echo "Cannot configure the GC"; exit; }
220 221
     GC=gc
     GCINC="-I../gc/include"
222
     GCLIB="../gc/.libs/libgc.a"
Erick's avatar
Erick committed
223
     COMP_LIBS="libgc $COMP_LIBS"
eg's avatar
eg committed
224
else
225 226
     echo "... Using system libgc library"
     GC=""
227
     if $PKGCONFIG --exists bdw-gc ;then
228 229 230 231 232 233
        GCINC=$(pkg-config  bdw-gc --cflags)
        GCLIB=$(pkg-config  bdw-gc --libs)
     else
        GCINC=""
        GCLIB="-lgc"
     fi
234
     AC_DEFINE(HAVE_GC, 1, [Use system GC])
Erick's avatar
Erick committed
235 236 237 238 239
     SYST_LIBS="libgc $SYST_LIBS"
fi


# ----------------------------------------------------------------------
240
# GMP support
Erick's avatar
Erick committed
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
# ----------------------------------------------------------------------
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

257
# Test if the user want to force with our GMP lib
Erick's avatar
Erick committed
258 259 260
# (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],
261
       PROV_GMP="$withval", PROV_GMP="no")
Erick's avatar
Erick committed
262

263 264
if test "$PROV_GMP" = "no" ;then
  AC_ARG_WITH(gmp-light,
Erick's avatar
Erick committed
265
         [  --with-gmp-light      a synonym for --with-provided-bignum],
266
         PROV_GMP="$withval", PROV_GMP="no")
267
fi
Erick's avatar
Erick committed
268 269

if test "$HAVE_GMP" = "no" -o "$PROV_GMP" = "yes"
270
then
Erick's avatar
Erick committed
271 272
     echo "... Configuring libgmp"
     (cd gmp; CC=${CC} CFLAGS="${cflags} -I../src -DFOR_STKLOS=1" ./configure \
Erick's avatar
Erick committed
273
              --prefix=$prefix) || { echo "Cannot configure the GMP"; exit; }
Erick's avatar
Erick committed
274 275 276 277 278 279 280 281 282 283 284
     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
285 286 287
fi


288
# ----------------------------------------------------------------------
289
# PCRE support
290 291 292 293 294
# ----------------------------------------------------------------------
echo "*****"
echo "***** Regexp support"
echo "*****"

295
# Try to determine if libpcre is installed
296
if ${PKGCONFIG} --exists libpcre ;then
297
   HAVE_PCRE="yes"
298
   PCREPKG="present"
299
else
300 301
   AC_CHECK_LIB(pcre, pcre_fullinfo, HAVE_PCRE="yes", HAVE_PCRE="no", $LIBS)
fi
302 303 304

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

if test "$HAVE_PCRE" = "no" -o "$PROV_PCRE" = "yes"
309
then
Erick's avatar
Erick committed
310 311 312 313
     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 \
314
           --enable-utf8 \
315
           --prefix=$prefix --disable-shared --disable-cpp) || \
Erick's avatar
Erick committed
316
           { echo "Cannot configure PCRE"; exit; }
Erick's avatar
Erick committed
317 318
     PCRE=pcre
     PCREINC="-I../pcre"
319
     PCRELIB="../pcre/.libs/libpcreposix.a ../pcre/.libs/libpcre.a"
Erick's avatar
Erick committed
320
     DEF_PCRE=""
Erick's avatar
Erick committed
321
     COMP_LIBS="libpcre $COMP_LIBS"
Erick's avatar
Erick committed
322 323 324
else
     echo "... Using system libpcre library"
     PCRE=""
325
     if $PKGCONFIG --exists libpcre ;then
326 327
        PCREINC="$($PKGCONFIG --cflags libpcre)"
        PCRELIB="$($PKGCONFIG --libs libpcre) -lpcreposix"
328
     else
329 330
        PCREINC=""
        PCRELIB="-lpcre -lpcreposix"
331
     fi
Erick's avatar
Erick committed
332 333
     AC_DEFINE(HAVE_PCRE, 1 , [We use our version of pcre])
     SYST_LIBS="libpcre $SYST_LIBS"
Erick's avatar
Erick committed
334
fi
335 336 337


# ----------------------------------------------------------------------
338
# FFI support
339 340 341 342 343
# ----------------------------------------------------------------------
echo "*****"
echo "***** FFI support"
echo "*****"

344
# Try to determine if libffi is installed
345
if ${PKGCONFIG} --exists libffi ;then
346
   HAVE_FFI="yes"
347
else
348 349
  AC_CHECK_LIB(ffi, ffi_prep_cif, HAVE_FFI="yes", HAVE_FFI="no", $LIBS)
fi
350 351 352

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

Erick's avatar
Erick committed
356
if test "$HAVE_FFI" = "no" -o "$PROV_FFI" = "yes"
357
then
Erick's avatar
Erick committed
358 359
     echo "... Configuring libffi"
     (cd ffi; CC=${CC} CFLAGS=${CFLAGS} ./configure \
360
           --disable-structs --disable-raw-api --disable-shared \
Erick's avatar
Erick committed
361
           --prefix=$prefix) || { echo "Cannot configure libffi"; exit; }
Erick's avatar
Erick committed
362
     FFI="ffi"
363 364
     FFIINC="-I../ffi/$(./config.guess)/include"
     FFILIB="../ffi/$(./config.guess)/.libs/libffi.a"
Erick's avatar
Erick committed
365
     COMP_LIBS="libffi $COMP_LIBS"
366
else
Erick's avatar
Erick committed
367 368
     echo "... Using system libffi library"
     FFI=""
369
     if $PKGCONFIG --exists libffi ;then
370 371 372
       FFIINC=$($PKGCONFIG libffi --cflags)
       FFILIB=$($PKGCONFIG libffi --libs)
     else
373
       FFIINC="-I/usr/include/ffi"
374 375
       FFILIB="-lffi"
     fi
Erick's avatar
Erick committed
376
     SYST_LIBS="libffi $SYST_LIBS"
eg's avatar
eg committed
377
fi
Erick's avatar
Erick committed
378
# We always want FFI. Should be modifiable in the future
379
AC_DEFINE(HAVE_FFI, 1, [System provides FFI])
380

381 382 383
###
### See in what direction the stack grows (code stolen from Sawfish)
###
Erick's avatar
Erick committed
384 385
AC_RUN_IFELSE([AC_LANG_SOURCE([[ 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"])
386

eg's avatar
eg committed
387

388 389 390 391 392 393
###
### Finishing ...
###
LIB_SUMMARY="(:system ($SYST_LIBS) :compiled ($COMP_LIBS))"


394
### Output files
395
AC_SUBST(STKCFLAGS)
eg's avatar
eg committed
396 397 398 399 400 401 402 403 404 405 406 407
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)
408
AC_SUBST(OS_NAME_VERSION)
409
AC_SUBST(EXTRA_COMP_FLAGS)
eg's avatar
eg committed
410 411 412 413
AC_SUBST(SH_COMP_FLAGS)
AC_SUBST(SH_LOAD_FLAGS)
AC_SUBST(SH_LOADER)
AC_SUBST(SH_SUFFIX)
414
AC_SUBST(SH_LIB_SUFFIX)
eg's avatar
eg committed
415 416 417 418 419 420
AC_SUBST(SH_MAIN_LOAD_FLAGS)
AC_SUBST(COMPOBJ)
AC_SUBST(COMPSRC)
AC_SUBST(STACK_DIRECTION)
AC_SUBST(HAVE_GNOME)
AC_SUBST(LDAP_LIB)
421 422 423 424
#GC
AC_SUBST(GC)
AC_SUBST(GCLIB)
AC_SUBST(GCINC)
Erick's avatar
Erick committed
425
# PCRE
eg's avatar
eg committed
426 427 428
AC_SUBST(PCRE)
AC_SUBST(PCRELIB)
AC_SUBST(PCREINC)
429
AC_SUBST(PCREPKG)
Erick's avatar
Erick committed
430 431 432 433 434
# FFI
AC_SUBST(FFI)
AC_SUBST(FFILIB)
AC_SUBST(FFIINC)

435
AC_SUBST(THREADS)
436
AC_SUBST(LIB_SUMMARY)
437

Erick's avatar
Erick committed
438
AC_CONFIG_FILES([Makefile src/Makefile src/extraconf.h doc/Makefile
439
          lib/Makefile utils/Makefile utils/stklos-config
Erick's avatar
Erick committed
440 441 442 443 444 445
          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
          doc/stklos-genlex.1 doc/stklos-pkg.1 doc/skb/stklos-version.stk
          pkgman/Makefile])
Erick's avatar
Erick committed
446
AC_OUTPUT
eg's avatar
eg committed
447 448 449 450 451 452 453

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

echo " "
echo " "
echo "SUMMARY"
echo "*******"
Erick's avatar
Erick committed
454 455 456 457 458 459
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
460
echo "       Thread support: " $THREADS
Erick's avatar
Erick committed
461 462
echo "System libraries used: " $SYST_LIBS
echo "   Compiled libraries: " $COMP_LIBS
eg's avatar
eg committed
463
echo " "
464

eg's avatar
eg committed
465
echo "If this is correct, you can just type 'make' now at your shell prompt."
466
echo "Otherwise, re-run 'configure' with correct options."
eg's avatar
eg committed
467
echo " "
Erick's avatar
Erick committed
468