Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detection du type signed char (pour parsing.c dans le cas big endian).
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
- Loading branch information
1 parent
fb6daf6
commit 9b0c59d
Showing
1 changed file
with
254 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,254 @@ | ||
#!/bin/sh | ||
|
||
case $1 in | ||
"") cc=cc;; | ||
*) cc=$1;; | ||
esac | ||
export cc | ||
|
||
cd auto-aux | ||
rm -f s.h m.h Makefile.h | ||
touch s.h m.h Makefile.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 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 | ||
|
||
# Determine endianness | ||
|
||
sh ./runtest endian.c | ||
case $? in | ||
0) echo "This is a big-endian architecture." | ||
echo "#define BIG_ENDIAN" >> m.h;; | ||
1) echo "This is a little-endian architecture." | ||
echo "#undef 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 BIG_ENDIAN in m.h).";; | ||
esac | ||
|
||
# Determine alignment constraints | ||
|
||
sh ./runtest dblalign.c | ||
case $? in | ||
0) echo "Doubles can be word-aligned.";; | ||
1) echo "Doubles must be doubleword-aligned." | ||
echo "#define 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 ALIGN_DOUBLE" >> m.h;; | ||
esac | ||
|
||
# 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." | ||
echo "You'll have to figure out a compiler option that" | ||
echo "causes the 'char' type to be signed, and" | ||
echo "add it to CCCOMPOPTS in Makefile.config.";; | ||
esac;; | ||
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 | ||
|
||
# Check for _longjmp and _setjmp | ||
|
||
sh ./runtest setjmp.c | ||
case $? in | ||
0) echo "_setjmp and _longjmp appear to work. Good!" | ||
echo "#define HAS__SETJMP" >> s.h;; | ||
*) echo "No _setjmp, _longjmp. We'll use setjmp and longjmp instead." | ||
esac | ||
|
||
# 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 terminfo module | ||
|
||
if sh hasgot -lcurses setupterm tigetstr tigetnum tputs; then | ||
echo "terminfo functions found." | ||
echo "#define HAS_TERMINFO" >> s.h | ||
echo "TERMINFOLIBS=-lcurses" >> Makefile.h | ||
fi | ||
|
||
if sh hasgot -lcurses -ltermcap tgetent tgetstr tgetnum tputs; then | ||
echo "termcap functions found." | ||
echo "#define HAS_TERMCAP" >> s.h | ||
echo "TERMINFOLIBS=-lcurses -ltermcap" >> Makefile.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 | ||
|
||
rm -f tst hasgot.c | ||
rm -f ../m.h ../s.h ../Makefile.h | ||
mv m.h s.h Makefile.h .. |