fix regression from a745c4bfc8a9b5db4e48387170da0dc1d39e3abe
[uclibc-ng.git] / extra / scripts / MAKEALL
blobf46d3bd661f5d420e02f7ae8801f22be8dd5434e
1 #!/bin/sh
3 # helper script to quick build testing with cross-compilers
6 : ${MAKE:=make}
8 : ${BUILD_NCPUS:=$(getconf _NPROCESSORS_ONLN)}
9 if [ "$BUILD_NCPUS" -gt 1 ] ; then
10 JOBS=-j$((BUILD_NCPUS + 1))
11 else
12 JOBS=""
14 MAKE="${MAKE} ${JOBS}"
16 : ${CROSS_COMPILE:=${CROSS_COMPILER_PREFIX}}
18 setconfig()
20 local opt=$1
21 shift
22 case $1 in
23 [yn]) ;;
24 [0-9]*) ;;
25 *) set -- '"'$*'"'
26 esac
27 sed -i \
28 -e "/${opt}=/s:=.*:=$*:" \
29 .config
30 echo " ## setconfig ${opt} $*"
33 get_arches()
35 case $1 in
36 hppa) echo hppa hppa2.0 hppa1.1 hppa1.0;;
37 i386) echo i386 i486 i586 i686;;
38 sh) echo sh4 sh2 sh3 sh1 sh;;
39 sparc) echo sparc sparc64;;
40 *) echo $1;;
41 esac
44 find_compiler()
46 local t a v o l
47 for a in $(get_arches $1) ; do
48 for l in uclibc gnu gnueabi "" ; do
49 for v in unknown pc gentoo "" ; do
50 for o in linux uclinux "" ; do
51 t="${a}${v:+-${v}}${o:+-${o}}${l:+-${l}}"
52 if ${t}-gcc --help > /dev/null 2>&1 ; then
53 echo ${t}-
54 return 0
56 done
57 done
58 done
59 done
62 do_make()
64 echo " ## ${MAKE} -s $*"
65 ${MAKE} -s "$@"
68 mark_arch()
70 local r=$1 a=$2
71 eval $r=\"\$$r $a\"
74 if [ -z "$*" ] ; then
75 set -- $(awk \
76 '$0 ~ /^config TARGET_/ { sub("TARGET_",""); print $NF }' \
77 extra/Configs/Config.in | grep -v SUBARCH)
79 pass=""
80 fail=""
81 skip=""
82 for a in "$@" ; do
83 if [ -z "${CROSS_COMPILE}" ] ; then
84 CROSS_COMPILE=$(find_compiler ${a})
87 if [ -z "${CROSS_COMPILE}" ] ; then
88 mark_arch skip $a
89 echo " ### SKIP: ${a}: could not find compiler"
90 continue
93 rm -f ${a}.log ${a}.fail
95 set -e
97 echo " ### Building target ${a} (${CROSS_COMPILE})"
99 do_make distclean
100 do_make ARCH=$a defconfig
101 do_make oldconfig
103 setconfig CROSS_COMPILER_PREFIX ${CROSS_COMPILE}
105 header_path=${KERNEL_HEADERS:-$(echo '#include <linux/version.h>' | ${CROSS_COMPILE}cpp 2>/dev/null | grep -o '[^"]*linux/version.h')} || :
106 if [ -z "${header_path}" ] ; then
107 for p in /usr/${CROSS_COMPILE%-}/usr/include ; do
108 if [ -e ${p}/linux/version.h ] ; then
109 header_path=${p}
110 break
112 done
113 if [ -z "${header_path}" ] ; then
114 echo " ## unable to locate KERNEL_HEADERS"
117 setconfig KERNEL_HEADERS ${header_path%/linux/version.h}
119 if do_make ; then
120 echo " ## PASS"
121 else
122 echo " ## FAIL"
123 touch ${a}.fail
125 ) 2>&1 | tee ${a}.log
127 if [ -e ${a}.fail ] ; then
128 rm -f ${a}.fail
129 mark_arch fail $a
130 else
131 mark_arch pass $a
134 unset CROSS_COMPILE
135 done
137 if [ -n "${skip}" ] ; then
138 printf '\nSKIPPED: %s\n' "${skip}"
140 if [ -n "${fail}" ] ; then
141 printf '\nPASSED: %s\nFAILED: %s\n\n' "${pass}" "${fail}"
142 exit 1
143 else
144 printf '\nAll arches passed!\n\n'
145 exit 0