gcc revision e18a033b
1
2# Copyright (C) Igor Sysoev
3# Copyright (C) Nginx, Inc.
4
5
6# gcc 2.7.2.3, 2.8.1, 2.95.4, egcs-1.1.2
7#     3.0.4, 3.1.1, 3.2.3, 3.3.2, 3.3.3, 3.3.4, 3.4.0, 3.4.2
8#     4.0.0, 4.0.1, 4.1.0
9
10
11NGX_GCC_VER=`$CC -v 2>&1 | grep 'gcc version' 2>&1 \
12                         | sed -e 's/^.* version \(.*\)/\1/'`
13
14echo " + gcc version: $NGX_GCC_VER"
15
16have=NGX_COMPILER value="\"gcc $NGX_GCC_VER\"" . auto/define
17
18
19# Solaris 7's /usr/ccs/bin/as does not support "-pipe"
20
21CC_TEST_FLAGS="-pipe"
22
23ngx_feature="gcc -pipe switch"
24ngx_feature_name=
25ngx_feature_run=no
26ngx_feature_incs=
27ngx_feature_path=
28ngx_feature_libs=
29ngx_feature_test=
30. auto/feature
31
32CC_TEST_FLAGS=
33
34if [ $ngx_found = yes ]; then
35    PIPE="-pipe"
36fi
37
38
39case "$NGX_MACHINE" in
40
41    sun4u | sun4v | sparc | sparc64 )
42        # "-mcpu=v9" enables the "casa" assembler instruction
43        CFLAGS="$CFLAGS -mcpu=v9"
44    ;;
45
46esac
47
48
49# optimizations
50
51#NGX_GCC_OPT="-O2"
52#NGX_GCC_OPT="-Os"
53NGX_GCC_OPT="-O"
54
55#CFLAGS="$CFLAGS -fomit-frame-pointer"
56
57case $CPU in
58    pentium)
59        # optimize for Pentium and Athlon
60        CPU_OPT="-march=pentium"
61        NGX_CPU_CACHE_LINE=32
62    ;;
63
64    pentiumpro | pentium3)
65        # optimize for Pentium Pro, Pentium II and Pentium III
66        CPU_OPT="-march=pentiumpro"
67        NGX_CPU_CACHE_LINE=32
68    ;;
69
70    pentium4)
71        # optimize for Pentium 4, gcc 3.x
72        CPU_OPT="-march=pentium4"
73        NGX_CPU_CACHE_LINE=128
74    ;;
75
76    athlon)
77        # optimize for Athlon, gcc 3.x
78        CPU_OPT="-march=athlon"
79        NGX_CPU_CACHE_LINE=64
80    ;;
81
82    opteron)
83        # optimize for Opteron, gcc 3.x
84        CPU_OPT="-march=opteron"
85        NGX_CPU_CACHE_LINE=64
86    ;;
87
88    sparc32)
89        # build 32-bit UltraSparc binary
90        CPU_OPT="-m32"
91        CORE_LINK="$CORE_LINK -m32"
92        NGX_CPU_CACHE_LINE=64
93    ;;
94
95    sparc64)
96        # build 64-bit UltraSparc binary
97        CPU_OPT="-m64"
98        CORE_LINK="$CORE_LINK -m64"
99        NGX_CPU_CACHE_LINE=64
100    ;;
101
102    ppc64)
103        # build 64-bit PowerPC binary
104        CPU_OPT="-m64"
105        CPU_OPT="$CPU_OPT -falign-functions=32 -falign-labels=32"
106        CPU_OPT="$CPU_OPT -falign-loops=32 -falign-jumps=32"
107        CORE_LINK="$CORE_LINK -m64"
108        NGX_CPU_CACHE_LINE=128
109    ;;
110
111esac
112
113CC_AUX_FLAGS="$CC_AUX_FLAGS $CPU_OPT"
114
115case "$NGX_GCC_VER" in
116    2.7*)
117        # batch build
118        CPU_OPT=
119    ;;
120esac
121
122
123CFLAGS="$CFLAGS $PIPE $CPU_OPT"
124
125if [ ".$PCRE_OPT" = "." ]; then
126    PCRE_OPT="-O2 -fomit-frame-pointer $PIPE $CPU_OPT"
127else
128    PCRE_OPT="$PCRE_OPT $PIPE"
129fi
130
131if [ ".$ZLIB_OPT" = "." ]; then
132    ZLIB_OPT="-O2 -fomit-frame-pointer $PIPE $CPU_OPT"
133else
134    ZLIB_OPT="$ZLIB_OPT $PIPE"
135fi
136
137
138# warnings
139
140# -W requires at least -O
141CFLAGS="$CFLAGS ${NGX_GCC_OPT:--O} -W"
142
143CFLAGS="$CFLAGS -Wall -Wpointer-arith"
144#CFLAGS="$CFLAGS -Wconversion"
145#CFLAGS="$CFLAGS -Winline"
146#CFLAGS="$CFLAGS -Wmissing-prototypes"
147
148case "$NGX_GCC_VER" in
149    2.*)
150        # we have a lot of the unused function arguments
151        CFLAGS="$CFLAGS -Wno-unused"
152    ;;
153
154    *)
155        # we have a lot of the unused function arguments
156        CFLAGS="$CFLAGS -Wno-unused-parameter"
157        # 4.2.1 shows the warning in wrong places
158        #CFLAGS="$CFLAGS -Wunreachable-code"
159
160        # deprecated system OpenSSL library on OS X
161        if [ "$NGX_SYSTEM" = "Darwin" ]; then
162            CFLAGS="$CFLAGS -Wno-deprecated-declarations"
163        fi
164    ;;
165esac
166
167
168# stop on warning
169CFLAGS="$CFLAGS -Werror"
170
171# debug
172CFLAGS="$CFLAGS -g"
173
174# DragonFly's gcc3 generates DWARF
175#CFLAGS="$CFLAGS -g -gstabs"
176
177if [ ".$CPP" = "." ]; then
178    CPP="$CC -E"
179fi
180