blob: 6ca47c1c591ff308ffc8cf6d4fffebfdfb24567c [file] [log] [blame]
# Copyright (C) Igor Sysoev
# Copyright (C) NGINX, Inc.
$nxt_echo checking for C compiler: $CC
cat << END >> $NXT_AUTOCONF_ERR
----------------------------------------
checking for C compiler: $CC
END
# Allow error exit status.
set +e
if [ -z `which $CC` ]; then
$nxt_echo
$nxt_echo $0: error: $CC not found.
$nxt_echo
exit 1;
fi
if `/bin/sh -c "($CC -v)" 2>&1 | grep "gcc version" >> $NXT_AUTOCONF_ERR 2>&1`
then
NXT_CC_NAME=gcc
$nxt_echo " + using GNU C compiler"
NXT_CC_VERSION=`/bin/sh -c "($CC -v)" 2>&1 | grep "gcc version" 2>&1`
$nxt_echo " + $NXT_CC_VERSION"
else
if `/bin/sh -c "($CC -v)" 2>&1 | grep "clang version" >> $NXT_AUTOCONF_ERR 2>&1`
then
NXT_CC_NAME=clang
$nxt_echo " + using Clang C compiler"
NXT_CC_VERSION=`/bin/sh -c "($CC -v)" 2>&1 | grep "clang version" 2>&1`
$nxt_echo " + $NXT_CC_VERSION"
else
if `/bin/sh -c "($CC -v)" 2>&1 \
| grep "Apple LLVM version" >> $NXT_AUTOCONF_ERR 2>&1`
then
NXT_CC_NAME=clang
$nxt_echo " + using Clang C compiler"
NXT_CC_VERSION=`/bin/sh -c "($CC -v)" 2>&1 | grep "Apple LLVM version" 2>&1`
$nxt_echo " + $NXT_CC_VERSION"
else
if `/bin/sh -c "($CC -V)" 2>&1 | grep "Sun C" >> $NXT_AUTOCONF_ERR 2>&1`
then
NXT_CC_NAME=SunC
$nxt_echo " + using Sun C compiler"
NXT_CC_VERSION=`/bin/sh -c "($CC -V)" 2>&1 | grep "Sun C" 2>&1`
$nxt_echo " + $NXT_CC_VERSION"
fi # SunC
fi # Apple LLVM clang
fi # clang
fi # gcc
case $NXT_CC_NAME in
gcc)
nxt_define=NXT_GCC . ${NXT_AUTO}define
NXT_CFLAGS="$NXT_CFLAGS -pipe"
NXT_CFLAGS="$NXT_CFLAGS -fPIC"
# Do not export symbols except explicitly marked with NXT_EXPORT.
NXT_CFLAGS="$NXT_CFLAGS -fvisibility=hidden"
# c99/gnu99 conflict with Solaris XOPEN.
#NXT_CFLAGS="$NXT_CFLAGS -std=gnu99"
NXT_CFLAGS="$NXT_CFLAGS -O"
#NXT_CFLAGS="$NXT_CFLAGS -O0"
NXT_CFLAGS="$NXT_CFLAGS -W -Wall -Wextra"
#NXT_CFLAGS="$NXT_CFLAGS -Wunused-result"
NXT_CFLAGS="$NXT_CFLAGS -Wno-unused-parameter"
#NXT_CFLAGS="$NXT_CFLAGS -Wshorten-64-to-32"
NXT_CFLAGS="$NXT_CFLAGS -Wwrite-strings"
# -O2 enables -fstrict-aliasing and -fstrict-overflow.
#NXT_CFLAGS="$NXT_CFLAGS -O2"
#NXT_CFLAGS="$NXT_CFLAGS -Wno-strict-aliasing"
#NXT_CFLAGS="$NXT_CFLAGS -fomit-frame-pointer"
#NXT_CFLAGS="$NXT_CFLAGS -momit-leaf-frame-pointer"
# -Wstrict-overflow is supported by GCC 4.2+.
#NXT_CFLAGS="$NXT_CFLAGS -Wstrict-overflow=5"
NXT_CFLAGS="$NXT_CFLAGS -Wmissing-prototypes"
# Stop on warning.
NXT_CFLAGS="$NXT_CFLAGS -Werror"
# Debug.
NXT_CFLAGS="$NXT_CFLAGS -g"
;;
clang)
nxt_define=NXT_CLANG . ${NXT_AUTO}define
NXT_CFLAGS="$NXT_CFLAGS -pipe"
NXT_CFLAGS="$NXT_CFLAGS -fPIC"
# Do not export symbols except explicitly marked with NXT_EXPORT.
NXT_CFLAGS="$NXT_CFLAGS -fvisibility=hidden"
NXT_CFLAGS="$NXT_CFLAGS -O"
#NXT_CFLAGS="$NXT_CFLAGS -O0"
NXT_CFLAGS="$NXT_CFLAGS -W -Wall -Wextra"
#NXT_CFLAGS="$NXT_CFLAGS -Wunused-result"
NXT_CFLAGS="$NXT_CFLAGS -Wno-unused-parameter"
#NXT_CFLAGS="$NXT_CFLAGS -Wshorten-64-to-32"
NXT_CFLAGS="$NXT_CFLAGS -Wwrite-strings"
#NXT_CFLAGS="$NXT_CFLAGS -O2"
#NXT_CFLAGS="$NXT_CFLAGS -fomit-frame-pointer"
NXT_CFLAGS="$NXT_CFLAGS -fstrict-aliasing"
NXT_CFLAGS="$NXT_CFLAGS -Wstrict-overflow=5"
NXT_CFLAGS="$NXT_CFLAGS -Wmissing-prototypes"
# Stop on warning.
NXT_CFLAGS="$NXT_CFLAGS -Werror"
# Debug.
if [ "$NXT_SYSTEM_PLATFORM" != "powerpc" ]; then
# "-g" flag causes the "unknown pseudo-op: `.cfi_sections'"
# error on PowerPC Clang.
NXT_CFLAGS="$NXT_CFLAGS -g"
fi
;;
SunC)
nxt_define=NXT_SUNC . ${NXT_AUTO}define
NXT_CFLAGS="$NXT_CFLAGS -fPIC"
# Optimization.
NXT_CFLAGS="$NXT_CFLAGS -O -fast"
# Stop on warning.
NXT_CFLAGS="$NXT_CFLAGS -errwarn=%all"
# Debug.
NXT_CFLAGS="$NXT_CFLAGS -g"
;;
*)
;;
esac
# Stop on error exit status again.
set -e
cat << END >> $NXT_MAKEFILE_CONF
NXT_CC = ${CC}
NXT_CFLAGS = ${CFLAGS} ${NXT_CFLAGS}
END