https://hal.archives-ouvertes.fr/hal-01863457
Tip revision: c812045b6b43f7bfeca7954a47baf2dcbb8c6d8d authored by Software Heritage on 03 September 2018, 13:40:43 UTC
hal: Deposit 174 in collection hal
hal: Deposit 174 in collection hal
Tip revision: c812045
autoconf
#!/bin/sh
case $1 in
"") cc=cc;;
*) cc=$1;;
esac
export cc
cd auto-aux
rm -f s.h m.h
touch s.h m.h
# Check the sizes of data types
echo "Checking the sizes of integers and pointers..."
set `sh ./runtest sizes.c`
case "$1,$2,$3" in
4,4,4) echo "OK, this is a regular 32 bit architecture.";;
4,8,8) echo "Wow! A 64 bit architecture!"
echo "#define CAML_SIXTYFOUR" >> m.h;;
8,*,*) echo "Wow! A 64 bit architecture!"
echo "Unfortunately, Caml Light does not handle the case"
echo "sizeof(int) = 8."
echo "Caml Light won't run on this architecture."
exit 2;;
*,4,8) echo "Wow! A 64 bit architecture!"
echo "Unfortunately, Caml Light cannot work in the case"
echo "sizeof(long) != sizeof(long *)."
echo "Caml Light won't run on this architecture."
exit 2;;
?,?,?) echo "This architecture seems to be neither 32 bits nor 64 bits."
echo "Caml Light won't run on this architecture."
exit 2;;
*) echo "Unable to compile the test program."
echo "Make sure the C compiler is properly installed."
exit 2;;
esac
# "unix" is not always defined by cpp, so add it here just in case
(echo "#ifndef unix"; echo "#define unix"; echo "#endif") >> s.h
# Are chars signed?
sh ./runtest schar.c
case $? in
0) echo "The char type is signed. Good!";;
1) echo "The char type is not signed. Let's see if 'signed char' works."
sh ./runtest schar2.c
case $? in
0) echo "Yes, it works. Good!"
echo "#define SIGNED_CHAR_WORKS" >> s.h;;
*) echo "No, it does not work. Let's try some compiler options."
goodopt=""
for option in -signed -fsigned-char; do
sh ./runtest $option schar.c
case $? in
0) goodopt=$option; break;;
esac
done
case "$goodopt" in
"") echo "Sorry, I can't find the right option."
echo "Please figure it out yourself, and"
echo "add it to OPTS in src/runtime/Makefile.";;
*) echo "Yippie! Option $goodopt works. Good!"
echo "Add \"$goodopt\" to OPTS in src/Makefile.";;
esac;;
esac;;
esac
# Determine endianness
sh ./runtest endian.c
case $? in
0) echo "This is a big-endian architecture."
echo "#define CAML_BIG_ENDIAN" >> m.h;;
1) echo "This is a little-endian architecture."
echo "#undef CAML_BIG_ENDIAN" >> m.h;;
2) echo "This architecture seems to be neither big endian nor little endian."
echo "Caml Light won't run on this architecture."
exit 2;;
*) echo "Something went wrong during endianness determination."
echo "You'll have to figure out endianness yourself"
echo "(option CAML_BIG_ENDIAN in m.h).";;
esac
# Determine alignment constraints
sh ./runtest align.c
status=$?
case $status in
100) echo "Your compiler seems to choke on the \"volatile\" modifier."
echo "Never mind, we'll do without it."
sh ./runtest -Dvolatile= align.c
status=$?
;;
esac
case $status in
0) echo "This architecture has no alignment constraints."
echo "#undef CAML_ALIGNMENT" >> m.h;;
1) echo "This architecture has alignment constraints."
echo "#define CAML_ALIGNMENT" >> m.h;;
*) echo "Something went wrong during alignment determination."
echo "I'm going to assume this architecture has alignment constraints."
echo "That's a safe bet: Caml Light will work even if it turns out that"
echo "this architecture actually has no alignment constraints."
echo "#define CAML_ALIGNMENT" >> m.h;;
esac
sh ./runtest dblalign.c
case $? in
0) echo "Doubles can be word-aligned.";;
1) echo "Doubles must be doubleword-aligned."
echo "#define CAML_ALIGN_DOUBLE" >> m.h;;
*) echo "Something went wrong during alignment determination for doubles."
echo "I'm going to assume this architecture has alignment constraints over doubles."
echo "That's a safe bet: Caml Light will work even if it turns out that"
echo "this architecture actually has no alignment constraints."
echo "#define CAML_ALIGN_DOUBLE" >> m.h;;
esac
# To find a good byte copy function
if sh ./runtest -Dcopy=memmove -Dreverse bytecopy.c; then
echo "Function \"memmove\" is provided and handles overlapping moves correctly."
echo "#define HAS_MEMMOVE" >> s.h
fi
if sh ./runtest -Dcopy=bcopy bytecopy.c; then
echo "Function \"bcopy\" is provided and handles overlapping moves correctly."
echo "#define HAS_BCOPY" >> s.h
fi
if sh ./runtest -Dcopy=memcpy -Dreverse bytecopy.c; then
echo "Function \"memcpy\" is provided and handles overlapping moves correctly."
echo "#define HAS_MEMCPY" >> s.h
fi
# Try to find the type of signal handlers
h=""
for ty in void int; do
rm -f /tmp/output$$
if $cc -c -DSIGRETURN=$ty sighandler.c 2>/tmp/output$$; then
if grep -s -i warning /tmp/output$$; then
:
else
h=$ty
break
fi
fi
done
rm -f sighandler.o
case "$h" in
"") echo "Sorry, I can't determine the return type for signal handlers."
echo "I'm assuming \"void\". If this seems to cause errors,"
echo "try to change \"sighandler_return_type\" in s.h"
h=void;;
*) echo "The return type for signal handlers appears to be \"$h\".";;
esac
echo "#define sighandler_return_type $h" >> s.h
# Check the semantics of signal handlers
if sh ./runtest signals.c; then
echo "Signals have the BSD semantics."
echo "#define BSD_SIGNALS" >> s.h
else
echo "Signals have the System V semantics."
fi
# For the sys module
if sh hasgot rename; then
echo "rename() found."
echo "#define HAS_RENAME" >> s.h
fi
# For the Unix library
if sh hasgot socket socketpair bind listen accept connect; then
echo "You have BSD sockets."
echo "#define HAS_SOCKETS" >> s.h
fi
if test -f /usr/include/unistd.h; then
echo "unistd.h found."
echo "#define HAS_UNISTD" >> s.h
fi
if test -f /usr/include/dirent.h; then
echo "dirent.h found."
echo "#define HAS_DIRENT" >> s.h
fi
if sh hasgot lockf; then
echo "lockf() found."
echo "#define HAS_LOCKF" >> s.h
fi
if sh hasgot mkfifo; then
echo "mkfifo() found."
echo "#define HAS_MKFIFO" >> s.h
fi
if sh hasgot getcwd; then
echo "getcwd() found."
echo "#define HAS_GETCWD" >> s.h
fi
if sh hasgot getwd; then
echo "getwd() found."
echo "#define HAS_GETWD" >> s.h
fi
if sh hasgot getpriority setpriority; then
echo "getpriority() found."
echo "#define HAS_GETPRIORITY" >> s.h
fi
if test -f /usr/include/utime.h && sh hasgot utime; then
echo "utime() found."
echo "#define HAS_UTIME" >> s.h
fi
if sh hasgot utimes; then
echo "utimes() found."
echo "#define HAS_UTIMES" >> s.h
fi
if sh hasgot dup2; then
echo "dup2() found."
echo "#define HAS_DUP2" >> s.h
fi
if sh hasgot fchmod fchown; then
echo "fchmod() found."
echo "#define HAS_FCHMOD" >> s.h
fi
if sh hasgot truncate ftruncate; then
echo "truncate() found."
echo "#define HAS_TRUNCATE" >> s.h
fi
if sh hasgot select; then
echo "select() found."
echo "#define HAS_SELECT" >> s.h
fi
if sh hasgot symlink readlink lstat; then
echo "symlink() found."
echo "#define HAS_SYMLINK" >> s.h
fi
if sh hasgot wait3; then
echo "wait3() found."
echo "#define HAS_WAIT3" >> s.h
fi
if sh hasgot waitpid; then
echo "waitpid() found."
echo "#define HAS_WAITPID" >> s.h
fi
if test -f /usr/include/sys/param.h && sh ./runtest getgroups.c; then
echo "getgroups() found."
echo "#define HAS_GETGROUPS" >> s.h
fi
if test -f /usr/include/termios.h &&
sh hasgot tcgetattr tcsetattr tcsendbreak tcflush tcflow; then
echo "POSIX termios found."
echo "#define HAS_TERMIOS" >> s.h
fi
# The following four lines must be commented out on DEC OSF1 3.0
if sh ./runtest async_io.c; then
echo "Asynchronous I/O are supported."
echo "#define HAS_ASYNC_IO" >> s.h
fi
if sh hasgot setitimer; then
echo "setitimer() found."
echo "#define HAS_SETITIMER" >> s.h
fi
if sh hasgot gethostname; then
echo "gethostname() found."
echo "#define HAS_GETHOSTNAME" >> s.h
fi
if test -f /usr/include/sys/utsname.h && sh hasgot uname; then
echo "uname() found."
echo "#define HAS_UNAME" >> s.h
fi
if sh hasgot gettimeofday; then
echo "gettimeofday() found."
echo "#define HAS_GETTIMEOFDAY" >> s.h
fi
rm -f tst hasgot.c
rm -f ../m.h ../s.h
mv m.h s.h ..