Magellan Linux

Annotation of /trunk/include/buildroot2.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9863 - (hide annotations) (download)
Fri Jan 13 19:22:05 2012 UTC (12 years, 9 months ago) by niro
Original Path: branches/magellan-next/include/buildroot2.sminc
File size: 47444 byte(s)
- PCATEGORIE -> PCAT transition
1 niro 9 # $Header: /magellan-cvs/smage/include/buildroot2.sminc,v 1.1 2008/10/06 17:55:09 niro Exp $
2     # Buildroot generic functions
3     sminclude mtools
4    
5     # needed vars:
6    
7     # TARGET_ARCH="i686" # must be set outside
8     : ${CROSS_CHOST="${ARCH}-cross-linux-gnu"}
9     : ${TARGET_CHOST="${TARGET_ARCH}-pc-linux-gnu"}
10    
11     # Destdirs:
12     # the buildroot of the toolchain
13     : ${BUILDROOT_DEST="/opt/buildroot-${TARGET_ARCH}"}
14     # target-tools dest: ${BUILDROOT_DEST}/${TARGET_DEST}
15     : ${TARGET_DEST="/buildroot-tools"}
16     # cross-tools dest: ${BUILDROOT_DEST}/${TARGET_DEST}
17     : ${CROSS_DEST="/cross-tools"}
18    
19    
20     : ${PNAME="buildroot-${TARGET_ARCH}"}
21 niro 9863 : ${PCAT="dev-misc"}
22 niro 9
23     : ${DESCRIPTION="A crosscompile toolchain to compile programms for the ${TARGET_ARCH} arch."}
24     : ${HOMEPAGE="http://magellan-linux.de/"}
25    
26     #SDEPEND="${SDEPEND}
27     # == dev-cross/cross-tools-${TARGET_ARCH}-${PVER}"
28    
29     # binutils
30     #BINUTILS_PVER="2.18.50.0.3"
31     : ${BINUTILS_SRCFILE="binutils-${BINUTILS_PVER}.tar.bz2"}
32     : ${BINUTILS_SRCDIR="${BUILDDIR}/binutils-${BINUTILS_PVER}"}
33    
34     # kernel-headers
35     #LINUX_HEADERS_PVER="2.6.24"
36     : ${LINUX_HEADERS_SRCFILE="linux-${LINUX_HEADERS_PVER}.tar.bz2"}
37     : ${LINUX_HEADERS_SRCDIR="${BUILDDIR}/linux-${LINUX_HEADERS_PVER}"}
38    
39     # glibc-headers and libc
40     #GLIBC_PVER="2.7.0"
41     : ${GLIBC_SRCFILE="glibc-${GLIBC_PVER}.tar.bz2"}
42     : ${GLIBC_SRCDIR="${BUILDDIR}/glibc-${GLIBC_PVER}"}
43    
44     # gcc
45     #GCC_PVER="4.2.3"
46     : ${GCC_SRCFILE="gcc-${GCC_PVER}.tar.bz2"}
47     : ${GCC_SRCDIR="${BUILDDIR}/gcc-${GCC_PVER}"}
48    
49     # ncurses
50     # NCURSES_PVER="5.6"
51     : ${NCURSES_SRCFILE="ncurses-${NCURSES_PVER}.tar.gz"}
52     : ${NCURSES_SRCDIR="${BUILDDIR}/ncurses-${NCURSES_PVER}"}
53    
54     # bash
55     # BASH_PVER="3.2"
56     : ${BASH_SRCFILE="bash-${BASH_PVER}.tar.gz"}
57     : ${BASH_SRCDIR="${BUILDDIR}/bash-${BASH_PVER}"}
58    
59     # bzip2
60     # BZIP2_PVER="1.0.4"
61     : ${BZIP2_SRCFILE="bzip2-${BZIP2_PVER}.tar.gz"}
62     : ${BZIP2_SRCDIR="${BUILDDIR}/bzip2-${BZIP2_PVER}"}
63    
64     # coreutils
65     # COREUTILS_PVER="3.2"
66     : ${COREUTILS_SRCFILE="coreutils-${COREUTILS_PVER}.tar.gz"}
67     : ${COREUTILS_SRCDIR="${BUILDDIR}/coreutils-${COREUTILS_PVER}"}
68    
69     # diffutils
70     # DIFFUTILS_PVER="3.2"
71     : ${DIFFUTILS_SRCFILE="diffutils-${DIFFUTILS_PVER}.tar.gz"}
72     : ${DIFFUTILS_SRCDIR="${BUILDDIR}/diffutils-${DIFFUTILS_PVER}"}
73    
74     # findutils
75     # FINDUTILS_PVER="3.2"
76     : ${FINDUTILS_SRCFILE="findutils-${FINDUTILS_PVER}.tar.gz"}
77     : ${FINDUTILS_SRCDIR="${BUILDDIR}/findutils-${FINDUTILS_PVER}"}
78    
79     # zlib
80     # ZLIB_PVER="3.2"
81     : ${ZLIB_SRCFILE="zlib-${ZLIB_PVER}.tar.gz"}
82     : ${ZLIB_SRCDIR="${BUILDDIR}/zlib-${ZLIB_PVER}"}
83    
84     # file
85     # FILE_PVER="3.2"
86     : ${FILE_SRCFILE="file-${FILE_PVER}.tar.gz"}
87     : ${FILE_SRCDIR="${BUILDDIR}/file-${FILE_PVER}"}
88    
89     # gawk
90     # GAWK_PVER="3.2"
91     : ${GAWK_SRCFILE="gawk-${GAWK_PVER}.tar.gz"}
92     : ${GAWK_SRCDIR="${BUILDDIR}/gawk-${GAWK_PVER}"}
93    
94     # gettext
95     # GETTEXT_PVER="3.2"
96     : ${GETTEXT_SRCFILE="gettext-${GETTEXT_PVER}.tar.gz"}
97     : ${GETTEXT_SRCDIR="${BUILDDIR}/gettext-${GETTEXT_PVER}"}
98    
99     # grep
100     # GREP_PVER="3.2"
101     : ${GREP_SRCFILE="grep-${GREP_PVER}.tar.gz"}
102     : ${GREP_SRCDIR="${BUILDDIR}/grep-${GREP_PVER}"}
103    
104     # gzip
105     # GZIP_PVER="3.2"
106     : ${GZIP_SRCFILE="gzip-${GZIP_PVER}.tar.gz"}
107     : ${GZIP_SRCDIR="${BUILDDIR}/gzip-${GZIP_PVER}"}
108    
109     # make
110     # MAKE_PVER="3.2"
111     : ${MAKE_SRCFILE="make-${MAKE_PVER}.tar.gz"}
112     : ${MAKE_SRCDIR="${BUILDDIR}/make-${MAKE_PVER}"}
113    
114     # patch
115     # PATCH_PVER="3.2"
116     : ${PATCH_SRCFILE="patch-${PATCH_PVER}.tar.gz"}
117     : ${PATCH_SRCDIR="${BUILDDIR}/patch-${PATCH_PVER}"}
118    
119     # sed
120     # SED_PVER="3.2"
121     : ${SED_SRCFILE="sed-${SED_PVER}.tar.gz"}
122     : ${SED_SRCDIR="${BUILDDIR}/sed-${SED_PVER}"}
123    
124     # tar
125     # TAR_PVER="3.2"
126     : ${TAR_SRCFILE="tar-${TAR_PVER}.tar.gz"}
127     : ${TAR_SRCDIR="${BUILDDIR}/tar-${TAR_PVER}"}
128    
129     # texinfo
130     # TEXINFO_PVER="3.2"
131     : ${TEXINFO_SRCFILE="texinfo-${TEXINFO_PVER}.tar.gz"}
132     : ${TEXINFO_SRCDIR="${BUILDDIR}/texinfo-${TEXINFO_PVER}"}
133    
134     # e2fsprogs
135     # E2FSPROGS_PVER="3.2"
136     : ${E2FSPROGS_SRCFILE="e2fsprogs-${E2FSPROGS_PVER}.tar.gz"}
137     : ${E2FSPROGS_SRCDIR="${BUILDDIR}/e2fsprogs-${E2FSPROGS_PVER}"}
138    
139     # util-linux
140     # UTIL_LINUX_PVER="3.2"
141     : ${UTIL_LINUX_SRCFILE="util-linux-ng-${UTIL_LINUX_PVER}.tar.gz"}
142     : ${UTIL_LINUX_SRCDIR="${BUILDDIR}/util-linux-ng-${UTIL_LINUX_PVER}"}
143    
144     # initscripts
145     # INITSCRIPTS_PVER="3.2"
146     : ${INITSCRIPTS_SRCFILE="initscripts-${INITSCRIPTS_PVER}.tar.bz2"}
147     : ${INITSCRIPTS_SRCDIR="${BUILDDIR}/initscripts-${INITSCRIPTS_PVER}"}
148    
149     # wget
150     # WGET_PVER="3.2"
151     : ${WGET_SRCFILE="wget-${WGET_PVER}.tar.gz"}
152     : ${WGET_SRCDIR="${BUILDDIR}/wget-${WGET_PVER}"}
153    
154     # rsync
155     # RSYNC_PVER="3.2"
156     : ${RSYNC_SRCFILE="rsync-${RSYNC_PVER}.tar.gz"}
157     : ${RSYNC_SRCDIR="${BUILDDIR}/rsync-${RSYNC_PVER}"}
158    
159     # cvs
160     # CVS_PVER="3.2"
161     : ${CVS_SRCFILE="cvs-${CVS_PVER}.tar.bz2"}
162     : ${CVS_SRCDIR="${BUILDDIR}/cvs-${CVS_PVER}"}
163    
164     # perl
165     # PERL_PVER="5.10.0"
166     : ${PERL_SRCFILE="perl-${PERL_PVER}.tar.gz"}
167     : ${PERL_SRCDIR="${BUILDDIR}/perl-${PERL_PVER}"}
168    
169     # m4
170     # M4_PVER="1.4.10"
171     : ${M4_SRCFILE="m4-${M4_PVER}.tar.bz2"}
172     : ${M4_SRCDIR="${BUILDDIR}/m4-${M4_PVER}"}
173    
174     # bison
175     # BISON_PVER="2.3"
176     : ${BISON_SRCFILE="bison-${BISON_PVER}.tar.bz2"}
177     : ${BISON_SRCDIR="${BUILDDIR}/bison-${BISON_PVER}"}
178    
179     # flex
180     # FLEX_PVER="2.5.33"
181     : ${FLEX_SRCFILE="flex-${FLEX_PVER}.tar.bz2"}
182     : ${FLEX_SRCDIR="${BUILDDIR}/flex-${FLEX_PVER}"}
183    
184     # fetch sources
185     SRC_URI=(
186     ${SRC_URI[*]}
187     http://www.kernel.org/pub/linux/devel/binutils/${BINUTILS_SRCFILE}
188     mirror://binutils/${BINUTILS_SRCFILE}
189     http://www.kernel.org/pub/linux/kernel/v${LINUX_HEADERS_PVER:0:3}/${LINUX_HEADERS_SRCFILE}
190     mirror://linux-libc-headers/${LINUX_HEADERS_SRCFILE}
191     gnu://glibc/${GLIBC_SRCFILE}
192     mirror://glibc/${GLIBC_SRCFILE}
193     gnu://gcc/gcc-${GCC_PVER}/${GCC_SRCFILE}
194     mirror://gcc/${GCC_SRCFILE}
195     gnu://ncurses/${NCURSES_SRCFILE}
196     mirror://ncurses/${NCURSES_SRCFILE}
197     gnu://bash/${BASH_SRCFILE}
198     mirror://bash/${BASH_SRCFILE}
199     http://www.bzip.org/${BZIP2_PVER}/${BZIP2_SRCFILE}
200     mirror://bzip2/${BZIP2_SRCFILE}
201     gnu://coreutils/${COREUTILS_SRCFILE}
202     mirror://coreutils/${COREUTILS_SRCFILE}
203     mirror://diffutils/${DIFFUTILS_SRCFILE}
204     gnu://findutils/${FINDUTILS_SRCFILE}
205     mirror://findutils/${FINDUTILS_SRCFILE}
206     http://www.zlib.net/${ZLIB_SRCFILE}
207     mirror://zlib/${ZLIB_SRCFILE}
208     ftp://ftp.astron.com/pub/file/${FILE_SRCFILE}
209     ftp://ftp.gw.com/mirrors/pub/unix/file/${FILE_SRCFILE}
210     mirror://file/${FILE_SRCFILE}
211     gnu://gawk/${GAWK_SRCFILE}
212     mirror://gawk/${GAWK_SRCFILE}
213     gnu://gettext/${GETTEXT_SRCFILE}
214     mirror://gettext/${GETTEXT_SRCFILE}
215     gnu://grep/${GREP_SRCFILE}
216     mirror://grep/${GREP_SRCFILE}
217     gnu://gzip/${GZIP_SRCFILE}
218     mirror://gzip/${GZIP_SRCFILE}
219     gnu://make/${MAKE_SRCFILE}
220     mirror://make/${MAKE_SRCFILE}
221     mirror://patch/${PATCH_SRCFILE}
222     gnu://sed/${SED_SRCFILE}
223     mirror://sed/${SED_SRCFILE}
224     gnu://tar/${TAR_SRCFILE}
225     mirror://tar/${TAR_SRCFILE}
226     gnu://texinfo/${TEXINFO_SRCFILE}
227     mirror://texinfo/${TEXINFO_SRCFILE}
228     sourceforge://e2fsprogs/${E2FSPROGS_SRCFILE}
229     mirror://e2fsprogs/${E2FSPROGS_SRCFILE}
230     http://www.kernel.org/pub/linux/utils/util-linux-ng/v${UTIL_LINUX_PVER/%.?/}/${UTIL_LINUX_SRCFILE}
231     mirror://util-linux-ng/${UTIL_LINUX_SRCFILE}
232     mirror://initscripts/${INITSCRIPTS_SRCFILE}
233     gnu://wget/${WGET_SRCFILE}
234     mirror://wget/${WGET_SRCFILE}
235     http://samba.anu.edu.au/ftp/rsync/${RSYNC_SRCFILE}
236     mirror://rsync/${RSYNC_SRCFILE}
237     gnu://non-gnu/cvs/source/stable/${CVS_PVER}/${CVS_SRCFILE}
238     gnu://non-gnu/cvs/source/nightly-snapshots/stable/${CVS_SRCFILE}
239     mirror://cvs/${CVS_SRCFILE}
240     http://ftp.funet.fi/pub/CPAN/src/${PERL_SRCFILE}
241     mirror://perl/${PERL_SRCFILE}
242     gnu://m4/${M4_SRCFILE}
243     mirror://m4/${M4_SRCFILE}
244     gnu://bison/${BISON_SRCFILE}
245     mirror://bison/${BISON_SRCFILE}
246     mirror://flex/${FLEX_SRCFILE}
247     mirror://glibc/glibc-2.3.5-localedef_segfault-1.patch
248     mirror://glibc/glibc-2.3.5-libgcc_eh-1.patch
249     mirror://gcc/gcc-${GCC_PVER}-no-fixincludes.patch
250     mirror://gcc/gcc-${GCC_PVER}-magellan-version.patch
251     mirror://gcc/gcc-${GCC_PVER}-cross-search-paths.patch
252     mirror://gcc/gcc-${GCC_PVER}-specs.patch
253     mirror://texinfo/texinfo-${TEXINFO_PVER}-mbstate-fix.patch
254     mirror://perl/perl-${PERL_PVER}-hardwired-libc.patch
255     )
256    
257     # do not get the idea to strip the resulting binaries!
258     # you must have build the strip program on the same arch,
259     # but this is propably not the case. so we force stripping off.
260     NOSTRIP=true
261    
262     activate_ccache()
263     {
264     if [[ ${SMAGE_USE_CCACHE} ]]
265     then
266     export PATH="/opt/cross-tools/bin:/usr/$(mlibdir)/ccache/bin:${PATH}"
267     fi
268     }
269    
270     deactivate_ccache()
271     {
272     # disable any ccache regardless if user-enabled or mage-enabled
273     if [[ ! -z $(echo ${PATH} | grep "/usr/$(mlibdir)/ccache/bin") ]]
274     then
275     export PATH="$(echo ${PATH} | sed s:/usr/$(mlibdir)/ccache/bin::g)"
276     fi
277     }
278    
279     # export2buildroot()
280     # {
281     # local cmd="$@"
282     #
283     # typeset -f die > ${BINDIR}/${BUILDROOT_DEST}/.chrootrc || die
284     # echo "${cmd}" >> ${BINDIR}/${BUILDROOT_DEST}/.chrootrc || die
285     # }
286    
287     chrooted()
288     {
289     local cmd="$@"
290     local mount="false"
291     local sources="false"
292    
293     # very basic getops
294     for i in $*
295     do
296     case $1 in
297     --mount) mount="true"; cmd="${cmd/--mount/}" ;;
298     --sources) sources="true"; cmd="${cmd/--sources/}" ;;
299     --chrootrc) cmd="/bin/bash /.chrootrc"; cmd="${cmd/--chrootrc/}" ;;
300     esac
301     shift
302     done
303    
304     if [[ ${mount} = true ]]
305     then
306     install -d ${BINDIR}/${BUILDROOT_DEST}/{dev,sys,proc} || die
307     mount -t sysfs sysfs ${BINDIR}/${BUILDROOT_DEST}/sys || die
308     mount -t proc proc ${BINDIR}/${BUILDROOT_DEST}/proc || die
309     mount -o bind /dev ${BINDIR}/${BUILDROOT_DEST}/dev || die
310     fi
311    
312     if [[ ${sources} = true ]]
313     then
314     install -d ${BINDIR}/${BUILDROOT_DEST}/${SOURCEDIR} || die
315     mount -o bind ${SOURCEDIR} ${BINDIR}/${BUILDROOT_DEST}/${SOURCEDIR} || die
316     fi
317    
318     chroot ${BINDIR}/${BUILDROOT_DEST} \
319     ${TARGET_DEST}/bin/env -i \
320     HOME=/root TERM="${TERM}" \
321     PS1='\u:\w\$ ' \
322     PATH=/bin:/usr/bin:/sbin:/usr/sbin:${TARGET_DEST}/bin \
323     http_proxy="${http_proxy}" \
324     ftp_proxy="${ftp_proxy}" \
325     no_proxy="${no_proxy}" \
326     ${cmd} #|| die "chroot exit code not null."
327    
328     if [[ ${sources} = true ]]
329     then
330     umount ${BINDIR}/${BUILDROOT_DEST}/${SOURCEDIR} || die
331     fi
332    
333     if [[ ${mount} = true ]]
334     then
335     umount ${BINDIR}/${BUILDROOT_DEST}/{dev,proc,sys} || die
336     fi
337     }
338    
339     stage1_configure()
340     {
341     ./configure \
342     --build=${CROSS_CHOST} \
343     --host=${TARGET_CHOST} \
344     --prefix=${TARGET_DEST} \
345     "$@" \
346     || die
347     }
348    
349     linux_headers_cross_src_prepare()
350     {
351     munpack ${LINUX_HEADERS_SRCFILE} || die
352     }
353    
354     linux_headers_cross_src_compile()
355     {
356     cd ${LINUX_HEADERS_SRCDIR}
357     make mrproper || die
358     make ARCH=${ARCH/i*86/x86} headers_check || die
359     }
360    
361     linux_headers_cross_src_install()
362     {
363     cd ${LINUX_HEADERS_SRCDIR}
364     make ARCH=${ARCH/i*86/x86} INSTALL_HDR_PATH=${TARGET_DEST} headers_install || die
365     }
366    
367    
368     binutils_cross_src_prepare()
369     {
370     munpack ${BINUTILS_SRCFILE} || die
371     install -d ${BINUTILS_SRCDIR}/build || die
372     }
373    
374     binutils_cross_src_compile()
375     {
376     cd ${BINUTILS_SRCDIR}/build
377    
378     AR=ar AS=as \
379     ../configure \
380     --host=${CROSS_CHOST} \
381     --target=${TARGET_CHOST} \
382     --prefix=${CROSS_DEST} \
383     --with-lib-path=${TARGET_DEST}/lib \
384     --disable-nls \
385     --enable-shared \
386     --disable-multilib \
387     || die
388    
389     make configure-host || die
390     mmake || die
391     }
392    
393     binutils_cross_src_install()
394     {
395     cd ${BINUTILS_SRCDIR}/build
396    
397     make install || die
398    
399     install -d ${TARGET_DEST}/include || die
400     cp ../include/libiberty.h ${TARGET_DEST}/include || die
401     }
402    
403    
404     gcc_static_cross_src_prepare()
405     {
406     munpack ${GCC_SRCFILE} || die
407     cd ${GCC_SRCDIR}
408    
409     mpatch gcc-${GCC_PVER}-no-fixincludes.patch || die
410     mpatch gcc-${GCC_PVER}-magellan-version.patch || die
411    
412     # fixes location of the dynamic linker and not append include
413     # search path to /usr/include
414     # but first set the location to ${TARGET_DEST} and than patch
415     sed "s:/tools/lib/:${TARGET_DEST}/lib/:g" \
416     ${SOURCEDIR}/${PNAME}/gcc-${GCC_PVER}-specs.patch | patch -Np1 || die
417    
418     # do not search the /usr directory for libgcc_s.so when cross-compiling
419     mpatch gcc-${GCC_PVER}-cross-search-paths.patch || die
420    
421     # suppress installation of libiberty, as we will be
422     # using the one from binutils
423     #sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in || die
424    
425     # fix up the startfile spec to search /opt/cross-tools/lib
426     # fixes errors like this on the final cross-gcc compilation
427     # /opt/cross-tools/i686-cross-linux-gnu/bin/ld: crti.o: No such file: No such file or directory
428     # collect2: ld returned 1 exit status
429     echo "
430     #undef STARTFILE_PREFIX_SPEC
431     #define STARTFILE_PREFIX_SPEC \"${TARGET_DEST}/lib/\"" >> ${GCC_SRCDIR}/gcc/config/linux.h || die
432    
433     # change header search path to look only in $TARGET_DEST/include
434     # and not the hosts own include pathes
435     sed -i "s@\(^CROSS_SYSTEM_HEADER_DIR =\).*@\1 ${TARGET_DEST}/include@g" \
436     ${GCC_SRCDIR}/gcc/Makefile.in || die
437    
438     install -d ${GCC_SRCDIR}/build || die
439     }
440    
441     gcc_static_cross_src_compile()
442     {
443     cd ${GCC_SRCDIR}/build
444    
445     ../configure \
446     --host=${CROSS_CHOST} \
447     --target=${TARGET_CHOST} \
448     --prefix=${CROSS_DEST} \
449     --with-local-prefix=${TARGET_DEST} \
450     --disable-nls \
451     --disable-shared \
452     --disable-threads \
453     --enable-languages=c \
454     --disable-multilib \
455     || die
456    
457     mmake all-gcc || die
458     }
459    
460     gcc_static_cross_src_install()
461     {
462     cd ${GCC_SRCDIR}/build
463     make install-gcc || die
464     }
465    
466    
467     glibc_cross_src_prepare()
468     {
469     munpack ${GLIBC_SRCFILE} || die
470     cd ${GLIBC_SRCDIR}
471    
472     # disable binutils -as-needed
473     sed -i 's/^have-as-needed.*/have-as-needed = no/' \
474     ${GLIBC_SRCDIR}/config.make.in || die
475    
476     # fix segfault of localdef on arches beside x86-32
477     mpatch glibc-2.3.5-localedef_segfault-1.patch || die
478    
479     # remove dependencies on libgcc_eh
480     mpatch glibc-2.3.5-libgcc_eh-1.patch || die
481    
482     # fix permissions on some of the scripts
483     chmod u+x ${GLIBC_SRCDIR}/scripts/*.sh || die
484    
485     install -d ${GLIBC_SRCDIR}/build || die
486     }
487    
488     glibc_cross_src_compile()
489     {
490     cd ${GLIBC_SRCDIR}/build
491    
492     local my_glibc_CFLAGS
493     local my_glibc_CXXFLAGS
494     # glibc-2.6.1 and above needs march CFLAGS: -march=${ARCH} -mtune=generic
495     [[ ${TARGET_ARCH} = i*86 ]] && my_glibc_CFLAGS="${CFLAGS} -march=${TARGET_ARCH}" # only i*86
496     my_glibc_CFLAGS="${my_glibc_CFLAGS} -mtune=generic" # all arches
497    
498     # force nptl support (may not detected always)
499     echo "libc_cv_forced_unwind=yes" > config.cache || die
500     echo "libc_cv_c_cleanup=yes" >> config.cache || die
501    
502     BUILD_CC="gcc" \
503     CC="${TARGET_CHOST}-gcc" \
504     AR="${TARGET_CHOST}-ar" \
505     RANLIB="${TARGET_CHOST}-ranlib" \
506     CFLAGS="${my_glibc_CFLAGS}" \
507     ../configure \
508     --host=${TARGET_CHOST} \
509     --build=${CROSS_CHOST} \
510     --prefix=${TARGET_DEST} \
511     --disable-profile \
512     --enable-add-ons=nptl --with-tls \
513     --with-__thread \
514     --enable-kernel=2.6.0 \
515     --without-cvs \
516     --with-headers=${TARGET_DEST}/include \
517     --with-binutils=${CROSS_DEST}/bin \
518     --cache-file=config.cache \
519     || die
520    
521     make PARALLELMFLAGS="-j2" || die
522     }
523    
524     glibc_cross_src_install()
525     {
526     cd ${GLIBC_SRCDIR}/build
527     make install || die
528     }
529    
530    
531     gcc_cross_src_prepare()
532     {
533     munpack ${GCC_SRCFILE} || die
534     cd ${GCC_SRCDIR}
535    
536     mpatch gcc-${GCC_PVER}-no-fixincludes.patch || die
537     mpatch gcc-${GCC_PVER}-magellan-version.patch || die
538    
539     # fixes location of the dynamic linker and not append include
540     # search path to /usr/include
541     # but first set the location to ${TARGET_DEST} and than patch
542     sed "s:/tools/lib/:${TARGET_DEST}/lib/:g" \
543     ${SOURCEDIR}/${PNAME}/gcc-${GCC_PVER}-specs.patch | patch -Np1 || die
544    
545     # do not search the /usr directory for libgcc_s.so when cross-compiling
546     mpatch gcc-${GCC_PVER}-cross-search-paths.patch || die
547    
548     # suppress installation of libiberty, as we will be
549     # using the one from binutils
550     #sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in || die
551    
552     # fix up the startfile spec to search /opt/cross-tools/lib
553     # fixes errors like this on the final cross-gcc compilation
554     # /opt/cross-tools/i686-cross-linux-gnu/bin/ld: crti.o: No such file: No such file or directory
555     # collect2: ld returned 1 exit status
556     echo "
557     #undef STARTFILE_PREFIX_SPEC
558     #define STARTFILE_PREFIX_SPEC \"${TARGET_DEST}/lib/\"" >> ${GCC_SRCDIR}/gcc/config/linux.h || die
559    
560     # change header search path to look only in $TARGET_DEST/include
561     # and not the hosts own include pathes
562     sed -i "s@\(^CROSS_SYSTEM_HEADER_DIR =\).*@\1 ${TARGET_DEST}/include@g" \
563     ${GCC_SRCDIR}/gcc/Makefile.in || die
564    
565     # disable -B in configure, so it doesn't pick up the host's header files
566     sed -i '/FLAGS_FOR_TARGET.*\/lib\//s@-B[^ ]*/lib/@@g' configure || die
567    
568     install -d ${GCC_SRCDIR}/build || die
569     }
570    
571     gcc_cross_src_compile()
572     {
573     cd ${GCC_SRCDIR}/build
574    
575     ../configure \
576     --host=${CROSS_CHOST} \
577     --target=${TARGET_CHOST} \
578     --prefix=${CROSS_DEST} \
579     --with-local-prefix=${TARGET_DEST} \
580     --enable-shared \
581     --enable-threads=posix \
582     --enable-__cxa_atexit \
583     --enable-c99 \
584     --enable-long-long \
585     --enable-languages=c,c++ \
586     --disable-nls \
587     --disable-multilib \
588     || die
589    
590     make \
591     AS_FOR_TARGET="${TARGET_CHOST}-as" \
592     LD_FOR_TARGET="${TARGET_CHOST}-ld" \
593     || die
594     }
595    
596     gcc_cross_src_install()
597     {
598     cd ${GCC_SRCDIR}/build
599     make install || die
600     }
601    
602    
603     binutils_stage1_src_prepare()
604     {
605     munpack ${BINUTILS_SRCFILE} || die
606     install -d ${BINUTILS_SRCDIR}/build || die
607     }
608    
609     binutils_stage1_src_compile()
610     {
611     cd ${BINUTILS_SRCDIR}/build
612    
613     ../configure \
614     --build=${CROSS_CHOST} \
615     --host=${TARGET_CHOST} \
616     --target=${TARGET_CHOST} \
617     --prefix=${TARGET_DEST} \
618     --with-lib-path=${TARGET_DEST}/lib \
619     --disable-nls \
620     --enable-shared \
621     --enable-64-bit-bfd \
622     --disable-multilib \
623     || die
624    
625     make configure-host || die
626     mmake || die
627     }
628    
629     binutils_stage1_src_install()
630     {
631     cd ${BINUTILS_SRCDIR}/build
632    
633     make install || die
634    
635     install -d ${TARGET_DEST}/include || die
636     cp ../include/libiberty.h ${TARGET_DEST}/include || die
637     }
638    
639    
640     gcc_stage1_src_prepare()
641     {
642     munpack ${GCC_SRCFILE} || die
643     cd ${GCC_SRCDIR}
644    
645     mpatch gcc-${GCC_PVER}-no-fixincludes.patch || die
646     mpatch gcc-${GCC_PVER}-magellan-version.patch || die
647    
648     # fixes location of the dynamic linker and not append include
649     # search path to /usr/include
650     # but first set the location to ${TARGET_DEST} and than patch
651     sed "s:/tools/lib/:${TARGET_DEST}/lib/:g" \
652     ${SOURCEDIR}/${PNAME}/gcc-${GCC_PVER}-specs.patch | patch -Np1 || die
653    
654     # do not search the /usr directory for libgcc_s.so when cross-compiling
655     mpatch gcc-${GCC_PVER}-cross-search-paths.patch || die
656    
657     # suppress installation of libiberty, as we will be
658     # using the one from binutils
659     #sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in || die
660    
661     # don't search headers in /usr/include
662     sed -i '/#define STANDARD_INCLUDE_DIR/s@"/usr/include"@0@g' gcc/cppdefault.c || die
663    
664     # set the directory searched by the fixincludes process for system headers
665     sed -i "s@\(^NATIVE_SYSTEM_HEADER_DIR =\).*@\1 ${TARGET_DEST}/include@g" gcc/Makefile.in || die
666    
667     install -d ${GCC_SRCDIR}/build || die
668     }
669    
670     gcc_stage1_src_compile()
671     {
672     cd ${GCC_SRCDIR}/build
673    
674     ../configure \
675     --build=${CROSS_CHOST} \
676     --host=${TARGET_CHOST} \
677     --target=${TARGET_CHOST} \
678     --prefix=${TARGET_DEST} \
679     --with-local-prefix=${TARGET_DEST} \
680     --disable-nls \
681     --enable-shared \
682     --enable-threads=posix \
683     --enable-__cxa_atexit \
684     --enable-long-long \
685     --enable-c99 \
686     --enable-cstdio=stdio \
687     --enable-languages=c,c++ \
688     --disable-libstdcxx-pch \
689     || die
690    
691     make AS_FOR_TARGET="${AS}" LD_FOR_TARGET="${LD}" || die
692     }
693    
694     gcc_stage1_src_install()
695     {
696     cd ${GCC_SRCDIR}/build
697     make install || die
698     }
699    
700    
701     ncurses_stage1_src_prepare()
702     {
703     munpack ${NCURSES_SRCFILE} || die
704     }
705    
706     ncurses_stage1_src_compile()
707     {
708     cd ${NCURSES_SRCDIR}
709    
710     stage1_configure \
711     --with-shared \
712     --without-debug \
713     --without-ada \
714     --enable-overwrite \
715     --with-build-cc=gcc \
716     || die
717    
718     mmake || die
719     }
720    
721     ncurses_stage1_src_install()
722     {
723     cd ${NCURSES_SRCDIR}
724     mmake install || die
725     }
726    
727    
728     bash_stage1_src_prepare()
729     {
730     munpack ${BASH_SRCFILE} || die
731     }
732    
733     bash_stage1_src_compile()
734     {
735     cd ${BASH_SRCDIR}
736    
737     # while cross-compiling, bash test for the presence of named pipes etc
738     echo "ac_cv_func_mmap_fixed_mapped=yes" > config.cache
739     echo "ac_cv_func_strcoll_works=yes" >> config.cache
740     echo "ac_cv_func_working_mktime=yes" >> config.cache
741     echo "bash_cv_func_sigsetjmp=present" >> config.cache
742     echo "bash_cv_getcwd_malloc=yes" >> config.cache
743     echo "bash_cv_job_control_missing=present" >> config.cache
744     echo "bash_cv_printf_a_format=yes" >> config.cache
745     echo "bash_cv_sys_named_pipes=present" >> config.cache
746     echo "bash_cv_ulimit_maxfds=yes" >> config.cache
747     echo "bash_cv_under_sys_siglist=yes" >> config.cache
748     echo "bash_cv_unusable_rtsigs=no" >> config.cache
749     echo "gt_cv_int_divbyzero_sigfpe=yes" >> config.cache
750    
751     stage1_configure \
752     --without-bash-malloc \
753     --cache-file=config.cache \
754     || die
755    
756     mmake || die
757     }
758    
759     bash_stage1_src_install()
760     {
761     cd ${BASH_SRCDIR}
762     mmake install || die
763    
764     # use bash as default shell
765     ln -snf bash ${TARGET_DEST}/bin/sh || die
766     }
767    
768    
769     bzip2_stage1_src_prepare()
770     {
771     munpack ${BZIP2_SRCFILE} || die
772     cd ${BZIP2_SRCDIR}
773    
774     # disable testsuite; won't work on multi-arch/cross build
775     sed -i 's@^\(all:.*\) test@\1@g' Makefile || die
776     }
777    
778     bzip2_stage1_src_compile()
779     {
780     cd ${BZIP2_SRCDIR}
781     mmake CC="${CC}" AR="${AR}" RANLIB="${RANLIB}" || die
782     }
783    
784     bzip2_stage1_src_install()
785     {
786     cd ${BZIP2_SRCDIR}
787     mmake PREFIX=${TARGET_DEST} install || die
788     }
789    
790    
791     coreutils_stage1_src_prepare()
792     {
793     munpack ${COREUTILS_SRCFILE} || die
794     }
795    
796     coreutils_stage1_src_compile()
797     {
798     cd ${COREUTILS_SRCDIR}
799    
800     # configure can not properly determine how to get free space
801     # and 'df' will not be built
802     #echo "fu_cv_sys_stat_statfs2_bsize=yes" > config.cache
803    
804     # from debian
805     # configure can not properly determine how to get free space
806     # and 'df' will not be built
807     #
808     # fixes include/stdio.h:718: error: conflicting types for 'rpl_fseeko'
809     # see: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=480706
810     #
811     # coreutils 6.10 needs a patch for the gettime issue
812     # see: http://bugs.gentoo.org/show_bug.cgi?id=207560
813     # (appling outside)
814     #
815     echo 'gl_cv_func_tzset_clobber=no' > config.cache
816     echo 'jm_cv_func_gettimeofday_clobber=no' >> config.cache
817     echo 'utils_cv_localtime_cache=no' >> config.cache
818     echo 'ac_cv_func_futimesat=yes' >> config.cache
819     echo 'ac_cv_prog_cc_c99=${ac_cv_prog_cc_c99=-std=gnu99}' >> config.cache
820     echo 'ac_cv_prog_cc_stdc=${ac_cv_prog_cc_stdc=-std=gnu99}' >> config.cache
821     echo 'fu_cv_sys_stat_statfs2_bsize=yes' >> config.cache
822     echo 'gl_cv_struct_dirent_d_ino=yes' >> config.cache
823     echo 'ac_cv_func_malloc_0_nonnull=yes' >> config.cache
824     echo 'ac_cv_func_realloc_0_nonnull=yes' >> config.cache
825     echo 'gl_cv_header_working_fcntl_h=yes' >> config.cache
826     echo 'gl_cv_func_gnu_getopt=yes' >> config.cache
827     echo 'ac_cv_func_calloc_0_nonnull=yes' >> config.cache
828     echo 'gl_cv_func_fflush_stdin=yes' >> config.cache
829     echo 'gl_cv_func_wcwidth_works=yes' >> config.cache
830     echo 'ac_cv_func_fnmatch_gnu=yes' >> config.cache
831     echo 'gl_cv_func_getcwd_null=yes' >> config.cache
832     echo 'ac_cv_func_memcmp_working=yes' >> config.cache
833     echo 'gl_cv_func_signbit=yes' >> config.cache
834     echo 'ac_cv_func_lstat_empty_string_bug=no' >> config.cache
835     echo 'gl_cv_func_working_acl_get_file=yes' >> config.cache
836     echo 'gl_cv_func_fchownat_nofollow_works=yes' >> config.cache
837    
838     stage1_configure --cache-file=config.cache || die
839     mmake || die
840     }
841    
842     coreutils_stage1_src_install()
843     {
844     cd ${COREUTILS_SRCDIR}
845     mmake install || die
846     }
847    
848    
849     diffutils_stage1_src_prepare()
850     {
851     munpack ${DIFFUTILS_SRCFILE} || die
852     }
853    
854     diffutils_stage1_src_compile()
855     {
856     cd ${DIFFUTILS_SRCDIR}
857     stage1_configure || die
858     mmake || die
859     }
860    
861     diffutils_stage1_src_install()
862     {
863     cd ${DIFFUTILS_SRCDIR}
864     mmake install || die
865     }
866    
867    
868     findutils_stage1_src_prepare()
869     {
870     munpack ${FINDUTILS_SRCFILE} || die
871     }
872    
873     findutils_stage1_src_compile()
874     {
875     cd ${FINDUTILS_SRCDIR}
876     stage1_configure || die
877     mmake || die
878     }
879    
880     findutils_stage1_src_install()
881     {
882     cd ${FINDUTILS_SRCDIR}
883     mmake install || die
884     }
885    
886    
887     zlib_stage1_src_prepare()
888     {
889     munpack ${ZLIB_SRCFILE} || die
890     }
891    
892     zlib_stage1_src_compile()
893     {
894     cd ${ZLIB_SRCDIR}
895     # zlib uses a non standart configure
896     ./configure --prefix=${TARGET_DEST} --shared || die
897     mmake || die
898     }
899    
900     zlib_stage1_src_install()
901     {
902     cd ${FINDUTILS_SRCDIR}
903     mmake install || die
904     }
905    
906    
907     file_stage1_src_prepare()
908     {
909     munpack ${FILE_SRCFILE} || die
910     }
911    
912     file_stage1_src_compile()
913     {
914     cd ${FILE_SRCDIR}
915     stage1_configure || die
916     mmake || die
917     }
918    
919     file_stage1_src_install()
920     {
921     cd ${FILE_SRCDIR}
922     mmake install || die
923     }
924    
925    
926     gawk_stage1_src_prepare()
927     {
928     munpack ${GAWK_SRCFILE} || die
929     }
930    
931     gawk_stage1_src_compile()
932     {
933     cd ${GAWK_SRCDIR}
934     stage1_configure || die
935     mmake || die
936     }
937    
938     gawk_stage1_src_install()
939     {
940     cd ${GAWK_SRCDIR}
941     mmake install || die
942     }
943    
944    
945     gettext_stage1_src_prepare()
946     {
947     munpack ${GETTEXT_SRCFILE} || die
948     }
949    
950     gettext_stage1_src_compile()
951     {
952     cd ${GETTEXT_SRCDIR}/gettext-tools
953    
954     # fixes compilation; configure assume that wcwidth is broken
955     echo "gl_cv_func_wcwidth_works=yes" > config.cache
956     stage1_configure --disable-shared --cache-file=config.cache || die
957    
958     # only built neccessary stuff
959     mmake -C gnulib-lib || die
960     mmake -C src msgfmt || die
961     }
962    
963     gettext_stage1_src_install()
964     {
965     cd ${GETTEXT_SRCDIR}/gettext-tools
966    
967     # only install neccessary stuff
968     install -m0755 src/msgfmt ${TARGET_DEST}/bin || die
969     }
970    
971    
972     grep_stage1_src_prepare()
973     {
974     munpack ${GREP_SRCFILE} || die
975     }
976    
977     grep_stage1_src_compile()
978     {
979     cd ${GREP_SRCDIR}
980     stage1_configure --disable-perl-regexp || die
981     mmake || die
982     }
983    
984     grep_stage1_src_install()
985     {
986     cd ${GREP_SRCDIR}
987     mmake install || die
988     }
989    
990    
991     gzip_stage1_src_prepare()
992     {
993     munpack ${GZIP_SRCFILE} || die
994     }
995    
996     gzip_stage1_src_compile()
997     {
998     cd ${GZIP_SRCDIR}
999     stage1_configure || die
1000     mmake || die
1001     }
1002    
1003     gzip_stage1_src_install()
1004     {
1005     cd ${GZIP_SRCDIR}
1006     mmake install || die
1007     }
1008    
1009    
1010     make_stage1_src_prepare()
1011     {
1012     munpack ${MAKE_SRCFILE} || die
1013     }
1014    
1015     make_stage1_src_compile()
1016     {
1017     cd ${MAKE_SRCDIR}
1018     stage1_configure || die
1019     mmake || die
1020     }
1021    
1022     make_stage1_src_install()
1023     {
1024     cd ${MAKE_SRCDIR}
1025     mmake install || die
1026     }
1027    
1028    
1029     patch_stage1_src_prepare()
1030     {
1031     munpack ${PATCH_SRCFILE} || die
1032     }
1033    
1034     patch_stage1_src_compile()
1035     {
1036     cd ${PATCH_SRCDIR}
1037     stage1_configure || die
1038     mmake || die
1039     }
1040    
1041     patch_stage1_src_install()
1042     {
1043     cd ${PATCH_SRCDIR}
1044     mmake install || die
1045     }
1046    
1047    
1048     sed_stage1_src_prepare()
1049     {
1050     munpack ${SED_SRCFILE} || die
1051     }
1052    
1053     sed_stage1_src_compile()
1054     {
1055     cd ${SED_SRCDIR}
1056     stage1_configure || die
1057     mmake || die
1058     }
1059    
1060     sed_stage1_src_install()
1061     {
1062     cd ${SED_SRCDIR}
1063     mmake install || die
1064     }
1065    
1066    
1067     tar_stage1_src_prepare()
1068     {
1069     munpack ${TAR_SRCFILE} || die
1070     }
1071    
1072     tar_stage1_src_compile()
1073     {
1074     cd ${TAR_SRCDIR}
1075    
1076     # fixes compilation; configure assume that wcwidth is broken
1077     echo "gl_cv_func_wcwidth_works=yes" > config.cache
1078    
1079     stage1_configure --cache-file=config.cache || die
1080     mmake || die
1081     }
1082    
1083     tar_stage1_src_install()
1084     {
1085     cd ${TAR_SRCDIR}
1086     mmake install || die
1087     }
1088    
1089    
1090     texinfo_stage1_src_prepare()
1091     {
1092     munpack ${TEXINFO_SRCFILE} || die
1093     cd ${TEXINFO_SRCDIR}
1094    
1095     # fixes a build error due to mbstate being undefined
1096     mpatch texinfo-${TEXINFO_PVER}-mbstate-fix.patch || die
1097     }
1098    
1099     texinfo_stage1_src_compile()
1100     {
1101     cd ${TEXINFO_SRCDIR}
1102    
1103    
1104     # forcefully override any activated ccache support,
1105     # which may break the built
1106     deactivate_ccache
1107    
1108     # sometimes texinfo includes the termcap.h from host system instead from our buildroot
1109     # see http://www.linuxquestions.org/questions/linux-from-scratch-13/compiling-temporary-system-tools-628818/
1110     CPPFLAGS="-I${TARGET_DEST}/include" \
1111     LDFLAGS="-L${TARGET_DEST}/lib" \
1112     stage1_configure || die
1113     mmake -C tools/gnulib/lib || die
1114     mmake -C tools || die
1115     mmake || die
1116    
1117     # re-activate ccache
1118     activate_ccache
1119     }
1120    
1121     texinfo_stage1_src_install()
1122     {
1123     cd ${TEXINFO_SRCDIR}
1124     mmake install || die
1125     }
1126    
1127    
1128     e2fsprogs_stage1_src_prepare()
1129     {
1130     munpack ${E2FSPROGS_SRCFILE} || die
1131     install -d ${E2FSPROGS_SRCDIR} || die
1132     }
1133    
1134     e2fsprogs_stage1_src_compile()
1135     {
1136     cd ${E2FSPROGS_SRCDIR}
1137    
1138     # lfs method
1139     # stage1_configure \
1140     # --with-cc="${CC}" \
1141     # --with-linker="${LD}" \
1142     # --enable-elf-shlibs \
1143     # --disable-evms \
1144     # || die
1145    
1146     # lfs not working, trying this one: http://www.oesf.org/forum/index.php?showtopic=1370
1147     CC="${TARGET_CHOST}-gcc" \
1148     LINKER="${TARGET_CHOST}-g++" \
1149     COMPILER="${TARGET_CHOST}-gcc" \
1150     stage1_configure --enable-elf-shlibs --disable-evms || die
1151     # libs only
1152     mmake libs || die
1153     }
1154    
1155     e2fsprogs_stage1_src_install()
1156     {
1157     cd ${E2FSPROGS_SRCDIR}
1158     # install libs only
1159     mmake install-libs || die
1160     }
1161    
1162    
1163     util_linux_stage1_src_prepare()
1164     {
1165     munpack ${UTIL_LINUX_SRCFILE} || die
1166     }
1167    
1168     util_linux_stage1_src_compile()
1169     {
1170     cd ${UTIL_LINUX_SRCDIR}
1171    
1172     stage1_configure || die
1173    
1174     # compile only {u,}mount and more
1175     mmake -C mount mount umount || die
1176     mmake -C text-utils more || die
1177     }
1178    
1179     util_linux_stage1_src_install()
1180     {
1181     cd ${UTIL_LINUX_SRCDIR}
1182    
1183     # install only {u,}mount and more
1184     install -m0755 mount/{,u}mount text-utils/more ${TARGET_DEST}/bin || die
1185     }
1186    
1187     wget_stage1_src_prepare()
1188     {
1189     munpack ${WGET_SRCFILE} || die
1190     cd ${WGET_SRCDIR}
1191    
1192     # enable passive mode by default
1193     sed -i 's:#passive_ftp = off:passive_ftp = on:g' doc/sample.wgetrc || die
1194     }
1195    
1196     wget_stage1_src_compile()
1197     {
1198     cd ${WGET_SRCDIR}
1199     stage1_configure || die
1200     mmake || die
1201     }
1202    
1203     wget_stage1_src_install()
1204     {
1205     cd ${WGET_SRCDIR}
1206     mmake install || die
1207     }
1208    
1209    
1210     rsync_stage1_src_prepare()
1211     {
1212     munpack ${RSYNC_SRCFILE} || die
1213     }
1214    
1215     rsync_stage1_src_compile()
1216     {
1217     cd ${RSYNC_SRCDIR}
1218     stage1_configure --with-rsyncd-conf=/etc/rsyncd.conf --with-included-popt || die
1219     mmake || die
1220     }
1221    
1222     rsync_stage1_src_install()
1223     {
1224     cd ${RSYNC_SRCDIR}
1225     mmake install || die
1226     }
1227    
1228    
1229     cvs_stage1_src_prepare()
1230     {
1231     munpack ${CVS_SRCFILE} || die
1232     }
1233    
1234     cvs_stage1_src_compile()
1235     {
1236     cd ${CVS_SRCDIR}
1237     stage1_configure --enable-client --disable-server || die
1238     mmake || die
1239     }
1240    
1241     cvs_stage1_src_install()
1242     {
1243     cd ${CVS_SRCDIR}
1244     mmake install || die
1245     }
1246    
1247    
1248     perl_minimal_stage1_src_prepare()
1249     {
1250     munpack ${PERL_SRCFILE} || die
1251     cd ${PERL_SRCDIR}
1252    
1253     mpatch perl-${PERL_PVER}-hardwired-libc.patch || die
1254     }
1255    
1256     perl_minimal_stage1_src_compile()
1257     {
1258     cd ${PERL_SRCDIR}
1259    
1260     ./configure.gnu \
1261     --prefix=${TARGET_DEST} \
1262     -Dstatic_ext='Data/Dumper IO Fcntl POSIX' \
1263     -Dcc="${CC}" \
1264     || die
1265    
1266     mmake perl utilities || die
1267     }
1268    
1269     perl_minimal_stage1_src_install()
1270     {
1271     cd ${PERL_SRCDIR}
1272    
1273     install -m0755 perl pod/pod2man ${TARGET_DEST}/bin || die
1274     install -d ${TARGET_DEST}/lib/perl${PERL_PVER:0:1}/${PERL_PVER} || die
1275     cp -Rv lib/* ${TARGET_DEST}/lib/perl${PERL_PVER:0:1}/${PERL_PVER} || die
1276     minstalldir ${BUILDROOT_DEST}/usr/bin || die
1277     mlink ${TARGET_DEST}/bin/perl ${BUILDROOT_DEST}/usr/bin || die
1278     }
1279    
1280    
1281     m4_stage1_src_prepare()
1282     {
1283     munpack ${M4_SRCFILE} || die
1284     }
1285    
1286     m4_stage1_src_compile()
1287     {
1288     cd ${M4_SRCDIR}
1289    
1290     stage1_configure --enable-changeword || die
1291     mmake || die
1292     }
1293    
1294     m4_stage1_src_install()
1295     {
1296     cd ${M4_SRCDIR}
1297     mmake install || die
1298     }
1299    
1300    
1301     bison_stage1_src_prepare()
1302     {
1303     munpack ${BISON_SRCFILE} || die
1304     }
1305    
1306     bison_stage1_src_compile()
1307     {
1308     cd ${BISON_SRCDIR}
1309    
1310     stage1_configure || die
1311     mmake || die
1312     }
1313    
1314     bison_stage1_src_install()
1315     {
1316     cd ${BISON_SRCDIR}
1317     mmake install || die
1318     }
1319    
1320    
1321     flex_stage1_src_prepare()
1322     {
1323     munpack ${FLEX_SRCFILE} || die
1324     }
1325    
1326     flex_stage1_src_compile()
1327     {
1328     cd ${FLEX_SRCDIR}
1329    
1330     stage1_configure || die
1331     mmake || die
1332     }
1333    
1334     flex_stage1_src_install()
1335     {
1336     cd ${FLEX_SRCDIR}
1337     mmake install || die
1338     }
1339    
1340     filesystem_stage2_src_prepare()
1341     {
1342     munpack ${INITSCRIPTS_SRCFILE} || die
1343     }
1344    
1345    
1346     filesystem_stage2_src_install()
1347     {
1348     local magerc="${BINDIR}/${BUILDROOT_DEST}/etc/mage.rc"
1349    
1350     mkeepdir ${BUILDROOT_DEST}/etc || die
1351     install -m0644 /etc/mage.rc ${magerc} || die
1352     install -m0644 /etc/resolv.conf ${BINDIR}/${BUILDROOT_DEST}/etc || die
1353     sed -i "s:\(ARCH=\).*:\1\"${TARGET_ARCH}\":" ${magerc} || die
1354     MAGERC="${magerc}" \
1355     MROOT="${BINDIR}/${BUILDROOT_DEST}" \
1356     mage srcinstall base-files || die
1357    
1358     # essential symlinks for the toolchain
1359     mlink ${TARGET_DEST}/bin/bash ${BUILDROOT_DEST}/bin || die
1360     mlink ${TARGET_DEST}/bin/cat ${BUILDROOT_DEST}/bin || die
1361     mlink ${TARGET_DEST}/bin/echo ${BUILDROOT_DEST}/bin || die
1362     mlink ${TARGET_DEST}/bin/grep ${BUILDROOT_DEST}/bin || die
1363     mlink ${TARGET_DEST}/bin/pwd ${BUILDROOT_DEST}/bin || die
1364     mlink ${TARGET_DEST}/bin/rm ${BUILDROOT_DEST}/bin || die
1365     mlink ${TARGET_DEST}/bin/stty ${BUILDROOT_DEST}/bin || die
1366     mlink ${TARGET_DEST}/bin/file ${BUILDROOT_DEST}/usr/bin || die
1367     # x86_64 multilib support
1368     if [[ ${TARGET_ARCH} = x86_64 ]]
1369     then
1370     mlink ${TARGET_DEST}/lib/libgcc_s.so ${BUILDROOT_DEST}/usr/lib64 || die
1371     mlink ${TARGET_DEST}/lib/libgcc_s.so.1 ${BUILDROOT_DEST}/usr/lib64 || die
1372     mlink ${TARGET_DEST}/lib/libstd\* ${BUILDROOT_DEST}/usr/lib || die
1373     else
1374     mlink ${TARGET_DEST}/lib/libgcc_s.so ${BUILDROOT_DEST}/usr/lib || die
1375     mlink ${TARGET_DEST}/lib/libgcc_s.so.1 ${BUILDROOT_DEST}/usr/lib || die
1376     mlink ${TARGET_DEST}/lib/libstd\* ${BUILDROOT_DEST}/usr/lib || die
1377     fi
1378     mlink bash ${BUILDROOT_DEST}/bin/sh || die
1379    
1380     # basic passwd @ group file
1381     install -m0644 ${INITSCRIPTS_SRCDIR}/etc/group ${BINDIR}/${BUILDROOT_DEST}/etc || die
1382     install -m0644 ${INITSCRIPTS_SRCDIR}/etc/passwd ${BINDIR}/${BUILDROOT_DEST}/etc || die
1383    
1384     # essential files for logging
1385     memptyfile ${BUILDROOT_DEST}/var/run/utmp || die
1386     memptyfile ${BUILDROOT_DEST}/var/log/btmp || die
1387     memptyfile ${BUILDROOT_DEST}/var/log/lastlog || die
1388     memptyfile ${BUILDROOT_DEST}/var/log/wtmp || die
1389     # permissions
1390     mchown root:utmp ${BUILDROOT_DEST}/var/run/utmp || die
1391     mchown root:utmp ${BUILDROOT_DEST}/var/log/lastlog || die
1392     mchmod 0664 ${BUILDROOT_DEST}/var/run/utmp || die
1393     mchmod 0664 ${BUILDROOT_DEST}/var/log/lastlog || die
1394     mchmod 0600 ${BUILDROOT_DEST}/var/log/btmp || die
1395     }
1396    
1397    
1398     mage_stage2_src_install()
1399     {
1400     MAGERC="${BINDIR}/${BUILDROOT_DEST}/etc/mage.rc" \
1401     MROOT="${BINDIR}/${BUILDROOT_DEST}" \
1402     mage srcinstall mage || die
1403    
1404     minstalldir ${BUILDROOT_DEST}/${MAGEDIR} || die
1405     minstalldir ${BUILDROOT_DEST}/${SMAGESCRIPTSDIR} || die
1406     minstalldir ${BUILDROOT_DEST}/${BUILDDIR} || die
1407    
1408     # link default profile of the host system
1409     mlink $(readlink /etc/mage-profile) ${BUILDROOT_DEST}/etc/mage-profile || die
1410    
1411     chrooted /sbin/mage update
1412     chrooted /sbin/smage2 update
1413     }
1414    
1415    
1416     # linux_headers_stage2_src_prepare()
1417     # {
1418     # munpack ${LINUX_HEADERS_SRCFILE} || die
1419     # }
1420     #
1421     # linux_headers_stage2_src_compile()
1422     # {
1423     # cd ${LINUX_HEADERS_SRCDIR}
1424     # make mrproper || die
1425     # make ARCH=${ARCH/i*86/x86} headers_check || die
1426     # }
1427     #
1428     # linux_headers_stage2_src_install()
1429     # {
1430     # cd ${LINUX_HEADERS_SRCDIR}
1431     # make ARCH=${ARCH/i*86/x86} INSTALL_HDR_PATH=/usr headers_install || die
1432     # }
1433    
1434     linux_headers_stage2_src_install()
1435     {
1436     chrooted --mount --sources /sbin/mage srcinstall linux-libc-headers || die
1437     }
1438    
1439     # glibc_stage2_src_prepare()
1440     # {
1441     # munpack ${GLIBC_SRCFILE} ${BUILDROOT}/${BUILDDIR} || die
1442     # cd ${BUILDROOT}/${GLIBC_SRCDIR}
1443     #
1444     # # disable binutils -as-needed
1445     # sed -i 's/^have-as-needed.*/have-as-needed = no/' \
1446     # ${BUILDROOT}/${GLIBC_SRCDIR}/config.make.in || die
1447     #
1448     # # fix segfault of localdef on arches beside x86-32
1449     # mpatch glibc-2.3.5-localedef_segfault-1.patch || die
1450     #
1451     # # fix permissions on some of the scripts
1452     # chmod u+x ${BUILDROOT}/${GLIBC_SRCDIR}/scripts/*.sh || die
1453     #
1454     # install -d ${BUILDROOT}/${GLIBC_SRCDIR}/build || die
1455     # }
1456     #
1457     # glibc_stage2_src_compile()
1458     # {
1459     # cd ${GLIBC_SRCDIR}/build
1460     #
1461     # local my_glibc_CFLAGS
1462     # local my_glibc_CXXFLAGS
1463     # # glibc-2.6.1 and above needs march CFLAGS: -march=${ARCH} -mtune=generic
1464     # [[ ${TARGET_ARCH} = i*86 ]] && my_glibc_CFLAGS="${CFLAGS} -march=${TARGET_ARCH}" # only i*86
1465     # my_glibc_CFLAGS="${my_glibc_CFLAGS} -mtune=generic" # all arches
1466     #
1467     # # force nptl support (may not detected always)
1468     # echo "libc_cv_forced_unwind=yes" > config.cache || die
1469     # echo "libc_cv_c_cleanup=yes" >> config.cache || die
1470     #
1471     # BUILD_CC="gcc" \
1472     # CC="${TARGET_CHOST}-gcc" \
1473     # AR="${TARGET_CHOST}-ar" \
1474     # RANLIB="${TARGET_CHOST}-ranlib" \
1475     # CFLAGS="${my_glibc_CFLAGS}" \
1476     # ../configure \
1477     # --host=${TARGET_CHOST} \
1478     # --build=${CROSS_CHOST} \
1479     # --prefix=${TARGET_DEST} \
1480     # --disable-profile \
1481     # --enable-add-ons=nptl --with-tls \
1482     # --with-__thread \
1483     # --enable-kernel=2.6.0 \
1484     # --without-cvs \
1485     # --with-headers=${TARGET_DEST}/include \
1486     # --with-binutils=${CROSS_DEST}/bin \
1487     # --cache-file=config.cache \
1488     # || die
1489     #
1490     # make PARALLELMFLAGS="-j2" || die
1491     # }
1492    
1493     glibc_stage2_src_install()
1494     {
1495     chrooted --mount --sources NODEPS=true mage srcinstall glibc-nptl || die
1496     }
1497    
1498     stage2_adjusting_toolchain()
1499     {
1500     local linker
1501     local libdir
1502     local linker_adjusted
1503     linker=$(basename $(chrooted readelf -l ${TARGET_DEST}/bin/ls | grep interpreter | sed 's/.*interpreter: \(.*\)]/\1/'))
1504    
1505     case ${TARGET_ARCH} in
1506     x86_64) libdir=lib64 ;;
1507     *) libdir=lib ;;
1508     esac
1509    
1510     chrooted gcc -dumpspecs | \
1511     sed -e "s:${TARGET_DEST}/${libdir}/${linker}:/${libdir}/${linker}:g" \
1512     -e "/\*startfile_prefix_spec:/{n;s@.*@/usr/${libdir}/ @}" \
1513     -e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' \
1514     > ${BINDIR}/${BUILDROOT_DEST}/$(dirname $(chrooted gcc --print-libgcc-file-name))/specs \
1515     || die
1516    
1517     # test it
1518     echo 'main(){}' > ${BINDIR}/${BUILDROOT_DEST}/dummy.c || die
1519     chrooted gcc /dummy.c -v -Wl,--verbose &> /dummy.log || die
1520     linker_adjusted=$(chrooted readelf -l /a.out | grep interpreter | sed 's/.*interpreter: \(.*\)]/\1/')
1521     if [[ ${linker_adjusted} != /${libdir}/${linker} ]]
1522     then
1523     die "broken toolchain: ${linker_adjusted} != /${libdir}/${linker}"
1524     fi
1525     }
1526    
1527     #binutils_stage2_src_prepare() { return 0; }
1528     #binutils_stage2_src_compile() { return 0; }
1529     binutils_stage2_src_install()
1530     {
1531     chrooted --mount --sources AR=ar NODEPS=true mage srcinstall binutils || die
1532     }
1533    
1534    
1535     #gcc_stage2_src_prepare() { return 0; }
1536     #gcc_stage2_src_compile() { return 0; }
1537     gcc_stage2_src_install()
1538     {
1539     # gcc is splitted into two packages: libstc++ and gcc
1540     chrooted --mount --sources NODEPS=true mage srcinstall libstdc++ || die
1541     chrooted --mount --sources NODEPS=true mage srcinstall gcc || die
1542     }
1543    
1544    
1545     buildroot_clean()
1546     {
1547     # prune packages
1548     # chrooted /sbin/mage update || die
1549     chrooted /sbin/mage clean || die
1550    
1551     # prune sources
1552     if [[ -d ${BUILDROOT_DEST}/${SOURCEDIR} ]]
1553     then
1554     rm -rf ${BUILDROOT_DEST}/${SOURCEDIR} || die
1555     fi
1556    
1557     # # prune install db
1558     # if [[ -d ${BUILDROOT_DEST}/${INSTALLDB} ]]
1559     # then
1560     # rm -rf ${BUILDROOT_DEST}/${INSTALLDB} || die
1561     # fi
1562     }
1563    
1564     buildroot_src_prepare()
1565     {
1566     if [[ -e ${TARGET_DEST} ]] || [[ -L ${TARGET_DEST} ]]
1567     then
1568     echo
1569     echo "Please uninstall any buildroot packages first."
1570     echo "To build the tools I'll create a fake symlink to ${TARGET_DEST},"
1571     echo "so this directory must not exist."
1572     echo
1573     die "${TARGET_DEST} exists."
1574     fi
1575    
1576     if [[ -e ${CROSS_DEST} ]] || [[ -L ${CROSS_DEST} ]]
1577     then
1578     echo
1579     echo "Please uninstall any buildroot packages first."
1580     echo "To build the tools I'll create a fake symlink to ${CROSS_DEST},"
1581     echo "so this directory must not exist."
1582     echo
1583     die "${CROSS_DEST} exists."
1584     fi
1585    
1586     if [[ ${CHOST} = ${TARGET_CHOST} ]]
1587     then
1588     echo
1589     echo "\$CHOST and \$TARGET_CHOST have the same values."
1590     echo " CHOST=${CHOST}"
1591     echo " TARGET_CHOST=${TARGET_CHOST}"
1592     echo
1593     echo "You cannot build a buildroot with these settings,"
1594     echo "please use the native gcc-\${ARCH} builds."
1595     echo
1596     die "\$CHOST equal \$TARGET_CHOST."
1597     fi
1598    
1599     # create a fake build-root
1600     install -d ${BINDIR}${BUILDROOT_DEST}${TARGET_DEST} || die
1601     ln -snf ${BINDIR}${BUILDROOT_DEST}${TARGET_DEST} ${TARGET_DEST} || die
1602    
1603     # create a fake cross-root
1604     install -d ${BINDIR}${BUILDROOT_DEST}${CROSS_DEST} || die
1605     ln -snf ${BINDIR}${BUILDROOT_DEST}${CROSS_DEST} ${CROSS_DEST} || die
1606     }
1607    
1608     buildroot_src_compile()
1609     {
1610     # setup a proper build environment
1611     export PATH=${CROSS_DEST}/bin:${PATH}
1612    
1613     # setup cross-compilation tools
1614    
1615     ####################################
1616     # toolchain - cross: linux-headers #
1617     ####################################
1618     linux_headers_cross_src_prepare
1619     linux_headers_cross_src_compile
1620     linux_headers_cross_src_install
1621    
1622    
1623     ###############################
1624     # toolchain - cross: binutils #
1625     ###############################
1626     binutils_cross_src_prepare
1627     binutils_cross_src_compile
1628     binutils_cross_src_install
1629    
1630     # remove BINUTILS_SRCDIR
1631     rm -rf ${BINUTILS_SRCDIR} || die
1632    
1633     #################################
1634     # toolchain - cross: gcc-static #
1635     #################################
1636     gcc_static_cross_src_prepare
1637     gcc_static_cross_src_compile
1638     gcc_static_cross_src_install
1639    
1640     # remove GCC_SRCDIR
1641     rm -rf ${GCC_SRCDIR} || die
1642    
1643    
1644     ############################
1645     # toolchain - cross: glibc #
1646     ############################
1647     glibc_cross_src_prepare
1648     glibc_cross_src_compile
1649     glibc_cross_src_install
1650    
1651    
1652     ##########################
1653     # toolchain - cross: gcc #
1654     ##########################
1655     gcc_cross_src_prepare
1656     gcc_cross_src_compile
1657     gcc_cross_src_install
1658    
1659     # remove GCC_SRCDIR
1660     rm -rf ${GCC_SRCDIR} || die
1661    
1662    
1663     # export TOOLCHAIN Variables
1664     export CC="${TARGET_CHOST}-gcc"
1665     export CXX="${TARGET_CHOST}-g++"
1666     export AR="${TARGET_CHOST}-ar"
1667     export AS="${TARGET_CHOST}-as"
1668     export RANLIB="${TARGET_CHOST}-ranlib"
1669     export LD="${TARGET_CHOST}-ld"
1670     export STRIP="${TARGET_CHOST}-strip"
1671    
1672    
1673     ################################
1674     # toolchain - stage1: binutils #
1675     ################################
1676     binutils_stage1_src_prepare
1677     binutils_stage1_src_compile
1678     binutils_stage1_src_install
1679    
1680    
1681     ###########################
1682     # toolchain - stage1: gcc #
1683     ###########################
1684     gcc_stage1_src_prepare
1685     gcc_stage1_src_compile
1686     gcc_stage1_src_install
1687    
1688    
1689     ###############################
1690     # toolchain - stage1: ncurses #
1691     ###############################
1692     ncurses_stage1_src_prepare
1693     ncurses_stage1_src_compile
1694     ncurses_stage1_src_install
1695    
1696    
1697     ############################
1698     # toolchain - stage1: bash #
1699     ############################
1700     bash_stage1_src_prepare
1701     bash_stage1_src_compile
1702     bash_stage1_src_install
1703    
1704    
1705     #############################
1706     # toolchain - stage1: bzip2 #
1707     #############################
1708     bzip2_stage1_src_prepare
1709     bzip2_stage1_src_compile
1710     bzip2_stage1_src_install
1711    
1712    
1713     #################################
1714     # toolchain - stage1: coreutils #
1715     #################################
1716     coreutils_stage1_src_prepare
1717     coreutils_stage1_src_compile
1718     coreutils_stage1_src_install
1719    
1720    
1721     #################################
1722     # toolchain - stage1: diffutils #
1723     #################################
1724     diffutils_stage1_src_prepare
1725     diffutils_stage1_src_compile
1726     diffutils_stage1_src_install
1727    
1728    
1729     #################################
1730     # toolchain - stage1: findutils #
1731     #################################
1732     findutils_stage1_src_prepare
1733     findutils_stage1_src_compile
1734     findutils_stage1_src_install
1735    
1736    
1737     ############################
1738     # toolchain - stage1: zlib #
1739     ############################
1740     zlib_stage1_src_prepare
1741     zlib_stage1_src_compile
1742     zlib_stage1_src_install
1743    
1744    
1745     ############################
1746     # toolchain - stage1: file #
1747     ############################
1748     file_stage1_src_prepare
1749     file_stage1_src_compile
1750     file_stage1_src_install
1751    
1752    
1753     ############################
1754     # toolchain - stage1: gawk #
1755     ############################
1756     gawk_stage1_src_prepare
1757     gawk_stage1_src_compile
1758     gawk_stage1_src_install
1759    
1760    
1761     ###############################
1762     # toolchain - stage1: gettext #
1763     ###############################
1764     gettext_stage1_src_prepare
1765     gettext_stage1_src_compile
1766     gettext_stage1_src_install
1767    
1768    
1769     ############################
1770     # toolchain - stage1: grep #
1771     ############################
1772     grep_stage1_src_prepare
1773     grep_stage1_src_compile
1774     grep_stage1_src_install
1775    
1776    
1777     ############################
1778     # toolchain - stage1: gzip #
1779     ############################
1780     gzip_stage1_src_prepare
1781     gzip_stage1_src_compile
1782     gzip_stage1_src_install
1783    
1784    
1785     ############################
1786     # toolchain - stage1: make #
1787     ############################
1788     make_stage1_src_prepare
1789     make_stage1_src_compile
1790     make_stage1_src_install
1791    
1792    
1793     #############################
1794     # toolchain - stage1: patch #
1795     #############################
1796     patch_stage1_src_prepare
1797     patch_stage1_src_compile
1798     patch_stage1_src_install
1799    
1800    
1801     ###########################
1802     # toolchain - stage1: sed #
1803     ###########################
1804     sed_stage1_src_prepare
1805     sed_stage1_src_compile
1806     sed_stage1_src_install
1807    
1808    
1809     ###########################
1810     # toolchain - stage1: tar #
1811     ###########################
1812     tar_stage1_src_prepare
1813     tar_stage1_src_compile
1814     tar_stage1_src_install
1815    
1816    
1817     ###############################
1818     # toolchain - stage1: texinfo #
1819     ###############################
1820     texinfo_stage1_src_prepare
1821     texinfo_stage1_src_compile
1822     texinfo_stage1_src_install
1823    
1824    
1825     #################################
1826     # toolchain - stage1: e2fsprogs #
1827     #################################
1828     e2fsprogs_stage1_src_prepare
1829     e2fsprogs_stage1_src_compile
1830     e2fsprogs_stage1_src_install
1831    
1832    
1833     ##################################
1834     # toolchain - stage1: util-linux #
1835     ##################################
1836     util_linux_stage1_src_prepare
1837     util_linux_stage1_src_compile
1838     util_linux_stage1_src_install
1839    
1840    
1841     ############################
1842     # toolchain - stage1: wget #
1843     ############################
1844     wget_stage1_src_prepare
1845     wget_stage1_src_compile
1846     wget_stage1_src_install
1847    
1848    
1849     #############################
1850     # toolchain - stage1: rsync #
1851     #############################
1852     rsync_stage1_src_prepare
1853     rsync_stage1_src_compile
1854     rsync_stage1_src_install
1855    
1856    
1857     ###########################
1858     # toolchain - stage1: cvs #
1859     ###########################
1860     cvs_stage1_src_prepare
1861     cvs_stage1_src_compile
1862     cvs_stage1_src_install
1863    
1864    
1865     ####################################
1866     # toolchain - stage1: perl minimal #
1867     ####################################
1868     # perl is needed by the final glibc
1869     perl_minimal_stage1_src_prepare
1870     perl_minimal_stage1_src_compile
1871     perl_minimal_stage1_src_install
1872    
1873    
1874     ##########################
1875     # toolchain - stage1: m4 #
1876     ##########################
1877     # m4 is needed by the final binutils
1878     m4_stage1_src_prepare
1879     m4_stage1_src_compile
1880     m4_stage1_src_install
1881    
1882    
1883     #############################
1884     # toolchain - stage1: bison #
1885     #############################
1886     # bison is needed by the final binutils
1887     bison_stage1_src_prepare
1888     bison_stage1_src_compile
1889     bison_stage1_src_install
1890    
1891    
1892     ############################
1893     # toolchain - stage1: flex #
1894     ############################
1895     # flex is needed by the final binutils
1896     flex_stage1_src_prepare
1897     flex_stage1_src_compile
1898     flex_stage1_src_install
1899    
1900    
1901     ########################################
1902     # basesystem - stage2: base filesystem #
1903     ########################################
1904     filesystem_stage2_src_prepare
1905     filesystem_stage2_src_install
1906    
1907    
1908     #############################
1909     # basesystem - stage2: mage #
1910     #############################
1911     mage_stage2_src_install
1912    
1913    
1914     ######################################
1915     # basesystem - stage2: linux-headers #
1916     ######################################
1917     # linux_headers_stage2_src_prepare
1918     # linux_headers_stage2_src_compile
1919     linux_headers_stage2_src_install
1920    
1921    
1922     ##############################
1923     # basesystem - stage2: glibc #
1924     ##############################
1925     #glibc_stage2_src_prepare
1926     #glibc_stage2_src_compile
1927     glibc_stage2_src_install
1928    
1929     ################################################
1930     # basesystem - stage2: adjusting the toolchain #
1931     ################################################
1932     stage2_adjusting_toolchain
1933    
1934    
1935     #################################
1936     # basesystem - stage2: binutils #
1937     #################################
1938     #binutils_stage2_src_prepare
1939     #binutils_stage2_src_compile
1940     binutils_stage2_src_install
1941    
1942    
1943     ############################
1944     # basesystem - stage2: gcc #
1945     ############################
1946     #gcc_stage2_src_prepare
1947     #gcc_stage2_src_compile
1948     gcc_stage2_src_install
1949    
1950     # cleanup
1951     # buildroot_clean
1952     }
1953    
1954     buildroot_src_install()
1955     {
1956     # remove unneeded man and info pages to save some space
1957     local dir
1958     for dir in info man
1959     do
1960     [ -d ${BINDIR}/${dir} ] && { rm -rf ${BINDIR}/${dir} || die; }
1961     done
1962    
1963     # remove ${TARGET_DEST} fake root symlink
1964     [[ -L ${TARGET_DEST} ]] && { rm ${TARGET_DEST} || die; }
1965     [[ -L ${CROSS_DEST} ]] && { rm ${CROSS_DEST} || die; }
1966    
1967     # # setup environment
1968     # install -d ${BINDIR}/etc/env.d || die
1969     #
1970     # echo "PATH=${TARGET_DEST}/bin" > ${BINDIR}/etc/env.d/99cross-${TARGET_ARCH} || die
1971     # echo "ROOTPATH=${TARGET_DEST}/bin" >> ${BINDIR}/etc/env.d/99cross-${TARGET_ARCH} || die
1972     # echo "LDPATH=${TARGET_DEST}/lib" >> ${BINDIR}/etc/env.d/99cross-${TARGET_ARCH} || die
1973    
1974     # # enter buildroot script
1975     #chroot /var/tmp/magebuild/builded /buildroot-tools/bin/env -i HOME=/root TERM="${TERM}" PS1='\u:\w\$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin:/buildroot-tools/bin /buildroot-tools/bin/bash --login +h
1976    
1977     echo "Building of ${PNAME}-toolchain finished ..."
1978     }
1979    
1980     export_inherits buildroot src_prepare src_compile src_install