annotate cross-compiler.sh @ 507:58e9523a775d

Tweak the readme, add comments, remove some dead code.
author Rob Landley <rob@landley.net>
date Sun, 30 Nov 2008 06:18:43 -0600
parents e98ed40c55ef
children ea7a010e5c47
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
175
6fd189c18c1c Three things: 1) dash->bash, 2) install cross-ldd and cross-readelf,
Rob Landley <rob@landley.net>
parents: 147
diff changeset
1 #!/bin/bash
1
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
2
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents: 33
diff changeset
3 # Get lots of predefined environment variables and shell functions.
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
4
503
e98ed40c55ef Move include.sh to sources/include.sh. End user doesn't call it directly, shouldn't be at top level.
Rob Landley <rob@landley.net>
parents: 487
diff changeset
5 source sources/include.sh
1
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
6
96
137ba51ee993 Delete output directories on re-run, teach build to log and build multiple
Rob Landley <rob@landley.net>
parents: 93
diff changeset
7 rm -rf "${CROSS}"
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 39
diff changeset
8 mkdir -p "${CROSS}" || dienow
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 39
diff changeset
9
485
b0438691e9e1 Move color selection into ./config. (The default colors don't look great on a white background.)
Rob Landley <rob@landley.net>
parents: 482
diff changeset
10 echo -e "$CROSS_COLOR"
b0438691e9e1 Move color selection into ./config. (The default colors don't look great on a white background.)
Rob Landley <rob@landley.net>
parents: 482
diff changeset
11 echo "=== Building cross compiler"
47
edaa86240321 Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents: 41
diff changeset
12
482
3e9d715e4a11 Rename CROSS_BUILD_STATIC, NATIVE_NOTOOLSDIR, NATIVE_NOTOOLCHAIN and make them work properly.
Rob Landley <rob@landley.net>
parents: 470
diff changeset
13 [ -z "$CROSS_BUILD_STATIC" ] || STATIC_FLAGS='--static'
363
80f520811ed6 Teach cross-compiler.sh how to produce static binaries when BUILD_STATIC=1
Rob Landley <rob@landley.net>
parents: 360
diff changeset
14
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
15 # 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
16
250
cef5bbd777fa Make sure error return from setupfor is noticed.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
17 setupfor binutils build-binutils &&
407
e64eb9ff27b9 Use unstable infrastructure to back off non-unstable kernel to 2.6.25 (where powerpc works) and bring back binutils 2.18 build as unstable version.
Rob Landley <rob@landley.net>
parents: 400
diff changeset
18 AR=ar AS=as LD=ld NM=nm OBJDUMP=objdump OBJCOPY=objcopy \
e64eb9ff27b9 Use unstable infrastructure to back off non-unstable kernel to 2.6.25 (where powerpc works) and bring back binutils 2.18 build as unstable version.
Rob Landley <rob@landley.net>
parents: 400
diff changeset
19 "${CURSRC}/configure" --prefix="${CROSS}" --host=${CROSS_HOST} \
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
20 --target=${CROSS_TARGET} --with-lib-path=lib --disable-nls \
59
18c065749b79 Add i686 and x86_64 config files. (Might or might not work, dunno.)
Rob Landley <rob@landley.net>
parents: 48
diff changeset
21 --disable-shared --disable-multilib --program-prefix="${ARCH}-" \
417
6dd7e870b1d4 No shipping package should ever use -Werror, no idea what new gcc versions will decide to warn on. (Fixes build on ubuntu 8.10.)
Rob Landley <rob@landley.net>
parents: 414
diff changeset
22 --disable-werror $BINUTILS_FLAGS &&
293
cdd26f8acc35 Update to gcc 4.1.2->4.2.2. Still doesn't fix the internal compiler error
Rob Landley <rob@landley.net>
parents: 287
diff changeset
23 make -j $CPUS configure-host &&
363
80f520811ed6 Teach cross-compiler.sh how to produce static binaries when BUILD_STATIC=1
Rob Landley <rob@landley.net>
parents: 360
diff changeset
24 make -j $CPUS CFLAGS="-O2 $STATIC_FLAGS" &&
293
cdd26f8acc35 Update to gcc 4.1.2->4.2.2. Still doesn't fix the internal compiler error
Rob Landley <rob@landley.net>
parents: 287
diff changeset
25 make -j $CPUS install &&
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
26 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
27 mkdir -p "${CROSS}/include" &&
301
309b574a5059 Redo the $CLEANUP logic to a cleanup function in include.sh (meaning if a
Rob Landley <rob@landley.net>
parents: 294
diff changeset
28 cp binutils/include/libiberty.h "${CROSS}/include"
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
29
301
309b574a5059 Redo the $CLEANUP logic to a cleanup function in include.sh (meaning if a
Rob Landley <rob@landley.net>
parents: 294
diff changeset
30 cleanup binutils build-binutils
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
31
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
32 # 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
33
250
cef5bbd777fa Make sure error return from setupfor is noticed.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
34 setupfor gcc-core build-gcc &&
442
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
35 setupfor gcc-g++ build-gcc gcc-core &&
59
18c065749b79 Add i686 and x86_64 config files. (Might or might not work, dunno.)
Rob Landley <rob@landley.net>
parents: 48
diff changeset
36 AR_FOR_TARGET="${ARCH}-ar" "${CURSRC}/configure" $GCC_FLAGS \
442
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
37 --prefix="${CROSS}" --host=${CROSS_HOST} --target=${CROSS_TARGET} \
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
38 --enable-languages=c,c++ --enable-long-long --enable-c99 \
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
39 --disable-shared --disable-threads --disable-nls --disable-multilib \
445
c2215a078923 On arm, gcc has an internal compiler error building dwarf2 exceptions in mini-native. (Yes, it dies builing _itself_.) Switch to setjmp/longjmp excpetions.
Rob Landley <rob@landley.net>
parents: 442
diff changeset
40 --enable-__cxa_atexit --disable-libstdcxx-pch --enable-sjlj-exceptions \
442
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
41 --program-prefix="${ARCH}-" &&
487
1828f3fe831e Continuing attempt to make gcc build like a normal program.
Rob Landley <rob@landley.net>
parents: 485
diff changeset
42
1828f3fe831e Continuing attempt to make gcc build like a normal program.
Rob Landley <rob@landley.net>
parents: 485
diff changeset
43 # Try to convince gcc build process not to rebuild itself with itself.
1828f3fe831e Continuing attempt to make gcc build like a normal program.
Rob Landley <rob@landley.net>
parents: 485
diff changeset
44 mkdir -p gcc &&
1828f3fe831e Continuing attempt to make gcc build like a normal program.
Rob Landley <rob@landley.net>
parents: 485
diff changeset
45 ln -s `which gcc` gcc/xgcc &&
1828f3fe831e Continuing attempt to make gcc build like a normal program.
Rob Landley <rob@landley.net>
parents: 485
diff changeset
46
363
80f520811ed6 Teach cross-compiler.sh how to produce static binaries when BUILD_STATIC=1
Rob Landley <rob@landley.net>
parents: 360
diff changeset
47 make -j $CPUS all-gcc LDFLAGS="$STATIC_FLAGS" &&
293
cdd26f8acc35 Update to gcc 4.1.2->4.2.2. Still doesn't fix the internal compiler error
Rob Landley <rob@landley.net>
parents: 287
diff changeset
48 make -j $CPUS install-gcc &&
442
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
49 cd ..
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
50
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
51 cleanup gcc-core build-gcc
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
52
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 39
diff changeset
53 echo Fixup toolchain... &&
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 39
diff changeset
54
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
55 # 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
56
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
57 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
58 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
59 mv "${CROSS}"/lib/gcc/*/* "${CROSS}"/gcc/lib &&
257
d37e39370d39 Fix cross compiler toolchain to be properly relocatable on x86-64 host.
Rob Landley <rob@landley.net>
parents: 250
diff changeset
60 ln -s ${CROSS_TARGET} ${CROSS}/tools &&
d37e39370d39 Fix cross compiler toolchain to be properly relocatable on x86-64 host.
Rob Landley <rob@landley.net>
parents: 250
diff changeset
61 ln -sf ../../../../tools/bin/ld ${CROSS}/libexec/gcc/*/*/collect2 &&
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
62
61
eb42ad9e8f81 Shuffle comments around.
Rob Landley <rob@landley.net>
parents: 59
diff changeset
63 # Build and install gcc wrapper script.
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 39
diff changeset
64
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 39
diff changeset
65 cd "${CROSS}"/bin &&
390
a9a9eee9e620 Teach the wrapper script to do the libgcc_s --as-needed stuff when
Rob Landley <rob@landley.net>
parents: 387
diff changeset
66 mv "${ARCH}-gcc" "$ARCH-rawgcc" &&
a9a9eee9e620 Teach the wrapper script to do the libgcc_s --as-needed stuff when
Rob Landley <rob@landley.net>
parents: 387
diff changeset
67 $CC $STATIC_FLAGS -Os -s "${SOURCES}"/toys/gcc-uClibc.c -o "${ARCH}-gcc" \
442
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
68 -DGCC_UNWRAPPED_NAME='"'"$ARCH"-rawgcc'"' &&
136
8c3d95f52237 Some tweaks to make toolchain debugging easier.
Rob Landley <rob@landley.net>
parents: 131
diff changeset
69
442
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
70 # Wrap C++
136
8c3d95f52237 Some tweaks to make toolchain debugging easier.
Rob Landley <rob@landley.net>
parents: 131
diff changeset
71
442
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
72 mv "${ARCH}-g++" "${ARCH}-rawg++" &&
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
73 rm "${ARCH}-c++" &&
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
74 ln -s "${ARCH}-g++" "${ARCH}-rawc++" &&
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
75 ln -s "${ARCH}-gcc" "${ARCH}-g++" &&
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
76 ln -s "${ARCH}-gcc" "${ARCH}-c++"
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
77
442
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
78 cleanup "${CROSS}"/{lib/gcc,{libexec/gcc,gcc/lib}/install-tools}
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
79
85
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents: 83
diff changeset
80 # Install kernel headers.
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
81
250
cef5bbd777fa Make sure error return from setupfor is noticed.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
82 setupfor linux &&
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
83 # Install Linux kernel headers (for use by uClibc).
182
fc827ab6166f Autodetect number of processors and feed appropriate -j to make.
Rob Landley <rob@landley.net>
parents: 175
diff changeset
84 make -j $CPUS headers_install ARCH="${KARCH}" INSTALL_HDR_PATH="${CROSS}" &&
301
309b574a5059 Redo the $CLEANUP logic to a cleanup function in include.sh (meaning if a
Rob Landley <rob@landley.net>
parents: 294
diff changeset
85 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
86
301
309b574a5059 Redo the $CLEANUP logic to a cleanup function in include.sh (meaning if a
Rob Landley <rob@landley.net>
parents: 294
diff changeset
87 cleanup linux
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
88
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
89 # 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
90
360
c9a9b8a25455 Only try to build $ARCH-ldd if /usr/include exists.
Rob Landley <rob@landley.net>
parents: 351
diff changeset
91 setupfor uClibc
400
f60b1189c0ea Teach build to use recent uClibc snapshot when USE_UNSTABLE=uClibc
Rob Landley <rob@landley.net>
parents: 394
diff changeset
92 if unstable uClibc
360
c9a9b8a25455 Only try to build $ARCH-ldd if /usr/include exists.
Rob Landley <rob@landley.net>
parents: 351
diff changeset
93 then
400
f60b1189c0ea Teach build to use recent uClibc snapshot when USE_UNSTABLE=uClibc
Rob Landley <rob@landley.net>
parents: 394
diff changeset
94 CONFIGFILE=miniconfig-alt-uClibc
f60b1189c0ea Teach build to use recent uClibc snapshot when USE_UNSTABLE=uClibc
Rob Landley <rob@landley.net>
parents: 394
diff changeset
95 BUILDIT="install -j $CPUS"
f60b1189c0ea Teach build to use recent uClibc snapshot when USE_UNSTABLE=uClibc
Rob Landley <rob@landley.net>
parents: 394
diff changeset
96 else
f60b1189c0ea Teach build to use recent uClibc snapshot when USE_UNSTABLE=uClibc
Rob Landley <rob@landley.net>
parents: 394
diff changeset
97 CONFIGFILE=miniconfig-uClibc
470
919121ba6c5c Move uClibc 0.9.30 build from unstable to stable (and an unrelated fix: symlink uClibc++.a like .so).
Rob Landley <rob@landley.net>
parents: 445
diff changeset
98 BUILDIT="install -j $CPUS"
360
c9a9b8a25455 Only try to build $ARCH-ldd if /usr/include exists.
Rob Landley <rob@landley.net>
parents: 351
diff changeset
99 fi
c9a9b8a25455 Only try to build $ARCH-ldd if /usr/include exists.
Rob Landley <rob@landley.net>
parents: 351
diff changeset
100
400
f60b1189c0ea Teach build to use recent uClibc snapshot when USE_UNSTABLE=uClibc
Rob Landley <rob@landley.net>
parents: 394
diff changeset
101 make CROSS= KCONFIG_ALLCONFIG="${CONFIG_DIR}"/$CONFIGFILE allnoconfig &&
66
57f77c25b39d Hit uClibc build with a large rock so it stops inserting hardwired paths in
Rob Landley <rob@landley.net>
parents: 61
diff changeset
102 make CROSS="${ARCH}-" KERNEL_HEADERS="${CROSS}/include" PREFIX="${CROSS}/" \
400
f60b1189c0ea Teach build to use recent uClibc snapshot when USE_UNSTABLE=uClibc
Rob Landley <rob@landley.net>
parents: 394
diff changeset
103 RUNTIME_PREFIX=/ DEVEL_PREFIX=/ $BUILDIT &&
301
309b574a5059 Redo the $CLEANUP logic to a cleanup function in include.sh (meaning if a
Rob Landley <rob@landley.net>
parents: 294
diff changeset
104 cd ..
400
f60b1189c0ea Teach build to use recent uClibc snapshot when USE_UNSTABLE=uClibc
Rob Landley <rob@landley.net>
parents: 394
diff changeset
105 cleanup uClibc
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
106
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
107
38
297bb57cf74c Apparently "" around EOF also disables variable substitution, not just ''.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
108 cat > "${CROSS}"/README << EOF &&
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
109 Cross compiler for $ARCH
507
58e9523a775d Tweak the readme, add comments, remove some dead code.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
110 From http://impactlinux.com/fwl
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
111
507
58e9523a775d Tweak the readme, add comments, remove some dead code.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
112 To use: Add the "bin" subdirectory to your \$PATH, and use "$ARCH-gcc" as
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
113 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
114
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
115 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
116
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 39
diff changeset
117 make ARCH=${KARCH} CROSS_COMPILE=${ARCH}-
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
118
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
119 EOF
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
120
507
58e9523a775d Tweak the readme, add comments, remove some dead code.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
121 # Strip the binaries
48
0f77e2472d27 Strip binaries.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
122
0f77e2472d27 Strip binaries.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
123 cd "$CROSS"
0f77e2472d27 Strip binaries.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
124 for i in `find bin -type f` `find "$CROSS_TARGET" -type f`
0f77e2472d27 Strip binaries.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
125 do
0f77e2472d27 Strip binaries.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
126 strip "$i" 2> /dev/null
0f77e2472d27 Strip binaries.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
127 done
507
58e9523a775d Tweak the readme, add comments, remove some dead code.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
128
58e9523a775d Tweak the readme, add comments, remove some dead code.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
129 # Tar it up
48
0f77e2472d27 Strip binaries.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
130
75
38e7e0cc3b9f Build mksquashfs in the non-short cross-compiler, and use it at the end of
Rob Landley <rob@landley.net>
parents: 66
diff changeset
131 echo -n creating "build/cross-compiler-${ARCH}".tar.bz2 &&
38e7e0cc3b9f Build mksquashfs in the non-short cross-compiler, and use it at the end of
Rob Landley <rob@landley.net>
parents: 66
diff changeset
132 cd "${BUILD}"
38e7e0cc3b9f Build mksquashfs in the non-short cross-compiler, and use it at the end of
Rob Landley <rob@landley.net>
parents: 66
diff changeset
133 { tar cjvf "cross-compiler-${ARCH}".tar.bz2 cross-compiler-"${ARCH}" || dienow
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 39
diff changeset
134 } | dotprogress
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
135
93
153ba1a0b427 Break out the qemu build (and squashfs) into something easy to comment out,
Rob Landley <rob@landley.net>
parents: 88
diff changeset
136 # A quick hello world program to test the cross-compiler out.
153ba1a0b427 Break out the qemu build (and squashfs) into something easy to comment out,
Rob Landley <rob@landley.net>
parents: 88
diff changeset
137 # Build hello.c dynamic, then static, to verify header/library paths.
153ba1a0b427 Break out the qemu build (and squashfs) into something easy to comment out,
Rob Landley <rob@landley.net>
parents: 88
diff changeset
138
175
6fd189c18c1c Three things: 1) dash->bash, 2) install cross-ldd and cross-readelf,
Rob Landley <rob@landley.net>
parents: 147
diff changeset
139 echo "Sanity test: building Hello World."
6fd189c18c1c Three things: 1) dash->bash, 2) install cross-ldd and cross-readelf,
Rob Landley <rob@landley.net>
parents: 147
diff changeset
140
93
153ba1a0b427 Break out the qemu build (and squashfs) into something easy to comment out,
Rob Landley <rob@landley.net>
parents: 88
diff changeset
141 "${ARCH}-gcc" -Os "${SOURCES}/toys/hello.c" -o "$WORK"/hello &&
153ba1a0b427 Break out the qemu build (and squashfs) into something easy to comment out,
Rob Landley <rob@landley.net>
parents: 88
diff changeset
142 "${ARCH}-gcc" -Os -static "${SOURCES}/toys/hello.c" -o "$WORK"/hello &&
144
8c7bcb36dcf5 Fix typo in path name.
Rob Landley <rob@landley.net>
parents: 143
diff changeset
143 if which qemu-"${QEMU_TEST}" > /dev/null
143
17d06149802e Only run the sanity check on the toolchain if the appropriate qemu is installed.
Rob Landley <rob@landley.net>
parents: 136
diff changeset
144 then
17d06149802e Only run the sanity check on the toolchain if the appropriate qemu is installed.
Rob Landley <rob@landley.net>
parents: 136
diff changeset
145 [ x"$(qemu-"${QEMU_TEST}" "${WORK}"/hello)" == x"Hello world!" ] &&
17d06149802e Only run the sanity check on the toolchain if the appropriate qemu is installed.
Rob Landley <rob@landley.net>
parents: 136
diff changeset
146 echo Cross-toolchain seems to work.
17d06149802e Only run the sanity check on the toolchain if the appropriate qemu is installed.
Rob Landley <rob@landley.net>
parents: 136
diff changeset
147 fi
93
153ba1a0b427 Break out the qemu build (and squashfs) into something easy to comment out,
Rob Landley <rob@landley.net>
parents: 88
diff changeset
148
153ba1a0b427 Break out the qemu build (and squashfs) into something easy to comment out,
Rob Landley <rob@landley.net>
parents: 88
diff changeset
149 [ $? -ne 0 ] && dienow
153ba1a0b427 Break out the qemu build (and squashfs) into something easy to comment out,
Rob Landley <rob@landley.net>
parents: 88
diff changeset
150
47
edaa86240321 Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents: 41
diff changeset
151 echo -e "\e[32mCross compiler toolchain build complete.\e[0m"