summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2021-05-12 14:33:44 -0700
committerH. Peter Anvin <hpa@zytor.com>2021-05-12 14:33:44 -0700
commit186222ef510a4fc3204d580ab06fcf7e15d2e173 (patch)
tree1d0d3fab1555ebc6cfde80ffd6c0c24613157355
parentf4f0051354fe8f6e52022f84b76b1b98b3739997 (diff)
downloadktest-186222ef510a4fc3204d580ab06fcf7e15d2e173.tar.gz
ktest-186222ef510a4fc3204d580ab06fcf7e15d2e173.tar.xz
ktest-186222ef510a4fc3204d580ab06fcf7e15d2e173.zip
allmake.sh: rewrite to make better use of current linux make
-rwxr-xr-xallmake.sh104
1 files changed, 65 insertions, 39 deletions
diff --git a/allmake.sh b/allmake.sh
index 7fc7de0..95f0ad6 100755
--- a/allmake.sh
+++ b/allmake.sh
@@ -12,13 +12,6 @@ date +'--- Start: %Y-%m-%d %H:%M:%S ---'
ulimit -u hard
ulimit -n hard
-canned='i386 x86_64 i386-pae'
-special='i386-allconfig x86_64-allconfig i386-modconfig x86_64-modconfig i386-noconfig x86_64-noconfig'
-
-if [ -z "$ALL" ]; then
- ALL="$canned $special"
-fi
-
here="$(cd "$(dirname "$0")" && pwd)"
if [ -z "$JOBS" ]; then
@@ -26,69 +19,102 @@ if [ -z "$JOBS" ]; then
JOBS=$((cpus*2))
fi
-# This can be 'ccache gcc'
-gcc=gcc
+make="make -R -r -j$JOBS ${@@Q}"
+
+archopt() {
+ local arch=${1%%[-.]*}
+ local cross=''
+
+ case $arch in
+ i386|x86_64) ;;
+ arm*) cross=arm-linux-gnu- ;;
+ riscv*) cross=riscv64-linux-gnu- ;;
+ powerpc*) cross=powerpc64-linux-gnu- ;;
+ *) echo "$0: define CROSS_COMPILE for architecture $arch" 1>&2;
+ cross='UNDEFINED' ;;
+ esac
+
+ echo "ARCH=$arch${cross:+ CROSS_COMPILE=}$cross"
+}
+
+makeopt() {
+ local llvm
+ if [ -z "${1##*-llvm*}" ]; then
+ llvm='LLVM=1'
+ fi
+ echo $(archopt $1) O=o.$1 $llvm
+}
#
# Canned configurations
#
-for c in $canned; do
+canned=''
+for cfg in "$here"/config.*; do
+ c="${cfg##*config.}"
+ canned="$canned $c"
mkdir -p o.$c
if [ ! -f o.$c/.config ]; then
- cp "$here"/config.$c o.$c/.config
- fi
- if grep -q -s '^CONFIG_X86_64=' o.$c/.config; then
- yes '' | make -j$JOBS ARCH=x86_64 O=o.$c CC="$gcc" oldconfig &
- else
- yes '' | make -j$JOBS ARCH=i386 O=o.$c CC="$gcc -m32" oldconfig &
+ cp -f "$cfg" o.$c/.config
fi
+ $make $(makeopt $c) olddefconfig &
done
#
# Automatic configurations
#
+special=''
for a in x86_64 i386; do
- if [ "$a" = i386 ]; then gccopt=' -m32'; else gccopt=''; fi
- mkdir -p o.$a-allconfig o.$a-modconfig o.$a-noconfig
- KCONFIG_ALLCONFIG="$here"/override.yes make -j$JOBS ARCH=$a O=o.$a-allconfig CC="$gcc$gccopt" allyesconfig &
- KCONFIG_ALLCONFIG="$here"/override.mod make -j$JOBS ARCH=$a O=o.$a-modconfig CC="$gcc$gccopt" allmodconfig &
- KCONFIG_ALLCONFIG="$here"/override.no make -j$JOBS ARCH=$a O=o.$a-noconfig CC="$gcc$gccopt" allnoconfig &
+ for s in yes mod no; do
+ c=$a.${s}config
+ special="$special $c"
+ mkdir -p o.$c
+ KCONFIG_ALLCONFIG="$here"/override.$s \
+ $make $(makeopt $c) all${s}config &
+ done
done
wait
+if [ -z "$ALL" ]; then
+ ALL="$canned $special"
+fi
+
date +'--- Config done: %Y-%m-%d %H:%M:%S ---'
-MKFILE=/tmp/allmake.$$
+MKFILE=allmake.mk
rm -f $MKFILE
-fdargs='ro root=/dev/sda1 console=tty0 console=ttyS0,115200 earlyprintk=serial,ttyS0 debug memblock=debug'
+fdargs='ro root=/dev/sdb2 console=tty0 console=ttyS0,115200 earlyprintk=serial,ttyS0 debug memblock=debug'
-cat > $MKFILE <<EOF
-TARGET=all
-TEEOPT=
+opts=''
+cat > $MKFILE <<EOF
CONFIG_DEBUG_SECTION_MISMATCH := y
export CONFIG_DEBUG_SECTION_MISMATCH
-all: $ALL
-EOF
+configs := $canned $special
+FDARGS := $fdargs
+export FDARGS
+OPTS := $opts
-for c in $canned $special; do
- arch=$(echo "$c" | cut -d- -f1)
- if [ "$arch" = i386 ]; then gccopt=' -m32'; else gccopt=''; fi
+ALL = \$(configs)
+
+all: \$(ALL:=.all)
+
+.PHONY: %.all %.isoimage %.hdimage
+%.all %.isoimage %.hdimage:
+ \$(MAKE) \$(MAKEOPT_\$*) \$(OPTS) \$(subst \$*.,,\$@)
-cat >> $MKFILE <<EOF
+%.isoimage %.hdimage: %.all
-.PHONY: $c
-$c:
- \$(MAKE) ARCH=$arch O=o.\$@ CC="$gcc$gccopt" \$(TARGET) \
- 2>&1 | tee \$(TEEOPT) o.\$@/make.log
EOF
+
+for c in $canned $special; do
+ rm -f o.$c/make.log
+ echo "MAKEOPT_$c := $(makeopt $c)" >> $MKFILE
done
-make -j$JOBS -f $MKFILE "$@"
-make -j$JOBS -f $MKFILE FDARGS="$fdargs" TARGET=isoimage TEEOPT='-a' "$@"
-rm -f $MKFILE
+$make -f $MKFILE ALL="${ALL}"
+# rm -f $MKFILE
date +'--- End: %Y-%m-%d %H:%M:%S ---'