configure.ac 12.1 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: 27-Sep-2009 19:37 (eg)
Erick's avatar
Erick committed
6 7 8 9 10 11 12 13 14

AC_PREREQ(2.64)
AC_INIT([stklos], [0.99dev])
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

Erick's avatar
Erick committed
25
### Checks for header files.
Erick's avatar
Erick committed
26
AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.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
Erick's avatar
Erick committed
45
AC_CHECK_FUNCS([atexit dup2 endpwent floor getcwd gethostbyaddr gethostbyname gethostname getpass gettimeofday 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 47

### Initialize prefix
eg's avatar
eg committed
48 49
if test X$prefix = XNONE ;then  prefix=$ac_default_prefix; fi

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


Erick's avatar
Erick committed
58 59 60 61 62
###
### Checks for libraries.
###

### Check for dynamic loading
eg's avatar
eg committed
63 64 65 66 67 68 69
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
  HAVE_DLOPEN="#define HAVE_DLOPEN 1"
fi

Erick's avatar
Erick committed
70 71 72 73

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

76
AC_ARG_ENABLE(threads,
Erick's avatar
Erick committed
77
  [AS_HELP_STRING([--enable-threads=TYPE],[choose threading package (none,pthread,lurc)])],
78
  THREADS=$enableval,
79
  THREADS=$deflt_threads)
80 81

AC_LANG(C)
Erick's avatar
Erick committed
82
### This checks for the presence of a given CPP define in a fiven header file
83
AC_DEFUN(GC_CHECK_DEFINE, [
Erick's avatar
Erick committed
84 85 86 87
 ### $1: header file
 ### $2: CPP variable
 ### $3: then
 ### $4: else
88 89 90 91 92 93 94 95 96 97 98
 AC_PREPROC_IFELSE([
 #include <$1>
 #ifndef $2
 # error "$2 undefined"
 #else
  ok
 #endif
 ],
 [$3], [$4])
])

99

Erick's avatar
Erick committed
100
### Now look at what threads we want
101 102 103
case "$THREADS" in
 no | none | single)
   THREADS=none
Erick Gallesio's avatar
Erick Gallesio committed
104
   CALLCC_STK='"callcc.stk"'
105 106 107
   AC_DEFINE(THREADS_NONE, [], [No thread support])
   ;;
 posix | pthreads)
Erick's avatar
Erick committed
108
   ### Check for pthreads
109 110 111
   AC_CHECK_LIB(pthread, pthread_create, LIBS="-lpthread $LIBS", 
                [AC_MSG_ERROR([Missing PThread library])])
   THREADS=pthreads
Erick Gallesio's avatar
Erick Gallesio committed
112
   CALLCC_STK='"callcc.stk"'
113 114 115
   AC_DEFINE(THREADS_PTHREADS, [], [PThread support])
   ;;
 lurc)
Erick's avatar
Erick committed
116
   ### Check for lurc
117 118 119
   AC_CHECK_LIB(lurc, lurc_thread_create, LIBS="-llurc $LIBS", 
                [AC_MSG_ERROR([Missing LURC library])])
   AC_CHECK_HEADER([lurc.h], [], [AC_MSG_ERROR([Missing LURC header file])])
Erick's avatar
Erick committed
120
   ### Now check if it is compiled with GC support
121 122 123 124
   AC_MSG_CHECKING([for LURC GC support])
   GC_CHECK_DEFINE([lurc.h], [LURC_ENABLE_GC], 
                   [AC_MSG_RESULT([ok])],
                   [AC_MSG_ERROR([Missing GC support in LURC])])
Erick's avatar
Erick committed
125
   ### That shold be good
126
   AC_DEFINE(THREADS_LURC, [], [LURC threads support])
Erick Gallesio's avatar
Erick Gallesio committed
127
   CALLCC_STK='"dyn-wind-lurc.stk"'
