annotate build.sh @ 33:bf2e771f4ba5

Update build script. Now uses a config file (usage: ./build.sh arch), and generates a tarball of the cross-compiler.
author Rob Landley <rob@landley.net>
date Mon, 11 Dec 2006 00:48:20 -0500
parents 8b75dee28f40
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
1 #!/bin/sh
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
2
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
3 # Memo: How should I pass this in?
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
4
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
5 ARCH="$(echo "$1" | sed 's@.*/@@')"
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
6 if [ ! -f sources/configs/"$1" ]
15
11b76d1cc1cd Trying to build an arm toolchain (so I can test "hello world" with arm
Rob Landley <rob@landley.net>
parents: 9
diff changeset
7 then
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
8 echo "Usage: $0 ARCH"
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
9 echo "Supported architectures: $(cd sources/configs && ls)"
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
10 exit 1
15
11b76d1cc1cd Trying to build an arm toolchain (so I can test "hello world" with arm
Rob Landley <rob@landley.net>
parents: 9
diff changeset
11 fi
11b76d1cc1cd Trying to build an arm toolchain (so I can test "hello world" with arm
Rob Landley <rob@landley.net>
parents: 9
diff changeset
12
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
13 CLEANUP="rm -rf"
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
14
1
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
15 function dienow()
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
16 {
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
17 echo "Exiting due to errors"
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
18 exit 1
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
19 }
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
20
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
21
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
22 function dotprogress()
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
23 {
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
24 x=0
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
25 while read i
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
26 do
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
27 x=$[$x + 1]
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
28 if [[ "$x" -eq 25 ]]
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
29 then
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
30 x=0
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
31 echo -n .
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
32 fi
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
33 done
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
34 echo
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
35 }
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
36
8
0068264ad65a Some work I did back in october but hadn't checked in yet: let setupfor()
Rob Landley <rob@landley.net>
parents: 3
diff changeset
37 # Extract package $1, use work directory $2 (or $1 if no $2), use source
0068264ad65a Some work I did back in october but hadn't checked in yet: let setupfor()
Rob Landley <rob@landley.net>
parents: 3
diff changeset
38 # directory $3 (or $1 if no $3)
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
39
1
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
40 function setupfor()
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
41 {
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
42 FILE="${SOURCES}/${STAGE}/$1"
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
43 if [ -f "${FILE}".tar.bz2 ]
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
44 then
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
45 FILE="${FILE}".tar.bz2
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
46 DECOMPRESS="j"
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
47 else
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
48 FILE="${FILE}".tar.gz
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
49 DECOMPRESS="z"
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
50 fi
1
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
51 echo "=== Building $1"
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
52 echo -n "Extracting"
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
53 cd "${WORK}" &&
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
54 { tar xv${DECOMPRESS}f "$FILE" || dienow
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
55 } | dotprogress
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
56 if [ -z "$2" ]
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
57 then
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
58 cd "$1"* || dienow
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
59 else
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
60 mkdir "$2"
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
61 cd "$2" || dienow
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
62 fi
8
0068264ad65a Some work I did back in october but hadn't checked in yet: let setupfor()
Rob Landley <rob@landley.net>
parents: 3
diff changeset
63 export CURSRC="$1"
0068264ad65a Some work I did back in october but hadn't checked in yet: let setupfor()
Rob Landley <rob@landley.net>
parents: 3
diff changeset
64 [ ! -z "$3" ] && CURSRC="$3"
0068264ad65a Some work I did back in october but hadn't checked in yet: let setupfor()
Rob Landley <rob@landley.net>
parents: 3
diff changeset
65 export CURSRC=`echo "${WORK}/${CURSRC}"*`
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
66 [ ! -d "${CURSRC}" ] && dienow
1
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
67 }
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
68
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
69 # Setup
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
70
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
71 umask 022
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
72 unset CFLAGS CXXFLAGS
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
73
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
74 # Find/create directories
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
75
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
76 TOP=`pwd`
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
77 export SOURCES="${TOP}/sources"
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
78 export CROSS="${TOP}/build/cross-compiler-$ARCH"
1
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
79 export WORK="${TOP}/build/temp"
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
80 mkdir -p "${CROSS}" "${WORK}"
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
81
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
82 [ $? -ne 0 ] && dienow
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
83
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
84 # For bash: check the $PATH for new executables added after startup.
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
85 set +h
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
86 # Put the cross compiler in the path
23
a5e004e33daa Balance quotes, add some missing quotes, preserve old $PATH.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
87 export PATH=${CROSS}/bin:"$PATH"
1
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
88
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
89 # Which platform are we building for?
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
90
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
91 export CROSS_HOST=i686-pc-linux-gnu
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
92 export CROSS_TARGET=${ARCH}-unknown-linux-gnu
1
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
93
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
94 export STAGE=build-cross
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
95
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
96 # Import the config for this arch.
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
97
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
98 . sources/configs/"$ARCH"
1
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
99
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
100 # Build and install binutils
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
101
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
102 setupfor binutils build-binutils
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
103 "${CURSRC}/configure" --prefix="${CROSS}" --host=${CROSS_HOST} \
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
104 --target=${CROSS_TARGET} --with-lib-path=lib --disable-nls \
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
105 --disable-shared --disable-multilib $BINUTILS_FLAGS &&
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
106 make configure-host &&
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
107 make &&
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
108 make install &&
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
109 cd .. &&
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
110 mkdir -p "${CROSS}/include" &&
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
111 cp binutils-*/include/libiberty.h "${CROSS}/include" &&
15
11b76d1cc1cd Trying to build an arm toolchain (so I can test "hello world" with arm
Rob Landley <rob@landley.net>
parents: 9
diff changeset
112 $CLEANUP binutils-* build-binutils
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
113
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
114 [ $? -ne 0 ] && dienow
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
115
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
116 # Build and install gcc
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
117
8
0068264ad65a Some work I did back in october but hadn't checked in yet: let setupfor()
Rob Landley <rob@landley.net>
parents: 3
diff changeset
118 setupfor gcc-core build-gcc gcc-
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
119 "${CURSRC}/configure" --prefix="${CROSS}" --host=${CROSS_HOST} \
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
120 --target=${CROSS_TARGET} --disable-threads --enable-languages=c \
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
121 --disable-multilib --disable-nls --disable-shared $GCC_FLAGS
15
11b76d1cc1cd Trying to build an arm toolchain (so I can test "hello world" with arm
Rob Landley <rob@landley.net>
parents: 9
diff changeset
122 #--with-local-prefix="${CROSS}" \
11b76d1cc1cd Trying to build an arm toolchain (so I can test "hello world" with arm
Rob Landley <rob@landley.net>
parents: 9
diff changeset
123 # --enable-languages=c,c++ --enable-__cxa_atexit --enable-c99 \
11b76d1cc1cd Trying to build an arm toolchain (so I can test "hello world" with arm
Rob Landley <rob@landley.net>
parents: 9
diff changeset
124 # --enable-long-long --enable-threads=posix &&
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
125 make all-gcc &&
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
126 make install-gcc &&
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
127 cd .. &&
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
128
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
129 # Move the gcc internal libraries and headers somewhere sane.
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
130
21
c4e1bd04035d Build uClibc under the wrapper script. (There's got to be a better way to
Rob Landley <rob@landley.net>
parents: 18
diff changeset
131 mkdir -p "${CROSS}"/gcc &&
c4e1bd04035d Build uClibc under the wrapper script. (There's got to be a better way to
Rob Landley <rob@landley.net>
parents: 18
diff changeset
132 mv "${CROSS}"/lib/gcc/*/*/include "${CROSS}"/gcc/include &&
c4e1bd04035d Build uClibc under the wrapper script. (There's got to be a better way to
Rob Landley <rob@landley.net>
parents: 18
diff changeset
133 mv "${CROSS}"/lib/gcc/*/* "${CROSS}"/gcc/lib &&
c4e1bd04035d Build uClibc under the wrapper script. (There's got to be a better way to
Rob Landley <rob@landley.net>
parents: 18
diff changeset
134 $CLEANUP "${CURSRC}" build-gcc "${CROSS}"/{lib/gcc,gcc/lib/install-tools} &&
c4e1bd04035d Build uClibc under the wrapper script. (There's got to be a better way to
Rob Landley <rob@landley.net>
parents: 18
diff changeset
135
c4e1bd04035d Build uClibc under the wrapper script. (There's got to be a better way to
Rob Landley <rob@landley.net>
parents: 18
diff changeset
136 # Build and install gcc wrapper script.
c4e1bd04035d Build uClibc under the wrapper script. (There's got to be a better way to
Rob Landley <rob@landley.net>
parents: 18
diff changeset
137
c4e1bd04035d Build uClibc under the wrapper script. (There's got to be a better way to
Rob Landley <rob@landley.net>
parents: 18
diff changeset
138 GCCNAME="$(echo "${CROSS}"/bin/*-gcc)" &&
c4e1bd04035d Build uClibc under the wrapper script. (There's got to be a better way to
Rob Landley <rob@landley.net>
parents: 18
diff changeset
139 mv "$GCCNAME" "${CROSS}"/bin/gcc-unwrapped &&
c4e1bd04035d Build uClibc under the wrapper script. (There's got to be a better way to
Rob Landley <rob@landley.net>
parents: 18
diff changeset
140 gcc "${TOP}"/sources/toys/gcc-uClibc.c -Os -s -o "$GCCNAME"
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
141
8
0068264ad65a Some work I did back in october but hadn't checked in yet: let setupfor()
Rob Landley <rob@landley.net>
parents: 3
diff changeset
142 [ $? -ne 0 ] && dienow
0068264ad65a Some work I did back in october but hadn't checked in yet: let setupfor()
Rob Landley <rob@landley.net>
parents: 3
diff changeset
143
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
144 # Install the linux kernel, and kernel headers.
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
145
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
146 setupfor linux
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
147 # Configure kernel
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
148 ##mv "${WORK}"/config-linux .config &&
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
149 ##(yes "" | make ARCH="${KARCH}" oldconfig) &&
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
150 # Install Linux kernel headers (for use by uClibc).
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
151 make headers_install ARCH="${KARCH}" INSTALL_HDR_PATH="${CROSS}" &&
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
152 # Build bootable kernel for target.
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
153 ##make ARCH="${KARCH}" CROSS_COMPILE="${CROSS_TARGET}"- &&
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
154 ##cp "${KERNEL_PATH}" "${CROSS}"/zImage &&
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
155 cd .. &&
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
156 $CLEANUP linux-*
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
157
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
158 [ $? -ne 0 ] && dienow
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
159
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
160 # Build and install uClibc
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
161
8
0068264ad65a Some work I did back in october but hadn't checked in yet: let setupfor()
Rob Landley <rob@landley.net>
parents: 3
diff changeset
162 setupfor uClibc
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
163 cp "${WORK}"/config-uClibc .config &&
23
a5e004e33daa Balance quotes, add some missing quotes, preserve old $PATH.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
164 (yes "" | make CROSS="${CROSS_TARGET}"- oldconfig) &&
a5e004e33daa Balance quotes, add some missing quotes, preserve old $PATH.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
165 make CROSS="${CROSS_TARGET}"- KERNEL_SOURCE="${CROSS}" &&
a5e004e33daa Balance quotes, add some missing quotes, preserve old $PATH.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
166 #make CROSS="${CROSS_TARGET}"- utils &&
8
0068264ad65a Some work I did back in october but hadn't checked in yet: let setupfor()
Rob Landley <rob@landley.net>
parents: 3
diff changeset
167 # The kernel headers are already installed, but uClibc's install will try to
0068264ad65a Some work I did back in october but hadn't checked in yet: let setupfor()
Rob Landley <rob@landley.net>
parents: 3
diff changeset
168 # be "helpful" and copy them over themselves, at which point hilarity ensues.
0068264ad65a Some work I did back in october but hadn't checked in yet: let setupfor()
Rob Landley <rob@landley.net>
parents: 3
diff changeset
169 # Make it not do that.
0068264ad65a Some work I did back in october but hadn't checked in yet: let setupfor()
Rob Landley <rob@landley.net>
parents: 3
diff changeset
170 rm include/{asm,asm-generic,linux} &&
23
a5e004e33daa Balance quotes, add some missing quotes, preserve old $PATH.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
171 make CROSS="${CROSS_TARGET}"- KERNEL_SOURCE="${CROSS}"/ \
21
c4e1bd04035d Build uClibc under the wrapper script. (There's got to be a better way to
Rob Landley <rob@landley.net>
parents: 18
diff changeset
172 RUNTIME_PREFIX="${CROSS}"/ DEVEL_PREFIX="${CROSS}"/ \
8
0068264ad65a Some work I did back in october but hadn't checked in yet: let setupfor()
Rob Landley <rob@landley.net>
parents: 3
diff changeset
173 install_runtime install_dev &&
22
775c1fdc1730 Minor cleanup on the wrapper script (much more cleanup needed before it's
Rob Landley <rob@landley.net>
parents: 21
diff changeset
174 # The uClibc build uses ./include instead of ${CROSS}/include, so the symlinks
775c1fdc1730 Minor cleanup on the wrapper script (much more cleanup needed before it's
Rob Landley <rob@landley.net>
parents: 21
diff changeset
175 # need to come back. (Yes, it links against the _headers_ from the source,
775c1fdc1730 Minor cleanup on the wrapper script (much more cleanup needed before it's
Rob Landley <rob@landley.net>
parents: 21
diff changeset
176 # but against the _libraries_ from the destination. Hence needing to install
775c1fdc1730 Minor cleanup on the wrapper script (much more cleanup needed before it's
Rob Landley <rob@landley.net>
parents: 21
diff changeset
177 # libc.so before building utils.)
23
a5e004e33daa Balance quotes, add some missing quotes, preserve old $PATH.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
178 ln -s "${CROSS}"/include/linux include/linux &&
a5e004e33daa Balance quotes, add some missing quotes, preserve old $PATH.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
179 ln -s "${CROSS}"/include/asm include/asm &&
a5e004e33daa Balance quotes, add some missing quotes, preserve old $PATH.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
180 ln -s "${CROSS}"/include/asm-generic include/asm-generic &&
22
775c1fdc1730 Minor cleanup on the wrapper script (much more cleanup needed before it's
Rob Landley <rob@landley.net>
parents: 21
diff changeset
181 make CROSS=${CROSS_TARGET}- RUNTIME_PREFIX="${CROSS}"/ install_utils &&
8
0068264ad65a Some work I did back in october but hadn't checked in yet: let setupfor()
Rob Landley <rob@landley.net>
parents: 3
diff changeset
182 cd .. &&
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
183 $CLEANUP uClibc*
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
184
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
185 [ $? -ne 0 ] && dienow
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
186
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
187 # A quick hello world program to test the cross-compiler out.
17
1202bdb44025 Build for the wrapper script. (Which still doesn't work right.)
Rob Landley <rob@landley.net>
parents: 15
diff changeset
188
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
189 cat > "$WORK"/hello.c << 'EOF' &&
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
190 #include <stdio.h>
17
1202bdb44025 Build for the wrapper script. (Which still doesn't work right.)
Rob Landley <rob@landley.net>
parents: 15
diff changeset
191
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
192 int main(int argc, char *argv[])
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
193 {
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
194 printf("Hello world!\n");
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
195 return 0;
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
196 }
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
197 EOF
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
198
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
199 # Build hello.c dynamic, then static, to verify header/library paths.
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
200
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
201 "$GCCNAME" -Os "$WORK"/hello.c -o "$WORK"/hello &&
24
60ad658c5aab One more missing path in the qemu-arm check. (Notice I'm not building qemu
Rob Landley <rob@landley.net>
parents: 23
diff changeset
202 "$GCCNAME" -Os -static "$WORK"/hello.c -o "$WORK"/hello &&
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
203 [ x"$(qemu-"${KARCH}" "${WORK}"/hello)" == x"Hello world!" ] &&
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
204 echo Cross-toolchain seems to work.
17
1202bdb44025 Build for the wrapper script. (Which still doesn't work right.)
Rob Landley <rob@landley.net>
parents: 15
diff changeset
205
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
206 [ $? -ne 0 ] && dienow
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
207
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
208 # Change the FSF's crazy names to something reasonable.
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
209
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
210 cd "${CROSS}"/bin &&
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
211 for i in "${ARCH}"-*
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
212 do
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
213 strip "$i"
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
214 mv "$i" "${ARCH}"-"$(echo "$i" | sed 's/.*-//')"
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
215 done
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
216
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
217 cat > "${CROSS}"/README << "EOF" &&
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
218 Cross compiler for $ARCH
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
219 From http://landley.net/code/firmware
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
220
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
221 To use: Add the \"bin\" directory to your \$PATH, and use \"$ARCH-gcc\" as
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
222 your compiler.
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
223
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
224 The syntax used to build the Linux kernel is:
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
225
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
226 make ARCH="${KARCH}" CROSS_COMPILE="${ARCH}"-
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
227
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
228 EOF
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
229
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
230 # Tar up the cross compiler.
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
231 cd "${TOP}"
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
232 tar cjvCf build cross-compiler-"${ARCH}".tar.bz2 cross-compiler-"${ARCH}" &&
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
233
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
234 [ $? -ne 0 ] && dienow