Files
mercury/runtime/configure.in
Fergus Henderson 020b837dcd Did a lot more work on the autoconf script.
configure.in:
	Did a lot more work on the autoconf script.
1995-05-12 19:13:34 +00:00

340 lines
9.1 KiB
Plaintext

#-----------------------------------------------------------------------------#
AC_INIT(wrapper.mod)
AC_CONFIG_HEADER(autoconf.h)
AC_CANONICAL_HOST
INSTALL_PREFIX="$prefix"
AC_SUBST(INSTALL_PREFIX)
AC_PROG_CC
AC_PROG_CPP
AC_C_CROSS
AC_PROG_RANLIB
AC_RETSIGTYPE
AC_HAVE_FUNCS(sysconf getpagesize memalign mprotect sigaction)
#-----------------------------------------------------------------------------#
AC_CHECK_HEADER(sys/siginfo.h, HAVE_SIGINFO_H=1)
if test "$HAVE_SIGINFO_H" = 1; then
AC_DEFINE(HAVE_SIGINFO_H)
fi
#-----------------------------------------------------------------------------#
AC_CHECK_HEADER(sys/ucontext.h, HAVE_UCONTEXT_H=1)
if test "$HAVE_UCONTEXT_H" = 1; then
AC_DEFINE(HAVE_UCONTEXT_H)
fi
#-----------------------------------------------------------------------------#
if test "$ac_cv_func_sigaction" = yes; then
PC_INDEX=""
AC_MSG_CHECKING(for sigaction field name)
AC_CACHE_VAL(mercury_cv_sigaction_field,
AC_TRY_RUN([
#include <signal.h>
extern void handler(int signum, siginfo_t *info, void *context);
main() {
struct sigaction act;
act.sa_flags = SA_SIGINFO | SA_RESTART;
act.sa_sigaction = handler;
if (sigemptyset(&act.sa_mask) != 0)
exit(1);
if (sigaction(SIGSEGV, &act, NULL) != 0)
exit(1);
exit(0);
}
void handler(int signum, siginfo_t *info, void *context) {
return;
}],
[mercury_cv_sigaction_field=sa_sigaction],
[mercury_cv_sigaction_field=sa_handler]))
AC_MSG_RESULT($mercury_cv_sigaction_field)
AC_DEFINE(SIGACTION_FIELD, $mercury_cv_sigaction_field)
#-----------------------------------------------------------------------------#
if test "$HAVE_SIGINFO_H" = 1 && test "$HAVE_UCONTEXT_H" = 1
then
AC_MSG_CHECKING(for pc access at signals)
AC_CACHE_VAL(mercury_cv_pc_index,
mercury_cv_pc_index=no
AC_TRY_RUN([
#include <stdio.h>
#include <signal.h>
#include <sys/siginfo.h>
#include <sys/ucontext.h>
int save_signum = 0;
int save_cause;
int save_pc;
extern void handler(int signum, siginfo_t *info, void *context);
main() {
struct sigaction act;
act.sa_flags = SA_SIGINFO | SA_RESTART;
act.$mercury_cv_sigaction_field = handler;
if (sigemptyset(&act.sa_mask) != 0)
exit(1);
if (sigaction(SIGSEGV, &act, NULL) != 0)
exit(1);
if (kill(getpid(), SIGSEGV) != 0)
exit(1);
if (save_signum == 0)
exit(1);
exit(0);
}
void handler(int signum, siginfo_t *info, void *context) {
save_signum = signum;
switch (info->si_code) {
case SEGV_MAPERR: save_cause = info->si_code;
break;
case SEGV_ACCERR: save_cause = info->si_code;
break;
}
switch (info->si_code) {
case BUS_ADRALN: save_cause = info->si_code;
break;
case BUS_ADRERR: save_cause = info->si_code;
break;
case BUS_OBJERR: save_cause = info->si_code;
break;
}
save_cause = info->si_code;
/* Don't use array indexing - the square brackets
are autoconf quote characters */
save_pc = *(((ucontext_t *) context)->uc_mcontext.gregs
+ REG_PC);
}], [mercury_cv_pc_index=REG_PC], [])
AC_TRY_RUN([
#include <stdio.h>
#include <signal.h>
#include <sys/siginfo.h>
#include <sys/ucontext.h>
int save_signum = 0;
int save_cause;
int save_pc;
extern void handler(int signum, siginfo_t *info, void *context);
main() {
struct sigaction act;
act.sa_flags = SA_SIGINFO | SA_RESTART;
act.$mercury_cv_sigaction_field = handler;
if (sigemptyset(&act.sa_mask) != 0)
exit(1);
if (sigaction(SIGSEGV, &act, NULL) != 0)
exit(1);
if (kill(getpid(), SIGSEGV) != 0)
exit(1);
if (save_signum == 0)
exit(1);
exit(0);
}
void handler(int signum, siginfo_t *info, void *context) {
save_signum = signum;
switch (info->si_code) {
case SEGV_MAPERR: save_cause = info->si_code;
break;
case SEGV_ACCERR: save_cause = info->si_code;
break;
}
switch (info->si_code) {
case BUS_ADRALN: save_cause = info->si_code;
break;
case BUS_ADRERR: save_cause = info->si_code;
break;
case BUS_OBJERR: save_cause = info->si_code;
break;
}
save_cause = info->si_code;
save_pc = *(((ucontext_t *) context)->uc_mcontext.gregs
+ CTX_EPC);
}], [mercury_cv_pc_index=CTX_EPC], [])
)
AC_MSG_RESULT($mercury_cv_pc_index)
if test $mercury_cv_pc_index != no; then
AC_DEFINE(PC_INDEX, $mercury_cv_pc_index)
fi
fi
fi
#-----------------------------------------------------------------------------#
AC_MSG_CHECKING(whether we can use gcc labels)
AC_CACHE_VAL(mercury_cv_gcc_labels,
AC_TRY_RUN([
main() {
void *succip;
succip = &&last;
goto *succip;
exit(1);
last:
exit(0);
}], [mercury_cv_gcc_labels=yes], [mercury_cv_gcc_labels=no])
)
AC_MSG_RESULT($mercury_cv_gcc_labels)
if test $mercury_cv_gcc_labels = yes; then
AC_DEFINE(HAVE_GCC_LABELS)
fi
#-----------------------------------------------------------------------------#
if test $mercury_cv_gcc_labels = yes; then
AC_MSG_CHECKING(whether we can use asm labels)
AC_CACHE_VAL(mercury_cv_asm_labels,
AC_TRY_RUN([
#include "imp.h"
void *volatile volatile_global_pointer;
extern void mercury__label1 (void) __asm__("entry_" "mercury__label1" );
main() {
void *addr;
volatile_global_pointer = &&mercury__label1;
addr = &mercury__label1;
goto *addr;
exit(1);
mercury__label1:
__asm__(".globl entry_" "mercury__label1" "\n" "entry_"
"mercury__label1" ":");
exit(0);
}], [mercury_cv_asm_labels=yes], [mercury_cv_asm_labels=no])
)
else
mercury_cv_asm_labels=no
fi
AC_MSG_RESULT($mercury_cv_asm_labels)
HAVE_ASM_LABELS=$mercury_cv_asm_labels
AC_SUBST(HAVE_ASM_LABELS)
if test $HAVE_ASM_LABELS = 1; then
AC_DEFINE(HAVE_ASM_LABELS)
fi
#-----------------------------------------------------------------------------#
if test $mercury_cv_gcc_labels = yes; then
AC_MSG_CHECKING(whether we can use gcc labels and global registers)
AC_CACHE_VAL(mercury_cv_gcc_model_fast,
AC_TRY_RUN([
#define reg register
typedef unsigned int Word;
#define USE_GCC_NONLOCAL_GOTOS
#define USE_GCC_GLOBAL_REGISTERS
#include "regs.h"
main() {
mr0 = 20;
mr7 = 22;
if (mr0 + mr7 != 42)
exit(1);
exit(0);
}], [mercury_cv_gcc_model_fast=yes], [mercury_cv_gcc_model_fast=no])
)
AC_MSG_RESULT($mercury_cv_gcc_model_fast)
else
mercury_cv_gcc_model_fast=no
fi
#-----------------------------------------------------------------------------#
AC_MSG_CHECKING(whether we can use global registers without gcc labels)
AC_CACHE_VAL(mercury_cv_gcc_model_reg,
AC_TRY_RUN([
#define reg register
typedef unsigned int Word;
#define USE_GCC_GLOBAL_REGISTERS
#include "regs.h"
#include "memory.h"
main() {
mr0 = 20;
mr7 = 22;
if (mr0 + mr7 != 42)
exit(1);
exit(0);
}], [mercury_cv_gcc_model_reg=yes], [mercury_cv_gcc_model_reg=no])
)
AC_MSG_RESULT($mercury_cv_gcc_model_reg)
#-----------------------------------------------------------------------------#
if test $mercury_cv_asm_labels = yes; then
if test $mercury_cv_gcc_model_fast = yes; then
GRADE=asm_fast.gc
else
GRADE=asm_jump.gc
fi
elif test $mercury_cv_gcc_labels = yes; then
if test $mercury_cv_gcc_model_fast = yes; then
GRADE=fast.gc
else
GRADE=jump.gc
fi
else
if test $mercury_cv_gcc_model_reg = yes; then
GRADE=reg.gc
else
GRADE=none.gc
fi
fi
echo "Using GRADE=$GRADE"
AC_SUBST(GRADE)
LIBGRADES="debug none"
if test $mercury_cv_gcc_labels = yes; then
LIBGRADES="$LIBGRADES jump"
fi
if test $mercury_cv_gcc_model_reg = yes; then
LIBGRADES="$LIBGRADES reg"
fi
if test $mercury_cv_gcc_model_fast = yes; then
LIBGRADES="$LIBGRADES fast"
fi
if test $mercury_cv_asm_labels = yes; then
if test $mercury_cv_gcc_model_fast = yes; then
LIBGRADES="$LIBGRADES asm_fast"
fi
if test $mercury_cv_gcc_labels = yes; then
LIBGRADES="$LIBGRADES asm_jump"
fi
fi
for grade in $LIBGRADES; do
LIBGRADES="$LIBGRADES $grade.gc"
done
echo "Using LIBGRADES=$LIBGRADES"
AC_SUBST(LIBGRADES)
#-----------------------------------------------------------------------------#
AC_MSG_CHECKING(whether Mercury supports shared libraries on this system)
# We ought to use $target here rather than $host - but we don't
# support cross-compilation at the moment anyhow.
case "$host" in
sparc-sun-solaris2.*)
AC_MSG_RESULT(yes)
LINK_SHARED_OBJ="$CC -G"
PIC=
PIC_O=o
SO=so
;;
*)
AC_MSG_RESULT(no)
LINK_SHARED_OBJ="$CC"
PIC=
PIC_O=o
SO=a
;;
esac
AC_SUBST(LINK_SHARED_OBJ)
AC_SUBST(PIC)
AC_SUBST(PIC_O)
AC_SUBST(SO)
#-----------------------------------------------------------------------------#
INSTALL_SICSTUS=
SP=
echo looking for SICStus Prolog:
AC_PROGRAMS_CHECK(SP,sp prolog)
if test "$SP" != ""; then
case "`$SP < /dev/null 2>&1`" in
SICStus*)
INSTALL_SICSTUS=install_sicstus
;;
esac
fi
AC_SUBST(INSTALL_SICSTUS)
#-----------------------------------------------------------------------------#
INSTALL_NUPROLOG=
NP=
echo looking for NU-Prolog:
AC_PROGRAMS_CHECK(NP,np)
if test "$NP" != ""; then
case "`$NP < /dev/null` 2>&1" in
NU-Prolog*)
INSTALL_NUPROLOG=install_nuprolog
;;
esac
fi
AC_SUBST(INSTALL_NUPROLOG)
#-----------------------------------------------------------------------------#
AC_OUTPUT(Makefile.conf)
chmod u-w Makefile.conf autoconf.h
#-----------------------------------------------------------------------------#