configure.ac 12.3 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:  5-Aug-2010 23:58 (eg)
Erick's avatar
Erick committed
6 7

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

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

Erick's avatar
Erick committed
26
### Checks for header files.
27
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
28

Erick's avatar
Erick committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
### 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
46
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
47

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

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

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

Erick's avatar
Erick committed
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
### Determine the options necessary for dynamic loading (even if disbaled later)
eval `CC=$CC /bin/sh ./utils/shlib-options`

case $OS_NAME_VERSION in
  SUNOS*) 
    CFLAGS="$CFLAGS -DSOLARIS";
    LIBS="$LIBS -lsocket -lrt -lnsl -lpthread"
    ;;
  DARWIN_10)
     GCINC="GCINC -D_XOPEN_SOURCE"
     ;;
  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>"
    exit 1 
    ;;
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
case $OS in 
   LINUX) 
      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
      ;;
  *) 
      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,
133
  [AS_HELP_STRING([--enable-threads=TYPE],[choose threading package (none,pthread)])],
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 148 149 150 151 152 153 154 155
   AC_CHECK_LIB(pthread, pthread_create, LIBS="-lpthread $LIBS", 
                [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 176 177 178 179 180
# ----------------------------------------------------------------------
# GC support 
# ----------------------------------------------------------------------
echo "*****"
echo "***** GC support"
echo "*****"

181 182 183 184 185 186
# Try to determine if libgc is installed
if ${PKGCONFIG} --exists bdw-gc ;then 
   HAVE_GC="yes"
else 
   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 192 193 194 195
       PROV_GC="yes", PROV_GC="no")

if test "$HAVE_GC" = "no" -o "$PROV_GC" = "yes"
then 
     echo "... Configuring libgc"
Erick's avatar
Erick committed
196 197 198 199 200 201 202 203

     case $OS_NAME_VERSION in
       DARWIN_10) 
          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 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
     SYST_LIBS="libgc $SYST_LIBS"
fi


# ----------------------------------------------------------------------
# GMP support 
# ----------------------------------------------------------------------
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

# Test if the user want to force with our GMP lib 
# (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],
       PROV_GMP="yes", PROV_GMP="no")

249 250 251 252 253
if test "$PROV_GMP" = "no" ;then
  AC_ARG_WITH(gmp-light,
         [  --with-gmp-light	  a synonym for --with-provided-bignum],
         PROV_GMP="yes", PROV_GMP="no")
fi
Erick's avatar
Erick committed
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270

if test "$HAVE_GMP" = "no" -o "$PROV_GMP" = "yes"
then 
     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 276 277 278 279 280
# ----------------------------------------------------------------------
# PCRE support 
# ----------------------------------------------------------------------
echo "*****"
echo "***** Regexp support"
echo "*****"

281 282 283
# Try to determine if libpcre is installed
if ${PKGCONFIG} --exists libpcre ;then 
   HAVE_PCRE="yes"
284
   PCREPKG="present"
285 286 287
else 
   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],
Erick's avatar
Erick committed
292 293 294 295 296 297 298 299
       PROV_PCRE="yes", PROV_PCRE="no")

if test "$HAVE_PCRE" = "no" -o "$PROV_PCRE" = "yes"
then 
     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 301
           --prefix=$prefix --disable-shared --disable-cpp) || \
	   { echo "Cannot configure PCRE"; exit; }
Erick's avatar
Erick committed
302 303
     PCRE=pcre
     PCREINC="-I../pcre"
304
     PCRELIB="../pcre/.libs/libpcreposix.a ../pcre/.libs/libpcre.a"
Erick's avatar
Erick committed
305
     DEF_PCRE=""
Erick's avatar
Erick committed
306
     COMP_LIBS="libpcre $COMP_LIBS"
Erick's avatar
Erick committed
307 308 309
else
     echo "... Using system libpcre library"
     PCRE=""
310
     if $PKGCONFIG --exists libpcre ;then
311 312 313 314 315
        PCREINC="$($PKGCONFIG --cflags libpcre)"
        PCRELIB="$($PKGCONFIG --libs libpcre) -lpcreposix"
     else 
        PCREINC=""
        PCRELIB="-lpcre -lpcreposix"
Erick's avatar
Erick committed
316 317 318
     fi 
     AC_DEFINE(HAVE_PCRE, 1 , [We use our version of pcre])
     SYST_LIBS="libpcre $SYST_LIBS"
Erick's avatar
Erick committed
319
fi
320 321 322


# ----------------------------------------------------------------------
Erick's avatar
Erick committed
323
# FFI support 
324 325 326 327 328
# ----------------------------------------------------------------------
echo "*****"
echo "***** FFI support"
echo "*****"

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

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

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

366 367 368 369 370 371 372 373
###
### 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")
374

eg's avatar
eg committed
375

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


Erick's avatar
Erick committed
382
### Output files 
383
AC_SUBST(STKCFLAGS)
eg's avatar
eg committed
384 385 386 387 388 389 390 391 392 393 394 395
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)
396
AC_SUBST(OS_NAME_VERSION)
eg's avatar
eg committed
397 398 399 400
AC_SUBST(SH_COMP_FLAGS)
AC_SUBST(SH_LOAD_FLAGS)
AC_SUBST(SH_LOADER)
AC_SUBST(SH_SUFFIX)
401
AC_SUBST(SH_LIB_SUFFIX)
eg's avatar
eg committed
402 403 404 405 406 407
AC_SUBST(SH_MAIN_LOAD_FLAGS)
AC_SUBST(COMPOBJ)
AC_SUBST(COMPSRC)
AC_SUBST(STACK_DIRECTION)
AC_SUBST(HAVE_GNOME)
AC_SUBST(LDAP_LIB)
408 409 410 411
#GC
AC_SUBST(GC)
AC_SUBST(GCLIB)
AC_SUBST(GCINC)
Erick's avatar
Erick committed
412
# PCRE
eg's avatar
eg committed
413 414 415
AC_SUBST(PCRE)
AC_SUBST(PCRELIB)
AC_SUBST(PCREINC)
416
AC_SUBST(PCREPKG)
Erick's avatar
Erick committed
417 418 419 420 421
# FFI
AC_SUBST(FFI)
AC_SUBST(FFILIB)
AC_SUBST(FFIINC)

422
AC_SUBST(THREADS)
423
AC_SUBST(LIB_SUMMARY)
424

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

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

echo " "
echo " "
echo "SUMMARY"
echo "*******"
Erick's avatar
Erick committed
442 443 444 445 446 447 448 449 450
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
echo "       Thread support: " $THREADS 
echo "System libraries used: " $SYST_LIBS
echo "   Compiled libraries: " $COMP_LIBS
eg's avatar
eg committed
451
echo " "
452

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