128 129 130 131 132
   ;;
 *)
   AC_MSG_ERROR([Unknown thread system: $THREADS])
   ;;
esac
133

Erick's avatar
Erick committed
134
### Add the options _REENTRANT and GC_LINUX_THREADS if we are on Linux
135 136
case "$THREADS" in
  none) true ;;
137
  lurc) true ;;
138
  *) case `uname -s` in
139
        Linux*) STKCFLAGS="-D_REENTRANT=1 -DGC_LINUX_THREADS=1";;
140 141 142 143 144
     esac
esac



Erick's avatar
Erick committed
145
### Automake nightmare
146 147 148
AM_CONDITIONAL(PTHREADS, test "$THREADS" = pthreads)
AM_CONDITIONAL(LURC, test "$THREADS" = lurc)
AM_CONDITIONAL(NO_THREAD, test "$THREADS" = none)
eg's avatar
eg committed
149

Erick's avatar
Erick committed
150
### check for GMP pre-version 3.0
eg's avatar
eg committed
151 152
AC_CHECK_LIB(gmp, mpz_init_set, HAVE_GMP="yes", HAVE_GMP="no")

Erick's avatar
Erick committed
153
### check for GMP version post 3.0
eg's avatar
eg committed
154 155 156 157 158 159
if test "$HAVE_GMP" = "no" ;then
  AC_CHECK_LIB(gmp, __gmpz_init_set, HAVE_GMP="yes", HAVE_GMP="no")
fi


# Eventually force our gmp usage
160
withval=""
eg's avatar
eg committed
161
AC_ARG_WITH(gmp-light,
162 163 164 165 166 167 168 169
	[  --with-gmp-light		use our GMP version even the system provides one])

case $withval in
  "yes") HAVE_GMP="no";;
  "no")  HAVE_GMP="yes";;
esac


eg's avatar
eg committed
170

Erick's avatar
Erick committed
171 172 173
###
### check for GC
###
174 175 176 177 178 179 180
if test "$THREADS" = lurc
then
  AC_MSG_WARN([Using the bundled GC for LURC support])
  HAVE_GC="no"
else
  AC_CHECK_LIB(gc, GC_malloc, HAVE_GC="yes", HAVE_GC="no", $LIBS)
fi
eg's avatar
eg committed
181 182

# Test if the user want to force with our GC
183
withval=""
eg's avatar
eg committed
184
AC_ARG_WITH(provided-gc,
185 186 187 188 189 190
       [  --with-provided-gc		use our GC version even the system provides one])

case $withval in
  "yes") HAVE_GC="no";;
  "no")  HAVE_GC="yes";;
esac
eg's avatar
eg committed
191

192
# On Mac OS X use the given GC (to compile it without -Ox)
eg's avatar
eg committed
193 194 195 196 197 198 199
case `uname -s` in
  Darwin*) echo "Force '--with-provided-gc' on MacOS";
           HAVE_GC="no" ;;
  *) true;;
esac


Erick's avatar
Erick committed
200 201 202
###
### configure libraries
###
203

eg's avatar
eg committed
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
if test "$HAVE_GMP" = "no"
then 
  echo "No GMP library. Using the one provided with the package"
  cmd="CC=\"$CC\" CFLAGS=\"$CFLAGS\" ./configure --prefix=$prefix"
  echo "Configuring GMP"	
  echo $cmd		
  (cd gmp; eval $cmd)
  GMP=gmp
  GMPLIB="../gmp/libgmp.a"
  GMPINC="-I../gmp"
else
  echo "Using the system GMP library"
  GMP=""
  GMPLIB="-lgmp"
  GMPINC=""
fi

if test "$HAVE_GC" = "no"
then
  echo "No Boehm-Demers-Weiser GC library. Using the one provided with the package"
224
  (cd gc; CC="$CC" CFLAGS="$CFLAGS" sh ./configure --prefix=$prefix \
225
          --includedir=$prefix/include/stklos \
226 227
          --enable-threads=$THREADS) || { echo "Cannot configure the GC"; exit; }
  
