Mercurial > hg > aboriginal
annotate sources/include.sh @ 578:715c94bd059e
Alas, bash won't leave variables set after a loop exits unless export every single one.
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 09 Jan 2009 22:40:15 -0600 |
parents | 036dbe218036 |
children | 9dffdd74c186 |
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" |
576
036dbe218036
Add BASE_ARCH support, so a hardware architecture can specify a base architecture and just provide a different kernel.
Rob Landley <rob@landley.net>
parents:
553
diff
changeset
|
65 if [ ! -f "${TOP}/sources/targets/${ARCH_NAME}/details" ] |
351
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
66 then |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
67 echo "Supported architectures: " |
387
f0ceae67ebd0
Convert sources/configs/$ARCH files to sources/targets/$ARCH directories.
Rob Landley <rob@landley.net>
parents:
378
diff
changeset
|
68 (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
|
69 exit 1 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
70 fi |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
71 |
576
036dbe218036
Add BASE_ARCH support, so a hardware architecture can specify a base architecture and just provide a different kernel.
Rob Landley <rob@landley.net>
parents:
553
diff
changeset
|
72 # Read the relevant config file, iterating to find base architecture if any. |
387
f0ceae67ebd0
Convert sources/configs/$ARCH files to sources/targets/$ARCH directories.
Rob Landley <rob@landley.net>
parents:
378
diff
changeset
|
73 |
578
715c94bd059e
Alas, bash won't leave variables set after a loop exits unless export every single one.
Rob Landley <rob@landley.net>
parents:
576
diff
changeset
|
74 ARCH="$ARCH_NAME" |
715c94bd059e
Alas, bash won't leave variables set after a loop exits unless export every single one.
Rob Landley <rob@landley.net>
parents:
576
diff
changeset
|
75 CONFIG_DIR="${TOP}/sources/targets/${ARCH}" |
715c94bd059e
Alas, bash won't leave variables set after a loop exits unless export every single one.
Rob Landley <rob@landley.net>
parents:
576
diff
changeset
|
76 source "${CONFIG_DIR}/details" |
715c94bd059e
Alas, bash won't leave variables set after a loop exits unless export every single one.
Rob Landley <rob@landley.net>
parents:
576
diff
changeset
|
77 if [ ! -z "$BASE_ARCH" ] |
715c94bd059e
Alas, bash won't leave variables set after a loop exits unless export every single one.
Rob Landley <rob@landley.net>
parents:
576
diff
changeset
|
78 then |
715c94bd059e
Alas, bash won't leave variables set after a loop exits unless export every single one.
Rob Landley <rob@landley.net>
parents:
576
diff
changeset
|
79 ARCH="$BASE_ARCH" |
715c94bd059e
Alas, bash won't leave variables set after a loop exits unless export every single one.
Rob Landley <rob@landley.net>
parents:
576
diff
changeset
|
80 CONFIG_DIR="${TOP}/sources/targets/${ARCH}" |
715c94bd059e
Alas, bash won't leave variables set after a loop exits unless export every single one.
Rob Landley <rob@landley.net>
parents:
576
diff
changeset
|
81 source "${CONFIG_DIR}/details" |
715c94bd059e
Alas, bash won't leave variables set after a loop exits unless export every single one.
Rob Landley <rob@landley.net>
parents:
576
diff
changeset
|
82 fi |
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 # 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
|
85 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
86 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
|
87 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
|
88 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
|
89 |
351
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
90 # 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
|
91 # 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
|
92 # 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
|
93 # 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
|
94 # wrong libc.) |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
95 [ -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
|
96 [ -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
|
97 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
98 # 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
|
99 |
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
100 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
|
101 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
|
102 export PATH="${CROSS}/bin:$PATH" |
576
036dbe218036
Add BASE_ARCH support, so a hardware architecture can specify a base architecture and just provide a different kernel.
Rob Landley <rob@landley.net>
parents:
553
diff
changeset
|
103 |
036dbe218036
Add BASE_ARCH support, so a hardware architecture can specify a base architecture and just provide a different kernel.
Rob Landley <rob@landley.net>
parents:
553
diff
changeset
|
104 if [ ! -z "${NATIVE_TOOLSDIR}" ] |
036dbe218036
Add BASE_ARCH support, so a hardware architecture can specify a base architecture and just provide a different kernel.
Rob Landley <rob@landley.net>
parents:
553
diff
changeset
|
105 then |
036dbe218036
Add BASE_ARCH support, so a hardware architecture can specify a base architecture and just provide a different kernel.
Rob Landley <rob@landley.net>
parents:
553
diff
changeset
|
106 TOOLS="${NATIVE}/tools" |
036dbe218036
Add BASE_ARCH support, so a hardware architecture can specify a base architecture and just provide a different kernel.
Rob Landley <rob@landley.net>
parents:
553
diff
changeset
|
107 else |
036dbe218036
Add BASE_ARCH support, so a hardware architecture can specify a base architecture and just provide a different kernel.
Rob Landley <rob@landley.net>
parents:
553
diff
changeset
|
108 TOOLS="${NATIVE}/usr" |
036dbe218036
Add BASE_ARCH support, so a hardware architecture can specify a base architecture and just provide a different kernel.
Rob Landley <rob@landley.net>
parents:
553
diff
changeset
|
109 fi |
351
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
110 else |
576
036dbe218036
Add BASE_ARCH support, so a hardware architecture can specify a base architecture and just provide a different kernel.
Rob Landley <rob@landley.net>
parents:
553
diff
changeset
|
111 HW_ARCH=host |
351
7f529baf0b57
Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents:
340
diff
changeset
|
112 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
|
113 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
|
114 fi |