#!/bin/bash # Default cflags CFLAGS="-O3 -fomit-frame-pointer -Wall" uname -a | grep -q "Darwin Kernel Version 9" LEOPARD=$? uname -a | grep -q "Darwin Kernel Version 8" TIGER=$? uname -a | grep -q ppc64 G5=$? uname -m | grep -q x86_64 X86_64=$? # Assume machines running leopard are 64-bit intel, and g5's on linux need # this flag (O3 is optimal on both of these, interestingly enough) if [ $LEOPARD = 0 -o $G5 = 0 ]; then CFLAGS="$CFLAGS -m64" fi # OSX is picky and needs libcrypto instead of lssl if [ $LEOPARD = 0 -o $TIGER = 0 ]; then LDFLAGS="-lcrypto" CFLAGS="$CFLAGS -DTIGER" else LDFLAGS="-lssl" fi # -O4 actually helps on ppc, hurts significantly on intel if [ $TIGER = 0 ]; then CFLAGS="$CFLAGS -O4" fi # -ffast-math hurts (377K/s -> 342K/s) on Linux mustang 2.6.26.8-57.fc8 #1 SMP Thu Dec 18 19:19:45 EST 2008 i686 i686 i386 GNU/Linux if ! uname -a | grep -q 'i686.*GNU/Linux'; then CFLAGS="$CFLAGS -ffast-math" fi # kianna (x86_64) reports significantly better speeds with O2 than O3 if [ $TIGER = 1 -a $LEOPARD = 1 -a $X86_64 = 0 ]; then CFLAGS="$CFLAGS -O2" fi echo "Using $CFLAGS $LDFLAGS" gcc -o runner $CFLAGS $LDFLAGS runner.c