1#!/bin/sh 2 3output="cpucycles.o cpucycles.h" 4cleanup="test cpucycles-impl.o cpucycles-impl.h cpucycles-impl.c" 5 6exec 2>do.notes 7rm -f $output $cleanup 8 9( 10 echo amd64tscfreq gcc 11 echo amd64cpuinfo gcc 12 echo x86tscfreq gcc 13 echo x86cpuinfo gcc 14 echo powerpclinux gcc 15 echo powerpcmacos gcc 16 echo powerpcaix gcc 17 echo powerpcaix ibmcc 18 echo sparcpsrinfo gcc 19 echo sparcpsrinfo suncc 20 echo sparc32psrinfo gcc 21 echo sparc32psrinfo suncc 22 echo hppapstat gcc 23 echo hppapstat hpcc 24 echo alpha gcc 25 echo clockmonotonic gcc 26 echo gettimeofday gcc 27) | ( 28 while read name compiler 29 do 30 echo ===== Trying $name.c with $compiler... >&2 31 rm -f $cleanup 32 cp $name.c cpucycles-impl.c || continue 33 cp $name.h cpucycles-impl.h || continue 34 env COMPILER=$compiler ./compile -c cpucycles-impl.c || continue 35 env COMPILER=$compiler ./compile -o test test.c cpucycles-impl.o || continue 36 ./test || continue 37 echo ===== Success. Using $name.c. >&2 38 mv cpucycles-impl.o cpucycles.o 39 mv cpucycles-impl.h cpucycles.h 40 rm -f $cleanup 41 exit 0 42 done 43 44 echo ===== Giving up. >&2 45 rm -f $output $cleanup 46 exit 111 47) 48