MAKEALL 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. hppa) echo hppa hppa2.0 hppa1.1 hppa1.0;;
  32. i386) echo i386 i486 i586 i686;;
  33. sh) echo sh4 sh2 sh3 sh1 sh;;
  34. sparc) echo sparc sparc64;;
  35. *) echo $1;;
  36. esac
  37. }
  38. find_compiler()
  39. {
  40. local t a v o l
  41. for a in $(get_arches $1) ; do
  42. for l in uclibc gnu gnueabi "" ; do
  43. for v in unknown pc gentoo "" ; do
  44. for o in linux uclinux "" ; do
  45. t="${a}${v:+-${v}}${o:+-${o}}${l:+-${l}}"
  46. if ${t}-gcc --help > /dev/null 2>&1 ; then
  47. echo ${t}-
  48. return 0
  49. fi
  50. done
  51. done
  52. done
  53. done
  54. }
  55. do_make()
  56. {
  57. echo " ## ${MAKE} -s $*"
  58. ${MAKE} -s "$@"
  59. }
  60. mark_arch()
  61. {
  62. local r=$1 a=$2
  63. eval $r=\"\$$r $a\"
  64. }
  65. if [ -z "$*" ] ; then
  66. set -- $(awk \
  67. '$0 ~ /^config TARGET_/ { sub("TARGET_",""); print $NF }' \
  68. extra/Configs/Config.in | grep -v SUBARCH)
  69. fi
  70. pass=""
  71. fail=""
  72. skip=""
  73. for a in "$@" ; do
  74. if [ -z "${CROSS_COMPILE}" ] ; then
  75. CROSS_COMPILE=$(find_compiler ${a})
  76. fi
  77. if [ -z "${CROSS_COMPILE}" ] ; then
  78. mark_arch skip $a
  79. echo " ### SKIP: ${a}: could not find compiler"
  80. continue
  81. fi
  82. rm -f ${a}.log ${a}.fail
  83. (
  84. set -e
  85. echo " ### Building target ${a} (${CROSS_COMPILE})"
  86. do_make distclean
  87. do_make ARCH=$a defconfig
  88. do_make oldconfig
  89. setconfig CROSS_COMPILER_PREFIX ${CROSS_COMPILE}
  90. header_path=${KERNEL_HEADERS:-$(echo '#include <linux/version.h>' | ${CROSS_COMPILE}cpp 2>/dev/null | grep -o '[^"]*linux/version.h')} || :
  91. if [ -z "${header_path}" ] ; then
  92. for p in /usr/${CROSS_COMPILE%-}/usr/include ; do
  93. if [ -e ${p}/linux/version.h ] ; then
  94. header_path=${p}
  95. break
  96. fi
  97. done
  98. if [ -z "${header_path}" ] ; then
  99. echo " ## unable to locate KERNEL_HEADERS"
  100. fi
  101. fi
  102. setconfig KERNEL_HEADERS ${header_path%/linux/version.h}
  103. if do_make ; then
  104. echo " ## PASS"
  105. else
  106. echo " ## FAIL"
  107. touch ${a}.fail
  108. fi
  109. ) 2>&1 | tee ${a}.log
  110. if [ -e ${a}.fail ] ; then
  111. rm -f ${a}.fail
  112. mark_arch fail $a
  113. else
  114. mark_arch pass $a
  115. fi
  116. unset CROSS_COMPILE
  117. done
  118. if [ -n "${skip}" ] ; then
  119. printf '\nSKIPPED: %s\n' "${skip}"
  120. fi
  121. if [ -n "${fail}" ] ; then
  122. printf '\nPASSED: %s\nFAILED: %s\n\n' "${pass}" "${fail}"
  123. exit 1
  124. else
  125. printf '\nAll arches passed!\n\n'
  126. exit 0
  127. fi