1dnl Process this file with autoconf to produce a configure script. 2AC_PREREQ([2.68]) 3AC_INIT([Gauche],[0.9.10],[shiro@acm.org],,[https://practical-scheme.net/gauche/]) 4AC_CANONICAL_BUILD 5AC_CANONICAL_HOST 6AC_CANONICAL_TARGET 7AC_CONFIG_HEADER([src/gauche/config.h]) 8AC_CONFIG_MACRO_DIRS([m4]) 9 10# ABI_VERSION is set to major.minor of Gauche version by default. 11# It can be overridden by uncommenting the following line. 12# (This may be useful for "prerelease", such as 0.99.x as pre-1.0) 13GAUCHE_ABI_VERSION=0.97 14 15AC_CHECK_TOOL(RC, windres, false) 16 17dnl ========================================================== 18dnl Process args given to configure 19dnl 20 21dnl ---------------------------------------------------------- 22dnl enable-multibyte 23dnl 24AC_MSG_CHECKING([multibyte encoding]) 25GAUCHE_CHAR_ENCODING=utf8 26AC_ARG_ENABLE(multibyte, 27 AS_HELP_STRING([--enable-multibyte=ENCODING], 28 [Use ENCODING as the internal multibyte string encoding. 29Following encodings are currently recognized: 30'euc-jp' (EUC-JP code), 'utf-8' (UTF-8), 'sjis' (Shift-JIS), 31or 'none' (No multibyte support)]), 32 [ 33 AS_CASE([$enable_multibyte], 34 [euc-jp|eucjp], [GAUCHE_CHAR_ENCODING=eucjp], 35 [utf-8|utf8|yes], [GAUCHE_CHAR_ENCODING=utf8], 36 [sjis|shift-jis], [GAUCHE_CHAR_ENCODING=sjis], 37 [no|none], [GAUCHE_CHAR_ENCODING=none], 38 [AC_MSG_ERROR([unrecognized encoding option: '$enable_multibyte'; type ./configure --help for available options], 1)]) 39 ], 40 [ 41 GAUCHE_CHAR_ENCODING=utf8 42 ac_configure_args="$ac_configure_args '--enable-multibyte=utf-8'" 43 ]) 44 45AS_CASE([$GAUCHE_CHAR_ENCODING], 46 [eucjp], [AC_DEFINE(GAUCHE_CHAR_ENCODING_EUC_JP, [], [Define if Gauche handles multi-byte character as EUC-JP])], 47 [utf8], [AC_DEFINE(GAUCHE_CHAR_ENCODING_UTF_8, [], [Define if Gauche handles multi-byte character as UTF-8])], 48 [sjis], [AC_DEFINE(GAUCHE_CHAR_ENCODING_SJIS, [], [Define if Gauche handles multi-byte character as Shift JIS])]) 49AC_MSG_RESULT([$GAUCHE_CHAR_ENCODING]) 50 51 52dnl ---------------------------------------------------------- 53dnl enable-thread=TYPE 54dnl 55AC_MSG_CHECKING([thread type]) 56GAUCHE_THREAD_TYPE=default 57AC_ARG_ENABLE(threads, 58 AS_HELP_STRING([--enable-threads=TYPE], 59 [Choose thread type. Possible values are: 'none' for not using threads, 'pthreads' to use pthreads, 'win32' to use Windows threads, and 'default' to choose system's suitable one (if any). ]), 60 [ 61 AS_CASE([$enableval], 62 [pthreads], 63 [GAUCHE_THREAD_TYPE=pthreads], 64 [win32], 65 [GAUCHE_THREAD_TYPE=win32], 66 [no|none], 67 [GAUCHE_THREAD_TYPE=none], 68 [default], 69 [GAUCHE_THREAD_TYPE=default], 70 71 [AC_MSG_ERROR([invalid value $enableval for --enable-threads option (must be either none, pthreads, win32, or default)])]) 72 ], []) 73 74dnl Platform-dependent thread configuration. This must be in sync 75dnl with gc's configure.ac. 76AS_CASE([$GAUCHE_THREAD_TYPE], 77 [pthreads|default], 78 [AS_CASE(["$host"], 79 [*-*-linux*], [ 80 AC_DEFINE(GC_LINUX_THREADS,1,[Define to use Linux threads]) 81 AC_DEFINE(_REENTRANT,1,[Define to use reentrant libc]) 82 THREADLIBS="-lpthread" 83 GAUCHE_THREAD_TYPE=pthreads 84 ], 85 [*-*-hpux*], [ 86 AC_MSG_WARN("Only HP/UX 11 threads are supported.") 87 AC_DEFINE(GC_HPUX_THREADS,1,[Define to use HP-UX threads]) 88 AC_DEFINE(_POSIX_C_SOURCE,199506L,[Define POSIX C version]) 89 THREADLIBS="-lpthread -lrt" 90 GAUCHE_THREAD_TYPE=pthreads 91 ], 92 [*-*-*freebsd*|*-*-dragonfly*], [ 93 AC_MSG_WARN("FreeBSD does not yet fully support threads with Boehm GC.") 94 AC_DEFINE(GC_FREEBSD_THREADS,1,[Define to use FreeBSD threads]) 95 INCLUDES="$INCLUDES -pthread" 96 THREADLIBS="-pthread" 97 GAUCHE_THREAD_TYPE=pthreads 98 ], 99 [*-*-kfreebsd*-gnu], [ 100 AC_DEFINE(GC_FREEBSD_THREADS,1,[Define to use FreeBSD threads]) 101 INCLUDES="$INCLUDES -pthread" 102 THREADDLLIBS=-pthread 103 AC_DEFINE(_REENTRANT,1,[Define to use reentrant libc]) 104 ], 105 [*-*-gnu*], [ 106 AC_DEFINE(GC_GNU_THREADS,1,[Define to use GNU threads]) 107 AC_DEFINE(_REENTRANT,1,[Define to use reentrant libc]) 108 THREADLIBS="-lpthread" 109 GAUCHE_THREAD_TYPE=pthreads 110 ], 111 [*-*-netbsd*], [ 112 AC_MSG_WARN("Only on NetBSD 2.0 or later.") 113 AC_DEFINE(GC_NETBSD_THREADS,1,[Define to use NetBSD threads]) 114 AC_DEFINE(_REENTRANT, [], [Define to use reentrant libc]) 115 AC_DEFINE(_PTHREADS, [], [Define if thread support requires this symbol]) 116 THREADLIBS="-lpthread" 117 THREADDLLIBS="-lpthread -lrt" 118 GAUCHE_THREAD_TYPE=pthreads 119 ], 120 [*-*-openbsd*], [ 121 AC_MSG_WARN([Gauche with pthread on OpenBSD has unresolved issues. We recommend you to build without threads (--disable-threads) unless you're trying to fix the issues. See https://github.com/shirok/Gauche/issues/276 and https://github.com/shirok/Gauche/issues/334 .]) 122 AC_DEFINE(GC_OPENBSD_THREADS,1,[Define to use OpenBSD threads]) 123 THREADLIBS="-lpthread" 124 THREADDLLIBS="-lpthread" 125 GAUCHE_THREAD_TYPE=pthreads 126 ], 127 [*-*-solaris*], [ 128 AC_DEFINE(GC_SOLARIS_THREADS,1,[Define to use Solaris threads]) 129 AC_DEFINE(GC_SOLARIS_PTHREADS,1,[Define to use Solaris pthreads]) 130 AC_DEFINE(_POSIX_PTHREAD_SEMANTICS,1,[Define to use Solaris pthreads]) 131 THREADLIBS="-lpthread" 132 GAUCHE_THREAD_TYPE=pthreads 133 ], 134 [*-*-irix*], [ 135 AC_DEFINE(GC_IRIX_THREADS,1,[Define to use IRIX threads]) 136 THREADLIBS="-lpthread" 137 GAUCHE_THREAD_TYPE=pthreads 138 ], 139 [*-*-cygwin*], [ 140 AC_DEFINE(GC_WIN32_THREADS,1,[Define to use Win32 threads]) 141 THREADLIBS="-lpthread" 142 GAUCHE_THREAD_TYPE=pthreads 143 ], 144 [*-*-darwin*], [ 145 AC_DEFINE(GC_DARWIN_THREADS,1,[Define to use Darwin threads]) 146 AC_DEFINE(GC_PTHREADS,1,[Define to use pthreads]) 147 INCLUDES="$INCLUDES -I/sw/include" 148 THREADLIBS="-lpthread" 149 GAUCHE_THREAD_TYPE=pthreads 150 ], 151 [*-*-mingw*], [ 152 AS_IF([test $GAUCHE_THREAD_TYPE = "pthreads"], 153 [ AC_MSG_ERROR([pthread can't be used on Windows. Use --enable-threads=win32 to enable threads]) ], 154 [ GAUCHE_THREAD_TYPE=win32 ]) 155 ], 156 [ 157 AS_IF([test $GAUCHE_THREAD_TYPE = "pthreads"], 158 [ AC_MSG_ERROR([pthread is not supported on $host]) ], 159 [ GAUCHE_THREAD_TYPE=none ]) 160 ])]) 161AS_CASE([$GAUCHE_THREAD_TYPE], 162 [pthreads], [ AC_DEFINE(GAUCHE_USE_PTHREADS,1,[Define if we use pthreads]) ], 163 [win32], [ AC_DEFINE(GAUCHE_USE_WTHREADS,1,[Define if we use windows threads]) ], 164 []) 165 166LIBS="$LIBS $THREADLIBS" 167dnl Save thread model to be inherited by gc/ subdir. 168AC_SUBST(GAUCHE_THREAD_TYPE) 169AC_MSG_RESULT([$GAUCHE_THREAD_TYPE]) 170 171dnl ---------------------------------------------------------- 172dnl with-slib 173dnl 174SLIB_DIR=/usr/local/slib 175AC_ARG_WITH(slib, 176 AS_HELP_STRING([--with-slib=PATH], 177 [Configure Gauche's slib module to use Aubrey Jaffer's SLIB 178installed under PATH. If PATH is not specified, or this option is omitted, 179Gauche still tries to find your slib installation from some typical places.]), 180 [ 181 AS_CASE([$with_slib], 182 [no], [search_slib=no], 183 [yes], [search_slib=yes], 184 [search_slib=no; SLIB_DIR=$with_slib]) 185 ], [ search_slib=yes ]) 186 187AS_IF([test $search_slib = "yes"], [ 188 AC_MSG_CHECKING(slib) 189 slib_found=no 190 for dir in /usr/share/slib /usr/local/slib /usr/local/lib/slib /usr/local/share/slib /usr/src/slib /opt/share/slib; do 191 AS_IF([test -f $dir/require.scm], [ 192 SLIB_DIR=$dir 193 AC_MSG_RESULT($SLIB_DIR) 194 slib_found=yes 195 break 196 ]) 197 done 198 AS_IF([test $slib_found = "no"], [ 199 AC_MSG_RESULT([not found, using fallback $SLIB_DIR]) 200 ]) 201]) 202AC_SUBST(SLIB_DIR) 203AC_DEFINE_UNQUOTED(SLIB_DIR, "$SLIB_DIR", [Slib installation path]) 204 205dnl ---------------------------------------------------------- 206dnl with-local=PATH:... 207dnl 208AC_ARG_WITH(local, 209 AS_HELP_STRING([--with-local=PATH:PATH...], 210 [For each PATH, add PATH/include to the include search 211paths and PATH/lib to the library search paths. Useful if you have some 212libraries installed in non-standard places. On MinGW/MSYS, use ';' as a 213separator instead of ':'.]), 214 [ 215 AS_CASE([$with_local], 216 [yes|no|""], [], dnl no effect 217 [IFS_save=$IFS 218 AS_CASE([$host], 219 [*mingw*], [IFS=";"], 220 [IFS=":"]) 221 sep0="" 222 sep1="" 223 for p in $with_local; do 224 LOCAL_INC="${LOCAL_INC}${sep0}-I$p/include" 225 LOCAL_LIB="${LOCAL_LIB}${sep0}-L$p/lib" 226 LOCAL_INCDIRS="${LOCAL_INCDIRS}${sep1}$p/include" 227 LOCAL_LIBDIRS="${LOCAL_LIBDIRS}${sep1}$p/lib" 228 sep0=" " 229 sep1="$IFS" 230 done 231 IFS=$IFS_save ]) 232 ]) 233AC_SUBST(LOCAL_INC) 234AC_SUBST(LOCAL_LIB) 235AC_SUBST(LOCAL_INCDIRS) 236AC_SUBST(LOCAL_LIBDIRS) 237dnl need to add here, for it may be used by the tests below. 238INCLUDES="$INCLUDES $LOCAL_INC" 239CPPFLAGS="$CPPFLAGS $LOCAL_INC" 240LDFLAGS="$LDFLAGS $LOCAL_LIB" 241 242dnl ---------------------------------------------------------- 243dnl with-rpath=PATH:... 244dnl 245try_rpath=yes 246rpath= 247AC_ARG_WITH(rpath, 248 AS_HELP_STRING([--with-rpath=PATH:PATH...], 249 [Use -rpath option while building dynamically loadable objects (experimental).]), 250 [ 251 AS_CASE([$with_rpath], 252 [yes], [], 253 [no], [try_rpath=no], 254 [rpath=`echo $with_rpath | sed -e 's/^/-Wl,-rpath=/ ; s/:/,-rpath=/g'`]) 255 ]) 256 257dnl ---------------------------------------------------------- 258dnl with-libatomic-ops[=yes|no|check|none] 259dnl 260dnl The check is fairly complicated, so we let gc/configure work on it. 261dnl There are four cases regarding libatomic-ops usage: 262dnl 1. No libatomic_ops is used (no threads) 263dnl 2. Internal - gc/libatomic_ops/* will have compiled library. 264dnl 3. External - we need to link with system's libatomic_ops library. 265dnl 4. Intrinsic - use compiler intrinsic support. 266dnl Among these cases, only 3 needs a special care, where we have to know 267dnl the compiler and library flags. It is set in ATOMIC_OPS_CFLAGS and 268dnl ATOMIC_OPS_LIBS inside gc/Makefile, and we extract them at compile time. 269dnl 270dnl Caveat: There's a case that the compiler supports intrinsic atomic ops 271dnl yet not having C11 stdatomic.h (gcc 4.8). 272dnl The following test is to catch it. See src/gauche/priv/atomicP.h for 273dnl how we handle it. 274 275AC_CHECK_HEADERS(stdatomic.h) 276 277dnl ---------------------------------------------------------- 278dnl enable-framework 279dnl 280ac_gauche_framework=no 281AC_ARG_ENABLE(framework, 282 AS_HELP_STRING([--enable-framework], 283 [On MacOSX, build Gauche as a framework. This flag has no effect on other platforms.]), 284 [ 285 AS_CASE([$enableval], 286 [no], [], 287 [ac_gauche_framework=yes]) 288 ], []) 289 290dnl ---------------------------------------------------------- 291dnl with-gperftools 292dnl 293AC_ARG_WITH(gperftools, 294 AS_HELP_STRING([--with-gperftools], 295 [Link with gperftools profiler. When linked, and run with CPUPROFILE=FILE environment variable, sampling profiler is run and the result is dumped to FILE. This is to profile Gauche system itself, not the programs written in Scheme (the latter is supported with gosh's -ptime runtime option). It is not recommended to build production release with this option.]), 296 [ 297 AS_CASE([$with_gperftools], 298 [no], [], 299 [AC_CHECK_HEADERS(gperftools/profiler.h) 300 AC_CHECK_LIB(profiler, ProfilerStart) 301 AS_IF([test "x$ac_cv_header_gperftools_profiler_h" != xyes 302 -o "x$ac_cv_lib_profiler_ProfilerStart" != xyes], 303 [AC_MSG_ERROR([The --with-gperftools option requires gperftools, but it doesn't appear to be installed on this system.])]) 304 ]) 305 ], []) 306 307dnl =========================================================== 308dnl Set up version-related macros 309GAUCHE_VERSION=$PACKAGE_VERSION 310AC_SUBST(GAUCHE_VERSION) 311AC_DEFINE_UNQUOTED(GAUCHE_VERSION, "$GAUCHE_VERSION", [Gauche version string]) 312 313GAUCHE_VERSION_TRUNC=`echo $GAUCHE_VERSION | sed 's/@<:@-_@:>@.*//'` 314OLD_IFS=$IFS; IFS="."; set $GAUCHE_VERSION_TRUNC; IFS=$OLD_IFS 315GAUCHE_MAJOR_VERSION=$1 316GAUCHE_MINOR_VERSION=$2 317GAUCHE_MICRO_VERSION=$3 318if test -z "$GAUCHE_MICRO_VERSION"; then GAUCHE_MICRO_VERSION=0; fi 319AC_SUBST(GAUCHE_MAJOR_VERSION) 320AC_SUBST(GAUCHE_MINOR_VERSION) 321AC_SUBST(GAUCHE_MICRO_VERSION) 322AC_DEFINE_UNQUOTED(GAUCHE_MAJOR_VERSION, $GAUCHE_MAJOR_VERSION,[Gauche major version number]) 323AC_DEFINE_UNQUOTED(GAUCHE_MINOR_VERSION, $GAUCHE_MINOR_VERSION,[Gauche minor version number]) 324AC_DEFINE_UNQUOTED(GAUCHE_MICRO_VERSION, $GAUCHE_MICRO_VERSION,[Gauche patch level number]) 325 326if test -z "$GAUCHE_ABI_VERSION"; then 327 GAUCHE_ABI_VERSION="$GAUCHE_MAJOR_VERSION.$GAUCHE_MINOR_VERSION" 328fi 329AC_SUBST(GAUCHE_ABI_VERSION) 330AC_DEFINE_UNQUOTED(GAUCHE_ABI_VERSION, "$GAUCHE_ABI_VERSION", [Gauche ABI version string]) 331 332GAUCHE_SIGNATURE="$GAUCHE_ABI_VERSION,$GAUCHE_CHAR_ENCODING,$GAUCHE_THREAD_TYPE" 333AC_DEFINE_UNQUOTED(GAUCHE_SIGNATURE, "$GAUCHE_SIGNATURE", [Gauche signature string]) 334 335LIBGAUCHE=libgauche-$GAUCHE_ABI_VERSION 336AC_SUBST(LIBGAUCHE) 337LIBGAUCHE_STATIC=libgauche-static-$GAUCHE_ABI_VERSION 338AC_SUBST(LIBGAUCHE_STATIC) 339LINKGAUCHE=gauche-$GAUCHE_ABI_VERSION 340AC_SUBST(LINKGAUCHE) 341 342dnl put the args to the configure in gauche-config script for later use. 343dnl the use of ac_configure_args depends on autoconf 2.52. 344GAUCHE_CONFIGURE_ARGS=`echo "$ac_configure_args" | sed 's/@<:@\\"\`\$@:>@/\\\\&/g'` 345AC_SUBST(GAUCHE_CONFIGURE_ARGS) 346 347dnl ========================================================== 348dnl Checks for programs. 349 350dnl Kludge for Solaris. We need this setup before start checking with 351dnl the compiler. NB: These flags do not coexist with -std=gnu99 flag. 352dnl Be careful when we start using C99 features. 353case $host in 354 *-pc-solaris2.*) 355 CFLAGS="$CFLAGS -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__" ;; 356esac 357 358AC_PROG_CC 359AC_PROG_CC_STDC 360AC_C_CONST 361AC_PROG_MAKE_SET 362AC_PROG_INSTALL 363AC_PROG_LN_S 364AC_CHECK_TOOLS(AR, ar gar) 365AC_CHECK_PROGS(MAKEINFO, makeinfo) 366AC_CHECK_PROGS(GZIP_PROGRAM, gzip) 367 368if test -z "$MAKEINFO" -o -z "$GZIP_PROGRAM"; then 369 build_doc="No (requires makeinfo and gzip to build documents)" 370else 371 build_doc=Yes 372fi 373 374dnl for cross build 375AC_CHECK_PROGS(BUILD_CC, ${build}-gcc ${build_alias}-gcc gcc cc) 376 377dnl for build from repo, we need preinstalled gosh 378dnl NB: The third arg is the value when we don't detect preinstalled gosh. 379dnl In such case, building from repo fails anyway; shall we use alternative 380dnl name or something to tell the builder that she needs preinstalled gosh? 381AC_ARG_VAR(BUILD_GOSH, [gosh command used during build]) 382if test -z ${BUILD_GOSH+z}; then 383 AC_PATH_PROG(BUILD_GOSH, gosh, gosh) 384fi 385 386dnl Safe default CFLAGS (usually -g -O2 if you're using gcc, empty otherwise). 387dnl If the user overrides CFLAGS during configure, which is recorded. 388dnl This information is used when configuring extensions. 389CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-label" 390DEFAULT_CFLAGS="$CFLAGS" 391AC_SUBST(DEFAULT_CFLAGS) 392 393dnl =========================================================== 394dnl Checks for header files. 395dnl We check sys/types.h merely to include it in the following tests, 396dnl for some tests needs it. 397AC_HEADER_STDC 398AC_HEADER_TIME 399AC_CHECK_HEADERS(time.h sys/time.h sys/types.h glob.h dlfcn.h getopt.h sched.h) 400AC_CHECK_HEADERS(unistd.h rpc/types.h malloc.h) 401AC_CHECK_HEADERS(syslog.h crypt.h) 402AC_CHECK_HEADERS(pty.h util.h bsd/libutil.h libutil.h sys/loadavg.h sys/resource.h) 403AC_CHECK_HEADERS(sys/statvfs.h) 404 405dnl glibc specific 406AC_CHECK_HEADERS(fpu_control.h) 407 408dnl solaris specific 409AC_CHECK_HEADERS(sunmath.h) 410 411dnl OSX specific. If this header exists, we assume that extern char **environ 412dnl isn't available and we should use _NSGetEnviron(). 413AC_CHECK_HEADERS(crt_externs.h) 414 415dnl OSX specific. To call proc_pidpath(). Note that this is not officially 416dnl supported by Apple. 417AC_CHECK_HEADERS(libproc.h) 418 419dnl =========================================================== 420dnl Checks processor type, for processor-specific stuff 421AS_CASE([$host], 422 [i?86-apple-darwin*], [ 423 AC_CHECK_DEFINED(i386, 424 AC_DEFINE(SCM_TARGET_I386,1,[Define to use i386 optimizations]))], 425 [i?86-*], [ 426 AC_DEFINE(SCM_TARGET_I386,1,[Define to use i386 optimizations])], 427 [x86_64-*], [ 428 AC_DEFINE(SCM_TARGET_X86_64,1,[Define to use x86_64 optimizations])], 429 [alpha*], [ 430 CFLAGS="$CFLAGS -mieee"], 431 [arm*], [ 432 dnl ARM processor may use a special mixed endian for doubles. It can 433 dnl be switched by processor configuration. So we check it at runtime. 434 AC_DEFINE(DOUBLE_ARMENDIAN,1,[Define to use mixed endian ARM processor])]) 435 436dnl =========================================================== 437dnl Checks for typedefs, structures, and compiler characteristics. 438AC_SYS_LARGEFILE 439AC_C_INLINE 440AC_C_BIGENDIAN 441AC_STRUCT_TM 442AC_CHECK_SIZEOF(long) 443AC_CHECK_SIZEOF(int) 444AC_CHECK_SIZEOF(intptr_t) 445AC_CHECK_SIZEOF(off_t) 446AC_CHECK_TYPES([long long, long double]) 447AC_CHECK_TYPES([struct timespec]) 448 449if test "$GAUCHE_THREAD_TYPE" = pthreads; then 450 AC_CHECK_TYPES(pthread_spinlock_t,,,[#include <pthread.h>]) 451fi 452 453AC_CHECK_SIZEOF(rlim_t,,[ 454#if HAVE_SYS_TIME_H 455# include <sys/time.h> 456#endif 457#if HAVE_SYS_RESOURCE_H 458# include <sys/resource.h> 459#endif 460]) 461 462dnl Checks nanosecond resolution in stat structure 463AC_CHECK_MEMBERS([struct stat.st_atim, 464 struct stat.st_mtim, 465 struct stat.st_ctim],,,[#include <sys/stat.h>]) 466 467dnl Checks non-POSIX members of system structure 468AC_CHECK_MEMBERS([struct group.gr_passwd],,,[#include <grp.h>]) 469AC_CHECK_MEMBERS([struct passwd.pw_passwd, 470 struct passwd.pw_gecos, 471 struct passwd.pw_class],,,[#include <pwd.h>]) 472 473dnl checks if time_t is integer or flonum 474AC_CACHE_CHECK(time_t is integral, ac_cv_type_time_t_integral, [ 475AC_TRY_RUN([ 476#include <time.h> 477int main() 478{ 479 time_t t = 3.14; 480 return (t == 3.14); 481}], ac_cv_type_time_t_integral=yes, ac_cv_type_time_t_integral=no, 482ac_cv_type_time_t_integral=yes)]) 483 484if test "$ac_cv_type_time_t_integral" = yes; then 485AC_DEFINE(INTEGRAL_TIME_T,1,[Define if time_t is typedef'ed to an integral type]) 486fi 487 488dnl =========================================================== 489dnl Checks for library functions. 490AC_PROG_GCC_TRADITIONAL 491 492dnl This is required to test trunc and rint below 493AC_CHECK_LIB(m, sin) 494 495dnl x86-solaris 9 requires this to use isinf 496AC_CHECK_LIB(sunmath, isinf) 497 498dnl clock_gettime may be in librt 499AC_CHECK_LIB(rt, clock_gettime) 500 501dnl OSX specific 502AC_CHECK_LIB(proc, proc_pidpath) 503 504dnl For Windows/MinGW, manually adds several libraries 505dnl Also adds -DUNICODE to CFLAGS enable Windows wchar API, 506dnl if GAUCHE_CHAR_ENCODING is UTF_8. 507dnl Also adds -D__USE_MINGW_ANSI_STDIO to CFLAGS to support 508dnl C99 printf format string. 509dnl ALTERNATIVE_GOSH is no-console version of gosh; only built on Windows. 510case "$host" in 511 *mingw*) LIBS="$LIBS -lnetapi32 -lshlwapi -lws2_32" 512 ALTERNATIVE_GOSH="gosh-noconsole.exe" 513 case "$GAUCHE_CHAR_ENCODING" in 514 utf8) CFLAGS="$CFLAGS -DUNICODE" ;; 515 esac 516 CFLAGS="$CFLAGS -D__USE_MINGW_ANSI_STDIO" ;; 517 *) ALTERNATIVE_GOSH="" ;; 518esac 519AC_SUBST(ALTERNATIVE_GOSH) 520 521AC_FUNC_ALLOCA 522AC_CHECK_FUNCS(isnan isinf trunc rint tgamma lgamma) 523AC_CHECK_FUNCS(symlink readlink lchown realpath nanosleep usleep utimensat) 524AC_CHECK_FUNCS(random srandom lrand48 srand48) 525AC_CHECK_FUNCS(putenv setenv unsetenv clearenv getpgid setgroups) 526AC_CHECK_FUNCS(gethostname sethostname getdomainname setdomainname) 527AC_CHECK_FUNCS(gettimeofday getloadavg clock_gettime clock_getres) 528AC_CHECK_FUNCS(syslog setlogmask) 529AC_CHECK_FUNCS(sigwait) 530AC_CHECK_FUNCS(fpsetprec) 531AC_CHECK_FUNCS(issetugid) 532 533dnl KLUDGE: As of Dec 2015, Mingw-w64 provides mkstemp() but it opens 534dnl the file with _O_TEMPORARY flag, so the file gets automatically deleted 535dnl when its opened file descriptors are all closed. It is incompatible 536dnl for typical behavior and we avoid using it. This kludge should be 537dnl removed once mingw-w64 fixes mkstemp. (We include mkdtemp here as 538dnl well, just because it's nice to see them togeter. Mingw-w64 doesn't 539dnl have mkdtemp yet, so it doesn't matter wheter we include it or not.) 540case "$host" in 541 *mingw*) ;; 542 *) 543 AC_CHECK_FUNCS(mkdtemp mkstemp);; 544esac 545 546dnl Check for select(). HP-UX and MinGW doesn't like the way configure tests 547dnl select() existence and we know they have one, so we skip the test on them. 548case "$host" in 549 *-hpux*|*mingw*) 550 AC_DEFINE(HAVE_SELECT, 1, [Define if you have select]) ;; 551 *) 552 AC_CHECK_FUNCS(select);; 553esac 554 555dnl Checks for pty-related fns. It appears that recent Cygwin has them, 556dnl but only in a static library. That prevents us from creating DLL 557dnl version of gauche. Thus we explicitly exclude them on cygwin. 558case "$host" in 559 *cygwin*) 560 : ;; 561 *) 562 AC_SEARCH_LIBS(openpty, util, AC_DEFINE(HAVE_OPENPTY, 1, [Define if you have openpty])) 563 AC_SEARCH_LIBS(forkpty, util, AC_DEFINE(HAVE_FORKPTY, 1, [Define if you have forkpty])) 564 ;; 565esac 566 567dnl Check for fcntl 568AC_CHECK_FUNCS(fcntl) 569 570dnl Checks if crypt() exists and whether it's in libc or libcrypt. 571dnl Note: on cygwin, libcrypt is only available as a static library, 572dnl and prevents libgauche.dll from building. We explicitly excludes it. 573dnl 574case "$host" in 575 *cygwin*) 576 : ;; 577 *) 578 AC_SEARCH_LIBS(crypt, crypt, AC_DEFINE(HAVE_CRYPT,1,[Define if uses libcrypt])) 579 ;; 580esac 581 582dnl Checks if dlopen exists, and if it's in libc or libdl. 583dnl On MinGW, we call LoadLibrary so we don't need dlopen (see dl_win.c) 584case "$host" in 585 *mingw*) 586 : ;; 587 *) 588 AC_SEARCH_LIBS(dlopen, dl, AC_DEFINE(HAVE_DLOPEN,1,[Define if the system has dlopen()])) 589 ;; 590esac 591 592dnl Checks for sched_yield. 593AC_SEARCH_LIBS(sched_yield, rt, AC_DEFINE(HAVE_SCHED_YIELD,1,[Define if uses librt])) 594 595dnl Use Resource file 596AS_CASE([$host], 597 [*mingw*], [USE_WIN_RESOURCE_yes="" 598 USE_WIN_RESOURCE_no="@%:@"], 599 [USE_WIN_RESOURCE_yes="@%:@" 600 USE_WIN_RESOURCE_no=""]) 601AC_SUBST(USE_WIN_RESOURCE_yes) 602AC_SUBST(USE_WIN_RESOURCE_no) 603 604dnl 605dnl Checks compiler options for dynamic link and thread support. 606dnl 607dnl SHLIB_SO_SUFFIX Suffix of dlopen-able module. most systems doesn't 608dnl have restriction for this. default "so". 609dnl SHLIB_DYLIB_SUFFIX Suffix of dynamic linkable module. On Unices 610dnl it is usuallly "so". On MacOSX it is "dylib". 611dnl On Win32 it is "dll". If not explicitly specified, 612dnl SHLIB_SO_SUFFIX is used. 613dnl SHLIB_SO_CFLAGS flags to compile files which is dlopen-able 614dnl e.g. "-fpic" 615dnl SHLIB_SO_LDFLAGS flags to link files to create dlopen-able 616dnl module, e.g. "-shared -o" 617dnl SHLIB_DYLIB_LDFLAGS flags to link files to create dynamically linkable 618dnl module. On most unices this is the same as 619dnl SHLIB_SO_LDFLAGS. 620dnl SHLIB_MAIN_LDFLAGS flags required to compile a main program which 621dnl exposes symbols to be referred by the dynamically 622dnl loaded module, e.g. "-rdynamic" 623dnl LINK_HELPER A script that helps linking libgauche. Sort of 624dnl simplified libtool. So far we only need this on 625dnl MacOSX. We have absolutely no intention to 626dnl re-invent libtool, though. 627dnl LIBGAUCHE_SO defined as "libgauche.$(SHLIB_SO_SUFFIX)" if 628dnl system supports dso. empty otherwise. 629dnl GOSH_USE_SHLIB If set to "yes", gosh uses dynamic linkable version 630dnl of libgauche, instead of statically links libgauche.a. 631dnl On Win32 it is required to allow extensions to work. 632 633AC_MSG_CHECKING(how to make dynamic loadable module) 634 635# A flag to indicate libgauche can be linked when building extension module. 636# It is required on cygwin; it has to be omitted on MacOS X; Other unices 637# generally don't care. 638ext_use_libgauche=no 639 640# A flag to indicate we need to create a link with version numbers to 641# libgauche.so after building it. 642libgauche_version_link=yes 643 644# A flag to indicate uvector.so should be added when linking extension module 645# that refers to uvector. It is required if we want to resolve all symbols, 646# and although it's the usual case, we can't add it on MacOS X, on which 647# we only build the static version of libgauche. 648ext_use_uvector=no 649 650# We put additional information, such as whether we use Framework for 651# darwin, in this variable. 652xhost=$host 653 654# On cygwin, we likely to need rebaseall to make dlls work with sys-fork. 655CYGWIN_FIXDLL=: 656 657AS_CASE([$host], 658 [*freebsd2*], [ 659 SHLIB_SO_CFLAGS="-fpic -fPIC" 660 SHLIB_SO_LDFLAGS="-v;ld -Bshareable -o" 661 SHLIB_SO_SUFFIX="so" 662 SHLIB_MAIN_LDFLAGS="" 663 SHLIB_OK=ok 664 ], 665 [*-linux-*|*-*-gnu*|*freebsd*|*dragonfly*], [ 666 SHLIB_SO_CFLAGS="-fPIC" 667 SHLIB_SO_LDFLAGS="$rpath -shared -o" 668 SHLIB_SO_SUFFIX="so" 669 SHLIB_MAIN_LDFLAGS="-rdynamic" 670 SHLIB_OK=ok 671 ], 672 [*netbsd*|*openbsd*], [ 673 SHLIB_SO_CFLAGS="-fPIC -DPIC" 674 SHLIB_SO_LDFLAGS="$rpath -shared -o" 675 SHLIB_SO_SUFFIX="so" 676 SHLIB_MAIN_LDFLAGS="-rdynamic" 677 SHLIB_OK=ok 678 ], 679 [*darwin*], [ 680 dnl -no-cpp-precomp is not related to shared library, but needed to 681 dnl get src/{vm.c,char.c} compiled -skimu 682 dnl [Shiro] Darwin 1.3 and later needs different flags 683 CPPFLAGS="$CPPFLAGS -no-cpp-precomp" 684 AS_CASE([$host_os], 685 [darwin1.@<:@012@:>@], [FLAT_NAMESPACE=""], 686 [FLAT_NAMESPACE="-flat_namespace"]) 687 AS_CASE([$host_os], 688 [darwin9.8.*], [], dnl Leopard doesn't like -no_pie 689 [SHLIB_MAIN_LDFLAGS="-Wl,-no_pie"]) 690 SHLIB_SO_CFLAGS="-no-cpp-precomp -fPIC -fno-common" 691 SHLIB_SO_LDFLAGS="-bundle $FLAT_NAMESPACE -undefined suppress -o" 692 SHLIB_SO_SUFFIX="so" 693 SHLIB_DYLIB_LDFLAGS='-framework CoreFoundation -dynamiclib -o' 694 AS_IF([test "$ac_gauche_framework" = yes], [ 695 AC_DEFINE(GAUCHE_MACOSX_FRAMEWORK, 1, [Define 1 if building framework on MacOSX]) 696 xhost="${host}-framework" 697 ]) 698 SHLIB_DYLIB_SUFFIX="dylib" 699 SHLIB_LIBS_FOR_EXT="" 700 SHLIB_OK=ok 701 LINK_HELPER='$(srcdir)/link-dylib' 702 ext_use_libgauche=no 703 libgauche_version_link=no 704 ], 705 [mips-sgi-irix*], [ 706 AS_IF([test "$GCC" = yes], 707 [SHLIB_SO_CFLAGS="-fPIC"], 708 [SHLIB_SO_CFLAGS="-KPIC"]) 709 SHLIB_SO_LDFLAGS="$rpath -shared -o" 710 SHLIB_SO_SUFFIX="so" 711 SHLIB_MAIN_LDFLAGS="" 712 SHLIB_OK=ok 713 ], 714 [*solaris*], [ 715 AS_IF([test "$GCC" = yes], [ 716 SHLIB_SO_CFLAGS="-fPIC" 717 SHLIB_SO_LDFLAGS="-shared -o" 718 ], [ 719 SHLIB_SO_CFLAGS="-Kpic" 720 SHLIB_SO_LDFLAGS="-G -o" 721 ]) 722 SHLIB_SO_SUFFIX="so" 723 SHLIB_MAIN_LDFLAGS="" 724 SHLIB_OK=ok 725 ], 726 [*hp*], [ 727 AS_IF([test "$GCC" = yes], [ 728 SHLIB_SO_CFLAGS="-fPIC" 729 SHLIB_SO_LDFLAGS="-shared -o" 730 ], [ 731 SHLIB_SO_CFLAGS="+z +Z" 732 SHLIB_SO_LDFLAGS=";ld -b -o" 733 ]) 734 SHLIB_SO_SUFFIX="sl" 735 SHLIB_MAIN_LDFLAGS="" 736 SHLIB_OK=ok 737 LINK_HELPER='$(srcdir)/link-hpux' 738 ], 739 [*cygwin*], [ 740 SHLIB_SO_CFLAGS="" 741 SHLIB_SO_LDFLAGS='-Wl,--export-all-symbols -Wl,--enable-auto-import -shared -o' 742 SHLIB_SO_SUFFIX="dll" 743 SHLIB_DYLIB_SUFFIX="dll" 744 SHLIB_MAIN_LDFLAGS="-Wl,--enable-auto-import" 745 SHLIB_OK=ok 746 GOSH_USE_SHLIB=yes 747 ext_use_uvector=yes 748 ext_use_libgauche=yes 749 libgauche_version_link=no 750 CYGWIN_FIXDLL='$(srcdir)/src/cygwin-fixdll.sh' 751 ], 752 [*mingw*], [ 753 dnl Kludge: We add -static-libgcc flag when creating dll, in order to avoid 754 dnl introducing dependency to libgcc_s_dw2-1.dll. 755 SHLIB_SO_CFLAGS="" 756 SHLIB_SO_LDFLAGS='-Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc -static-libgcc -shared -o' 757 SHLIB_SO_SUFFIX="dll" 758 SHLIB_DYLIB_SUFFIX="dll" 759 SHLIB_MAIN_LDFLAGS="-Wl,--enable-auto-import -static-libgcc" 760 SHLIB_OK=ok 761 GOSH_USE_SHLIB=yes 762 ext_use_uvector=yes 763 ext_use_libgauche=yes 764 libgauche_version_link=no 765 ], 766 [ 767 SHLIB_SO_CFLAGS="" 768 SHLIB_SO_LDFLAGS="" 769 SHLIB_SO_SUFFIX="" 770 SHLIB_MAIN_LDFLAGS="" 771 SHLIB_OK=unknown 772 ]) 773AS_IF([test -z "$SHLIB_DYLIB_LDFLAGS"], 774 [SHLIB_DYLIB_LDFLAGS=$SHLIB_SO_LDFLAGS]) 775AS_IF([test -z "$SHLIB_DYLIB_SUFFIX"], 776 [SHLIB_DYLIB_SUFFIX=$SHLIB_SO_SUFFIX]) 777AS_IF([test "$SHLIB_OK" = ok], 778 [LIBGAUCHE_SO="$LIBGAUCHE.$SHLIB_DYLIB_SUFFIX"], 779 [LIBGAUCHE_SO=]) 780AS_IF([test "$ext_use_libgauche" = yes], 781 [EXT_LIBGAUCHE="-l$LINKGAUCHE"], 782 [EXT_LIBGAUCHE=]) 783AS_IF([test "$ext_use_uvector" = yes], 784 [EXT_UVECTOR='$(top_builddir)/ext/uvector/libgauche-uvector.$(SOEXT)'], 785 [EXT_UVECTOR=]) 786AS_IF([test "$libgauche_version_link" = yes -a "$SHLIB_OK" = ok], 787 [MAKEVERSLINK='$(SHELL) ./makeverslink'], 788 [MAKEVERSLINK=:]) 789 790AC_SUBST(xhost) 791AC_SUBST(SHLIB_SO_CFLAGS) 792AC_SUBST(SHLIB_SO_LDFLAGS) 793AC_SUBST(SHLIB_SO_SUFFIX) 794AC_SUBST(SHLIB_LIBS_FOR_EXT) 795AC_SUBST(SHLIB_DYLIB_LDFLAGS) 796AC_SUBST(SHLIB_DYLIB_SUFFIX) 797AC_SUBST(SHLIB_MAIN_LDFLAGS) 798AC_SUBST(EXT_LIBGAUCHE) 799AC_SUBST(EXT_UVECTOR) 800AC_SUBST(LIBGAUCHE_SO) 801AC_SUBST(GOSH_USE_SHLIB) 802AC_DEFINE_UNQUOTED(SHLIB_SO_SUFFIX, "$SHLIB_SO_SUFFIX", [Shared library file suffix]) 803AC_SUBST(LINK_HELPER) 804AC_SUBST(MAKEVERSLINK) 805AC_SUBST(CYGWIN_FIXDLL) 806AC_MSG_RESULT($SHLIB_OK) 807 808dnl Check to see if the linker takes --rpath flag via -Wl. 809RPATH_FLAG= 810if test "$try_rpath" = "yes"; then 811 cflags_save="$CFLAGS" 812 CFLAGS="$CFLAGS -Wl,--rpath=/" 813 AC_CACHE_CHECK([linker takes --rpath flag], ac_cv_linker_rpath_flag, [ 814 AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) {return 0;}])], 815 ac_cv_linker_rpath_flag=yes, 816 ac_cv_linker_rpath_flag=no) 817 ]) 818 CFLAGS="$cflags_save" 819 if test "$ac_cv_linker_rpath_flag" = "yes"; then 820 RPATH_FLAG='-Wl,--rpath=' 821 else 822 # solaris' ld uses -R instead of --rpath 823 CFLAGS="$CFLAGS -Wl,-R,/" 824 AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) {return 0;}])], 825 ac_cv_linker_rpath_flag=yes, 826 ac_cv_linker_rpath_flag=no) 827 CFLAGS="$cflags_save" 828 if test "$ac_cv_linker_rpath_flag" = "yes"; then 829 RPATH_FLAG='-Wl,-R,' 830 fi 831 fi 832 if test "$RPATH_FLAG" != ""; then 833 RPATH_TMP=$RPATH_FLAG'"`pwd`"' 834 RPATH_REAL=$RPATH_FLAG'"$(ARCH_INSTALL_DIR)"' 835 fi 836fi 837AC_SUBST(RPATH_FLAG) 838AC_SUBST(RPATH_TMP) 839AC_SUBST(RPATH_REAL) 840 841dnl Check to see if the linker takes --soname flag 842cflags_save="$CFLAGS" 843CFLAGS="$CFLAGS -Wl,--soname,libgauche.so.0" 844AC_CACHE_CHECK([linker takes --soname flag], ac_cv_linker_soname_flag, [ 845 AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) {return 0;}])], 846 ac_cv_linker_soname_flag=yes, 847 ac_cv_linker_soname_flag=no) 848 ]) 849CFLAGS="$cflags_save" 850if test "$ac_cv_linker_soname_flag" = "yes"; then 851 SONAME_FLAG="-Wl,--soname,$LIBGAUCHE.so.0.$GAUCHE_MICRO_VERSION" 852fi 853AC_SUBST(SONAME_FLAG) 854 855dnl Sets some optimization flags by heuristics. 856AC_GAUCHE_OPTFLAGS 857 858dnl =========================================================== 859dnl Tests for extensions 860 861EXT_LIBS= 862# Those *.ac's may add libraries to EXT_LIBS. 863m4_include([ext/charconv/charconv.ac]) 864m4_include([ext/dbm/dbm.ac]) 865m4_include([ext/net/net.ac]) 866m4_include([ext/zlib/zlib.ac]) 867m4_include([ext/tls/tls.ac]) 868 869dnl Setup STATIC_LIBS 870#STATIC_LIBS= 871#for lib in $EXT_LIBS $LIBS; do 872# AS_IF([ echo "${STATIC_LIBS}" | grep -F -w -e "${lib}" > /dev/null 2>&1 ], 873# [], dnl lib is alreay in STATIC_LIBS. do nothing 874# [STATIC_LIBS="$STATIC_LIBS $lib"]) 875#done 876STATIC_LIBS="$EXT_LIBS $LIBS" 877STATIC_LIBS="`echo $LIBGAUCHE_STATIC | sed s/^lib/-l/` $STATIC_LIBS" 878AC_SUBST(STATIC_LIBS) 879 880dnl =========================================================== 881dnl Cross compiling 882if test ${cross_compiling} = no ; then 883 # self compile 884 CROSS_COMPILING_yes="@%:@" 885 CROSS_COMPILING_no= 886else 887 # cross compile 888 CROSS_COMPILING_yes= 889 CROSS_COMPILING_no="@%:@" 890fi 891AC_SUBST(CROSS_COMPILING_yes) 892AC_SUBST(CROSS_COMPILING_no) 893 894dnl =========================================================== 895dnl Configure gc 896AC_CONFIG_SUBDIRS(gc) 897 898dnl =========================================================== 899dnl Create output files 900AC_CONFIG_FILES([ 901 Makefile 902 src/Makefile src/genconfig src/makeverslink 903 lib/Makefile 904 doc/gosh.1 doc/gauche-config.1 doc/gauche-cesconv.1 905 doc/gauche-install.1 doc/gauche-package.1 doc/Makefile 906 ext/Makefile ext/Makefile.ext 907 ext/bcrypt/Makefile 908 ext/binary/Makefile 909 ext/charconv/Makefile ext/charconv/iconv-adapter.h 910 ext/data/Makefile 911 ext/dbm/Makefile 912 ext/digest/Makefile 913 ext/fcntl/Makefile 914 ext/file/Makefile 915 ext/gauche/Makefile 916 ext/mt-random/Makefile 917 ext/net/Makefile 918 ext/peg/Makefile 919 ext/sparse/Makefile 920 ext/srfi/Makefile 921 ext/sxml/Makefile 922 ext/syslog/Makefile 923 ext/tls/Makefile 924 ext/termios/Makefile 925 ext/text/Makefile 926 ext/threads/Makefile 927 ext/util/Makefile 928 ext/uvector/Makefile 929 ext/vport/Makefile 930 ext/rfc/Makefile 931 ext/zlib/Makefile 932 ext/windows/Makefile 933 examples/Makefile 934 examples/standalone/Makefile 935 gc/configure.gnu-gauche:tools/gc-configure.gnu-gauche.in 936 Gauche.spec 937 tools/Makefile 938 tools/scoop/Makefile 939 tools/tls/Makefile 940 ]) 941AC_CONFIG_COMMANDS([VERSION], 942 [echo "${GAUCHE_VERSION}" > VERSION], 943 [GAUCHE_VERSION="${GAUCHE_VERSION}"]) 944AC_CONFIG_COMMANDS([src/features], 945 [${srcdir}/src/gen-features.sh ${ac_srcdir} ${ac_builddir}]) 946AC_OUTPUT 947 948dnl =========================================================== 949dnl Show some of the configuration results, for developer's 950dnl convenience. 951 952[OPTDBMS=`echo "$DBM_SCMFILES" | sed 's/\.sci//g'`] 953AS_IF([test "$ac_cv_use_zlib" = yes], [OPTZLIB=" zlib"], [OPTZLIB=" "]) 954 955AC_MSG_RESULT( 956[ 957This Gauche has been configured with the following parameters: 958 version: $GAUCHE_VERSION 959 multibyte: $GAUCHE_CHAR_ENCODING 960 documentation: $build_doc 961 slib: $SLIB_DIR 962 thread: $GAUCHE_THREAD_TYPE 963 tls/ssl: $GAUCHE_TLS_TYPES 964 CA store: $TLS_CA_TYPE $TLS_CA_PATH 965 optional modules: $OPTDBMS$OPTZLIB 966]) 967