annotate mini-native.sh @ 43:6d16887ec084

Intermediate snapshot. Doesn't work yet.
author Rob Landley <rob@landley.net>
date Sun, 17 Dec 2006 14:21:02 -0500
parents
children 41e82517e123
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
43
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 #!/bin/sh
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
2
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 # Get lots of predefined environment variables and shell functions.
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
4
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
5 source include.sh
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
6 TOOLS="${NATIVE}/tools"
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
7
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
8 mkdir -p "${TOOLS}/bin" || dienow
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
9
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
10 if false
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
11 then
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
12
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
13 # Build qemu
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 setupfor qemu &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
15 ./configure --disable-gcc-check --prefix="${NATIVE}" &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
16 make &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
17 make install &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
18 cd .. &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
19 $CLEANUP qemu-*
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
20
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
21 [ $? -ne 0 ] && dienow
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
22
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
23 setupfor linux
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
24 # Install Linux kernel headers (for use by uClibc).
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
25 make headers_install ARCH="${KARCH}" INSTALL_HDR_PATH="${TOOLS}" &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
26 # build bootable kernel for target
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
27 mv "${WORK}/config-linux" .config &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
28 (yes "" | make ARCH="${KARCH}" oldconfig) &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
29 make ARCH="${KARCH}" CROSS_COMPILE="${ARCH}-" &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
30 cp "${KERNEL_PATH}" "${NATIVE}/zImage-${ARCH}" &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
31 cd .. &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
32 $CLEANUP linux-*
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
33
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
34 [ $? -ne 0 ] && dienow
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
35
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
36 # Build and install busybox
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
37
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
38 setupfor busybox
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
39 make defconfig &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
40 make CONFIG_STATIC=y CROSS_COMPILE="${ARCH}-" &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
41 cp busybox "${TOOLS}/bin"
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
42 [ $? -ne 0 ] && dienow
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
43 for i in $(sed 's@.*/@@' busybox.links)
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
44 do
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
45 ln -s busybox "${TOOLS}/bin/$i" || dienow
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
46 done
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
47 cd .. &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
48 $CLEANUP busybox
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
49
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
50 [ $? -ne 0 ] && dienow
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
51
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
52 # Build and install native binutils
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
53
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
54 setupfor binutils build-binutils
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
55 CC="${ARCH}"-gcc AR="${ARCH}"-ar "${CURSRC}/configure" --prefix="${TOOLS}" \
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
56 --build="${CROSS_HOST}" --host=${CROSS_TARGET} --target=${CROSS_TARGET} \
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
57 --disable-nls --disable-shared --disable-multilib $BINUTILS_FLAGS &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
58 make configure-host &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
59 make &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
60 make install &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
61 cd .. &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
62 mkdir -p "${TOOLS}/include" &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
63 cp binutils-*/include/libiberty.h "${TOOLS}/include" &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
64 $CLEANUP binutils-* build-binutils
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
65
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
66 [ $? -ne 0 ] && dienow
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
67
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
68 # Build and install native gcc, with c++ support this time.
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
69
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
70 setupfor gcc-core build-gcc gcc-
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
71 echo -n "Adding c++" &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
72 (tar xvjCf "${WORK}" "${LINKDIR}/gcc-g++.tar.bz2" || dienow ) | dotprogress &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
73 CC="${ARCH}-gcc" AS="${ARCH-gcc}" LD="${ARCH}-ld" "${CURSRC}/configure" \
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
74 --prefix="${TOOLS}" --disable-multilib \
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
75 --build="${CROSS_HOST}" --host="${CROSS_TARGET}" --target="${CROSS_TARGET}" \
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
76 --enable-long-long --enable-c99 --enable-shared --enable-threads=posix \
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
77 --enable-__cxa_atexit --disable-nls --enable-languages=c,c++ \
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
78 --disable-libstdcxx-pch &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
79 cd "${WORK}"/build-gcc &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
80
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
81 make all-gcc && # CC_FOR_TARGET="${ARCH}-gcc" AS_FOR_TARGET="${ARCH}-as" \
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
82 # LD_FOR_TARGET="${ARCH}-ld" all-gcc &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
83 make install-gcc &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
84 ln -s gcc "${TOOLS}/bin/cc" &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
85 cd .. &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
86 $CLEANUP gcc-* build-gcc
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
87
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
88 [ $? -ne 0 ] && dienow
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
89
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
90 # Move the gcc internal libraries and headers somewhere sane.
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
91
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
92 mkdir -p "${TOOLS}"/gcc &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
93 mv "${TOOLS}"/lib/gcc/*/*/include "${TOOLS}"/gcc/include &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
94 mv "${TOOLS}"/lib/gcc/*/* "${TOOLS}"/gcc/lib &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
95 $CLEANUP "${TOOLS}"/{lib/gcc,gcc/lib/install-tools} &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
96
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
97 exit 0
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
98
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
99 # Build and install gcc wrapper script.
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
100
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
101 mv "$GCCNAME" "${CROSS}"/bin/gcc-unwrapped &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
102 gcc "${TOP}"/sources/toys/gcc-uClibc.c -Os -s -o "$GCCNAME"
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
103
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
104 [ $? -ne 0 ] && dienow
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
105
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
106 # Install the linux kernel, and kernel headers.
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
107
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
108 setupfor linux
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
109 # Configure kernel
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
110 ##mv "${WORK}"/config-linux .config &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
111 ##(yes "" | make ARCH="${KARCH}" oldconfig) &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
112 # Install Linux kernel headers (for use by uClibc).
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
113 make headers_install ARCH="${KARCH}" INSTALL_HDR_PATH="${CROSS}" &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
114 # Build bootable kernel for target.
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
115 ##make ARCH="${KARCH}" CROSS_COMPILE="${CROSS_TARGET}"- &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
116 ##cp "${KERNEL_PATH}" "${CROSS}"/zImage &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
117 cd .. &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
118 $CLEANUP linux-*
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
119
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
120 [ $? -ne 0 ] && dienow
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
121
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
122 # Build and install uClibc
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
123
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
124 setupfor uClibc
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
125 cp "${WORK}"/config-uClibc .config &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
126 (yes "" | make CROSS="${CROSS_TARGET}"- oldconfig) &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
127 make CROSS="${CROSS_TARGET}"- KERNEL_SOURCE="${CROSS}" &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
128 #make CROSS="${CROSS_TARGET}"- utils &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
129 # The kernel headers are already installed, but uClibc's install will try to
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
130 # be "helpful" and copy them over themselves, at which point hilarity ensues.
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
131 # Make it not do that.
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
132 rm include/{asm,asm-generic,linux} &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
133 make CROSS="${CROSS_TARGET}"- KERNEL_SOURCE="${CROSS}"/ \
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
134 RUNTIME_PREFIX="${CROSS}"/ DEVEL_PREFIX="${CROSS}"/ \
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
135 install_runtime install_dev &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
136 # The uClibc build uses ./include instead of ${CROSS}/include, so the symlinks
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
137 # need to come back. (Yes, it links against the _headers_ from the source,
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
138 # but against the _libraries_ from the destination. Hence needing to install
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
139 # libc.so before building utils.)
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
140 ln -s "${CROSS}"/include/linux include/linux &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
141 ln -s "${CROSS}"/include/asm include/asm &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
142 ln -s "${CROSS}"/include/asm-generic include/asm-generic &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
143 make CROSS=${CROSS_TARGET}- RUNTIME_PREFIX="${CROSS}"/ install_utils &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
144 cd .. &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
145 $CLEANUP uClibc*
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
146
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
147 [ $? -ne 0 ] && dienow
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
148
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
149 # A quick hello world program to test the cross-compiler out.
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
150
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
151 cat > "$WORK"/hello.c << 'EOF' &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
152 #include <stdio.h>
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
153
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
154 int main(int argc, char *argv[])
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
155 {
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
156 printf("Hello world!\n");
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
157 return 0;
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
158 }
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
159 EOF
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
160
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
161 # Build hello.c dynamic, then static, to verify header/library paths.
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
162
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
163 "$GCCNAME" -Os "$WORK"/hello.c -o "$WORK"/hello &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
164 "$GCCNAME" -Os -static "$WORK"/hello.c -o "$WORK"/hello &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
165 [ x"$(qemu-"${KARCH}" "${WORK}"/hello)" == x"Hello world!" ] &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
166 echo Cross-toolchain seems to work.
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
167
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
168 [ $? -ne 0 ] && dienow
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
169
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
170 # Change the FSF's crazy names to something reasonable.
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
171
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
172 cd "${CROSS}"/bin &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
173 for i in "${ARCH}"-*
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
174 do
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
175 strip "$i"
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
176 mv "$i" "${ARCH}"-"$(echo "$i" | sed 's/.*-//')"
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
177 done
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
178
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
179 cat > "${CROSS}"/README << "EOF" &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
180 Cross compiler for $ARCH
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
181 From http://landley.net/code/firmware
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
182
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
183 To use: Add the \"bin\" directory to your \$PATH, and use \"$ARCH-gcc\" as
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
184 your compiler.
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
185
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
186 The syntax used to build the Linux kernel is:
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
187
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
188 make ARCH="${KARCH}" CROSS_COMPILE="${ARCH}"-
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
189
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
190 EOF
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
191
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
192 # Tar up the cross compiler.
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
193 cd "${TOP}"
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
194 tar cjvCf build cross-compiler-"${ARCH}".tar.bz2 cross-compiler-"${ARCH}" &&
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
195
6d16887ec084 Intermediate snapshot. Doesn't work yet.
Rob Landley <rob@landley.net>
parents:
diff changeset
196 [ $? -ne 0 ] && dienow