1
0

do 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #!/bin/sh -e
  2. okabi | (
  3. while read abi
  4. do
  5. rm -f cpucycles.o cpucycles.h
  6. (
  7. case "$abi" in
  8. ppc*)
  9. echo powerpccpuinfo
  10. echo powerpcmacos
  11. ;;
  12. amd64*)
  13. echo amd64tscfreq
  14. echo amd64cpuinfo
  15. echo amd64cpuspeed
  16. ;;
  17. x86*)
  18. echo x86tscfreq
  19. echo x86cpuinfo
  20. echo x86cpuspeed
  21. echo x86estimate
  22. ;;
  23. cell*)
  24. echo celllinux
  25. ;;
  26. sparc*)
  27. echo sparccpuinfo
  28. echo sparc32cpuinfo
  29. ;;
  30. mips*)
  31. echo mips
  32. ;;
  33. hppa*)
  34. echo hppapstat
  35. ;;
  36. alpha*)
  37. echo alpha
  38. ;;
  39. sgi*)
  40. echo sgi
  41. ;;
  42. arm*)
  43. echo cortex
  44. echo dev4ns
  45. ;;
  46. esac
  47. echo amd64tscfreq
  48. echo amd64cpuinfo
  49. echo amd64cpuspeed
  50. echo x86tscfreq
  51. echo x86cpuinfo
  52. echo x86cpuspeed
  53. echo x86estimate
  54. echo ia64cpuinfo
  55. echo powerpccpuinfo
  56. echo powerpcmacos
  57. echo celllinux
  58. echo sparccpuinfo
  59. echo sparc32cpuinfo
  60. echo mips
  61. echo hppapstat
  62. echo alpha
  63. echo sgi
  64. echo cortex
  65. echo dev4ns
  66. echo monotoniccpuinfo
  67. echo monotonic
  68. echo gettimeofday
  69. ) | (
  70. while read n
  71. do
  72. okc-$abi | (
  73. while read c
  74. do
  75. echo "=== `date` === Trying $n.c with $c..." >&2
  76. rm -f test cpucycles-impl.o cpucycles-impl.h cpucycles-impl.c
  77. cp $n.c cpucycles-impl.c || continue
  78. cp $n.h cpucycles-impl.h || continue
  79. $c -c cpucycles-impl.c || continue
  80. $c -o test test.c cpucycles-impl.o || continue
  81. ./test || continue
  82. echo "=== `date` === Success. Using $n.c." >&2
  83. mkdir -p lib/$abi
  84. mv cpucycles-impl.o lib/$abi/cpucycles.o
  85. mkdir -p include/$abi
  86. mv cpucycles-impl.h include/$abi/cpucycles.h
  87. exit 0
  88. done
  89. exit 111
  90. ) && exit 0
  91. done
  92. exit 111
  93. ) || (
  94. echo ===== Giving up. >&2
  95. rm -f test cpucycles-impl.o cpucycles-impl.h cpucycles-impl.c
  96. exit 111
  97. ) || exit 0
  98. done
  99. exit 0
  100. ) || exit 111