eg's avatar
eg committed
228 229
  GC=gc
  GCLIB="../gc/.libs/libgc.a"
230
  GCINC="-I../gc/include"
eg's avatar
eg committed
231 232 233 234 235 236
  # Eventually add a distclean target to the GC Makefile
else
  echo "Using the system Boehm-Demers-Weiser library"
  GC=""
  GCLIB="-lgc"
  GCINC=""
separdau's avatar
separdau committed
237
  AC_DEFINE(HAVE_GC, [], [Use system GC])
eg's avatar
eg committed
238 239 240
fi


241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
# ----------------------------------------------------------------------
# PCRE support 
# ----------------------------------------------------------------------
echo "*****"
echo "***** Regexp support"
echo "*****"

AC_CHECK_LIB(pcre, pcre_fullinfo, HAVE_PCRE="yes", HAVE_PCRE="no", $LIBS)

# Test if the user want to force with our PCRE lib
AC_ARG_WITH(provided-regexp,
       [  --with-provided-regexp	use the provided Regexp (PCRE) library],
       HAVE_PCRE="no", HAVE_PCRE="yes")

case $HAVE_PCRE in
  no)
       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 \
           --prefix=$prefix --disable-shared --disable-cpp)
       PCRE=pcre
       PCRELIB="../pcre/.libs/libpcreposix.a ../pcre/.libs/libpcre.a"
       PCREINC="-I../pcre"
       DEF_PCRE=""
       pcrelib="use provided library";;
  yes)
       echo "... Using system libpcre library"
       PCRE=""
       PCRELIB="-lpcre -lpcreposix"
       PCREINC=""
       DEF_PCRE="#define HAVE_PCRE 1"
       pcrelib="use the system library";;
esac


# ----------------------------------------------------------------------
Erick's avatar
Erick committed
278
# FFI support 
279 280 281 282 283
# ----------------------------------------------------------------------
echo "*****"
echo "***** FFI support"
echo "*****"

284 285 286 287 288 289 290 291 292
AC_CHECK_LIB(ffi, ffi_prep_cif, HAVE_FFI="yes", HAVE_FFI="no", $LIBS)

# Test if the user want to force with our FFI lib
AC_ARG_WITH(provided-ffi,
       [  --with-provided-ffi	use the provided FFI library],
       HAVE_FFI="no", HAVE_FFI="yes")

case $HAVE_FFI in
  no)
293
       echo "... Configuring libffi"
294
       (cd ffi; CC=${CC} CFLAGS=${CFLAGS} ./configure \
295 296
           --disable-structs --disable-raw-api --disable-shared \
	   --prefix=$prefix)
297
       FFI="ffi"
Erick's avatar
Erick committed
298 299 300
       FFIINC="-I../ffi/include"
       FFILIB="../ffi/.libs/libffi.a"
       ffimsg="use provided library";;
301
  yes)
302
       echo "... Using system libffi library"
303
       FFI=""
Erick's avatar
Erick committed
304 305 306
       FFIINC="`pkg-config libffi --cflags`"
       FFILIB="`pkg-config libffi --libs`"
       ffimsg="use the system library";;
307
esac
Erick's avatar
Erick committed
308 309
DEF_FFI="#define HAVE_FFI 1" ; # We always want FFI. 
		               # Should be modifiable in the future
eg's avatar
eg committed
310

Erick's avatar
Erick committed
311 312 313
### ======================================================================
### Various stuff done by hand
### ======================================================================
eg's avatar
eg committed
314 315


Erick's avatar
Erick committed
316
### Determine the options necessary for dynamic loading
eg's avatar
eg committed
317 318 319 320
eval `CC=$CC /bin/sh ./utils/shlib-options`

case $OS in
  SUNOS) 
321
    CFLAGS="$CFLAGS -DSOLARIS";
