dnl $Header: /afs/cs/project/gwydion/dylan/src/RCS/configure.in,v 1.23 97/05/31 01:23:23 ram Exp $ dnl dnl This file is an input file used by the GNU "autoconf" program dnl to generate the file "configure", which is run during mindy dnl installation to configure the system for the local dnl environment. dnl dnl The dnl m4 macro discards the rest of the line as a comment. dnl dnl Pound sign comments get copied into configure, which dnl will be a normal shell script. dnl dnl This macro determines whether the source root is the current dnl directory or the parent of the current directory. If you make dnl a subdirectory of the source root, then configure will build a dnl directory tree suitable for making mindy. dnl dnl This must come first -- do not move. AC_INIT(mindy/interp/mindy.h) # Require the use of Autoconf 2.12 or later to generate ./configure # some earlier versions don't have all the install directory output # variables. Don't really know when they came in. # AC_PREREQ(2.12) #-------------------------------------------------------------------- # See if the #!interpreter syntax is supported #-------------------------------------------------------------------- AC_SYS_INTERPRETER if test $ac_cv_sys_interpreter = no; then AC_DEFINE(NO_SHARP_BANG) fi #-------------------------------------------------------------------- # See if Perl exists, and flame if not. #-------------------------------------------------------------------- AC_PATH_PROG(PERL, perl, no) if test "$PERL" = no; then AC_MSG_WARN([Cannot build without perl to run gen-makefile]) PERL=perl elif test "$PERL" != "/usr/local/bin/perl"; then AC_MSG_WARN([Perl is not in /usr/local/bin, so you need to fix the script \ sharp-bang interpreter comments by hand.]) fi #-------------------------------------------------------------------- # builddir is the directory in which we run configure. #-------------------------------------------------------------------- builddir=`pwd` AC_SUBST(builddir) #-------------------------------------------------------------------- # Get host and target system information. #-------------------------------------------------------------------- AC_CANONICAL_SYSTEM AC_MSG_CHECKING([system type for d2c target name]) case $target in *pc-linux-gnu) d2c_target=x86-linux ;; hppa*-hp-hpux*) d2c_target=hppa-hpux ;; sparc*-solaris*) d2c_target=sparc-solaris ;; i*86-pc-cygwin32) d2c_target=x86-win32-gcc ;; i*86-pc-none) d2c_target=x86-win32-vc ;; *) d2c_target=unknown-unix ;; esac if test "$d2c_target" = "unknown-unix"; then AC_MSG_RESULT([unsupported target type, using unknown-unix]) else AC_MSG_RESULT($d2c_target) fi AC_SUBST(d2c_target) AC_MSG_CHECKING([system type for d2c host name]) case $host in *pc-linux-gnu) d2c_host=x86-linux ;; hppa*-hp-hpux*) d2c_host=hppa-hpux ;; sparc*-solaris*) d2c_host=sparc-solaris ;; i*86-pc-cygwin32) d2c_host=x86-win32-gcc ;; *) d2c_host=unknown-unix ;; esac AC_MSG_RESULT($d2c_host) AC_SUBST(d2c_host) if test "$d2c_host" = "$d2c_target"; then # If self compiling, always run mindy out of the build area, since the # installed version might be wrong. MINDY=$builddir/mindy/interp/mindy MC=$builddir/mindy/comp/mindycomp if $stage2; then # We're using the installed compiler, but we want to use the new libraries. # The individual makegens already include the needed -L's, so just use an # empty path to make sure we don't get inconsistent libraries. DYLANPATH="" else # Set DYLANPATH so that we can find the uninstalled libraries. DYLANPATH="" for dir in coll-ext format format-out internal-time matrix print \ regexp standard-io stream-ext streams string-ext table-ext time \ transcendental do DYLANPATH=${DYLANPATH}":"$builddir/common/$dir done for dir in random dylan inspector tk; do DYLANPATH=${DYLANPATH}":"$builddir/mindy/libraries/$dir done fi else # If cross compiling, hopefully mindy will be on PATH. It won't be in the # build area. Building the mindy stuff is actually unnecessary when # cross-compiling, perhaps undesirable. But it's easier not to # conditionalize the files. MINDY="mindy" MC="mindycomp" DYLANPATH=0 fi DYLANPATH='"'$DYLANPATH'"' AC_SUBST(DYLANPATH) AC_SUBST(MINDY) AC_SUBST(MC) #-------------------------------------------------------------------- # See if we can find an installed d2c. They might have installed binaries but # not set up environment variable yet, so look in the install area as well as on # path. If not found we must bootstrap. #-------------------------------------------------------------------- stage2=1 AC_CHECK_PROG(D2C, d2c, d2c, no) if test "$D2C" = no; then AC_PATH_PROG(D2C, d2c, no, $bindir:$prefix/bin) if test "$D2C" != no; then D2C="$D2C -p$sysconfdir/platforms.descr" fi fi if test "$D2C" = no; then AC_MSG_WARN(d2c executable not found: configuring in bootstrap mode.) stage2=0 D2C="$MINDY -f $builddir/d2c/compiler/main/d2c.dbc -p$srcdir/d2c/compiler/platforms.descr"; fi AC_SUBST(stage2) #-------------------------------------------------------------------- # These macros find a BSD install, a C compiler, and so on, and # establish bindings for @INSTALL@, @CC@, and so on. #-------------------------------------------------------------------- AC_PROG_INSTALL AC_PROG_CC AC_PROG_LEX AC_PROG_YACC AC_PROG_RANLIB #-------------------------------------------------------------------- # Establish the default compile options for cc #-------------------------------------------------------------------- if test $CC = gcc then CCOPTS="-g -O4 -finline-functions -Wall" else CCOPTS="-g -O" fi AC_SUBST(CCOPTS)dnl #-------------------------------------------------------------------- # Establish the default options for lex #-------------------------------------------------------------------- if test $LEX = flex; then LFLAGS=${LFLAGS--i} else echo "I could not find flex, so do not try to rebuild comp/lexer-tab.c" echo "because lex cannot do it." LFLAGS=${LFLAGS-} fi AC_SUBST(LFLAGS) #-------------------------------------------------------------------- # Establish the default options for yacc #-------------------------------------------------------------------- if test "$YACC" = "bison -y"; then # do nothing (an empty then clause is a syntax error) DUMMY=dummy else echo "I could not find bison, so do not try to rebuild comp/parser-tab.c" echo "or interp/parser-tab.c because yacc cannot do it." fi #-------------------------------------------------------------------- # Find out if sigaction is available. #-------------------------------------------------------------------- AC_FUNC_CHECK(sigaction, sigaction=1, sigaction=0) if test $sigaction = 0; then AC_DEFINE(NO_SIGACTION) LIBOBJS="${LIBOBJS-} sigaction.o" AC_FUNC_CHECK(sigsetmask, sigsetmask=1, sigsetmask=0) AC_FUNC_CHECK(sigrelse, sigrelse=1, sigrelse=0) if test $sigsetmask = 1; then echo "BSD_signals" AC_DEFINE(BSD_SIGNALS) elif test $sigrelse = 1; then echo "USG_signals" AC_DEFINE(USG_SIGNALS) else echo "I couldn't find posix, bsd, or sysV signal support." echo "You may be able to compile compat/sigaction.c by hand." fi fi #-------------------------------------------------------------------- # This next section is lifted from tcl-7.3, it deals with # establishing which of the known faults in POSIX compliance # need to be corrected. #-------------------------------------------------------------------- #-------------------------------------------------------------------- # Supply substitutes for missing POSIX library procedures, or # set flags so Tcl uses alternate procedures. #-------------------------------------------------------------------- AC_REPLACE_FUNCS(getcwd opendir strerror strstr) AC_REPLACE_FUNCS(strtol memmove tmpnam waitpid) AC_CHECK_FUNC(gettimeofday, , AC_DEFINE(NO_GETTOD)) AC_CHECK_FUNC(getwd, , AC_DEFINE(NO_GETWD)) AC_CHECK_FUNC(wait3, , AC_DEFINE(NO_WAIT3)) #-------------------------------------------------------------------- # Supply substitutes for missing POSIX header files. Special # notes: # - Sprite's dirent.h exists but is bogus. # - stdlib.h doesn't define strtol, strtoul, or # strtod insome versions of SunOS # - some versions of string.h don't declare procedures such # as strstr #-------------------------------------------------------------------- AC_HEADER_CHECK(unistd.h, , AC_DEFINE(NO_UNISTD_H)) AC_MSG_CHECKING(dirent.h) AC_TRY_COMPILE([#include #include ], [ DIR *d; struct dirent *entryPtr; char *p; d = opendir("foobar"); entryPtr = readdir(d); p = entryPtr->d_name; closedir(d); ], tcl_ok=1, tcl_ok=0) AC_EGREP_HEADER([Sprite version.* NOT POSIX], dirent.h, tcl_ok=0) if test $tcl_ok = 0; then AC_DEFINE(NO_DIRENT_H) AC_MSG_RESULT(no dirent.h) else AC_MSG_RESULT(yes) fi AC_CHECK_HEADER(errno.h, , AC_DEFINE(NO_ERRNO_H)) AC_CHECK_HEADER(float.h, , AC_DEFINE(NO_FLOAT_H)) AC_CHECK_HEADER(limits.h, , AC_DEFINE(NO_LIMITS_H)) AC_CHECK_HEADER(bstring.h, , AC_DEFINE(NO_BSTRING_H)) AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0) AC_EGREP_HEADER(getenv, stdlib.h, , tcl_ok=0) AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0) AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0) AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0) if test $tcl_ok = 0; then AC_DEFINE(NO_STDLIB_H) fi AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0) AC_EGREP_HEADER(strstr, string.h, , tcl_ok=0) AC_EGREP_HEADER(strerror, string.h, , tcl_ok=0) if test $tcl_ok = 0; then AC_DEFINE(NO_STRING_H) fi AC_EGREP_HEADER(setsid, unistd.h, tcl_ok=1, tcl_ok=0) if test $tcl_ok = 0; then LIBOBJS="${LIBOBJS-} setsid.o" fi AC_CHECK_HEADER(sys/time.h, , AC_DEFINE(NO_SYS_TIME_H)) AC_CHECK_HEADER(sys/wait.h, , AC_DEFINE(NO_SYS_WAIT_H)) #-------------------------------------------------------------------- # Include sys/select.h if it exists and if it supplies things # that appear to be useful and aren't already in sys/types.h. # This appears to be true only on the RS/6000 under AIX. Some # systems like OSF/1 have a sys/select.h that's of no use, and # other systems like SCO UNIX have a sys/select.h that's # pernicious. If "fd_set" isn't defined anywhere then set a # special flag. #-------------------------------------------------------------------- AC_MSG_CHECKING(fd_set) AC_TRY_COMPILE([#include ], [fd_set readMask, writeMask;], AC_MSG_RESULT(yes), [AC_EGREP_HEADER(fd_mask, sys/select.h, AC_DEFINE(HAVE_SYS_SELECT_H) AC_DEFINE(NO_FD_SET)) AC_MSG_RESULT(no fd_set)]) # On the HP, select is defined in sys/time.h # AC_EGREP_HEADER(select, sys/time.h, AC_DEFINE(SELECT_IN_TIME_H)) #-------------------------------------------------------------------- # On some systems strstr is broken: it returns a pointer even # even if the original string is empty. #-------------------------------------------------------------------- AC_TRY_RUN([ extern int strstr(); int main() { exit(strstr("\0test", "test") ? 1 : 0); } ], , [LIBOBJS="${LIBOBJS-} strstr.o"]) #-------------------------------------------------------------------- # Check for strtoul function. This is tricky because under some # versions of AIX strtoul returns an incorrect terminator # pointer for the string "0". #-------------------------------------------------------------------- AC_CHECK_FUNC(strtoul, tcl_ok=1, tcl_ok=0) AC_TRY_RUN([ extern int strtoul(); int main() { char *string = "0"; char *term; int value; value = strtoul(string, &term, 0); if ((value != 0) || (term != (string+1))) { exit(1); } exit(0); }], , tcl_ok=0) if test $tcl_ok = 0; then LIBOBJS="${LIBOBJS-} strtoul.o" fi #-------------------------------------------------------------------- # Check for the strtod function. This is tricky because under # some versions of Linux it mis-parses the string "+". #-------------------------------------------------------------------- AC_CHECK_FUNC(strtod, tcl_ok=1, tcl_ok=0) AC_TRY_RUN([ extern double strtod(); int main() { char *string = "+"; char *term; double value; value = strtod(string, &term); if (term != string) { exit(1); } exit(0); }], , tcl_ok=0) if test $tcl_ok = 0; then LIBOBJS="${LIBOBJS-} strtod.o" fi #-------------------------------------------------------------------- # Check for various typedefs and provide substitutes if # they don't exist. #-------------------------------------------------------------------- AC_TYPE_MODE_T AC_TYPE_PID_T AC_TYPE_SIZE_T AC_TYPE_UID_T #-------------------------------------------------------------------- # If a system doesn't have an opendir function (man, that's old!) # then we have to supply a different version of dirent.h which # is compatible with the substitute version of opendir that's # provided. This version only works with V7-style directories. #-------------------------------------------------------------------- AC_CHECK_FUNC(opendir, , AC_DEFINE(USE_DIRENT2_H)) #-------------------------------------------------------------------- # Check for the existence of sys_errlist (this is only needed if # there's no strerror, but I don't know how to conditionalize the # check). #-------------------------------------------------------------------- AC_MSG_CHECKING(sys_errlist) AC_TRY_COMPILE( , [ extern char *sys_errlist[]; extern int sys_nerr; sys_errlist[sys_nerr-1][0] = 0; ], AC_MSG_RESULT(yes), [AC_DEFINE(NO_SYS_ERRLIST) AC_MSG_RESULT(no sys_errlist)]) #-------------------------------------------------------------------- # The check below checks whether defines the type # "union wait" correctly. It's needed because of weirdness in # HP-UX where "union wait" is defined in both the BSD and SYS-V # environments. Checking the usability of WIFEXITED seems to do # the trick. #-------------------------------------------------------------------- AC_MSG_CHECKING(union wait) AC_TRY_COMPILE([#include #include ], [ union wait x; WIFEXITED(x); /* Generates compiler error if WIFEXITED * uses an int. */ ], AC_MSG_RESULT(yes), [AC_DEFINE(NO_UNION_WAIT) AC_MSG_RESULT(no union wait)]) #-------------------------------------------------------------------- # Check to see whether the system supports the matherr function # and its associated type "struct exception". #-------------------------------------------------------------------- AC_MSG_CHECKING(matherr support) AC_TRY_COMPILE([#include ], [ struct exception x; x.type = DOMAIN; x.type = SING; ], [LIBOBJS="${LIBOBJS-} matherr.o" AC_DEFINE(NEED_MATHERR) AC_MSG_RESULT(need matherr)], AC_MSG_RESULT(don't need matherr)) #-------------------------------------------------------------------- # End of the section lifted from tcl. #-------------------------------------------------------------------- #-------------------------------------------------------------------- # Check for rint() #-------------------------------------------------------------------- LIBS="${LIBS-} -lm" AC_CHECK_LIB(dld, shl_load) AC_REPLACE_FUNCS(rint) #-------------------------------------------------------------------- # Check for GNU Readline library #-------------------------------------------------------------------- AC_ARG_ENABLE(readline, GNU Readline, [if test $enableval = yes; then AC_DEFINE(HAVE_LIBREADLINE) echo "Using GNU Readline" LIBS="${LIBS-} -lreadline -ltermcap" fi]) #-------------------------------------------------------------------- # Check for HP shared library emulation on ELF systems # testing for /usr/include/dlfcn.h might be a good automatic test? #-------------------------------------------------------------------- AC_ARG_ENABLE(elflibs, ELF shared libs, [if test $enableval = yes; then AC_DEFINE(HAVE_LIBDLDELF) AC_DEFINE(HAVE_LIBDLD) echo "Using ELF shared library support" LIBOBJS="$LIBOBJS shl.o" LIBS="${LIBS-} -ldl" fi]) #-------------------------------------------------------------------- # Check to see whether we know how to read the number of bytes # in a stdio buffer. #-------------------------------------------------------------------- AC_MSG_CHECKING(stdio support) AC_TRY_COMPILE([#include ], [ FILE f; (f._IO_read_ptr >= f._IO_read_end); ],[AC_DEFINE(USE_LINUX_FBUFEMPTYP) AC_MSG_RESULT(using Linux fbufempty)], AC_MSG_RESULT(yes)) #-------------------------------------------------------------------- # Check to see if fsync is available. #-------------------------------------------------------------------- AC_CHECK_FUNC(fsync, , AC_DEFINE(NO_FSYNC)) #-------------------------------------------------------------------- # Look for select() in various places. # Tk adds all of these libraries that are found. # Under Irix 5.2, all three are found, but none should be # used. Go figure. So I test to see when select() is # found and stop adding libraries at that point. #-------------------------------------------------------------------- AC_CHECK_FUNC(select, select=1, select=0) SAVE_LIBS="$LIBS" for lib in Xbsd socket nsl; do if test $select = 0; then AC_CHECK_LIB($lib, main, tryit=1, tryit=0) if test $tryit = 1; then LIBS="$LIBS -l$lib" AC_CHECK_FUNC(select, select=1, LIBS="$SAVE_LIBS") fi fi done if test $select = 0; then echo "I can't find a select() in any library I've looked in," echo "and you won't be able to compile without it. Sorry." fi #-------------------------------------------------------------------- # See if _setjmp and _longjmp are defined. If not, use # setjmp and longjmp. #-------------------------------------------------------------------- AC_CHECK_FUNCS(_setjmp) AC_CHECK_FUNCS(_longjmp) #-------------------------------------------------------------------- # Now we read this file to determine which libraries were # shipped with Mindy. #-------------------------------------------------------------------- #Not! dnl sinclude(mindy/distribution-options) dnl AC_SUBST(BUNDLED_LIBRARY_DIRS)dnl #-------------------------------------------------------------------- # Finally, output the Makefiles for each part of the # distribution. As a side effect the necessary directories are # created, too. # # In the best of all possible worlds, you would only need to add # new files to this list as mindy expands, and create the # Makefile.in for each of them; in this world, however, you'll # probably have to mess with the rest of the file, so be warned: # autoconf is a very brittle programming language. #-------------------------------------------------------------------- # Autoconf only seems to create one directory level at a time, so we need to # create mindy (which contains no makefile.in) # $srcdir/mkinstalldirs mindy AC_OUTPUT(Defaults \ mindy/comp/Makefile \ mindy/interp/Makefile \ mindy/compat/Makefile \ mindy/etc/Makefile \ ) ${INSTALL} -m uog+rx $srcdir/tools/shared-misc/mk-build-tree ./ ${INSTALL} -m uog+rx $srcdir/tools/shared-misc/gen-makefile ./ (PATH=`pwd`:${PATH}; export PATH; mk-build-tree -p$srcdir/d2c/compiler/platforms.descr)