1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
|
# Copyright (C) Igor Sysoev
# Copyright (C) NGINX, Inc.
echo checking for C compiler: $CC
cat << END >> $NJS_AUTOCONF_ERR
----------------------------------------
checking for C compiler: $CC
END
# Allow error exit status.
set +e
if [ -z "$(which $CC)" ]; then
echo
echo $0: error: $CC not found.
echo
exit 1;
fi
if `/bin/sh -c "($CC -v)" 2>&1 | grep "gcc version" >> $NJS_AUTOCONF_ERR 2>&1`
then
NJS_CC_NAME=gcc
echo " + using GNU C compiler"
NJS_CC_VERSION=`/bin/sh -c "($CC -v)" 2>&1 | grep "gcc version" 2>&1`
echo " + $NJS_CC_VERSION"
else
if `/bin/sh -c "($CC -v)" 2>&1 | grep "clang version" >> $NJS_AUTOCONF_ERR 2>&1`
then
NJS_CC_NAME=clang
echo " + using Clang C compiler"
NJS_CC_VERSION=`/bin/sh -c "($CC -v)" 2>&1 | grep "clang version" 2>&1`
echo " + $NJS_CC_VERSION"
else
if `/bin/sh -c "($CC -v)" 2>&1 \
| grep "Apple LLVM version" >> $NJS_AUTOCONF_ERR 2>&1`
then
NJS_CC_NAME=clang
echo " + using Clang C compiler"
NJS_CC_VERSION=`/bin/sh -c "($CC -v)" 2>&1 | grep "Apple LLVM version" 2>&1`
echo " + $NJS_CC_VERSION"
else
if `/bin/sh -c "($CC -V)" 2>&1 | grep "Sun C" >> $NJS_AUTOCONF_ERR 2>&1`
then
NJS_CC_NAME=SunC
echo " + using Sun C compiler"
NJS_CC_VERSION=`/bin/sh -c "($CC -V)" 2>&1 | grep "Sun C" 2>&1`
echo " + $NJS_CC_VERSION"
fi # SunC
fi # Apple LLVM clang
fi # clang
fi # gcc
case $NJS_CC_NAME in
gcc)
njs_define=NJS_GCC . auto/define
NJS_CFLAGS="$NJS_CFLAGS -pipe"
NJS_CFLAGS="$NJS_CFLAGS -fPIC"
# Do not export symbols except explicitly marked with NJS_EXPORT.
NJS_CFLAGS="$NJS_CFLAGS -fvisibility=hidden"
# c99/gnu99 conflict with Solaris XOPEN.
#NJS_CFLAGS="$NJS_CFLAGS -std=gnu99"
NJS_CFLAGS="$NJS_CFLAGS -O"
#NJS_CFLAGS="$NJS_CFLAGS -O0"
NJS_CFLAGS="$NJS_CFLAGS -W -Wall -Wextra"
#NJS_CFLAGS="$NJS_CFLAGS -Wunused-result"
NJS_CFLAGS="$NJS_CFLAGS -Wno-unused-parameter"
#NJS_CFLAGS="$NJS_CFLAGS -Wshorten-64-to-32"
NJS_CFLAGS="$NJS_CFLAGS -Wwrite-strings"
# -O2 enables -fstrict-aliasing and -fstrict-overflow.
#NJS_CFLAGS="$NJS_CFLAGS -O2"
#NJS_CFLAGS="$NJS_CFLAGS -Wno-strict-aliasing"
#NJS_CFLAGS="$NJS_CFLAGS -fomit-frame-pointer"
#NJS_CFLAGS="$NJS_CFLAGS -momit-leaf-frame-pointer"
# -Wstrict-overflow is supported by GCC 4.2+.
#NJS_CFLAGS="$NJS_CFLAGS -Wstrict-overflow=5"
NJS_CFLAGS="$NJS_CFLAGS -Wmissing-prototypes"
# Stop on warning.
NJS_CFLAGS="$NJS_CFLAGS -Werror"
# Debug.
NJS_CFLAGS="$NJS_CFLAGS -g"
if [ "$NJS_ADDRESS_SANITIZER" = "YES" ]; then
NJS_CFLAGS="$NJS_CFLAGS -fsanitize=address"
NJS_CFLAGS="$NJS_CFLAGS -fno-omit-frame-pointer"
fi
;;
clang)
njs_define=NJS_CLANG . auto/define
NJS_CFLAGS="$NJS_CFLAGS -pipe"
NJS_CFLAGS="$NJS_CFLAGS -fPIC"
# Do not export symbols except explicitly marked with NJS_EXPORT.
NJS_CFLAGS="$NJS_CFLAGS -fvisibility=hidden"
NJS_CFLAGS="$NJS_CFLAGS -O"
#NJS_CFLAGS="$NJS_CFLAGS -O0"
NJS_CFLAGS="$NJS_CFLAGS -W -Wall -Wextra"
#NJS_CFLAGS="$NJS_CFLAGS -Wunused-result"
NJS_CFLAGS="$NJS_CFLAGS -Wno-unused-parameter"
#NJS_CFLAGS="$NJS_CFLAGS -Wshorten-64-to-32"
NJS_CFLAGS="$NJS_CFLAGS -Wwrite-strings"
#NJS_CFLAGS="$NJS_CFLAGS -O2"
#NJS_CFLAGS="$NJS_CFLAGS -fomit-frame-pointer"
NJS_CFLAGS="$NJS_CFLAGS -fstrict-aliasing"
NJS_CFLAGS="$NJS_CFLAGS -Wstrict-overflow=5"
NJS_CFLAGS="$NJS_CFLAGS -Wmissing-prototypes"
# Stop on warning.
NJS_CFLAGS="$NJS_CFLAGS -Werror"
# Debug.
if [ "$NJS_SYSTEM_PLATFORM" != "powerpc" ]; then
# "-g" flag causes the "unknown pseudo-op: `.cfi_sections'"
# error on PowerPC Clang.
NJS_CFLAGS="$NJS_CFLAGS -g"
fi
if [ "$NJS_ADDRESS_SANITIZER" = "YES" ]; then
NJS_CFLAGS="$NJS_CFLAGS -fsanitize=address"
NJS_CFLAGS="$NJS_CFLAGS -fno-omit-frame-pointer"
NJS_CFLAGS="$NJS_CFLAGS -fsanitize-address-use-after-scope"
fi
;;
SunC)
njs_define=NJS_SUNC . auto/define
NJS_CFLAGS="$NJS_CFLAGS -fPIC"
# Optimization.
NJS_CFLAGS="$NJS_CFLAGS -O -fast"
# Stop on warning.
NJS_CFLAGS="$NJS_CFLAGS -errwarn=%all"
# Debug.
NJS_CFLAGS="$NJS_CFLAGS -g"
if [ "$NJS_ADDRESS_SANITIZER" = "YES" ]; then
echo " - Address sanitizer is not supported by $NJS_CC_NAME"
fi
;;
*)
;;
esac
if [ "$NJS_DEBUG" = "YES" ]; then
njs_define=NJS_DEBUG . auto/define
fi
if [ "$NJS_DEBUG_MEMORY" = "YES" ]; then
njs_define=NJS_DEBUG_MEMORY . auto/define
fi
if [ "$NJS_DEBUG_OPCODE" = "YES" ]; then
njs_define=NJS_DEBUG_OPCODE . auto/define
fi
if [ "$NJS_DEBUG_GENERATOR" = "YES" ]; then
njs_define=NJS_DEBUG_GENERATOR . auto/define
fi
# Stop on error exit status again.
set -e
|