Mercurial > hg > aboriginal
annotate include.sh @ 214:0c60dc8d7fd5
Make sure the patches are sorted even if the filesystem doesn't do it for us.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 09 Sep 2007 03:42:28 -0500 |
parents | 1080306ae20e |
children | 8d2d0feff1ef |
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 |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
3 function download() |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
4 { |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
5 FILENAME=`echo "$URL" | sed 's .*/ '` |
166
87feb7deddbc
Mike released an actual uClibc 0.9.29-rc1 (even though it's named weird), so
Rob Landley <rob@landley.net>
parents:
163
diff
changeset
|
6 BASENAME=`echo "$FILENAME" | sed -r -e 's/-*([0-9\.]|[_-]rc|-pre|[0-9][a-zA-Z])*(\.tar\..z2*)$/\2/'` |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
7 |
36
2f1a6a4645ed
Why didn't "hg mv build.sh cross-compiler.sh" figure out what build.sh had
Rob Landley <rob@landley.net>
parents:
35
diff
changeset
|
8 if [ ! -z "$LINKDIR" ] |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
9 then |
36
2f1a6a4645ed
Why didn't "hg mv build.sh cross-compiler.sh" figure out what build.sh had
Rob Landley <rob@landley.net>
parents:
35
diff
changeset
|
10 rm -f "$LINKDIR/$BASENAME" 2> /dev/null |
163
729dd17a7b74
Point uClibc at the 0.9.29-pre1 I just uploaded, teach include.sh about
Rob Landley <rob@landley.net>
parents:
155
diff
changeset
|
11 ln -s "$FROMSRC/$FILENAME" "$LINKDIR/$BASENAME" || dienow |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
12 fi |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
13 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
14 # The extra "" is so we test the sha1sum after the last download. |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
15 |
101
9b7fcdfbe11c
Add a third mirror, with older versions.
Rob Landley <rob@landley.net>
parents:
98
diff
changeset
|
16 for i in "$URL" http://www.landley.net/code/firmware/mirror/"$FILENAME" \ |
9b7fcdfbe11c
Add a third mirror, with older versions.
Rob Landley <rob@landley.net>
parents:
98
diff
changeset
|
17 http://engineering.timesys.com/~landley/mirror/"$FILENAME" "" |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
18 do |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
19 # Return success if we have a valid copy of the file |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
20 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
21 # Test first (so we don't re-download a file we've already got). |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
22 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
23 SUM=`cat "$SRCDIR/$FILENAME" | sha1sum | awk '{print $1}'` |
41 | 24 if [ -z "$SHA1" ] && [ -f "$SRCDIR/$FILENAME" ] |
25 then | |
26 touch "$SRCDIR/$FILENAME" | |
210
9bd872911a60
Slightly better debug info: show sha1sum of file when none to compare against.
Rob Landley <rob@landley.net>
parents:
191
diff
changeset
|
27 echo "No SHA1 for $FILENAME ($SUM)" |
41 | 28 return 0 |
29 elif [ x"$SUM" == x"$SHA1" ] | |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
30 then |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
31 touch "$SRCDIR/$FILENAME" |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
32 echo "Confirmed $FILENAME" |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
33 return 0 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
34 fi |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
35 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
36 # If there's a corrupted file, delete it. In theory it would be nice |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
37 # to resume downloads, but wget creates "*.1" files instead. |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
38 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
39 rm "$SRCDIR/$FILENAME" 2> /dev/null |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
40 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
41 # If we have another source, try to download file. |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
42 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
43 if [ -n "$i" ] |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
44 then |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
45 wget -P "$SRCDIR" "$i" |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
46 fi |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
47 done |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
48 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
49 # Return failure. |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
50 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
51 echo "Could not download $FILENAME" |
81
6dd38c925bc4
Upgrade some packages, and other cleanups.
Rob Landley <rob@landley.net>
parents:
62
diff
changeset
|
52 echo -en "\e[0m" |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
53 return 1 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
54 } |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
55 |
41 | 56 # Clean obsolete files out of the source directory |
57 | |
58 START_TIME=`date +%s` | |
59 | |
60 function cleanup_oldfiles() | |
61 { | |
62 for i in "${SRCDIR}"/* | |
63 do | |
64 if [ -f "$i" ] && [ "$(date +%s -r "$i")" -lt "${START_TIME}" ] | |
65 then | |
66 echo Removing old file "$i" | |
67 rm -rf "$i" | |
68 fi | |
69 done | |
70 } | |
71 | |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
72 function dienow() |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
73 { |
170
440ccb0c6acb
Suggestion from Ben Stoltz to improve diagnostic output.
Rob Landley <rob@landley.net>
parents:
166
diff
changeset
|
74 echo -e "\e[31mExiting due to errors ($(caller))\e[0m" |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
75 exit 1 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
76 } |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
77 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
78 function dotprogress() |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
79 { |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
80 x=0 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
81 while read i |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
82 do |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
83 x=$[$x + 1] |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
84 if [[ "$x" -eq 25 ]] |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
85 then |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
86 x=0 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
87 echo -n . |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
88 fi |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
89 done |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
90 echo |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
91 } |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
92 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
93 # Extract package $1, use work directory $2 (or $1 if no $2), use source |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
94 # directory $3 (or $1 if no $3) |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
95 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
96 function setupfor() |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
97 { |
41 | 98 # Is it a bzip2 or gzip tarball? |
99 | |
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
|
100 FILE="$1".tar.bz2 |
8b4c243a212e
Add better debug info to a status report, and stop fighting ubuntu so much
Rob Landley <rob@landley.net>
parents:
170
diff
changeset
|
101 DECOMPRESS="j" |
8b4c243a212e
Add better debug info to a status report, and stop fighting ubuntu so much
Rob Landley <rob@landley.net>
parents:
170
diff
changeset
|
102 |
8b4c243a212e
Add better debug info to a status report, and stop fighting ubuntu so much
Rob Landley <rob@landley.net>
parents:
170
diff
changeset
|
103 if [ ! -f "${LINKDIR}/${FILE}" ] |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
104 then |
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
|
105 FILE="$1".tar.gz |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
106 DECOMPRESS="z" |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
107 fi |
41 | 108 |
109 # Announce package, with easy-to-grep-for "===" marker. Extract it. | |
110 | |
125
2dd9f480ff4e
Set PATH for run-mini-native.sh and add more obvious arch display info when
Rob Landley <rob@landley.net>
parents:
124
diff
changeset
|
111 echo "=== Building $1 ($ARCH_NAME)" |
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
|
112 echo -n "Extracting '${FILE}'" |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
113 cd "${WORK}" && |
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
|
114 { tar xv${DECOMPRESS}f "${LINKDIR}/${FILE}" || dienow |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
115 } | dotprogress |
41 | 116 |
117 # Do we have a separate working directory? | |
118 | |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
119 if [ -z "$2" ] |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
120 then |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
121 cd "$1"* || dienow |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
122 else |
47
edaa86240321
Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents:
41
diff
changeset
|
123 mkdir -p "$2" && |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
124 cd "$2" || dienow |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
125 fi |
41 | 126 |
127 # Set CURSRC | |
128 | |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
129 export CURSRC="$1" |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
130 [ ! -z "$3" ] && CURSRC="$3" |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
131 export CURSRC=`echo "${WORK}/${CURSRC}"*` |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
132 [ ! -d "${CURSRC}" ] && dienow |
41 | 133 |
134 # Apply any patches to this package | |
135 | |
214
0c60dc8d7fd5
Make sure the patches are sorted even if the filesystem doesn't do it for us.
Rob Landley <rob@landley.net>
parents:
213
diff
changeset
|
136 ls "${SOURCES}/patches/$1"* 2> /dev/null | sort | while read i |
41 | 137 do |
138 if [ -f "$i" ] | |
139 then | |
188
ee8aefd2760b
Note which patch is being applied, in case it doesn't.
Rob Landley <rob@landley.net>
parents:
182
diff
changeset
|
140 echo "Applying $i" |
41 | 141 (cd "${CURSRC}" && patch -p1 -i "$i") || dienow |
142 fi | |
143 done | |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
144 } |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
145 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
146 # Setup |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
147 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
148 umask 022 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
149 unset CFLAGS CXXFLAGS |
191
485dabec83c4
Comment one of the non-obvious (and optional) bits.
Rob Landley <rob@landley.net>
parents:
188
diff
changeset
|
150 # This tells gcc to aggressively garbage collect its internal data |
485dabec83c4
Comment one of the non-obvious (and optional) bits.
Rob Landley <rob@landley.net>
parents:
188
diff
changeset
|
151 # structures. Without this, gcc triggers the OOM killer trying to rebuild |
485dabec83c4
Comment one of the non-obvious (and optional) bits.
Rob Landley <rob@landley.net>
parents:
188
diff
changeset
|
152 # itself in 128 megs of ram, which is the QEMU default size. |
124
d5e9d5cf0172
According to http://hostingfu.com/article/compiling-with-gcc-on-low-memory-vps
Rob Landley <rob@landley.net>
parents:
120
diff
changeset
|
153 export CFLAGS="--param ggc-min-expand=0 --param ggc-min-heapsize=8192" |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
154 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
155 # Find/create directories |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
156 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
157 TOP=`pwd` |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
158 export SOURCES="${TOP}/sources" |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
159 export SRCDIR="${SOURCES}/packages" |
98
b6b4386a6c83
Make host-tools.sh work when run standalone.
Rob Landley <rob@landley.net>
parents:
96
diff
changeset
|
160 export FROMSRC=../packages |
36
2f1a6a4645ed
Why didn't "hg mv build.sh cross-compiler.sh" figure out what build.sh had
Rob Landley <rob@landley.net>
parents:
35
diff
changeset
|
161 export LINKDIR="${SOURCES}/build-links" |
41 | 162 export BUILD="${TOP}/build" |
98
b6b4386a6c83
Make host-tools.sh work when run standalone.
Rob Landley <rob@landley.net>
parents:
96
diff
changeset
|
163 export HOSTTOOLS="${BUILD}/host" |
b6b4386a6c83
Make host-tools.sh work when run standalone.
Rob Landley <rob@landley.net>
parents:
96
diff
changeset
|
164 export WORK="${BUILD}/host-temp" |
b6b4386a6c83
Make host-tools.sh work when run standalone.
Rob Landley <rob@landley.net>
parents:
96
diff
changeset
|
165 export PATH="${HOSTTOOLS}:$PATH" |
62
4125b672b00c
Get i686 cross-compiling to work like armv4l cross-compiling by lying to
Rob Landley <rob@landley.net>
parents:
60
diff
changeset
|
166 mkdir -p "${SRCDIR}" "${LINKDIR}" |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
167 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
168 # For bash: check the $PATH for new executables added after startup. |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
169 set +h |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
170 |
47
edaa86240321
Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents:
41
diff
changeset
|
171 # Are we doing a short build? |
edaa86240321
Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents:
41
diff
changeset
|
172 |
edaa86240321
Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents:
41
diff
changeset
|
173 if [ "$1" == "--short" ] |
edaa86240321
Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents:
41
diff
changeset
|
174 then |
edaa86240321
Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents:
41
diff
changeset
|
175 export BUILD_SHORT=1 |
edaa86240321
Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents:
41
diff
changeset
|
176 shift |
edaa86240321
Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents:
41
diff
changeset
|
177 fi |
edaa86240321
Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents:
41
diff
changeset
|
178 |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
179 # Get target platform from first command line argument. |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
180 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
181 if [ -z "$NO_ARCH" ] |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
182 then |
125
2dd9f480ff4e
Set PATH for run-mini-native.sh and add more obvious arch display info when
Rob Landley <rob@landley.net>
parents:
124
diff
changeset
|
183 ARCH_NAME="$1" |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
184 ARCH="$(echo "$1" | sed 's@.*/@@')" |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
185 if [ ! -f "${TOP}/sources/configs/${ARCH}" ] |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
186 then |
35
25bfa6ac9f84
Make the "supported architecutes" list have sane line breaks.
Rob Landley <rob@landley.net>
parents:
34
diff
changeset
|
187 echo "Supported architectures: " |
25bfa6ac9f84
Make the "supported architecutes" list have sane line breaks.
Rob Landley <rob@landley.net>
parents:
34
diff
changeset
|
188 (cd "${TOP}/sources/configs" && ls) |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
189 exit 1 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
190 fi |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
191 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
192 # Which platform are we building for? |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
193 |
62
4125b672b00c
Get i686 cross-compiling to work like armv4l cross-compiling by lying to
Rob Landley <rob@landley.net>
parents:
60
diff
changeset
|
194 export WORK="${BUILD}/temp-$ARCH" |
107
72f414b2939d
Have to make the include directory before we can put config files in it.
Rob Landley <rob@landley.net>
parents:
101
diff
changeset
|
195 rm -rf "${WORK}" |
72f414b2939d
Have to make the include directory before we can put config files in it.
Rob Landley <rob@landley.net>
parents:
101
diff
changeset
|
196 mkdir -p "${WORK}" |
62
4125b672b00c
Get i686 cross-compiling to work like armv4l cross-compiling by lying to
Rob Landley <rob@landley.net>
parents:
60
diff
changeset
|
197 # Say "unknown" in two different ways so it doesn't assume we're NOT |
4125b672b00c
Get i686 cross-compiling to work like armv4l cross-compiling by lying to
Rob Landley <rob@landley.net>
parents:
60
diff
changeset
|
198 # cross compiling when the host and target are the same processor. (If host |
4125b672b00c
Get i686 cross-compiling to work like armv4l cross-compiling by lying to
Rob Landley <rob@landley.net>
parents:
60
diff
changeset
|
199 # and target match, the binutils/gcc/make builds won't use the cross compiler |
4125b672b00c
Get i686 cross-compiling to work like armv4l cross-compiling by lying to
Rob Landley <rob@landley.net>
parents:
60
diff
changeset
|
200 # during mini-native.sh, and the host compiler links binaries against the |
4125b672b00c
Get i686 cross-compiling to work like armv4l cross-compiling by lying to
Rob Landley <rob@landley.net>
parents:
60
diff
changeset
|
201 # wrong libc.) |
213
1080306ae20e
Allow host to be overridden (to build on MacOS X).
Rob Landley <rob@landley.net>
parents:
210
diff
changeset
|
202 [ -z "$CROSS_HOST" ] && export CROSS_HOST=`uname -m`-walrus-linux |
1080306ae20e
Allow host to be overridden (to build on MacOS X).
Rob Landley <rob@landley.net>
parents:
210
diff
changeset
|
203 [ -z "$CROSS_TARGET" ] && export CROSS_TARGET=${ARCH}-unknown-linux |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
204 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
205 # Read the relevant config file. |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
206 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
207 source "${TOP}/sources/configs/${ARCH}" |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
208 |
62
4125b672b00c
Get i686 cross-compiling to work like armv4l cross-compiling by lying to
Rob Landley <rob@landley.net>
parents:
60
diff
changeset
|
209 # Setup directories and add the cross compiler to the start of the path. |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
210 |
41 | 211 export CROSS="${BUILD}/cross-compiler-$ARCH" |
212 export NATIVE="${BUILD}/mini-native-$ARCH" | |
145
b174c242934b
Remove redundant $PATH element pointed out by George Boudreau.
Rob Landley <rob@landley.net>
parents:
138
diff
changeset
|
213 export PATH="${CROSS}/bin:$PATH" |
108
b66d638a3844
Build User Mode Linux and have that do the ext2 packaging (for now, anyway).
Rob Landley <rob@landley.net>
parents:
107
diff
changeset
|
214 export IMAGE="${BUILD}/image-${ARCH}.ext2" |
155
ce1ca3d0f95b
Put zImage-$ARCH in build directory, not mini-native-$ARCH, and eliminate
Rob Landley <rob@landley.net>
parents:
145
diff
changeset
|
215 |
ce1ca3d0f95b
Put zImage-$ARCH in build directory, not mini-native-$ARCH, and eliminate
Rob Landley <rob@landley.net>
parents:
145
diff
changeset
|
216 |
ce1ca3d0f95b
Put zImage-$ARCH in build directory, not mini-native-$ARCH, and eliminate
Rob Landley <rob@landley.net>
parents:
145
diff
changeset
|
217 emulator_command image-$ARCH.ext2 zImage-$ARCH \ |
ce1ca3d0f95b
Put zImage-$ARCH in build directory, not mini-native-$ARCH, and eliminate
Rob Landley <rob@landley.net>
parents:
145
diff
changeset
|
218 "rw init=/tools/bin/sh panic=1 PATH=/tools/bin" > "$BUILD/run-$ARCH.sh" && |
ce1ca3d0f95b
Put zImage-$ARCH in build directory, not mini-native-$ARCH, and eliminate
Rob Landley <rob@landley.net>
parents:
145
diff
changeset
|
219 chmod +x "$BUILD/run-$ARCH.sh" |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
220 fi |
98
b6b4386a6c83
Make host-tools.sh work when run standalone.
Rob Landley <rob@landley.net>
parents:
96
diff
changeset
|
221 mkdir -p "${WORK}" |
34
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
222 |
ad1cfcb043c7
Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
223 [ -z "$CLEANUP" ] && CLEANUP="rm -rf" |
110
62f6268ff61b
Build uClibc's readelf and ldd by hand to work around inadequate cross-compile
Rob Landley <rob@landley.net>
parents:
108
diff
changeset
|
224 [ -z "$CC" ] && CC=gcc |
182
fc827ab6166f
Autodetect number of processors and feed appropriate -j to make.
Rob Landley <rob@landley.net>
parents:
173
diff
changeset
|
225 if [ -z "$CPUS" ] |
fc827ab6166f
Autodetect number of processors and feed appropriate -j to make.
Rob Landley <rob@landley.net>
parents:
173
diff
changeset
|
226 then |
fc827ab6166f
Autodetect number of processors and feed appropriate -j to make.
Rob Landley <rob@landley.net>
parents:
173
diff
changeset
|
227 export CPUS=$[$(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)+0] |
fc827ab6166f
Autodetect number of processors and feed appropriate -j to make.
Rob Landley <rob@landley.net>
parents:
173
diff
changeset
|
228 [ "$CPUS" -lt 1 ] && CPUS=1 |
fc827ab6166f
Autodetect number of processors and feed appropriate -j to make.
Rob Landley <rob@landley.net>
parents:
173
diff
changeset
|
229 fi |