comparison sources/include.sh @ 1623:6cef85eefede

Break out variable setting into sources/variables.sh
author Rob Landley <rob@landley.net>
date Sat, 24 Aug 2013 05:56:35 -0500
parents 59c1495d5b5e
children
comparison
equal deleted inserted replaced
1622:ca0cf2dc37c2 1623:6cef85eefede
1 #!/bin/echo "This file is sourced, not run" 1 #!/bin/echo "This file is sourced, not run"
2
3 # This is the top level include file sourced by each build stage.
4
5 # Guard against multiple inclusion
2 6
3 if ! already_included_this 2>/dev/null 7 if ! already_included_this 2>/dev/null
4 then 8 then
5 alias already_included_this=true 9 alias already_included_this=true
6 10
7 # Set up all the environment variables and functions for a build stage. 11 # Set up all the environment variables and functions for a build stage.
8 # This file is sourced, not run.
9 12
10 # Include config and source shell function files. 13 source config
11
12 [ -e config ] && source config
13
14 source sources/utility_functions.sh 14 source sources/utility_functions.sh
15 source sources/functions.sh 15 source sources/functions.sh
16 source sources/download_functions.sh 16 source sources/download_functions.sh
17 17 source sources/variables.sh
18 # Avoid trouble from unexpected environment settings
19
20 [ -z "$NO_SANITIZE_ENVIRONMENT" ] && sanitize_environment
21
22 # List of fallback mirrors to download package source from
23
24 MIRROR_LIST="http://landley.net/code/aboriginal/mirror http://127.0.0.1/code/aboriginal/mirror"
25
26 # Where are our working directories?
27
28 export_if_blank TOP=`pwd`
29 export_if_blank SOURCES="$TOP/sources"
30 export_if_blank SRCDIR="$TOP/packages"
31 export_if_blank PATCHDIR="$SOURCES/patches"
32 export_if_blank BUILD="$TOP/build"
33 export_if_blank SRCTREE="$BUILD/packages"
34 export_if_blank HOSTTOOLS="$BUILD/host"
35 export_if_blank WRAPDIR="$BUILD/record-commands"
36
37 # Set a default non-arch
38
39 export WORK="${BUILD}/host-temp"
40 export ARCH_NAME=host
41
42 # What host compiler should we use?
43
44 export_if_blank CC=cc
45
46 # How many processors should make -j use?
47
48 MEMTOTAL="$(awk '/MemTotal:/{print $2}' /proc/meminfo)"
49 if [ -z "$CPUS" ]
50 then
51 export CPUS=$(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)
52 [ "$CPUS" -lt 1 ] && CPUS=1
53
54 # If we're not using hyper-threading, and there's plenty of memory,
55 # use 50% more CPUS than we actually have to keep system busy
56
57 [ -z "$(cat /proc/cpuinfo | grep '^flags' | head -n 1 | grep -w ht)" ] &&
58 [ $(($CPUS*512*1024)) -le $MEMTOTAL ] &&
59 CPUS=$((($CPUS*3)/2))
60 fi
61
62 export_if_blank STAGE_NAME=`echo $0 | sed 's@.*/\(.*\)\.sh@\1@'`
63 [ ! -z "$BUILD_VERBOSE" ] && VERBOSITY="V=1"
64
65 export_if_blank BUILD_STATIC=busybox,toybox,binutils,gcc-core,gcc-g++,make
66
67 # Adjust $PATH
68
69 # If record-commands.sh set up a wrapper directory, adjust $PATH again.
70
71 export PATH
72 if [ -z "$OLDPATH" ]
73 then
74 export OLDPATH="$PATH"
75 [ -z "$BUSYBOX" ] || BUSYBOX=busybox
76 [ -f "$HOSTTOOLS/${BUSYBOX:-toybox}" ] &&
77 PATH="$(hosttools_path)" ||
78 PATH="$(hosttools_path):$PATH"
79
80 if [ -f "$WRAPDIR/wrappy" ]
81 then
82 OLDPATH="$PATH"
83 mkdir -p "$BUILD/logs"
84 [ $? -ne 0 ] && echo "Bad $WRAPDIR" >&2 && dienow
85 PATH="$WRAPDIR"
86 fi
87 fi
88 export WRAPPY_LOGPATH="$BUILD/logs/cmdlines.$ARCH_NAME.early"
89 18
90 # Create files with known permissions 19 # Create files with known permissions
91 umask 022 20 umask 022
92 21
93 # Tell bash not to cache the $PATH because we modify it. (Without this, bash 22 # Tell bash not to cache the $PATH because we modify it. (Without this, bash