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-Oct-2010 23:17 (eg)
Erick's avatar
Erick committed
6 7

AC_PREREQ(2.64)
Erick's avatar
.  
Erick committed
8
AC_INIT([stklos], [1.01])
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
### 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"
72
     EXTRA_COMP_FLAGS="-I/opt/local/include"
Erick's avatar
Erick committed
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 107
     ;;
  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'`
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,
134
  [AS_HELP_STRING([--enable-threads=TYPE],[choose threading package (none,pthread)])],
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 149 150 151 152 153 154 155 156
   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
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 177 178 179 180 181
# ----------------------------------------------------------------------
# GC support 
# ----------------------------------------------------------------------
echo "*****"
echo "***** GC support"
echo "*****"

182 183 184 185 186 187
# 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
188 189 190

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

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

     case $OS_NAME_VERSION in
       DARWIN_10) 
          cflags="${CFLAGS} -D_XOPEN_SOURCE";;
       *)
          cflags="${CFLAGS}";;
     esac
     (cd gc; CC=${CC} CFLAGS=${cflags} ./configure --prefix=$prefix \
205 206 207 208
              --includedir=$prefix/include/stklos \
	      --enable-threads=$THREADS) || { echo "Cannot configure the GC"; exit; }
     GC=gc
     GCINC="-I../gc/include"
209
     GCLIB="../gc/.libs/libgc.a"
Erick's avatar
Erick committed
210
     COMP_LIBS="libgc $COMP_LIBS"
eg's avatar
eg committed
211
else
212 213
     echo "... Using system libgc library"
     GC=""
214
     if $PKGCONFIG --exists bdw-gc ;then
215 216 217 218 219 220
        GCINC=$(pkg-config  bdw-gc --cflags)
        GCLIB=$(pkg-config  bdw-gc --libs)
     else
        GCINC=""
        GCLIB="-lgc"
     fi
221
     AC_DEFINE(HAVE_GC, 1, [Use system GC])
Erick's avatar
Erick committed
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
     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],
248
       PROV_GMP="$withval", PROV_GMP="no")
Erick's avatar
Erick committed
249

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

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
272 273 274
fi


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

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

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

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 \
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 314 315 316
        PCREINC="$($PKGCONFIG --cflags libpcre)"
        PCRELIB="$($PKGCONFIG --libs libpcre) -lpcreposix"
     else 
        PCREINC=""
        PCRELIB="-lpcre -lpcreposix"
Erick's avatar
Erick committed
317 318 319
     fi 
     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


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

330 331 332 333 334 335
# 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
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 343 344 345
if test "$HAVE_FFI" = "no" -o "$PROV_FFI" = "yes"
then 
     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"
Erick's avatar
Erick committed
352 353 354
else 
     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 365
# We always want FFI. Should be modifiable in the future
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))"


Erick's avatar
Erick committed
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
          lib/Makefile utils/Makefile utils/stklos-config 
	  utils/stklos-script examples/Makefile 
430
	  lib/Match.d/Makefile lib/SILex.d/Makefile lib/Lalr.d/Makefile 
Erick's avatar
Erick committed
431
	  lib/ScmPkg.d/Makefile tests/Makefile  
eg's avatar
eg committed
432
	  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 449 450 451
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
452
echo " "
453

eg's avatar
eg committed
454 455 456
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
457