configure: check if C compiler works
Check if the C compiler works to get a useful error message when it doesn't or it's missing. If the CC environment variable is not set, try gcc and then cc.
This commit is contained in:
parent
4f172f6f9f
commit
3cd32ed660
1 changed files with 29 additions and 20 deletions
49
configure
vendored
49
configure
vendored
|
@ -10,26 +10,6 @@
|
|||
|
||||
# This configure script determines the operating system type and version
|
||||
|
||||
if [ "x${CC}" = "x" ]; then
|
||||
MYCC="gcc"
|
||||
else
|
||||
MYCC="${CC}"
|
||||
fi
|
||||
|
||||
if [ "x${CFLAGS}" = "x" ]; then
|
||||
MYCFLAGS="-O2 -g"
|
||||
else
|
||||
MYCFLAGS="${CFLAGS}"
|
||||
fi
|
||||
|
||||
MYCPPFLAGS="${CPPFLAGS}"
|
||||
|
||||
if [ "x${MYCC}" = "xgcc" ]; then
|
||||
MYCFLAGS="${MYCFLAGS} -Wmissing-prototypes -Wall"
|
||||
fi
|
||||
|
||||
MYLDFLAGS="${LDFLAGS}"
|
||||
|
||||
# ======================================================================
|
||||
# FUNCTIONS
|
||||
|
||||
|
@ -449,6 +429,35 @@ if [ $feat_refclock = "1" ]; then
|
|||
EXTRA_OBJECTS="$EXTRA_OBJECTS refclock.o refclock_phc.o refclock_pps.o refclock_shm.o refclock_sock.o"
|
||||
fi
|
||||
|
||||
MYCC="$CC"
|
||||
MYCFLAGS="$CFLAGS"
|
||||
MYCPPFLAGS="$CPPFLAGS"
|
||||
MYLDFLAGS="$LDFLAGS"
|
||||
|
||||
if [ "x$MYCC" = "x" ]; then
|
||||
MYCC=gcc
|
||||
if ! test_code "$MYCC" '' '' '' ''; then
|
||||
MYCC=cc
|
||||
if ! test_code "$MYCC" '' '' '' ''; then
|
||||
echo "error: no C compiler found"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if ! test_code "$MYCC" '' '' '' ''; then
|
||||
echo "error: C compiler $MYCC cannot create executables"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "x$MYCFLAGS" = "x" ]; then
|
||||
MYCFLAGS="-O2 -g"
|
||||
fi
|
||||
|
||||
if [ "x$MYCC" = "xgcc" ]; then
|
||||
MYCFLAGS="$MYCFLAGS -Wmissing-prototypes -Wall"
|
||||
fi
|
||||
|
||||
if test_code '64-bit time_t' 'time.h' '' '' '
|
||||
char x[sizeof(time_t) > 4 ? 1 : -1] = {0};
|
||||
return x[0];'
|
||||
|
|
Loading…
Reference in a new issue