sunc revision e18a033b
1
2# Copyright (C) Igor Sysoev
3# Copyright (C) Nginx, Inc.
4
5
6# Sun C 5.7 Patch 117837-04 2005/05/11    Sun Studio 10
7# Sun C 5.8 2005/10/13                    Sun Studio 11
8# Sun C 5.9 SunOS_i386 2007/05/03         Sun Studio 12
9# Sun C 5.9 SunOS_sparc 2007/05/03
10# Sun C 5.10 SunOS_i386 2009/06/03        Sun Studio 12.1
11# Sun C 5.11 SunOS_i386 2010/08/13        Sun Studio 12.2
12
13NGX_SUNC_VER=`$CC -V 2>&1 | grep 'Sun C' 2>&1 \
14                          | sed -e 's/^.* Sun C \(.*\)/\1/'`
15
16echo " + Sun C version: $NGX_SUNC_VER"
17
18have=NGX_COMPILER value="\"Sun C $NGX_SUNC_VER\"" . auto/define
19
20
21cat << END > $NGX_AUTOTEST.c
22
23int main(void) {
24    printf("%d", __SUNPRO_C);
25    return 0;
26}
27
28END
29
30eval "$CC -o $NGX_AUTOTEST $NGX_AUTOTEST.c >> $NGX_ERR 2>&1"
31
32if [ -x $NGX_AUTOTEST ]; then
33    ngx_sunc_ver=`$NGX_AUTOTEST`
34fi
35
36rm -rf $NGX_AUTOTEST*
37
38# 1424 == 0x590, Sun Studio 12
39
40if [ "$ngx_sunc_ver" -ge 1424 ]; then
41    ngx_sparc32="-m32"
42    ngx_sparc64="-m64"
43    ngx_amd64="-m64"
44
45else
46    ngx_sparc32="-xarch=v8plus"
47    ngx_sparc64="-xarch=v9"
48    ngx_amd64="-xarch=amd64"
49fi
50
51case "$NGX_MACHINE" in
52
53    i86pc)
54        NGX_AUX=" src/os/unix/ngx_sunpro_x86.il"
55    ;;
56
57    sun4u | sun4v)
58        NGX_AUX=" src/os/unix/ngx_sunpro_sparc64.il"
59    ;;
60
61esac
62
63MAIN_LINK=
64MODULE_LINK="-G"
65
66
67# optimizations
68
69# 20736 == 0x5100, Sun Studio 12.1
70
71if [ "$ngx_sunc_ver" -ge 20736 ]; then
72    ngx_fast="-fast"
73
74else
75    # older versions had problems with bit-fields
76    ngx_fast="-fast -xalias_level=any"
77fi
78
79IPO=-xipo
80CFLAGS="$CFLAGS $ngx_fast $IPO"
81CORE_LINK="$CORE_LINK $ngx_fast $IPO"
82
83
84case $CPU in
85    pentium)
86        # optimize for Pentium and Athlon
87        CPU_OPT="-xchip=pentium"
88    ;;
89
90    pentiumpro)
91        # optimize for Pentium Pro, Pentium II
92        CPU_OPT="-xchip=pentium_pro"
93    ;;
94
95    pentium3)
96        # optimize for Pentium III
97        CPU_OPT="-xchip=pentium3"
98        #CPU_OPT="$CPU_OPT -xarch=sse"
99        CPU_OPT="$CPU_OPT -xcache=16/32/4:256/32/4"
100    ;;
101
102    pentium4)
103        # optimize for Pentium 4
104        CPU_OPT="-xchip=pentium4"
105        #CPU_OPT="$CPU_OPT -xarch=sse2"
106        CPU_OPT="$CPU_OPT -xcache=8/64/4:256/128/8"
107    ;;
108
109    opteron)
110        # optimize for Opteron
111        CPU_OPT="-xchip=opteron"
112        #CPU_OPT="$CPU_OPT -xarch=sse2"
113        CPU_OPT="$CPU_OPT -xcache=64/64/2:1024/64/16"
114    ;;
115
116    sparc32)
117        # build 32-bit UltraSparc binary
118        CPU_OPT="$ngx_sparc32"
119        CORE_LINK="$CORE_LINK $ngx_sparc32"
120        CC_AUX_FLAGS="$CC_AUX_FLAGS $ngx_sparc32"
121        NGX_CPU_CACHE_LINE=64
122    ;;
123
124    sparc64)
125        # build 64-bit UltraSparc binary
126        CPU_OPT="$ngx_sparc64"
127        CORE_LINK="$CORE_LINK $ngx_sparc64"
128        CC_AUX_FLAGS="$CC_AUX_FLAGS $ngx_sparc64"
129        NGX_CPU_CACHE_LINE=64
130    ;;
131
132    amd64)
133        # build 64-bit amd64 binary
134        CPU_OPT="$ngx_amd64"
135        CORE_LINK="$CORE_LINK $ngx_amd64"
136        CC_AUX_FLAGS="$CC_AUX_FLAGS $ngx_amd64"
137        NGX_AUX=" src/os/unix/ngx_sunpro_amd64.il"
138        NGX_CPU_CACHE_LINE=64
139    ;;
140
141esac
142
143
144CFLAGS="$CFLAGS $CPU_OPT"
145
146
147if [ ".$PCRE_OPT" = "." ]; then
148    PCRE_OPT="$ngx_fast $IPO $CPU_OPT"
149fi
150
151if [ ".$ZLIB_OPT" = "." ]; then
152    ZLIB_OPT="$ngx_fast $IPO $CPU_OPT"
153fi
154
155
156# stop on warning
157CFLAGS="$CFLAGS -errwarn=%all"
158
159# debug
160CFLAGS="$CFLAGS -g"
161