Klaus Demo nginx / 8dd36f4
Merge of r4763: added the Clang compiler support. The -Werror is commented out to not break builds on Linux. Maxim Dounin 9 years ago
3 changed file(s) with 108 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0
1 # Copyright (C) Nginx, Inc.
2
3
4 # clang
5
6
7 NGX_CLANG_VER=`$CC -v 2>&1 | grep 'clang version' 2>&1 \
8 | sed -e 's/^.*clang version \(.*\)/\1/'`
9
10 echo " + clang version: $NGX_CLANG_VER"
11
12 have=NGX_COMPILER value="\"clang $NGX_CLANG_VER\"" . auto/define
13
14
15 CC_TEST_FLAGS="-pipe"
16
17
18 # optimizations
19
20 #NGX_CLANG_OPT="-O2"
21 #NGX_CLANG_OPT="-Oz"
22 NGX_CLANG_OPT="-O"
23
24 case $CPU in
25 pentium)
26 # optimize for Pentium
27 CPU_OPT="-march=pentium"
28 NGX_CPU_CACHE_LINE=32
29 ;;
30
31 pentiumpro | pentium3)
32 # optimize for Pentium Pro, Pentium II and Pentium III
33 CPU_OPT="-march=pentiumpro"
34 NGX_CPU_CACHE_LINE=32
35 ;;
36
37 pentium4)
38 # optimize for Pentium 4
39 CPU_OPT="-march=pentium4"
40 NGX_CPU_CACHE_LINE=128
41 ;;
42
43 athlon)
44 # optimize for Athlon
45 CPU_OPT="-march=athlon"
46 NGX_CPU_CACHE_LINE=64
47 ;;
48
49 opteron)
50 # optimize for Opteron
51 CPU_OPT="-march=opteron"
52 NGX_CPU_CACHE_LINE=64
53 ;;
54
55 esac
56
57 CC_AUX_FLAGS="$CC_AUX_FLAGS $CPU_OPT"
58
59
60 CFLAGS="$CFLAGS -pipe $CPU_OPT"
61
62 if [ ".$PCRE_OPT" = "." ]; then
63 PCRE_OPT="-O2 -pipe $CPU_OPT"
64 else
65 PCRE_OPT="$PCRE_OPT -pipe"
66 fi
67
68 if [ ".$MD5_OPT" = "." ]; then
69 MD5_OPT="-O2 -pipe $CPU_OPT"
70 else
71 MD5_OPT="$MD5_OPT -pipe"
72 fi
73
74 if [ ".$ZLIB_OPT" = "." ]; then
75 ZLIB_OPT="-O2 -pipe $CPU_OPT"
76 else
77 ZLIB_OPT="$ZLIB_OPT -pipe"
78 fi
79
80
81 # warnings
82
83 CFLAGS="$CFLAGS $NGX_CLANG_OPT -Wall -Wextra -Wpointer-arith"
84 #CFLAGS="$CFLAGS -Wmissing-prototypes"
85
86 # we have a lot of unused function arguments
87 CFLAGS="$CFLAGS -Wno-unused-parameter"
88
89 # stop on warning
90 #CFLAGS="$CFLAGS -Werror"
91
92 # debug
93 CFLAGS="$CFLAGS -g"
94
95 if [ ".$CPP" = "." ]; then
96 CPP="$CC -E"
97 fi
5353 # 4.0.0, 4.0.1, 4.1.0
5454
5555 . auto/cc/gcc
56 ;;
57
58 clang)
59 # Clang C compiler
60
61 . auto/cc/clang
5662 ;;
5763
5864 icc)
6666 NGX_CC_NAME=gcc
6767 echo " + using GNU C compiler"
6868
69 elif `$CC -v 2>&1 | grep 'clang version' >/dev/null 2>&1`; then
70 NGX_CC_NAME=clang
71 echo " + using Clang C compiler"
72
6973 elif `$CC -V 2>&1 | grep 'Sun C' >/dev/null 2>&1`; then
7074 NGX_CC_NAME=sunc
7175 echo " + using Sun C compiler"