MAKEALL 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #!/bin/sh
  2. #
  3. # helper script to quick build testing with cross-compilers
  4. #
  5. : ${MAKE:=make}
  6. : ${BUILD_NCPUS:=$(getconf _NPROCESSORS_ONLN)}
  7. if [ "$BUILD_NCPUS" -gt 1 ] ; then
  8. JOBS=-j$((BUILD_NCPUS + 1))
  9. else
  10. JOBS=""
  11. fi
  12. MAKE="${MAKE} ${JOBS}"
  13. : ${CROSS_COMPILE:=${CROSS_COMPILER_PREFIX}}
  14. setconfig()
  15. {
  16. local opt=$1
  17. shift
  18. case $1 in
  19. [yn]) ;;
  20. [0-9]*) ;;
  21. *) set -- '"'$*'"'
  22. esac
  23. sed -i \
  24. -e "/${opt}=/s:=.*:=$*:" \
  25. .config
  26. echo " ## setconfig ${opt} $*"
  27. }
  28. get_arches()
  29. {
  30. case $1 in
  31. sh) echo sh4 sh2 sh3 sh1 sh;;
  32. *) echo $1;;
  33. esac
  34. }
  35. find_compiler()
  36. {
  37. local t a v o l
  38. for a in $(get_arches $1) ; do
  39. for v in unknown pc gentoo "" ; do
  40. for o in linux uclinux "" ; do
  41. for l in uclibc "" ; do
  42. t="${a}${v:+-${v}}${o:+-${o}}${l:+-${l}}"
  43. if ${t}-gcc --help > /dev/null 2>&1 ; then
  44. echo ${t}-
  45. return 0
  46. fi
  47. done
  48. done
  49. done
  50. done
  51. }
  52. do_make()
  53. {
  54. echo " ## ${MAKE} -s $*"
  55. ${MAKE} -s "$@"
  56. }
  57. mark_arch()
  58. {
  59. local r=$1 a=$2
  60. eval $r=\"\$$r $a\"
  61. }
  62. if [ -z "$*" ] ; then
  63. set -- $(awk \
  64. '$0 ~ /^config TARGET_/ { sub("TARGET_",""); print $NF }' \
  65. extra/Configs/Config.in | grep -v SUBARCH)
  66. fi
  67. pass=""
  68. fail=""
  69. skip=""
  70. for a in "$@" ; do
  71. if [ -n "${CROSS_COMPILE}" ] ; then
  72. CROSS=${CROSS_COMPILE}
  73. else
  74. CROSS=$(find_compiler ${a})
  75. fi
  76. if [ -z "${CROSS}" ] ; then
  77. mark_arch skip $a
  78. echo " ### SKIP: ${a}: could not find compiler"
  79. continue
  80. fi
  81. rm -f ${a}.log ${a}.fail
  82. (
  83. set -e
  84. echo " ### Building target ${a} (${CROSS})"
  85. do_make distclean
  86. do_make ARCH=$a defconfig
  87. do_make oldconfig
  88. setconfig CROSS_COMPILER_PREFIX ${CROSS}
  89. header_path=$(echo '#include <linux/version.h>' | ${CROSS}cpp 2>&1 | grep -o '[^"]*linux/version.h')
  90. setconfig KERNEL_HEADERS ${header_path%/linux/version.h}
  91. if do_make ; then
  92. echo " ## PASS"
  93. else
  94. echo " ## FAIL"
  95. touch ${a}.fail
  96. fi
  97. ) 2>&1 | tee ${a}.log
  98. if [ -e ${a}.fail ] ; then
  99. rm -f ${a}.fail
  100. mark_arch fail $a
  101. else
  102. mark_arch pass $a
  103. fi
  104. done
  105. if [ -n "${skip}" ] ; then
  106. printf '\nSKIPPED: %s\n' "${skip}"
  107. fi
  108. if [ -n "${fail}" ] ; then
  109. printf '\nPASSED: %s\nFAILED: %s\n\n' "${pass}" "${fail}"
  110. exit 1
  111. else
  112. printf '\nAll arches passed!\n\n'
  113. exit 0
  114. fi