annotate sources/include.sh @ 984:9840847885e8

Add export_if_blank and make lots of build paths overrideable.
author Rob Landley <rob@landley.net>
date Wed, 24 Feb 2010 10:08:38 -0600
parents cfeaae1c55ed
children 491eec5512dd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
840
96b276eda7f1 Comment tweaks.
Rob Landley <rob@landley.net>
parents: 798
diff changeset
1 #!/bin/echo "This file is sourced, not run"
96b276eda7f1 Comment tweaks.
Rob Landley <rob@landley.net>
parents: 798
diff changeset
2
96b276eda7f1 Comment tweaks.
Rob Landley <rob@landley.net>
parents: 798
diff changeset
3 # Set up all the environment variables and functions for a build stage.
96b276eda7f1 Comment tweaks.
Rob Landley <rob@landley.net>
parents: 798
diff changeset
4 # This file is sourced, not run.
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
5
897
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
6 # Include config and sources/functions.sh
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
7
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
8 [ -e config ] && source config
897
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
9
744
759adf5a0fe9 Refactor so include.sh mostly just sets environment variables. Move read_arch_dir to function and call it explicitly (no more need for $NO_ARCH). Make blank_tempdir a function, called explicitly by stages when needed, with some sanity checks. Insert prerequisite tests to later stages so they can detect failure early and provide an explicit erro rmessage, and have those tests happen before blanking $WORK dir, to preserve debugging info. Make buildall.sh depend on prerequisite tests rather than trying to avoid calling later stages (and thus do flow control from asynchronous context). Add FAIL_QUIET option so buildall.sh doesn't spam the log with the new prerequisite error messages.
Rob Landley <rob@landley.net>
parents: 743
diff changeset
10 source sources/functions.sh
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
11
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents: 910
diff changeset
12 # List of fallback mirrors to download package source from
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents: 910
diff changeset
13
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents: 910
diff changeset
14 MIRROR_LIST="http://impactlinux.com/firmware/mirror http://landley.net/code/firmware/mirror http://127.0.0.1/code/firmware/mirror"
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents: 910
diff changeset
15
897
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
16 # Where are our working directories?
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
17
984
9840847885e8 Add export_if_blank and make lots of build paths overrideable.
Rob Landley <rob@landley.net>
parents: 973
diff changeset
18 export_if_blank TOP=`pwd`
9840847885e8 Add export_if_blank and make lots of build paths overrideable.
Rob Landley <rob@landley.net>
parents: 973
diff changeset
19 export_if_blank SOURCES="$TOP/sources"
9840847885e8 Add export_if_blank and make lots of build paths overrideable.
Rob Landley <rob@landley.net>
parents: 973
diff changeset
20 export_if_blank SRCDIR="$TOP/packages"
9840847885e8 Add export_if_blank and make lots of build paths overrideable.
Rob Landley <rob@landley.net>
parents: 973
diff changeset
21 export_if_blank PATCHDIR="$SOURCES/patches"
9840847885e8 Add export_if_blank and make lots of build paths overrideable.
Rob Landley <rob@landley.net>
parents: 973
diff changeset
22 export_if_blank BUILD="$TOP/build"
9840847885e8 Add export_if_blank and make lots of build paths overrideable.
Rob Landley <rob@landley.net>
parents: 973
diff changeset
23 export_if_blank SRCTREE="$BUILD/packages"
9840847885e8 Add export_if_blank and make lots of build paths overrideable.
Rob Landley <rob@landley.net>
parents: 973
diff changeset
24 export_if_blank HOSTTOOLS="$BUILD/host"
9840847885e8 Add export_if_blank and make lots of build paths overrideable.
Rob Landley <rob@landley.net>
parents: 973
diff changeset
25 export_if_blank WRAPDIR="$BUILD/wrapdir"
897
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
26
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
27 # Set a default non-arch
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
28
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
29 export WORK="${BUILD}/host-temp"
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
30 export ARCH_NAME=host
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
31
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
32 # 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
33
984
9840847885e8 Add export_if_blank and make lots of build paths overrideable.
Rob Landley <rob@landley.net>
parents: 973
diff changeset
34 export_if_blank CC=cc
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
35
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
36 # 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
37
900
266dc7ea04c2 If there's enough memory (half a gig per processor), use 1.5x as many CPUs to try to keep 'em busy.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
38 MEMTOTAL="$(awk '/MemTotal:/{print $2}' /proc/meminfo)"
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
39 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
40 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
41 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
42 [ "$CPUS" -lt 1 ] && CPUS=1
900
266dc7ea04c2 If there's enough memory (half a gig per processor), use 1.5x as many CPUs to try to keep 'em busy.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
43
266dc7ea04c2 If there's enough memory (half a gig per processor), use 1.5x as many CPUs to try to keep 'em busy.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
44 # If there's enough memory, try to make CPUs stay busy.
266dc7ea04c2 If there's enough memory (half a gig per processor), use 1.5x as many CPUs to try to keep 'em busy.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
45
266dc7ea04c2 If there's enough memory (half a gig per processor), use 1.5x as many CPUs to try to keep 'em busy.
Rob Landley <rob@landley.net>
parents: 897
diff changeset
46 [ $(($CPUS*512*1024)) -le $MEMTOTAL ] && CPUS=$((($CPUS*3)/2))
351
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
47 fi
7f529baf0b57 Reorganize include.sh to put config options at the top, minor cleanups.
Rob Landley <rob@landley.net>
parents: 340
diff changeset
48
984
9840847885e8 Add export_if_blank and make lots of build paths overrideable.
Rob Landley <rob@landley.net>
parents: 973
diff changeset
49 export_if_blank STAGE_NAME=`echo $0 | sed 's@.*/\(.*\)\.sh@\1@'`
897
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
50 [ ! -z "$BUILD_VERBOSE" ] && VERBOSITY="V=1"
615
7523d1f3b818 Some slight paranoia against multiple host-tools.sh runs that get interrupted in the middle. (Yeah, in general that's not guaranteed to work, but still...)
Rob Landley <rob@landley.net>
parents: 608
diff changeset
51
352
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
52 # 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
53
897
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
54 export OLDPATH="$PATH"
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
55 PATH="$(hosttools_path)"
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
56
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
57 # If record-commands.sh set up a wrapper directory, adjust $PATH again.
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
58 if [ -f "$WRAPDIR/wrappy" ]
352
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
59 then
897
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
60 export WRAPPY_LOGPATH="$BUILD/logs/cmdlines.$ARCH_NAME.early"
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
61 OLDPATH="$PATH:$OLDPATH"
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
62 PATH="$WRAPDIR"
910
f1671488c740 Split busybox and toybox builds, update toybox and linux package versions.
Rob Landley <rob@landley.net>
parents: 900
diff changeset
63 elif [ ! -f "$HOSTTOOLS/busybox" ] || [ ! -f "$HOSTTOOLS/toybox" ]
897
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
64 then
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
65 PATH="$PATH:$OLDPATH"
352
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
66 fi
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
67
897
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
68 # Create files with known permissions
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
69 umask 022
608
ab76d4cdd392 Jean Wolter pointed out that running RECORD_COMMANDS=1 twice could create circular symlinks. Hopefully fixed now, and some related cleanups/clarifications.
Rob Landley <rob@landley.net>
parents: 597
diff changeset
70
897
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
71 # Tell bash not to cache the $PATH because we modify it. (Without this, bash
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
72 # won't find new executables added after startup.)
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
73 set +h
352
1782b77fae15 Add command logging. Set RECORD_COMMANDS=1 to log every command line run
Rob Landley <rob@landley.net>
parents: 351
diff changeset
74
897
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
75 # Disable internationalization so sort and sed and such can cope with ASCII.
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
76
850da666acc6 Redo command recording: no longer RECORD_COMMMANDS config entry, now sources/more/record-commands.sh run to set up the wrapper (either before or after host-tools.sh). General cleanup and simplification of code this interacted with, plus clean up bit rot in the reporting.
Rob Landley <rob@landley.net>
parents: 854
diff changeset
77 export LC_ALL=C