blob: 46b0aabb93cb26f84e70b3277c4bd740502a0a3b [file] [log] [blame]
Igor Sysoevc0edbcc2004-10-21 15:34:38 +00001
2# Copyright (C) Igor Sysoev
3
4
Igor Sysoevc1571722005-03-19 12:38:37 +00005# gcc 2.7.2.3, 2.8.1, 2.95.4, egcs-1.1.2
Igor Sysoev11d75322005-03-01 15:20:36 +00006# 3.0.4, 3.1.1, 3.2.3, 3.3.2, 3.3.3, 3.3.4, 3.4.0, 3.4.2
Igor Sysoevc1571722005-03-19 12:38:37 +00007# 4.0.0
8
9
10NGX_GCC_VER=`$CC -v 2>&1 | grep 'gcc version' 2>&1 \
11 | sed -e 's/^.* version \(.*\)/\1/'`
12
13echo " + gcc version: $NGX_GCC_VER"
Igor Sysoevc0edbcc2004-10-21 15:34:38 +000014
15
16# Solaris 7's /usr/ccs/bin/as does not support "-pipe"
17
18CC_TEST_FLAGS="-pipe"
19
20ngx_feature="gcc -pipe switch"
21ngx_feature_name=
22ngx_feature_run=no
23ngx_feature_incs=
24ngx_feature_libs=
25ngx_feature_test=
26. auto/feature
27
28CC_TEST_FLAGS=
29
30if [ $ngx_found = yes ]; then
31 PIPE="-pipe"
32fi
33
Igor Sysoevc0edbcc2004-10-21 15:34:38 +000034# optimizations
35
Igor Sysoevaa828612005-02-09 14:31:07 +000036#NGX_GCC_OPT="-O2"
37#NGX_GCC_OPT="-Os"
38NGX_GCC_OPT="-O"
39
40CFLAGS="$CFLAGS $NGX_GCC_OPT"
41
42#CFLAGS="$CFLAGS -fomit-frame-pointer"
Igor Sysoevc0edbcc2004-10-21 15:34:38 +000043
44case $CPU in
45 pentium)
46 # optimize for Pentium and Athlon
47 CPU_OPT="-march=pentium"
48 ;;
49
50 pentiumpro)
51 # optimize for Pentium Pro, Pentium II and Pentium III
52 CPU_OPT="-march=pentiumpro"
53 ;;
54
55 pentium4)
56 # optimize for Pentium 4, gcc 3.x
57 CPU_OPT="-march=pentium4"
58 ;;
59
60 sparc64)
61 # build 64-bit UltraSparc binary
62 CPU_OPT="-m64"
63 CORE_LINK="$CORE_LINK -m64"
64 CC_AUX_FLAGS="$CC_AUX_FLAGS -m64"
65 ;;
66
67esac
68
69
Igor Sysoevc1571722005-03-19 12:38:37 +000070case "$NGX_GCC_VER" in
71 2.7*)
72 # batch build
73 CPU_OPT=
74 ;;
75esac
Igor Sysoevc0edbcc2004-10-21 15:34:38 +000076
77
78CFLAGS="$CFLAGS $PIPE $CPU_OPT"
79
80if [ ".$PCRE_OPT" = "." ]; then
81 PCRE_OPT="-O2 -fomit-frame-pointer $PIPE $CPU_OPT"
82else
83 PCRE_OPT="$PCRE_OPT $PIPE"
84fi
85
86if [ ".$MD5_OPT" = "." ]; then
87 MD5_OPT="-O2 -fomit-frame-pointer $PIPE $CPU_OPT"
88else
89 MD5_OPT="$MD5_OPT $PIPE"
90fi
91
92if [ ".$ZLIB_OPT" = "." ]; then
93 ZLIB_OPT="-O2 -fomit-frame-pointer $PIPE $CPU_OPT"
94else
95 ZLIB_OPT="$ZLIB_OPT $PIPE"
96fi
97
98
99# warnings
100
Igor Sysoevaa828612005-02-09 14:31:07 +0000101# -W requires at least -O
102CFLAGS="$CFLAGS ${NGX_GCC_OPT:-O} -W"
103
Igor Sysoevc0edbcc2004-10-21 15:34:38 +0000104CFLAGS="$CFLAGS -Wall -Wpointer-arith"
105#CFLAGS="$CFLAGS -Wconversion"
106#CFLAGS="$CFLAGS -Winline"
107
Igor Sysoevc1571722005-03-19 12:38:37 +0000108
109case "$NGX_GCC_VER" in
110 3.* | 4.* )
111 # we have a lot of the unused function arguments
112 CFLAGS="$CFLAGS -Wno-unused-parameter"
113 CFLAGS="$CFLAGS -Wno-unused-function"
114 #CFLAGS="$CFLAGS -Wunreachable-code"
115 ;;
116
117 *)
118 # we have a lot of the unused function arguments
119 CFLAGS="$CFLAGS -Wno-unused"
120 ;;
121esac
122
Igor Sysoevc0edbcc2004-10-21 15:34:38 +0000123
124# stop on warning
125CFLAGS="$CFLAGS -Werror"
126
127# debug
128CFLAGS="$CFLAGS -g"
129
130# DragonFly's gcc3 generates DWARF
131#CFLAGS="$CFLAGS -g -gstabs"
132
133if [ ".$CPP" = "." ]; then
134 CPP="$CC -E"
135fi