summaryrefslogtreecommitdiffhomepage
path: root/auto/cc/test
blob: b1745505507447dd9a866ce4567a63ec8bf4e583 (plain) (blame)
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

# Copyright (C) Igor Sysoev
# Copyright (C) NGINX, Inc.


$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
    $echo
    $echo $0: error: $CC not found.
    $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
    $echo " + using GNU C compiler"
    NXT_CC_VERSION=`/bin/sh -c "($CC -v)" 2>&1 | grep "gcc version" 2>&1`
    $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
    $echo " + using Clang C compiler"
    NXT_CC_VERSION=`/bin/sh -c "($CC -v)" 2>&1 | grep "clang version" 2>&1`
    $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
    $echo " + using Clang C compiler"
    NXT_CC_VERSION=`/bin/sh -c "($CC -v)" 2>&1 | grep "Apple LLVM version" 2>&1`
    $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
    $echo " + using Sun C compiler"
    NXT_CC_VERSION=`/bin/sh -c "($CC -V)" 2>&1 | grep "Sun C" 2>&1`
    $echo " + $NXT_CC_VERSION"

else
if `/bin/sh -c "($CC -qversion)" 2>&1 \
                | grep "^IBM XL" >> $NXT_AUTOCONF_ERR 2>&1`
then
    NXT_CC_NAME=xlC
    $echo " + using AIX xlC compiler"
    NXT_CC_VERSION=`/bin/sh -c "($CC -qversion)" 2>&1 | grep "IBM XL" 2>&1`
    $echo " + $NXT_CC_VERSION"

else
    NXT_CC_NAME=cc
    NXT_CC_VERSION=cc

fi # xlC
fi # SunC
fi # Apple LLVM clang
fi # clang
fi # gcc


case $NXT_CC_NAME in

    gcc)
        nxt_have=NXT_GCC . auto/have

        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_have=NXT_CLANG . auto/have

        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_have=NXT_SUNC . auto/have

        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"
    ;;

    xlC)
        nxt_have=NXT_XLC . auto/have

        #NXT_CFLAGS="$NXT_CFLAGS -qalloca"
        # alloca support.
        NXT_CFLAGS="$NXT_CFLAGS -qlanglvl=extc99"
        # __thread support.
        NXT_CFLAGS="$NXT_CFLAGS -qtls"
        # Suppress warning
        #    1506-159 (E) Bit field type specified for XXX is not valid.
        #    Type unsigned assumed.
        NXT_CFLAGS="$NXT_CFLAGS -qsuppress=1506-159"
    ;;

    *)
    ;;

esac

# Stop on error exit status again.
set -e