annotate sources/include.sh @ 553:80f3356577fc

Move kernel building from mini-native to package-mini-native in preparation for initramfs packaging option.
author Rob Landley <rob@landley.net>
date Sat, 27 Dec 2008 06:21:42 -0600
parents 808ba1d186ac
children 036dbe218036
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
173
8b4c243a212e Add better debug info to a status report, and stop fighting ubuntu so much
Rob Landley <rob@landley.net>
parents: 170
diff changeset
1 #!/bin/bash
138
7dffe9648a56 Installing bash but not using it. Yeah, there's a political agenda at work
Rob Landley <rob@landley.net>
parents: 125
diff changeset
2
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
3
399
4e11cfb255e2 Break config out from include.sh, so environment variables users can edit to affect the build are collected together in one place with nothing else in it.
Rob Landley <rob@landley.net>
parents: 398
diff changeset
4 [ -e config ] && source config
398
a7daae215647 Implement unstable package download logic, with examples. (Try "USE_UNSTABLE=uClibc,linux ./download.sh" for example.)
Rob Landley <rob@landley.net>
parents: 396
diff changeset
5
428
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents: 419
diff changeset
6 source sources/functions.sh
c88e25996320 Split function definitions out from include.sh.
Rob Landley <rob@landley.net>
parents: 419
diff changeset
7
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
8 # What host compiler should we use?
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
9
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
10 [ -z "$CC" ] && CC=gcc
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
11
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
12 # How many processors should make -j use?
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
13
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
14 if [ -z "$CPUS" ]
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
15 then
553
80f3356577fc Move kernel building from mini-native to package-mini-native in preparation for initramfs packaging option.
Rob Landley <rob@landley.net>
parents: 538
diff changeset
16 export CPUS=$(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
17 [ "$CPUS" -lt 1 ] && CPUS=1
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
18 fi
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
19
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
20 umask 022
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
21 unset CFLAGS CXXFLAGS
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
22
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
23 # Find/create directories
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
24
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
25 TOP=`pwd`
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
26 export SOURCES="${TOP}/sources"
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
27 export SRCDIR="${SOURCES}/packages"
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
28 export FROMSRC=../packages
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
29 export BUILD="${TOP}/build"
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
30 export HOSTTOOLS="${BUILD}/host"
352
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
31
357
5c61d556fe0c Make forkbomb.sh --fork work with RECORD_COMMANDS.
Rob Landley <rob@landley.net>
parents: 352
diff changeset
32 [ -z "$WRAPPY_LOGDIR" ] && WRAPPY_LOGDIR="$BUILD"
5c61d556fe0c Make forkbomb.sh --fork work with RECORD_COMMANDS.
Rob Landley <rob@landley.net>
parents: 352
diff changeset
33
352
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
34 # Adjust $PATH
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
35
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
36 if [ "$PATH" != "$HOSTTOOLS" ]
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
37 then
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
38 if [ -f "$HOSTTOOLS/busybox" ]
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
39 then
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
40 PATH="$HOSTTOOLS"
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
41 else
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
42 PATH="${HOSTTOOLS}:$PATH"
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
43 fi
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
44 fi
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
45
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
46 STAGE_NAME=`echo $0 | sed 's@.*/\(.*\)\.sh@\1@'`
357
5c61d556fe0c Make forkbomb.sh --fork work with RECORD_COMMANDS.
Rob Landley <rob@landley.net>
parents: 352
diff changeset
47 export WRAPPY_LOGPATH="$WRAPPY_LOGDIR/cmdlines.${STAGE_NAME}.setupfor"
352
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
48 if [ -f "$BUILD/wrapdir/wrappy" ]
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
49 then
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
50 export WRAPPY_REALPATH="$PATH"
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
51 PATH="$BUILD/wrapdir"
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
52 fi
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
53
553
80f3356577fc Move kernel building from mini-native to package-mini-native in preparation for initramfs packaging option.
Rob Landley <rob@landley.net>
parents: 538
diff changeset
54 mkdir -p "${SRCDIR}" || dienow
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
55
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
56 # Tell bash not to cache the $PATH because we modify it. Without this, bash
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
57 # won't find new executables added after startup.
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
58 set +h
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
59
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
60 # Get target platform from first command line argument.
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
61
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
62 if [ -z "$NO_ARCH" ]
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
63 then
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
64 ARCH_NAME="$1"
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
65 ARCH="$(echo "$1" | sed 's@.*/@@')"
387
f0ceae67ebd0 Convert sources/configs/$ARCH files to sources/targets/$ARCH directories.
Rob Landley <rob@landley.net>
parents: 378
diff changeset
66 if [ ! -f "${TOP}/sources/targets/${ARCH}/details" ]
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
67 then
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
68 echo "Supported architectures: "
387
f0ceae67ebd0 Convert sources/configs/$ARCH files to sources/targets/$ARCH directories.
Rob Landley <rob@landley.net>
parents: 378
diff changeset
69 (cd "${TOP}/sources/targets" && ls)
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
70 exit 1
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
71 fi
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
72
387
f0ceae67ebd0 Convert sources/configs/$ARCH files to sources/targets/$ARCH directories.
Rob Landley <rob@landley.net>
parents: 378
diff changeset
73 # Read the relevant config file.
f0ceae67ebd0 Convert sources/configs/$ARCH files to sources/targets/$ARCH directories.
Rob Landley <rob@landley.net>
parents: 378
diff changeset
74
f0ceae67ebd0 Convert sources/configs/$ARCH files to sources/targets/$ARCH directories.
Rob Landley <rob@landley.net>
parents: 378
diff changeset
75 CONFIG_DIR="${TOP}/sources/targets/${ARCH}"
f0ceae67ebd0 Convert sources/configs/$ARCH files to sources/targets/$ARCH directories.
Rob Landley <rob@landley.net>
parents: 378
diff changeset
76 source "${CONFIG_DIR}/details"
f0ceae67ebd0 Convert sources/configs/$ARCH files to sources/targets/$ARCH directories.
Rob Landley <rob@landley.net>
parents: 378
diff changeset
77
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
78 # Which platform are we building for?
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
79
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
80 export WORK="${BUILD}/temp-$ARCH"
538
808ba1d186ac Setup can delete the temporary directory now, nothing persistent in it.
Rob Landley <rob@landley.net>
parents: 513
diff changeset
81 rm -rf "${WORK}"
553
80f3356577fc Move kernel building from mini-native to package-mini-native in preparation for initramfs packaging option.
Rob Landley <rob@landley.net>
parents: 538
diff changeset
82 mkdir -p "${WORK}" || dienow
387
f0ceae67ebd0 Convert sources/configs/$ARCH files to sources/targets/$ARCH directories.
Rob Landley <rob@landley.net>
parents: 378
diff changeset
83
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
84 # Say "unknown" in two different ways so it doesn't assume we're NOT
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
85 # cross compiling when the host and target are the same processor. (If host
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
86 # and target match, the binutils/gcc/make builds won't use the cross compiler
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
87 # during mini-native.sh, and the host compiler links binaries against the
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
88 # wrong libc.)
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
89 [ -z "$CROSS_HOST" ] && export CROSS_HOST=`uname -m`-walrus-linux
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
90 [ -z "$CROSS_TARGET" ] && export CROSS_TARGET=${ARCH}-unknown-linux
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
91
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
92 # Setup directories and add the cross compiler to the start of the path.
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
93
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
94 export CROSS="${BUILD}/cross-compiler-$ARCH"
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
95 export NATIVE="${BUILD}/mini-native-$ARCH"
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
96 export PATH="${CROSS}/bin:$PATH"
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
97 else
436
2ffa9dab13e5 Slightly improved display.
Rob Landley <rob@landley.net>
parents: 428
diff changeset
98 ARCH_NAME=host
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
99 export WORK="${BUILD}/host-temp"
553
80f3356577fc Move kernel building from mini-native to package-mini-native in preparation for initramfs packaging option.
Rob Landley <rob@landley.net>
parents: 538
diff changeset
100 mkdir -p "${WORK}" || dienow
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
101 fi
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
102
553
80f3356577fc Move kernel building from mini-native to package-mini-native in preparation for initramfs packaging option.
Rob Landley <rob@landley.net>
parents: 538
diff changeset
103 if [ ! -z "${NATIVE_TOOLSDIR}" ]
80f3356577fc Move kernel building from mini-native to package-mini-native in preparation for initramfs packaging option.
Rob Landley <rob@landley.net>
parents: 538
diff changeset
104 then
80f3356577fc Move kernel building from mini-native to package-mini-native in preparation for initramfs packaging option.
Rob Landley <rob@landley.net>
parents: 538
diff changeset
105 TOOLS="${NATIVE}/tools"
80f3356577fc Move kernel building from mini-native to package-mini-native in preparation for initramfs packaging option.
Rob Landley <rob@landley.net>
parents: 538
diff changeset
106 else
80f3356577fc Move kernel building from mini-native to package-mini-native in preparation for initramfs packaging option.
Rob Landley <rob@landley.net>
parents: 538
diff changeset
107 TOOLS="${NATIVE}/usr"
80f3356577fc Move kernel building from mini-native to package-mini-native in preparation for initramfs packaging option.
Rob Landley <rob@landley.net>
parents: 538
diff changeset
108 fi