MAKEALL 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. find_compiler()
  29. {
  30. local t a v o l
  31. a=$1
  32. for v in unknown pc gentoo "" ; do
  33. for o in linux uclinux "" ; do
  34. for l in uclibc "" ; do
  35. t="${a}${v:+-${v}}${o:+-${o}}${l:+-${l}}"
  36. if ${t}-gcc --help > /dev/null 2>&1 ; then
  37. echo ${t}-
  38. return 0
  39. fi
  40. done
  41. done
  42. done
  43. }
  44. do_make()
  45. {
  46. echo " ## ${MAKE} -s $*"
  47. ${MAKE} -s "$@"
  48. }
  49. mark_arch()
  50. {
  51. local r=$1 a=$2
  52. eval $r=\"\$$r $a\"
  53. }
  54. if [ -z "$*" ] ; then
  55. set -- $(awk \
  56. '$0 ~ /^config TARGET_/ { sub("TARGET_",""); print $NF }' \
  57. extra/Configs/Config.in | grep -v SUBARCH)
  58. fi
  59. pass=""
  60. fail=""
  61. skip=""
  62. for a in "$@" ; do
  63. if [ -n "${CROSS_COMPILE}" ] ; then
  64. CROSS=${CROSS_COMPILE}
  65. else
  66. CROSS=$(find_compiler ${a})
  67. fi
  68. if [ -z "${CROSS}" ] ; then
  69. mark_arch skip $a
  70. echo " ### SKIP: ${a}: could not find compiler"
  71. continue
  72. fi
  73. rm -f ${a}.log ${a}.fail
  74. (
  75. set -e
  76. echo " ### Building target ${a} (${CROSS})"
  77. do_make distclean
  78. do_make ARCH=$a defconfig
  79. do_make oldconfig
  80. setconfig CROSS_COMPILER_PREFIX ${CROSS}
  81. header_path=$(echo '#include <linux/version.h>' | ${CROSS}cpp 2>&1 | grep -o '[^"]*linux/version.h')
  82. setconfig KERNEL_HEADERS ${header_path%/linux/version.h}
  83. if do_make ; then
  84. echo " ## PASS"
  85. else
  86. echo " ## FAIL"
  87. touch ${a}.fail
  88. fi
  89. ) 2>&1 | tee ${a}.log
  90. if [ -e ${a}.fail ] ; then
  91. rm -f ${a}.fail
  92. mark_arch fail $a
  93. else
  94. mark_arch pass $a
  95. fi
  96. done
  97. if [ -n "${skip}" ] ; then
  98. printf '\nSKIPPED: %s\n' "${skip}"
  99. fi
  100. if [ -n "${fail}" ] ; then
  101. printf '\nPASSED: %s\nFAILED: %s\n\n' "${pass}" "${fail}"
  102. exit 1
  103. else
  104. printf '\nAll arches passed!\n\n'
  105. exit 0
  106. fi