eg's avatar
eg committed
322 323 324 325 326 327 328 329 330 331 332
    LIBS="$LIBS -lsocket -lrt -lnsl -lpthread" ;;
  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


Erick's avatar
Erick committed
333
### Initilize the extra conf file in src
eg's avatar
eg committed
334 335 336 337
SCMDIR=$prefix/share/$PACKAGE/$VERSION
EXECDIR=$prefix/lib/$PACKAGE/$VERSION
PREFIX=$prefix

Erick's avatar
Erick committed
338
### Determine the kind of the machine which is running this script
eg's avatar
eg committed
339 340 341 342
BUILD_OS=$os-$version
BUILD_ARCH=`uname -m`
OS_NAME=$OS

Erick's avatar
Erick committed
343 344
### Place version number in VERSION file
### echo "VERSION=${VERSION}">VERSION
eg's avatar
eg committed
345 346


Erick's avatar
Erick committed
347 348 349
###
### display some informations for the user
### 
eg's avatar
eg committed
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364

if test "$HAVE_GMP" = "no"
then
  biglib="compile provided library (better perf. can be achieved with a recent GMP)"
else 
  biglib="use the system library"
fi

if test "$HAVE_GC" = "no"
then
  gclib="compile provided library"
else 
  gclib="use the system library"
fi

365 366 367 368 369 370
# LURC adjustment
LURCDIR=""
if test "$THREADS" = "lurc" ;then
   LURCDIR=Lurc.d
fi

371 372 373 374 375 376 377 378
###
### 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")
379

eg's avatar
eg committed
380

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

419 420
AC_SUBST(THREADS)
AC_SUBST(LURCDIR)
separdau's avatar
separdau committed
421
AC_SUBST(CALLCC_STK)
eg's avatar
eg committed
422
	
Erick's avatar
Erick committed
423
AC_CONFIG_FILES([Makefile src/Makefile src/extraconf.h doc/Makefile
Erick's avatar
Erick committed
424
          lib/Makefile utils/Makefile lib/boot-callcc.stk
eg's avatar
eg committed
425
	  utils/stklos-config utils/stklos-script
Erick's avatar
Erick committed
426
	  examples/Makefile lib/Match.d/Makefile 
427
	  lib/SILex.d/Makefile lib/Lalr.d/Makefile lib/Lurc.d/Makefile
Erick's avatar
Erick committed
428
	  lib/ScmPkg.d/Makefile tests/Makefile  
eg's avatar
eg committed
429
	  doc/stklos.1 doc/stklos-config.1 doc/stklos-compile.1 
430
	  doc/stklos-genlex.1 doc/stklos-install.1 doc/stklos-pkg.1 
431
	  doc/skb/stklos-version.stk
Erick's avatar
Erick committed
432 433
	  pkgman/Makefile])
AC_OUTPUT
eg's avatar
eg committed
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448

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

echo " "
echo " "
echo "SUMMARY"
echo "*******"
echo "            System: " $BUILD_OS
echo "           OS type: " $OS_FLAVOUR
echo "   Install prefix : " $prefix
echo "        C compiler: " $CC
echo " Compilation flags: " $CFLAGS
echo "    Bignum library: " $biglib
echo "    Regexp library: " $pcrelib
echo "        GC library: " $gclib
449
echo "       FFI library: " $ffilib
450
echo "    Thread support: " $THREADS 
eg's avatar
eg committed
451
echo " "
452 453 454 455 456 457 458 459 460 461
if test "$THREADS" = "lurc" 
then 
     echo "*** WARNING: To use LURC threads, you need to replace (or install) "
     echo "*** a special GC package (available at http://www.stklos.net/download)."
     echo "*** You have to: "
     echo "***    - Remove the current gc directory"
     echo "***    - untar this package in this directory."
     echo "***    - re-run configure"
     echo "*** The GC for LURC probably doesn't work on MacOS 10.5"
fi
eg's avatar
eg committed
462 463 464
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
465