pkg/kamailio/fedora/16: Updated rel in .spec to dev2
[sip-router] / ccopts.sh
1 #!/bin/sh
2
3 #$Id$
4 #
5 # returns the CFLAGS for the given compiler (maximum optimizations)
6 #
7
8
9 ARCH=`uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/ `
10
11 # gcc 3.x optimize for:
12 x86CPU=athlon
13 WARN_ARCH="WARNING: Not tested on architecture $ARCH, using default flags"
14
15 if [ $# -lt 1 ]
16 then 
17         echo "ERROR: you must specify the compiler name" 1>&2
18         exit 1
19 fi
20
21 if [ "$1" = "-h" ]
22 then
23         echo "Usage: "
24         echo "      $0 compiler_name"
25         exit 1
26 fi
27
28
29 if  CCVER=`./ccver.sh $1` 
30 then
31         NAME=`echo "$CCVER"|cut -d" " -f 1`
32         VER=`echo "$CCVER"|cut -d" " -f 2`
33         MAJOR_VER=`echo "$CCVER"|cut -d" " -f 3`
34 else
35         echo "ERROR executing ./ccver.sh" 2>&1
36         exit 1
37 fi
38
39 echo "name=$NAME, ver=$VER, mver=$MAJOR_VER"
40 case $NAME
41 in
42 gcc) 
43                 #common stuff
44                 CFLAGS="-O9 -funroll-loops -Winline -Wall"
45                 case $MAJOR_VER
46                 in
47                         3)
48                                 case $ARCH
49                                 in
50                                         i386)
51                                                 CFLAGS="$CFLAGS -minline-all-stringops -malign-double"
52                                                 CFLAGS="$CFLAGS -falign-loops -march=$x86CPU"
53                                                 ;;
54                                         sparc64)
55                                                 CFLAGS="$CFLAGS -mcpu=ultrasparc -mtune=ultrasparc"
56                                                 CFLAGS="$CFLAGS -m32"
57                                                 #other interesting options:
58                                                 # -mcpu=v9 or ultrasparc? # -mtune implied by -mcpu
59                                                 #-mno-epilogue #try to inline function exit code
60                                                 #-mflat # omit save/restore
61                                                 #-faster-structs #faster non Sparc ABI structure copy
62                                                 ;;
63                                         armv4l)
64                                                 CFLAGS="$CFLAGS -mcpu=strongarm1100"
65                                                 ;;
66                                                 *)
67                                                 echo "$WARN_ARCH" 1>&2
68                                                 ;;
69                                 esac
70                                 ;;
71                         2|*)
72                                 case $ARCH
73                                 in
74                                         i386)
75                                                 CFLAGS="$CFLAGS -m486 -malign-loops=4"
76                                                 ;;
77                                         sparc64)
78                                                 CFLAGS="$CFLAGS -mv8 -Wa,-xarch=v8plus"
79                                                 ;;
80                                         armv4l)
81                                                 ;;
82                                                 *)
83                                                 echo "$WARN_ARCH" 1>&2
84                                                 ;;
85                                 esac
86                                 ;;
87                 esac
88                 ;;
89
90 icc)
91         CFLAGS="-O3 -ipo -ipo_obj -unroll"
92         case $ARCH
93         in
94                 i386)
95                         CFLAGS="$CFLAGS -tpp6 -xK"
96                         #-openmp  #optimize for PIII 
97                         # -prefetch doesn't seem to work
98                         #( ty to inline acroos files, unroll loops,prefetch,
99                         # optimize for PIII, use PIII instructions & vect.,
100                         # mutlithread loops)
101                 ;;
102                 *)
103                         echo "$WARN_ARCH" 1>&2
104                 ;;
105         esac
106         ;;
107
108 suncc)
109         CFLAGS="-xO5 -fast -native -xCC -xc99"
110         case $ARCH
111         in
112                 sparc64)
113                         CFLAGS="$CFLAGS -xarch=v8plusa"
114                         ;;
115                 *)
116                         echo "$WARN_ARCH" 1>&2
117                         ;;
118         esac
119         ;;
120
121 *)
122         echo "WARNING: unknown compiler $NAME, trying _very_ generic flags" 1>&2
123         CFLAGS="-O2"
124 esac
125
126
127 echo "CFLAGS=$CFLAGS"