summaryrefslogtreecommitdiffstats
path: root/allmake.sh
blob: 0a5111b35ca4be3baa9cfce52446025b31de95f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash

if [ ! -f MAINTAINERS ]; then
    echo "Run this in a kernel root directory!" 1>&2
    exit 1
fi

set -xe

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=`dirname "$0"`

if [ -z "$JOBS" ]; then
  cpus=$(grep '^processor' < /proc/cpuinfo | wc -l)
  JOBS=$((cpus))
fi

# This can be 'ccache gcc'
gcc=gcc

#
# Canned configurations
#
for c in $canned; do
    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 ARCH=x86_64 O=o.$c CC="$gcc" oldconfig
    else
	yes '' | make ARCH=i386 O=o.$c CC="$gcc -m32" oldconfig
    fi
done

#
# Automatic configurations
#
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
  export KCONFIG_ALLCONFIG="$here"/override.yes
  make ARCH=$a O=o.$a-allconfig CC="$gcc$gccopt" allyesconfig
  export KCONFIG_ALLCONFIG="$here"/override.mod
  make ARCH=$a O=o.$a-modconfig CC="$gcc$gccopt" allmodconfig
  export KCONFIG_ALLCONFIG="$here"/override.no
  make ARCH=$a O=o.$a-noconfig CC="$gcc$gccopt" allnoconfig
  unset KCONFIG_ALLCONFIG
done

MKFILE=/tmp/allmake.$$
rm -f $MKFILE

fdargs='ro root=/dev/sda1 console=tty0 console=ttyS0,115200 earlyprintk=serial,ttyS0 debug'

cat > $MKFILE <<EOF
TARGET=all
TEEOPT=

CONFIG_DEBUG_SECTION_MISMATCH := y
export CONFIG_DEBUG_SECTION_MISMATCH

all: $ALL
EOF

for c in $canned $special; do
    arch=$(echo "$c" | cut -d- -f1)
    if [ "$arch" = i386 ]; then gccopt=' -m32'; else gccopt=''; fi

cat >> $MKFILE <<EOF

.PHONY: $c
$c:
	\$(MAKE) ARCH=$arch O=o.\$@ CC="$gcc$gccopt" \$(TARGET) \
		2>&1 | tee \$(TEEOPT) o.\$@/make.log
EOF
done

make -j$JOBS -f $MKFILE "$@"
make -j$JOBS -f $MKFILE FDARGS="$fdargs" TARGET=isoimage TEEOPT='-a' "$@"
rm -f $MKFILE