MAKEALL 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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=${KERNEL_HEADERS:-$(echo '#include <linux/version.h>' | ${CROSS}cpp 2>/dev/null | grep -o '[^"]*linux/version.h')} || :
  90. if [ -z "${header_path}" ] ; then
  91. for p in /usr/${CROSS%-}/usr/include ; do
  92. if [ -e ${p}/linux/version.h ] ; then
  93. header_path=${p}
  94. break
  95. fi
  96. done
  97. if [ -z "${header_path}" ] ; then
  98. echo " ## unable to locate KERNEL_HEADERS"
  99. fi
  100. fi
  101. setconfig KERNEL_HEADERS ${header_path%/linux/version.h}
  102. if do_make ; then
  103. echo " ## PASS"
  104. else
  105. echo " ## FAIL"
  106. touch ${a}.fail
  107. fi
  108. ) 2>&1 | tee ${a}.log
  109. if [ -e ${a}.fail ] ; then
  110. rm -f ${a}.fail
  111. mark_arch fail $a
  112. else
  113. mark_arch pass $a
  114. fi
  115. done
  116. if [ -n "${skip}" ] ; then
  117. printf '\nSKIPPED: %s\n' "${skip}"
  118. fi
  119. if [ -n "${fail}" ] ; then
  120. printf '\nPASSED: %s\nFAILED: %s\n\n' "${pass}" "${fail}"
  121. exit 1
  122. else
  123. printf '\nAll arches passed!\n\n'
  124. exit 0
  125. fi