#!/bin/sh

#
# here we try to figure out the best optimization flags for compiler
# I am quessing a lot here so comments are more than welcome.
#
# Antti Barck <proff@iki.fi> 12/1997
#

#
# usage: cflags <cpu> <os>
#        cflags --help
#
flaggies="(default)"


case $1 in 
  --help)
  cat << __HELP__

  usage: cflags <cpu> <os>

  known combinations:
  
                alpha linux
                      osf
	              ultrix
                sparc sunos
                i386  linux
                i486  
                i586
		
__HELP__
;;
  alpha)
    case $2 in
      linux*)
        # gcc-2.7 for alpha compiles slower code 
	# with any optimization level over -O2
        flaggies="-Wall -O2"
        ;;
      osf*)
        # (umm, you can run gcc on OSF as well?!)
        flaggies="-O3"
        ;;
      ultrix*)
        # Does this happen?!
        flaggies="-O2"
        ;;
    esac
    ;;
  sparc)
    case $2 in
      sunos*)
        # what about gcc?!
        flaggies="-O3 -s"
        ;;
    esac
    ;;
  i386)
    case $2 in
      linux*)
        flaggies="-Wall -O3"
        ;;
    esac
    ;;   
  i486)
    case $2 in
      linux*)
        flaggies="-Wall -O4 -m486 -fomit-frame-pointer -funroll-loops"
        ;;
    esac
    ;;   
  i586)
    case $2 in
      linux*)
        flaggies="-Wall -O4 -m486 -fomit-frame-pointer -fforce-addr -fforce-mem -malign-loops=2 -malign-functions=2 -malign-jumps=2 -funroll-loops"
        # this might work for pentium povered linux machines that have PGCC
        # flaggies="-Wall -O6 -mpentium -frisc"
        ;;
    esac
    ;;   
esac

echo $flaggies
