summaryrefslogtreecommitdiffstats
path: root/allmake.sh
blob: 7fc7de0e319899a4184e6cfdc25040a77228c729 (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
88
89
90
91
92
93
94
#!/bin/bash

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

set -xe

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
  cpus=$(grep '^processor' < /proc/cpuinfo | wc -l)
  JOBS=$((cpus*2))
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 -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 &
    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
  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 &
done

wait

date +'--- Config done: %Y-%m-%d %H:%M:%S ---'

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

fdargs='ro root=/dev/sda1 console=tty0 console=ttyS0,115200 earlyprintk=serial,ttyS0 debug memblock=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

date +'--- End: %Y-%m-%d %H:%M:%S ---'