- added test cc ver & options scripts ser_0_8_10_pre4
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Thu, 7 Nov 2002 15:26:11 +0000 (15:26 +0000)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Thu, 7 Nov 2002 15:26:11 +0000 (15:26 +0000)
ccopts.sh [new file with mode: 0755]
ccver.sh [new file with mode: 0755]

diff --git a/ccopts.sh b/ccopts.sh
new file mode 100755 (executable)
index 0000000..39e5ef7
--- /dev/null
+++ b/ccopts.sh
@@ -0,0 +1,127 @@
+#!/bin/sh
+
+#$Id$
+#
+# returns the CFLAGS for the given compiler (maximum optimizations)
+#
+
+
+ARCH=`uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/ `
+
+# gcc 3.x optimize for:
+x86CPU=athlon
+WARN_ARCH="WARNING: Not tested on architecture $ARCH, using default flags"
+
+if [ $# -lt 1 ]
+then 
+       echo "ERROR: you must specify the compiler name" 1>&2
+       exit 1
+fi
+
+if [ "$1" = "-h" ]
+then
+       echo "Usage: "
+       echo "      $0 compiler_name"
+       exit 1
+fi
+
+
+if  CCVER=`./ccver.sh $1` 
+then
+       NAME=`echo "$CCVER"|cut -d" " -f 1`
+       VER=`echo "$CCVER"|cut -d" " -f 2`
+       MAJOR_VER=`echo "$CCVER"|cut -d" " -f 3`
+else
+       echo "ERROR executing ./ccver.sh" 2>&1
+       exit 1
+fi
+
+echo "name=$NAME, ver=$VER, mver=$MAJOR_VER"
+case $NAME
+in
+gcc) 
+               #common stuff
+               CFLAGS="-O9 -funroll-loops -Winline -Wall"
+               case $MAJOR_VER
+               in
+                       3)
+                               case $ARCH
+                               in
+                                       i386)
+                                               CFLAGS="$CFLAGS -minline-all-stringops -malign-double"
+                                               CFLAGS="$CFLAGS -falign-loops -march=$x86CPU"
+                                               ;;
+                                       sparc64)
+                                               CFLAGS="$CFLAGS -mcpu=ultrasparc -mtune=ultrasparc"
+                                               CFLAGS="$CFLAGS -m32"
+                                               #other interesting options:
+                                               # -mcpu=v9 or ultrasparc? # -mtune implied by -mcpu
+                                               #-mno-epilogue #try to inline function exit code
+                                               #-mflat # omit save/restore
+                                               #-faster-structs #faster non Sparc ABI structure copy
+                                               ;;
+                                       armv4l)
+                                               CFLAGS="$CFLAGS -mcpu=strongarm1100"
+                                               ;;
+                                               *)
+                                               echo "$WARN_ARCH" 1>&2
+                                               ;;
+                               esac
+                               ;;
+                       2|*)
+                               case $ARCH
+                               in
+                                       i386)
+                                               CFLAGS="$CFLAGS -m486 -malign-loops=4"
+                                               ;;
+                                       sparc64)
+                                               CFLAGS="$CFLAGS -mv8 -Wa,-xarch=v8plus"
+                                               ;;
+                                       armv4l)
+                                               ;;
+                                               *)
+                                               echo "$WARN_ARCH" 1>&2
+                                               ;;
+                               esac
+                               ;;
+               esac
+               ;;
+
+icc)
+       CFLAGS="-O3 -ipo -ipo_obj -unroll"
+       case $ARCH
+       in
+               i386)
+                       CFLAGS="$CFLAGS -tpp6 -xK"
+                       #-openmp  #optimize for PIII 
+                       # -prefetch doesn't seem to work
+                       #( ty to inline acroos files, unroll loops,prefetch,
+                       # optimize for PIII, use PIII instructions & vect.,
+                       # mutlithread loops)
+               ;;
+               *)
+                       echo "$WARN_ARCH" 1>&2
+               ;;
+       esac
+       ;;
+
+suncc)
+       CFLAGS="-xO5 -fast -native -xCC -xc99"
+       case $ARCH
+       in
+               sparc64)
+                       CFLAGS="$CFLAGS -xarch=v8plusa"
+                       ;;
+               *)
+                       echo "$WARN_ARCH" 1>&2
+                       ;;
+       esac
+       ;;
+
+*)
+       echo "WARNING: unknown compiler $NAME, trying _very_ generic flags" 1>&2
+       CFLAGS="-O2"
+esac
+
+
+echo "CFLAGS=$CFLAGS"
diff --git a/ccver.sh b/ccver.sh
new file mode 100755 (executable)
index 0000000..78cfc58
--- /dev/null
+++ b/ccver.sh
@@ -0,0 +1,83 @@
+#!/bin/sh
+
+#$Id$
+#
+# finds CC version and prints it in the following format:
+# compiler_name version major_version
+#
+
+
+
+if [ $# -lt 1 ]
+then 
+       echo "Error: you must specify the compiler name" 1>&2
+       exit 1
+fi
+
+if [ "$1" = "-h" ]
+then
+       echo "Usage: "
+       echo "      $0 compiler_name"
+       exit 1
+fi
+
+
+CC=$1
+
+if  which $CC >/dev/null
+then
+       (test ! -x `which $CC`) && echo "Error: $CC not executable" 1>&2 && exit 1
+else
+       echo "Error: $CC not found or not executable" 1>&2
+       exit 1 
+fi
+
+
+if $CC -v 2>/dev/null 1>/dev/null
+then
+       FULLVER=`$CC -v 2>&1` 
+else
+       FULLVER=`$CC -V 2>&1`
+fi
+
+
+
+if [ -n "$FULLVER" ]
+then
+       # check if gcc
+       if echo "$FULLVER"|grep gcc >/dev/null
+       then
+               NAME=gcc
+               VER=`$CC --version|head -1| \
+                               sed -e 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/'\
+                                   -e 's/.*[^.0-9]\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/'`
+       elif echo "$FULLVER"|grep Sun >/dev/null
+       then
+               NAME=suncc
+               VER=`echo "$FULLVER"|head -1| \
+                               sed -e 's/.*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/'`
+       elif echo "$FULLVER"|grep "Intel(R) C++ Compiler" >/dev/null
+       then
+               NAME=icc
+               VER=`echo "$FULLVER"|head -1| \
+                               sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/' ` 
+       fi
+       
+       # find major ver
+       if [  -n "$VER"  -a -z "$MAJOR_VER" ]
+       then
+               MAJOR_VER=`echo "$VER" |cut -d. -f1`
+       fi
+fi     
+
+
+#unknown
+if [ -z "$NAME" ]
+then
+       NAME="unknown"
+       VER="unknown"
+       MAJOR_VER="unkown"
+fi
+
+
+echo "$NAME $VER $MAJOR_VER"