1 |
# $Header: /magellan-cvs/smage/include/cross_tools.sminc,v 1.1 2005/12/24 14:03:26 niro Exp $ |
# $Header: /magellan-cvs/smage/include/cross_tools.sminc,v 1.3 2008/10/06 17:55:48 niro Exp $ |
2 |
# Cross-tools generic functions |
# Cross-tools generic functions |
3 |
|
|
4 |
# # needed vars |
# needed vars: |
5 |
# TARGET_ARCH="i686" |
# TARGET_DEST dir |
6 |
# TARGET_CHOST="${TARGET_ARCH}-cross-linux-gnu" |
: ${TARGET_DEST="/opt/cross-tools"} |
7 |
# |
|
8 |
# PNAME="cross-tools-${TARGET_ARCH}" |
# needed vars |
9 |
# |
#TARGET_ARCH="i686" # must be set outside |
10 |
# # version of the compiler |
: ${CROSS_CHOST="${ARCH}-cross-linux-gnu"} |
11 |
# PVER="4.0.2" |
: ${TARGET_CHOST="${TARGET_ARCH}-pc-linux-gnu"} |
12 |
# PBUILD="r2" |
|
13 |
# |
: ${PNAME="cross-tools-${TARGET_ARCH}"} |
14 |
# PCATEGORIE="dev-misc" |
|
15 |
# STATE="unstable" |
: ${PCATEGORIE="dev-cross"} |
16 |
# |
|
17 |
# DESCRIPTION="A crosscompile toolchain to compile programms for the ${TARGET_ARCH} arch." |
: ${DESCRIPTION="A crosscompile toolchain to compile programms for the ${TARGET_ARCH} arch."} |
18 |
# HOMEPAGE="http://magellan-linux.de/" |
: ${HOMEPAGE="http://magellan-linux.de/"} |
19 |
# |
|
20 |
# DEPEND="" |
# binutils |
21 |
# |
#BINUTILS_PVER="2.16.91.0.3" |
22 |
# # binutils |
: ${BINUTILS_SRCFILE="binutils-${BINUTILS_PVER}.tar.bz2"} |
23 |
# BINUTILS_PVER="2.16.91.0.3" |
: ${BINUTILS_SRCDIR="${BUILDDIR}/binutils-${BINUTILS_PVER}"} |
24 |
# BINUTILS_SRCFILE="binutils-${BINUTILS_PVER}.tar.bz2" |
|
25 |
# BINUTILS_SRCDIR="${BUILDDIR}/binutils-${BINUTILS_PVER}" |
# kernel-headers |
26 |
# |
#LINUX_HEADERS_PVER="2.6.12.0" |
27 |
# # kernel-headers |
: ${LINUX_HEADERS_SRCFILE="linux-${LINUX_HEADERS_PVER}.tar.bz2"} |
28 |
# LINUX_HEADERS_PVER="2.6.12.0" |
: ${LINUX_HEADERS_SRCDIR="${BUILDDIR}/linux-${LINUX_HEADERS_PVER}"} |
29 |
# LINUX_HEADERS_SRCFILE="linux-libc-headers-${LINUX_HEADERS_PVER}.tar.bz2" |
|
30 |
# LINUX_HEADERS_SRCDIR="${BUILDDIR}/linux-libc-headers-${LINUX_HEADERS_PVER}" |
# glibc-headers and libc |
31 |
# |
#GLIBC_PVER="2.3.5_20051107" |
32 |
# # glibc-headers and libc |
: ${GLIBC_SRCFILE="glibc-${GLIBC_PVER}.tar.bz2"} |
33 |
# GLIBC_PVER="2.3.5_20051107" |
#: ${GLIBC_LINUXTHREADS="glibc-linuxthreads-${GLIBC_PVER}.tar.bz2"} |
34 |
# GLIBC_SRCFILE="glibc-${GLIBC_PVER/*_/}.tar.bz2" |
: ${GLIBC_SRCDIR="${BUILDDIR}/glibc-${GLIBC_PVER}"} |
35 |
# GLIBC_LINUXTHREADS="glibc-linuxthreads-${GLIBC_PVER/*_/}.tar.bz2" |
|
36 |
# GLIBC_SRCDIR="${BUILDDIR}/glibc-${GLIBC_PVER/*_/}" |
# gcc |
37 |
# |
#GCC_PVER="${PVER}" |
38 |
# # gcc |
: ${GCC_SRCFILE="gcc-${GCC_PVER}.tar.bz2"} |
39 |
# GCC_PVER="${PVER}" |
: ${GCC_SRCDIR="${BUILDDIR}/gcc-${GCC_PVER}"} |
|
# GCC_SRCFILE="gcc-${GCC_PVER}.tar.bz2" |
|
|
# GCC_SRCDIR="${BUILDDIR}/gcc-${GCC_PVER}" |
|
|
# |
|
|
# # TARGET_DEST dir |
|
|
# TARGET_DEST=/opt/cross-tools |
|
|
# |
|
40 |
|
|
41 |
# do not get the idea to strip the resulting binaries! |
# do not get the idea to strip the resulting binaries! |
42 |
# you must have build the strip program on the same arch, |
# you must have build the strip program on the same arch, |
43 |
# but this is propably not the case. so we force stripping off. |
# but this is propably not the case. so we force stripping off. |
44 |
NOSTRIP=true |
NOSTRIP=true |
45 |
|
|
46 |
|
# fetch sources |
47 |
|
SRC_URI=( |
48 |
|
${SRC_URI[*]} |
49 |
|
http://www.kernel.org/pub/linux/devel/binutils/${BINUTILS_SRCFILE} |
50 |
|
mirror://binutils/${BINUTILS_SRCFILE} |
51 |
|
http://www.kernel.org/pub/linux/kernel/v${LINUX_HEADERS_PVER:0:3}/${LINUX_HEADERS_SRCFILE} |
52 |
|
mirror://linux-libc-headers/${LINUX_HEADERS_SRCFILE} |
53 |
|
gnu://glibc/${GLIBC_SRCFILE} |
54 |
|
mirror://glibc/${GLIBC_SRCFILE} |
55 |
|
gnu://gcc/gcc-${GCC_PVER}/${GCC_SRCFILE} |
56 |
|
mirror://gcc/${GCC_SRCFILE} |
57 |
|
mirror://glibc/glibc-2.3.5-localedef_segfault-1.patch |
58 |
|
mirror://glibc/glibc-2.3.5-libgcc_eh-1.patch |
59 |
|
mirror://gcc/gcc-${GCC_PVER}-no-fixincludes.patch |
60 |
|
mirror://gcc/gcc-${GCC_PVER}-magellan-version.patch |
61 |
|
mirror://gcc/gcc-${GCC_PVER}-cross-search-paths.patch |
62 |
|
mirror://gcc/gcc-${GCC_PVER}-specs.patch |
63 |
|
) |
64 |
|
|
65 |
binutils_src_prepare() |
binutils_src_prepare() |
66 |
{ |
{ |
67 |
munpack ${BINUTILS_SRCFILE} || die |
munpack ${BINUTILS_SRCFILE} || die |
72 |
{ |
{ |
73 |
cd ${BINUTILS_SRCDIR}/build |
cd ${BINUTILS_SRCDIR}/build |
74 |
|
|
75 |
|
AR=ar AS=as \ |
76 |
../configure \ |
../configure \ |
77 |
--host=${CHOST} \ |
--host=${CROSS_CHOST} \ |
78 |
--target=${TARGET_CHOST} \ |
--target=${TARGET_CHOST} \ |
79 |
--prefix=${TARGET_DEST} \ |
--prefix=${TARGET_DEST} \ |
80 |
--with-lib-path=${TARGET_DEST}/lib \ |
--with-lib-path=${TARGET_DEST}/lib \ |
81 |
--disable-nls \ |
--disable-nls \ |
82 |
--enable-shared \ |
--enable-shared \ |
83 |
--enable-64-bit-bfd \ |
--disable-multilib \ |
84 |
|| die |
|| die |
85 |
|
|
86 |
make configure-host || die |
make configure-host || die |
100 |
linux_headers_src_prepare() |
linux_headers_src_prepare() |
101 |
{ |
{ |
102 |
munpack ${LINUX_HEADERS_SRCFILE} || die |
munpack ${LINUX_HEADERS_SRCFILE} || die |
103 |
cd ${LINUX_HEADERS_SRCDIR} |
} |
104 |
|
|
105 |
# set correct permissions |
linux_headers_src_compile() |
106 |
chown -R root:root * || die |
{ |
107 |
chmod -R a+r-w+X,u+w * || die |
cd ${LINUX_HEADERS_SRCDIR} |
108 |
|
make mrproper || die |
109 |
|
make ARCH=${ARCH/i*86/x86} headers_check || die |
110 |
} |
} |
111 |
|
|
112 |
linux_headers_src_install() |
linux_headers_src_install() |
113 |
{ |
{ |
114 |
cd ${LINUX_HEADERS_SRCDIR} |
cd ${LINUX_HEADERS_SRCDIR} |
115 |
|
make ARCH=${ARCH/i*86/x86} INSTALL_HDR_PATH=${BINDIR}/${TARGET_DEST} headers_install || die |
|
# using correct arch |
|
|
local myarch=${TARGET_ARCH} |
|
|
[[ ${myarch} = i?86 ]] && myarch=i386 |
|
|
|
|
|
# needed directories |
|
|
install -d ${TARGET_DEST}/include/{asm,linux} || die |
|
|
|
|
|
cp -ax ${LINUX_HEADERS_SRCDIR}/include/linux/* \ |
|
|
${TARGET_DEST}/include/linux || die |
|
|
cp -ax ${LINUX_HEADERS_SRCDIR}/include/asm-${myarch}/* \ |
|
|
${TARGET_DEST}/include/asm || die |
|
116 |
} |
} |
117 |
|
|
118 |
# building the glibc-headers |
# building the glibc-headers |
173 |
sed -i 's/^have-as-needed.*/have-as-needed = no/' \ |
sed -i 's/^have-as-needed.*/have-as-needed = no/' \ |
174 |
${GLIBC_SRCDIR}/config.make.in || die |
${GLIBC_SRCDIR}/config.make.in || die |
175 |
|
|
176 |
|
# fix segfault of localdef on arches beside x86-32 |
177 |
|
mpatch glibc-2.3.5-localedef_segfault-1.patch || die |
178 |
|
|
179 |
# fix permissions on some of the scripts |
# fix permissions on some of the scripts |
180 |
chmod u+x ${GLIBC_SRCDIR}/scripts/*.sh || die |
chmod u+x ${GLIBC_SRCDIR}/scripts/*.sh || die |
181 |
|
|
186 |
glibc_src_prepare() |
glibc_src_prepare() |
187 |
{ |
{ |
188 |
glibc_generic_src_prepare |
glibc_generic_src_prepare |
189 |
|
cd ${GLIBC_SRCDIR} |
190 |
|
|
191 |
|
# remove dependencies on libgcc_eh |
192 |
|
mpatch glibc-2.3.5-libgcc_eh-1.patch || die |
193 |
} |
} |
194 |
|
|
195 |
glibc_src_compile() |
glibc_src_compile() |
196 |
{ |
{ |
197 |
cd ${GLIBC_SRCDIR}/build |
cd ${GLIBC_SRCDIR}/build |
198 |
|
|
199 |
|
local my_glibc_CFLAGS |
200 |
|
local my_glibc_CXXFLAGS |
201 |
|
# glibc-2.6.1 and above needs march CFLAGS: -march=${ARCH} -mtune=generic |
202 |
|
[[ ${TARGET_ARCH} = i*86 ]] && my_glibc_CFLAGS="${CFLAGS} -march=${TARGET_ARCH}" # only i*86 |
203 |
|
my_glibc_CFLAGS="${my_glibc_CFLAGS} -mtune=generic" # all arches |
204 |
|
|
205 |
# force nptl support (may not detected always) |
# force nptl support (may not detected always) |
206 |
echo "libc_cv_forced_unwind=yes" > config.cache || die |
echo "libc_cv_forced_unwind=yes" > config.cache || die |
207 |
echo "libc_cv_c_cleanup=yes" >> config.cache || die |
echo "libc_cv_c_cleanup=yes" >> config.cache || die |
208 |
|
|
209 |
BUILD_CC="gcc" \ |
BUILD_CC="gcc" \ |
210 |
CC="${TARGET_CHOST}-gcc -m32" \ |
CC="${TARGET_CHOST}-gcc" \ |
211 |
AR="${TARGET_CHOST}-ar" \ |
AR="${TARGET_CHOST}-ar" \ |
212 |
RANLIB="${TARGET_CHOST}-ranlib" \ |
RANLIB="${TARGET_CHOST}-ranlib" \ |
213 |
|
CFLAGS="${my_glibc_CFLAGS}" \ |
214 |
../configure \ |
../configure \ |
215 |
--host=${TARGET_CHOST} \ |
--host=${TARGET_CHOST} \ |
216 |
--build=${CHOST} \ |
--build=${CROSS_CHOST} \ |
217 |
--prefix=${TARGET_DEST} \ |
--prefix=${TARGET_DEST} \ |
218 |
--disable-profile \ |
--disable-profile \ |
219 |
--enable-add-ons=nptl --with-tls \ |
--enable-add-ons=nptl --with-tls \ |
221 |
--enable-kernel=2.6.0 \ |
--enable-kernel=2.6.0 \ |
222 |
--without-cvs \ |
--without-cvs \ |
223 |
--with-headers=${TARGET_DEST}/include \ |
--with-headers=${TARGET_DEST}/include \ |
224 |
--with-binutils=${TARGET_DEST}/${TARGET_CHOST}/bin \ |
--with-binutils=${TARGET_DEST}/bin \ |
225 |
--cache-file=config.cache \ |
--cache-file=config.cache \ |
226 |
|| die |
|| die |
227 |
|
|
245 |
cd ${GCC_SRCDIR}/build |
cd ${GCC_SRCDIR}/build |
246 |
|
|
247 |
../configure \ |
../configure \ |
248 |
--host=${CHOST} \ |
--host=${CROSS_CHOST} \ |
249 |
--target=${TARGET_CHOST} \ |
--target=${TARGET_CHOST} \ |
250 |
--prefix=${TARGET_DEST} \ |
--prefix=${TARGET_DEST} \ |
251 |
--with-local-prefix=${TARGET_DEST} \ |
--with-local-prefix=${TARGET_DEST} \ |
316 |
munpack ${GCC_SRCFILE} || die |
munpack ${GCC_SRCFILE} || die |
317 |
cd ${GCC_SRCDIR} |
cd ${GCC_SRCDIR} |
318 |
|
|
319 |
|
mpatch gcc-${GCC_PVER}-no-fixincludes.patch || die |
320 |
|
mpatch gcc-${GCC_PVER}-magellan-version.patch || die |
321 |
|
|
322 |
|
# fixes location of the dynamic linker and not append include |
323 |
|
# search path to /usr/include |
324 |
|
# but first set the location to ${TARGET_DEST} and than patch |
325 |
|
sed "s:/tools/lib/:${TARGET_DEST}/lib/:g" \ |
326 |
|
${SOURCEDIR}/${PNAME}/gcc-${GCC_PVER}-specs.patch | patch -Np1 || die |
327 |
|
|
328 |
|
# do not search the /usr directory for libgcc_s.so when cross-compiling |
329 |
|
mpatch gcc-${GCC_PVER}-cross-search-paths.patch || die |
330 |
|
|
331 |
# suppress installation of libiberty, as we will be |
# suppress installation of libiberty, as we will be |
332 |
# using the one from binutils |
# using the one from binutils |
333 |
#sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in || die |
#sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in || die |
395 |
# now install the linux-headers # |
# now install the linux-headers # |
396 |
################################# |
################################# |
397 |
linux_headers_src_prepare |
linux_headers_src_prepare |
398 |
|
linux_headers_src_compile |
399 |
linux_headers_src_install |
linux_headers_src_install |
400 |
|
|
401 |
|
|
456 |
# echo "ROOTPATH=${TARGET_DEST}/bin" >> ${BINDIR}/etc/env.d/99cross-${TARGET_ARCH} || die |
# echo "ROOTPATH=${TARGET_DEST}/bin" >> ${BINDIR}/etc/env.d/99cross-${TARGET_ARCH} || die |
457 |
# echo "LDPATH=${TARGET_DEST}/lib" >> ${BINDIR}/etc/env.d/99cross-${TARGET_ARCH} || die |
# echo "LDPATH=${TARGET_DEST}/lib" >> ${BINDIR}/etc/env.d/99cross-${TARGET_ARCH} || die |
458 |
|
|
459 |
|
# # setup cross-tools script |
460 |
|
# echo "#!/bin/sh" > ${TARGET_DEST}/bin/setup-cross-tools |
461 |
|
# echo "export TARGET_CHOST=${TARGET_ARCH}-pc-linux-gnu" >> ${TARGET_DEST}/bin/setup-cross-tools |
462 |
|
# echo "export CROSS_CHOST=${ARCH}-cross-linux-gnu" >> ${TARGET_DEST}/bin/setup-cross-tools |
463 |
|
# echo "export CC=${TARGET_CHOST}-gcc" >> ${TARGET_DEST}/bin/setup-cross-tools |
464 |
|
# echo "export CXX=${TARGET_CHOST}-g++" >> ${TARGET_DEST}/bin/setup-cross-tools |
465 |
|
# echo "export AR=${TARGET_CHOST}-ar" >> ${TARGET_DEST}/bin/setup-cross-tools |
466 |
|
# echo "export AS=${TARGET_CHOST}-as" >> ${TARGET_DEST}/bin/setup-cross-tools |
467 |
|
# echo "export RANLIB=${TARGET_CHOST}-ranlib" >> ${TARGET_DEST}/bin/setup-cross-tools |
468 |
|
# echo "export LD=${TARGET_CHOST}-ld" >> ${TARGET_DEST}/bin/setup-cross-tools |
469 |
|
# echo "export STRIP=${TARGET_CHOST}-strip" >> ${TARGET_DEST}/bin/setup-cross-tools |
470 |
|
# echo "export PATH=${TARGET_DEST}/bin:${PATH}" >> ${TARGET_DEST}/bin/setup-cross-tools |
471 |
|
# chmod 0755 ${TARGET_DEST}/bin/setup-cross-tools || die |
472 |
|
|
473 |
echo "Building of ${PNAME}-toolchain finished ..." |
echo "Building of ${PNAME}-toolchain finished ..." |
474 |
} |
} |
475 |
|
|