# $Header: /magellan-cvs/smage/include/buildroot2.sminc,v 1.1 2008/10/06 17:55:09 niro Exp $ # Buildroot generic functions sminclude mtools # needed vars: # TARGET_ARCH="i686" # must be set outside : ${CROSS_CHOST="${ARCH}-cross-linux-gnu"} : ${TARGET_CHOST="${TARGET_ARCH}-pc-linux-gnu"} # Destdirs: # the buildroot of the toolchain : ${BUILDROOT_DEST="/opt/buildroot-${TARGET_ARCH}"} # target-tools dest: ${BUILDROOT_DEST}/${TARGET_DEST} : ${TARGET_DEST="/buildroot-tools"} # cross-tools dest: ${BUILDROOT_DEST}/${TARGET_DEST} : ${CROSS_DEST="/cross-tools"} : ${PNAME="buildroot-${TARGET_ARCH}"} : ${PCAT="dev-misc"} : ${DESCRIPTION="A crosscompile toolchain to compile programms for the ${TARGET_ARCH} arch."} : ${HOMEPAGE="http://magellan-linux.de/"} #SDEPEND="${SDEPEND} # == dev-cross/cross-tools-${TARGET_ARCH}-${PVER}" # binutils #BINUTILS_PVER="2.18.50.0.3" : ${BINUTILS_SRCFILE="binutils-${BINUTILS_PVER}.tar.bz2"} : ${BINUTILS_SRCDIR="${BUILDDIR}/binutils-${BINUTILS_PVER}"} # kernel-headers #LINUX_HEADERS_PVER="2.6.24" : ${LINUX_HEADERS_SRCFILE="linux-${LINUX_HEADERS_PVER}.tar.bz2"} : ${LINUX_HEADERS_SRCDIR="${BUILDDIR}/linux-${LINUX_HEADERS_PVER}"} # glibc-headers and libc #GLIBC_PVER="2.7.0" : ${GLIBC_SRCFILE="glibc-${GLIBC_PVER}.tar.bz2"} : ${GLIBC_SRCDIR="${BUILDDIR}/glibc-${GLIBC_PVER}"} # gcc #GCC_PVER="4.2.3" : ${GCC_SRCFILE="gcc-${GCC_PVER}.tar.bz2"} : ${GCC_SRCDIR="${BUILDDIR}/gcc-${GCC_PVER}"} # ncurses # NCURSES_PVER="5.6" : ${NCURSES_SRCFILE="ncurses-${NCURSES_PVER}.tar.gz"} : ${NCURSES_SRCDIR="${BUILDDIR}/ncurses-${NCURSES_PVER}"} # bash # BASH_PVER="3.2" : ${BASH_SRCFILE="bash-${BASH_PVER}.tar.gz"} : ${BASH_SRCDIR="${BUILDDIR}/bash-${BASH_PVER}"} # bzip2 # BZIP2_PVER="1.0.4" : ${BZIP2_SRCFILE="bzip2-${BZIP2_PVER}.tar.gz"} : ${BZIP2_SRCDIR="${BUILDDIR}/bzip2-${BZIP2_PVER}"} # coreutils # COREUTILS_PVER="3.2" : ${COREUTILS_SRCFILE="coreutils-${COREUTILS_PVER}.tar.gz"} : ${COREUTILS_SRCDIR="${BUILDDIR}/coreutils-${COREUTILS_PVER}"} # diffutils # DIFFUTILS_PVER="3.2" : ${DIFFUTILS_SRCFILE="diffutils-${DIFFUTILS_PVER}.tar.gz"} : ${DIFFUTILS_SRCDIR="${BUILDDIR}/diffutils-${DIFFUTILS_PVER}"} # findutils # FINDUTILS_PVER="3.2" : ${FINDUTILS_SRCFILE="findutils-${FINDUTILS_PVER}.tar.gz"} : ${FINDUTILS_SRCDIR="${BUILDDIR}/findutils-${FINDUTILS_PVER}"} # zlib # ZLIB_PVER="3.2" : ${ZLIB_SRCFILE="zlib-${ZLIB_PVER}.tar.gz"} : ${ZLIB_SRCDIR="${BUILDDIR}/zlib-${ZLIB_PVER}"} # file # FILE_PVER="3.2" : ${FILE_SRCFILE="file-${FILE_PVER}.tar.gz"} : ${FILE_SRCDIR="${BUILDDIR}/file-${FILE_PVER}"} # gawk # GAWK_PVER="3.2" : ${GAWK_SRCFILE="gawk-${GAWK_PVER}.tar.gz"} : ${GAWK_SRCDIR="${BUILDDIR}/gawk-${GAWK_PVER}"} # gettext # GETTEXT_PVER="3.2" : ${GETTEXT_SRCFILE="gettext-${GETTEXT_PVER}.tar.gz"} : ${GETTEXT_SRCDIR="${BUILDDIR}/gettext-${GETTEXT_PVER}"} # grep # GREP_PVER="3.2" : ${GREP_SRCFILE="grep-${GREP_PVER}.tar.gz"} : ${GREP_SRCDIR="${BUILDDIR}/grep-${GREP_PVER}"} # gzip # GZIP_PVER="3.2" : ${GZIP_SRCFILE="gzip-${GZIP_PVER}.tar.gz"} : ${GZIP_SRCDIR="${BUILDDIR}/gzip-${GZIP_PVER}"} # make # MAKE_PVER="3.2" : ${MAKE_SRCFILE="make-${MAKE_PVER}.tar.gz"} : ${MAKE_SRCDIR="${BUILDDIR}/make-${MAKE_PVER}"} # patch # PATCH_PVER="3.2" : ${PATCH_SRCFILE="patch-${PATCH_PVER}.tar.gz"} : ${PATCH_SRCDIR="${BUILDDIR}/patch-${PATCH_PVER}"} # sed # SED_PVER="3.2" : ${SED_SRCFILE="sed-${SED_PVER}.tar.gz"} : ${SED_SRCDIR="${BUILDDIR}/sed-${SED_PVER}"} # tar # TAR_PVER="3.2" : ${TAR_SRCFILE="tar-${TAR_PVER}.tar.gz"} : ${TAR_SRCDIR="${BUILDDIR}/tar-${TAR_PVER}"} # texinfo # TEXINFO_PVER="3.2" : ${TEXINFO_SRCFILE="texinfo-${TEXINFO_PVER}.tar.gz"} : ${TEXINFO_SRCDIR="${BUILDDIR}/texinfo-${TEXINFO_PVER}"} # e2fsprogs # E2FSPROGS_PVER="3.2" : ${E2FSPROGS_SRCFILE="e2fsprogs-${E2FSPROGS_PVER}.tar.gz"} : ${E2FSPROGS_SRCDIR="${BUILDDIR}/e2fsprogs-${E2FSPROGS_PVER}"} # util-linux # UTIL_LINUX_PVER="3.2" : ${UTIL_LINUX_SRCFILE="util-linux-ng-${UTIL_LINUX_PVER}.tar.gz"} : ${UTIL_LINUX_SRCDIR="${BUILDDIR}/util-linux-ng-${UTIL_LINUX_PVER}"} # initscripts # INITSCRIPTS_PVER="3.2" : ${INITSCRIPTS_SRCFILE="initscripts-${INITSCRIPTS_PVER}.tar.bz2"} : ${INITSCRIPTS_SRCDIR="${BUILDDIR}/initscripts-${INITSCRIPTS_PVER}"} # wget # WGET_PVER="3.2" : ${WGET_SRCFILE="wget-${WGET_PVER}.tar.gz"} : ${WGET_SRCDIR="${BUILDDIR}/wget-${WGET_PVER}"} # rsync # RSYNC_PVER="3.2" : ${RSYNC_SRCFILE="rsync-${RSYNC_PVER}.tar.gz"} : ${RSYNC_SRCDIR="${BUILDDIR}/rsync-${RSYNC_PVER}"} # cvs # CVS_PVER="3.2" : ${CVS_SRCFILE="cvs-${CVS_PVER}.tar.bz2"} : ${CVS_SRCDIR="${BUILDDIR}/cvs-${CVS_PVER}"} # perl # PERL_PVER="5.10.0" : ${PERL_SRCFILE="perl-${PERL_PVER}.tar.gz"} : ${PERL_SRCDIR="${BUILDDIR}/perl-${PERL_PVER}"} # m4 # M4_PVER="1.4.10" : ${M4_SRCFILE="m4-${M4_PVER}.tar.bz2"} : ${M4_SRCDIR="${BUILDDIR}/m4-${M4_PVER}"} # bison # BISON_PVER="2.3" : ${BISON_SRCFILE="bison-${BISON_PVER}.tar.bz2"} : ${BISON_SRCDIR="${BUILDDIR}/bison-${BISON_PVER}"} # flex # FLEX_PVER="2.5.33" : ${FLEX_SRCFILE="flex-${FLEX_PVER}.tar.bz2"} : ${FLEX_SRCDIR="${BUILDDIR}/flex-${FLEX_PVER}"} # fetch sources SRC_URI=( ${SRC_URI[*]} http://www.kernel.org/pub/linux/devel/binutils/${BINUTILS_SRCFILE} mirror://binutils/${BINUTILS_SRCFILE} http://www.kernel.org/pub/linux/kernel/v${LINUX_HEADERS_PVER:0:3}/${LINUX_HEADERS_SRCFILE} mirror://linux-libc-headers/${LINUX_HEADERS_SRCFILE} gnu://glibc/${GLIBC_SRCFILE} mirror://glibc/${GLIBC_SRCFILE} gnu://gcc/gcc-${GCC_PVER}/${GCC_SRCFILE} mirror://gcc/${GCC_SRCFILE} gnu://ncurses/${NCURSES_SRCFILE} mirror://ncurses/${NCURSES_SRCFILE} gnu://bash/${BASH_SRCFILE} mirror://bash/${BASH_SRCFILE} http://www.bzip.org/${BZIP2_PVER}/${BZIP2_SRCFILE} mirror://bzip2/${BZIP2_SRCFILE} gnu://coreutils/${COREUTILS_SRCFILE} mirror://coreutils/${COREUTILS_SRCFILE} mirror://diffutils/${DIFFUTILS_SRCFILE} gnu://findutils/${FINDUTILS_SRCFILE} mirror://findutils/${FINDUTILS_SRCFILE} http://www.zlib.net/${ZLIB_SRCFILE} mirror://zlib/${ZLIB_SRCFILE} ftp://ftp.astron.com/pub/file/${FILE_SRCFILE} ftp://ftp.gw.com/mirrors/pub/unix/file/${FILE_SRCFILE} mirror://file/${FILE_SRCFILE} gnu://gawk/${GAWK_SRCFILE} mirror://gawk/${GAWK_SRCFILE} gnu://gettext/${GETTEXT_SRCFILE} mirror://gettext/${GETTEXT_SRCFILE} gnu://grep/${GREP_SRCFILE} mirror://grep/${GREP_SRCFILE} gnu://gzip/${GZIP_SRCFILE} mirror://gzip/${GZIP_SRCFILE} gnu://make/${MAKE_SRCFILE} mirror://make/${MAKE_SRCFILE} mirror://patch/${PATCH_SRCFILE} gnu://sed/${SED_SRCFILE} mirror://sed/${SED_SRCFILE} gnu://tar/${TAR_SRCFILE} mirror://tar/${TAR_SRCFILE} gnu://texinfo/${TEXINFO_SRCFILE} mirror://texinfo/${TEXINFO_SRCFILE} sourceforge://e2fsprogs/${E2FSPROGS_SRCFILE} mirror://e2fsprogs/${E2FSPROGS_SRCFILE} http://www.kernel.org/pub/linux/utils/util-linux-ng/v${UTIL_LINUX_PVER/%.?/}/${UTIL_LINUX_SRCFILE} mirror://util-linux-ng/${UTIL_LINUX_SRCFILE} mirror://initscripts/${INITSCRIPTS_SRCFILE} gnu://wget/${WGET_SRCFILE} mirror://wget/${WGET_SRCFILE} http://samba.anu.edu.au/ftp/rsync/${RSYNC_SRCFILE} mirror://rsync/${RSYNC_SRCFILE} gnu://non-gnu/cvs/source/stable/${CVS_PVER}/${CVS_SRCFILE} gnu://non-gnu/cvs/source/nightly-snapshots/stable/${CVS_SRCFILE} mirror://cvs/${CVS_SRCFILE} http://ftp.funet.fi/pub/CPAN/src/${PERL_SRCFILE} mirror://perl/${PERL_SRCFILE} gnu://m4/${M4_SRCFILE} mirror://m4/${M4_SRCFILE} gnu://bison/${BISON_SRCFILE} mirror://bison/${BISON_SRCFILE} mirror://flex/${FLEX_SRCFILE} mirror://glibc/glibc-2.3.5-localedef_segfault-1.patch mirror://glibc/glibc-2.3.5-libgcc_eh-1.patch mirror://gcc/gcc-${GCC_PVER}-no-fixincludes.patch mirror://gcc/gcc-${GCC_PVER}-magellan-version.patch mirror://gcc/gcc-${GCC_PVER}-cross-search-paths.patch mirror://gcc/gcc-${GCC_PVER}-specs.patch mirror://texinfo/texinfo-${TEXINFO_PVER}-mbstate-fix.patch mirror://perl/perl-${PERL_PVER}-hardwired-libc.patch ) # do not get the idea to strip the resulting binaries! # you must have build the strip program on the same arch, # but this is propably not the case. so we force stripping off. NOSTRIP=true activate_ccache() { if [[ ${SMAGE_USE_CCACHE} ]] then export PATH="/opt/cross-tools/bin:/usr/$(mlibdir)/ccache/bin:${PATH}" fi } deactivate_ccache() { # disable any ccache regardless if user-enabled or mage-enabled if [[ ! -z $(echo ${PATH} | grep "/usr/$(mlibdir)/ccache/bin") ]] then export PATH="$(echo ${PATH} | sed s:/usr/$(mlibdir)/ccache/bin::g)" fi } # export2buildroot() # { # local cmd="$@" # # typeset -f die > ${BINDIR}/${BUILDROOT_DEST}/.chrootrc || die # echo "${cmd}" >> ${BINDIR}/${BUILDROOT_DEST}/.chrootrc || die # } chrooted() { local cmd="$@" local mount="false" local sources="false" # very basic getops for i in $* do case $1 in --mount) mount="true"; cmd="${cmd/--mount/}" ;; --sources) sources="true"; cmd="${cmd/--sources/}" ;; --chrootrc) cmd="/bin/bash /.chrootrc"; cmd="${cmd/--chrootrc/}" ;; esac shift done if [[ ${mount} = true ]] then install -d ${BINDIR}/${BUILDROOT_DEST}/{dev,sys,proc} || die mount -t sysfs sysfs ${BINDIR}/${BUILDROOT_DEST}/sys || die mount -t proc proc ${BINDIR}/${BUILDROOT_DEST}/proc || die mount -o bind /dev ${BINDIR}/${BUILDROOT_DEST}/dev || die fi if [[ ${sources} = true ]] then install -d ${BINDIR}/${BUILDROOT_DEST}/${SOURCEDIR} || die mount -o bind ${SOURCEDIR} ${BINDIR}/${BUILDROOT_DEST}/${SOURCEDIR} || die fi chroot ${BINDIR}/${BUILDROOT_DEST} \ ${TARGET_DEST}/bin/env -i \ HOME=/root TERM="${TERM}" \ PS1='\u:\w\$ ' \ PATH=/bin:/usr/bin:/sbin:/usr/sbin:${TARGET_DEST}/bin \ http_proxy="${http_proxy}" \ ftp_proxy="${ftp_proxy}" \ no_proxy="${no_proxy}" \ ${cmd} #|| die "chroot exit code not null." if [[ ${sources} = true ]] then umount ${BINDIR}/${BUILDROOT_DEST}/${SOURCEDIR} || die fi if [[ ${mount} = true ]] then umount ${BINDIR}/${BUILDROOT_DEST}/{dev,proc,sys} || die fi } stage1_configure() { ./configure \ --build=${CROSS_CHOST} \ --host=${TARGET_CHOST} \ --prefix=${TARGET_DEST} \ "$@" \ || die } linux_headers_cross_src_prepare() { munpack ${LINUX_HEADERS_SRCFILE} || die } linux_headers_cross_src_compile() { cd ${LINUX_HEADERS_SRCDIR} make mrproper || die make ARCH=${ARCH/i*86/x86} headers_check || die } linux_headers_cross_src_install() { cd ${LINUX_HEADERS_SRCDIR} make ARCH=${ARCH/i*86/x86} INSTALL_HDR_PATH=${TARGET_DEST} headers_install || die } binutils_cross_src_prepare() { munpack ${BINUTILS_SRCFILE} || die install -d ${BINUTILS_SRCDIR}/build || die } binutils_cross_src_compile() { cd ${BINUTILS_SRCDIR}/build AR=ar AS=as \ ../configure \ --host=${CROSS_CHOST} \ --target=${TARGET_CHOST} \ --prefix=${CROSS_DEST} \ --with-lib-path=${TARGET_DEST}/lib \ --disable-nls \ --enable-shared \ --disable-multilib \ || die make configure-host || die mmake || die } binutils_cross_src_install() { cd ${BINUTILS_SRCDIR}/build make install || die install -d ${TARGET_DEST}/include || die cp ../include/libiberty.h ${TARGET_DEST}/include || die } gcc_static_cross_src_prepare() { munpack ${GCC_SRCFILE} || die cd ${GCC_SRCDIR} mpatch gcc-${GCC_PVER}-no-fixincludes.patch || die mpatch gcc-${GCC_PVER}-magellan-version.patch || die # fixes location of the dynamic linker and not append include # search path to /usr/include # but first set the location to ${TARGET_DEST} and than patch sed "s:/tools/lib/:${TARGET_DEST}/lib/:g" \ ${SOURCEDIR}/${PNAME}/gcc-${GCC_PVER}-specs.patch | patch -Np1 || die # do not search the /usr directory for libgcc_s.so when cross-compiling mpatch gcc-${GCC_PVER}-cross-search-paths.patch || die # suppress installation of libiberty, as we will be # using the one from binutils #sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in || die # fix up the startfile spec to search /opt/cross-tools/lib # fixes errors like this on the final cross-gcc compilation # /opt/cross-tools/i686-cross-linux-gnu/bin/ld: crti.o: No such file: No such file or directory # collect2: ld returned 1 exit status echo " #undef STARTFILE_PREFIX_SPEC #define STARTFILE_PREFIX_SPEC \"${TARGET_DEST}/lib/\"" >> ${GCC_SRCDIR}/gcc/config/linux.h || die # change header search path to look only in $TARGET_DEST/include # and not the hosts own include pathes sed -i "s@\(^CROSS_SYSTEM_HEADER_DIR =\).*@\1 ${TARGET_DEST}/include@g" \ ${GCC_SRCDIR}/gcc/Makefile.in || die install -d ${GCC_SRCDIR}/build || die } gcc_static_cross_src_compile() { cd ${GCC_SRCDIR}/build ../configure \ --host=${CROSS_CHOST} \ --target=${TARGET_CHOST} \ --prefix=${CROSS_DEST} \ --with-local-prefix=${TARGET_DEST} \ --disable-nls \ --disable-shared \ --disable-threads \ --enable-languages=c \ --disable-multilib \ || die mmake all-gcc || die } gcc_static_cross_src_install() { cd ${GCC_SRCDIR}/build make install-gcc || die } glibc_cross_src_prepare() { munpack ${GLIBC_SRCFILE} || die cd ${GLIBC_SRCDIR} # disable binutils -as-needed sed -i 's/^have-as-needed.*/have-as-needed = no/' \ ${GLIBC_SRCDIR}/config.make.in || die # fix segfault of localdef on arches beside x86-32 mpatch glibc-2.3.5-localedef_segfault-1.patch || die # remove dependencies on libgcc_eh mpatch glibc-2.3.5-libgcc_eh-1.patch || die # fix permissions on some of the scripts chmod u+x ${GLIBC_SRCDIR}/scripts/*.sh || die install -d ${GLIBC_SRCDIR}/build || die } glibc_cross_src_compile() { cd ${GLIBC_SRCDIR}/build local my_glibc_CFLAGS local my_glibc_CXXFLAGS # glibc-2.6.1 and above needs march CFLAGS: -march=${ARCH} -mtune=generic [[ ${TARGET_ARCH} = i*86 ]] && my_glibc_CFLAGS="${CFLAGS} -march=${TARGET_ARCH}" # only i*86 my_glibc_CFLAGS="${my_glibc_CFLAGS} -mtune=generic" # all arches # force nptl support (may not detected always) echo "libc_cv_forced_unwind=yes" > config.cache || die echo "libc_cv_c_cleanup=yes" >> config.cache || die BUILD_CC="gcc" \ CC="${TARGET_CHOST}-gcc" \ AR="${TARGET_CHOST}-ar" \ RANLIB="${TARGET_CHOST}-ranlib" \ CFLAGS="${my_glibc_CFLAGS}" \ ../configure \ --host=${TARGET_CHOST} \ --build=${CROSS_CHOST} \ --prefix=${TARGET_DEST} \ --disable-profile \ --enable-add-ons=nptl --with-tls \ --with-__thread \ --enable-kernel=2.6.0 \ --without-cvs \ --with-headers=${TARGET_DEST}/include \ --with-binutils=${CROSS_DEST}/bin \ --cache-file=config.cache \ || die make PARALLELMFLAGS="-j2" || die } glibc_cross_src_install() { cd ${GLIBC_SRCDIR}/build make install || die } gcc_cross_src_prepare() { munpack ${GCC_SRCFILE} || die cd ${GCC_SRCDIR} mpatch gcc-${GCC_PVER}-no-fixincludes.patch || die mpatch gcc-${GCC_PVER}-magellan-version.patch || die # fixes location of the dynamic linker and not append include # search path to /usr/include # but first set the location to ${TARGET_DEST} and than patch sed "s:/tools/lib/:${TARGET_DEST}/lib/:g" \ ${SOURCEDIR}/${PNAME}/gcc-${GCC_PVER}-specs.patch | patch -Np1 || die # do not search the /usr directory for libgcc_s.so when cross-compiling mpatch gcc-${GCC_PVER}-cross-search-paths.patch || die # suppress installation of libiberty, as we will be # using the one from binutils #sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in || die # fix up the startfile spec to search /opt/cross-tools/lib # fixes errors like this on the final cross-gcc compilation # /opt/cross-tools/i686-cross-linux-gnu/bin/ld: crti.o: No such file: No such file or directory # collect2: ld returned 1 exit status echo " #undef STARTFILE_PREFIX_SPEC #define STARTFILE_PREFIX_SPEC \"${TARGET_DEST}/lib/\"" >> ${GCC_SRCDIR}/gcc/config/linux.h || die # change header search path to look only in $TARGET_DEST/include # and not the hosts own include pathes sed -i "s@\(^CROSS_SYSTEM_HEADER_DIR =\).*@\1 ${TARGET_DEST}/include@g" \ ${GCC_SRCDIR}/gcc/Makefile.in || die # disable -B in configure, so it doesn't pick up the host's header files sed -i '/FLAGS_FOR_TARGET.*\/lib\//s@-B[^ ]*/lib/@@g' configure || die install -d ${GCC_SRCDIR}/build || die } gcc_cross_src_compile() { cd ${GCC_SRCDIR}/build ../configure \ --host=${CROSS_CHOST} \ --target=${TARGET_CHOST} \ --prefix=${CROSS_DEST} \ --with-local-prefix=${TARGET_DEST} \ --enable-shared \ --enable-threads=posix \ --enable-__cxa_atexit \ --enable-c99 \ --enable-long-long \ --enable-languages=c,c++ \ --disable-nls \ --disable-multilib \ || die make \ AS_FOR_TARGET="${TARGET_CHOST}-as" \ LD_FOR_TARGET="${TARGET_CHOST}-ld" \ || die } gcc_cross_src_install() { cd ${GCC_SRCDIR}/build make install || die } binutils_stage1_src_prepare() { munpack ${BINUTILS_SRCFILE} || die install -d ${BINUTILS_SRCDIR}/build || die } binutils_stage1_src_compile() { cd ${BINUTILS_SRCDIR}/build ../configure \ --build=${CROSS_CHOST} \ --host=${TARGET_CHOST} \ --target=${TARGET_CHOST} \ --prefix=${TARGET_DEST} \ --with-lib-path=${TARGET_DEST}/lib \ --disable-nls \ --enable-shared \ --enable-64-bit-bfd \ --disable-multilib \ || die make configure-host || die mmake || die } binutils_stage1_src_install() { cd ${BINUTILS_SRCDIR}/build make install || die install -d ${TARGET_DEST}/include || die cp ../include/libiberty.h ${TARGET_DEST}/include || die } gcc_stage1_src_prepare() { munpack ${GCC_SRCFILE} || die cd ${GCC_SRCDIR} mpatch gcc-${GCC_PVER}-no-fixincludes.patch || die mpatch gcc-${GCC_PVER}-magellan-version.patch || die # fixes location of the dynamic linker and not append include # search path to /usr/include # but first set the location to ${TARGET_DEST} and than patch sed "s:/tools/lib/:${TARGET_DEST}/lib/:g" \ ${SOURCEDIR}/${PNAME}/gcc-${GCC_PVER}-specs.patch | patch -Np1 || die # do not search the /usr directory for libgcc_s.so when cross-compiling mpatch gcc-${GCC_PVER}-cross-search-paths.patch || die # suppress installation of libiberty, as we will be # using the one from binutils #sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in || die # don't search headers in /usr/include sed -i '/#define STANDARD_INCLUDE_DIR/s@"/usr/include"@0@g' gcc/cppdefault.c || die # set the directory searched by the fixincludes process for system headers sed -i "s@\(^NATIVE_SYSTEM_HEADER_DIR =\).*@\1 ${TARGET_DEST}/include@g" gcc/Makefile.in || die install -d ${GCC_SRCDIR}/build || die } gcc_stage1_src_compile() { cd ${GCC_SRCDIR}/build ../configure \ --build=${CROSS_CHOST} \ --host=${TARGET_CHOST} \ --target=${TARGET_CHOST} \ --prefix=${TARGET_DEST} \ --with-local-prefix=${TARGET_DEST} \ --disable-nls \ --enable-shared \ --enable-threads=posix \ --enable-__cxa_atexit \ --enable-long-long \ --enable-c99 \ --enable-cstdio=stdio \ --enable-languages=c,c++ \ --disable-libstdcxx-pch \ || die make AS_FOR_TARGET="${AS}" LD_FOR_TARGET="${LD}" || die } gcc_stage1_src_install() { cd ${GCC_SRCDIR}/build make install || die } ncurses_stage1_src_prepare() { munpack ${NCURSES_SRCFILE} || die } ncurses_stage1_src_compile() { cd ${NCURSES_SRCDIR} stage1_configure \ --with-shared \ --without-debug \ --without-ada \ --enable-overwrite \ --with-build-cc=gcc \ || die mmake || die } ncurses_stage1_src_install() { cd ${NCURSES_SRCDIR} mmake install || die } bash_stage1_src_prepare() { munpack ${BASH_SRCFILE} || die } bash_stage1_src_compile() { cd ${BASH_SRCDIR} # while cross-compiling, bash test for the presence of named pipes etc echo "ac_cv_func_mmap_fixed_mapped=yes" > config.cache echo "ac_cv_func_strcoll_works=yes" >> config.cache echo "ac_cv_func_working_mktime=yes" >> config.cache echo "bash_cv_func_sigsetjmp=present" >> config.cache echo "bash_cv_getcwd_malloc=yes" >> config.cache echo "bash_cv_job_control_missing=present" >> config.cache echo "bash_cv_printf_a_format=yes" >> config.cache echo "bash_cv_sys_named_pipes=present" >> config.cache echo "bash_cv_ulimit_maxfds=yes" >> config.cache echo "bash_cv_under_sys_siglist=yes" >> config.cache echo "bash_cv_unusable_rtsigs=no" >> config.cache echo "gt_cv_int_divbyzero_sigfpe=yes" >> config.cache stage1_configure \ --without-bash-malloc \ --cache-file=config.cache \ || die mmake || die } bash_stage1_src_install() { cd ${BASH_SRCDIR} mmake install || die # use bash as default shell ln -snf bash ${TARGET_DEST}/bin/sh || die } bzip2_stage1_src_prepare() { munpack ${BZIP2_SRCFILE} || die cd ${BZIP2_SRCDIR} # disable testsuite; won't work on multi-arch/cross build sed -i 's@^\(all:.*\) test@\1@g' Makefile || die } bzip2_stage1_src_compile() { cd ${BZIP2_SRCDIR} mmake CC="${CC}" AR="${AR}" RANLIB="${RANLIB}" || die } bzip2_stage1_src_install() { cd ${BZIP2_SRCDIR} mmake PREFIX=${TARGET_DEST} install || die } coreutils_stage1_src_prepare() { munpack ${COREUTILS_SRCFILE} || die } coreutils_stage1_src_compile() { cd ${COREUTILS_SRCDIR} # configure can not properly determine how to get free space # and 'df' will not be built #echo "fu_cv_sys_stat_statfs2_bsize=yes" > config.cache # from debian # configure can not properly determine how to get free space # and 'df' will not be built # # fixes include/stdio.h:718: error: conflicting types for 'rpl_fseeko' # see: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=480706 # # coreutils 6.10 needs a patch for the gettime issue # see: http://bugs.gentoo.org/show_bug.cgi?id=207560 # (appling outside) # echo 'gl_cv_func_tzset_clobber=no' > config.cache echo 'jm_cv_func_gettimeofday_clobber=no' >> config.cache echo 'utils_cv_localtime_cache=no' >> config.cache echo 'ac_cv_func_futimesat=yes' >> config.cache echo 'ac_cv_prog_cc_c99=${ac_cv_prog_cc_c99=-std=gnu99}' >> config.cache echo 'ac_cv_prog_cc_stdc=${ac_cv_prog_cc_stdc=-std=gnu99}' >> config.cache echo 'fu_cv_sys_stat_statfs2_bsize=yes' >> config.cache echo 'gl_cv_struct_dirent_d_ino=yes' >> config.cache echo 'ac_cv_func_malloc_0_nonnull=yes' >> config.cache echo 'ac_cv_func_realloc_0_nonnull=yes' >> config.cache echo 'gl_cv_header_working_fcntl_h=yes' >> config.cache echo 'gl_cv_func_gnu_getopt=yes' >> config.cache echo 'ac_cv_func_calloc_0_nonnull=yes' >> config.cache echo 'gl_cv_func_fflush_stdin=yes' >> config.cache echo 'gl_cv_func_wcwidth_works=yes' >> config.cache echo 'ac_cv_func_fnmatch_gnu=yes' >> config.cache echo 'gl_cv_func_getcwd_null=yes' >> config.cache echo 'ac_cv_func_memcmp_working=yes' >> config.cache echo 'gl_cv_func_signbit=yes' >> config.cache echo 'ac_cv_func_lstat_empty_string_bug=no' >> config.cache echo 'gl_cv_func_working_acl_get_file=yes' >> config.cache echo 'gl_cv_func_fchownat_nofollow_works=yes' >> config.cache stage1_configure --cache-file=config.cache || die mmake || die } coreutils_stage1_src_install() { cd ${COREUTILS_SRCDIR} mmake install || die } diffutils_stage1_src_prepare() { munpack ${DIFFUTILS_SRCFILE} || die } diffutils_stage1_src_compile() { cd ${DIFFUTILS_SRCDIR} stage1_configure || die mmake || die } diffutils_stage1_src_install() { cd ${DIFFUTILS_SRCDIR} mmake install || die } findutils_stage1_src_prepare() { munpack ${FINDUTILS_SRCFILE} || die } findutils_stage1_src_compile() { cd ${FINDUTILS_SRCDIR} stage1_configure || die mmake || die } findutils_stage1_src_install() { cd ${FINDUTILS_SRCDIR} mmake install || die } zlib_stage1_src_prepare() { munpack ${ZLIB_SRCFILE} || die } zlib_stage1_src_compile() { cd ${ZLIB_SRCDIR} # zlib uses a non standart configure ./configure --prefix=${TARGET_DEST} --shared || die mmake || die } zlib_stage1_src_install() { cd ${FINDUTILS_SRCDIR} mmake install || die } file_stage1_src_prepare() { munpack ${FILE_SRCFILE} || die } file_stage1_src_compile() { cd ${FILE_SRCDIR} stage1_configure || die mmake || die } file_stage1_src_install() { cd ${FILE_SRCDIR} mmake install || die } gawk_stage1_src_prepare() { munpack ${GAWK_SRCFILE} || die } gawk_stage1_src_compile() { cd ${GAWK_SRCDIR} stage1_configure || die mmake || die } gawk_stage1_src_install() { cd ${GAWK_SRCDIR} mmake install || die } gettext_stage1_src_prepare() { munpack ${GETTEXT_SRCFILE} || die } gettext_stage1_src_compile() { cd ${GETTEXT_SRCDIR}/gettext-tools # fixes compilation; configure assume that wcwidth is broken echo "gl_cv_func_wcwidth_works=yes" > config.cache stage1_configure --disable-shared --cache-file=config.cache || die # only built neccessary stuff mmake -C gnulib-lib || die mmake -C src msgfmt || die } gettext_stage1_src_install() { cd ${GETTEXT_SRCDIR}/gettext-tools # only install neccessary stuff install -m0755 src/msgfmt ${TARGET_DEST}/bin || die } grep_stage1_src_prepare() { munpack ${GREP_SRCFILE} || die } grep_stage1_src_compile() { cd ${GREP_SRCDIR} stage1_configure --disable-perl-regexp || die mmake || die } grep_stage1_src_install() { cd ${GREP_SRCDIR} mmake install || die } gzip_stage1_src_prepare() { munpack ${GZIP_SRCFILE} || die } gzip_stage1_src_compile() { cd ${GZIP_SRCDIR} stage1_configure || die mmake || die } gzip_stage1_src_install() { cd ${GZIP_SRCDIR} mmake install || die } make_stage1_src_prepare() { munpack ${MAKE_SRCFILE} || die } make_stage1_src_compile() { cd ${MAKE_SRCDIR} stage1_configure || die mmake || die } make_stage1_src_install() { cd ${MAKE_SRCDIR} mmake install || die } patch_stage1_src_prepare() { munpack ${PATCH_SRCFILE} || die } patch_stage1_src_compile() { cd ${PATCH_SRCDIR} stage1_configure || die mmake || die } patch_stage1_src_install() { cd ${PATCH_SRCDIR} mmake install || die } sed_stage1_src_prepare() { munpack ${SED_SRCFILE} || die } sed_stage1_src_compile() { cd ${SED_SRCDIR} stage1_configure || die mmake || die } sed_stage1_src_install() { cd ${SED_SRCDIR} mmake install || die } tar_stage1_src_prepare() { munpack ${TAR_SRCFILE} || die } tar_stage1_src_compile() { cd ${TAR_SRCDIR} # fixes compilation; configure assume that wcwidth is broken echo "gl_cv_func_wcwidth_works=yes" > config.cache stage1_configure --cache-file=config.cache || die mmake || die } tar_stage1_src_install() { cd ${TAR_SRCDIR} mmake install || die } texinfo_stage1_src_prepare() { munpack ${TEXINFO_SRCFILE} || die cd ${TEXINFO_SRCDIR} # fixes a build error due to mbstate being undefined mpatch texinfo-${TEXINFO_PVER}-mbstate-fix.patch || die } texinfo_stage1_src_compile() { cd ${TEXINFO_SRCDIR} # forcefully override any activated ccache support, # which may break the built deactivate_ccache # sometimes texinfo includes the termcap.h from host system instead from our buildroot # see http://www.linuxquestions.org/questions/linux-from-scratch-13/compiling-temporary-system-tools-628818/ CPPFLAGS="-I${TARGET_DEST}/include" \ LDFLAGS="-L${TARGET_DEST}/lib" \ stage1_configure || die mmake -C tools/gnulib/lib || die mmake -C tools || die mmake || die # re-activate ccache activate_ccache } texinfo_stage1_src_install() { cd ${TEXINFO_SRCDIR} mmake install || die } e2fsprogs_stage1_src_prepare() { munpack ${E2FSPROGS_SRCFILE} || die install -d ${E2FSPROGS_SRCDIR} || die } e2fsprogs_stage1_src_compile() { cd ${E2FSPROGS_SRCDIR} # lfs method # stage1_configure \ # --with-cc="${CC}" \ # --with-linker="${LD}" \ # --enable-elf-shlibs \ # --disable-evms \ # || die # lfs not working, trying this one: http://www.oesf.org/forum/index.php?showtopic=1370 CC="${TARGET_CHOST}-gcc" \ LINKER="${TARGET_CHOST}-g++" \ COMPILER="${TARGET_CHOST}-gcc" \ stage1_configure --enable-elf-shlibs --disable-evms || die # libs only mmake libs || die } e2fsprogs_stage1_src_install() { cd ${E2FSPROGS_SRCDIR} # install libs only mmake install-libs || die } util_linux_stage1_src_prepare() { munpack ${UTIL_LINUX_SRCFILE} || die } util_linux_stage1_src_compile() { cd ${UTIL_LINUX_SRCDIR} stage1_configure || die # compile only {u,}mount and more mmake -C mount mount umount || die mmake -C text-utils more || die } util_linux_stage1_src_install() { cd ${UTIL_LINUX_SRCDIR} # install only {u,}mount and more install -m0755 mount/{,u}mount text-utils/more ${TARGET_DEST}/bin || die } wget_stage1_src_prepare() { munpack ${WGET_SRCFILE} || die cd ${WGET_SRCDIR} # enable passive mode by default sed -i 's:#passive_ftp = off:passive_ftp = on:g' doc/sample.wgetrc || die } wget_stage1_src_compile() { cd ${WGET_SRCDIR} stage1_configure || die mmake || die } wget_stage1_src_install() { cd ${WGET_SRCDIR} mmake install || die } rsync_stage1_src_prepare() { munpack ${RSYNC_SRCFILE} || die } rsync_stage1_src_compile() { cd ${RSYNC_SRCDIR} stage1_configure --with-rsyncd-conf=/etc/rsyncd.conf --with-included-popt || die mmake || die } rsync_stage1_src_install() { cd ${RSYNC_SRCDIR} mmake install || die } cvs_stage1_src_prepare() { munpack ${CVS_SRCFILE} || die } cvs_stage1_src_compile() { cd ${CVS_SRCDIR} stage1_configure --enable-client --disable-server || die mmake || die } cvs_stage1_src_install() { cd ${CVS_SRCDIR} mmake install || die } perl_minimal_stage1_src_prepare() { munpack ${PERL_SRCFILE} || die cd ${PERL_SRCDIR} mpatch perl-${PERL_PVER}-hardwired-libc.patch || die } perl_minimal_stage1_src_compile() { cd ${PERL_SRCDIR} ./configure.gnu \ --prefix=${TARGET_DEST} \ -Dstatic_ext='Data/Dumper IO Fcntl POSIX' \ -Dcc="${CC}" \ || die mmake perl utilities || die } perl_minimal_stage1_src_install() { cd ${PERL_SRCDIR} install -m0755 perl pod/pod2man ${TARGET_DEST}/bin || die install -d ${TARGET_DEST}/lib/perl${PERL_PVER:0:1}/${PERL_PVER} || die cp -Rv lib/* ${TARGET_DEST}/lib/perl${PERL_PVER:0:1}/${PERL_PVER} || die minstalldir ${BUILDROOT_DEST}/usr/bin || die mlink ${TARGET_DEST}/bin/perl ${BUILDROOT_DEST}/usr/bin || die } m4_stage1_src_prepare() { munpack ${M4_SRCFILE} || die } m4_stage1_src_compile() { cd ${M4_SRCDIR} stage1_configure --enable-changeword || die mmake || die } m4_stage1_src_install() { cd ${M4_SRCDIR} mmake install || die } bison_stage1_src_prepare() { munpack ${BISON_SRCFILE} || die } bison_stage1_src_compile() { cd ${BISON_SRCDIR} stage1_configure || die mmake || die } bison_stage1_src_install() { cd ${BISON_SRCDIR} mmake install || die } flex_stage1_src_prepare() { munpack ${FLEX_SRCFILE} || die } flex_stage1_src_compile() { cd ${FLEX_SRCDIR} stage1_configure || die mmake || die } flex_stage1_src_install() { cd ${FLEX_SRCDIR} mmake install || die } filesystem_stage2_src_prepare() { munpack ${INITSCRIPTS_SRCFILE} || die } filesystem_stage2_src_install() { local magerc="${BINDIR}/${BUILDROOT_DEST}/etc/mage.rc" mkeepdir ${BUILDROOT_DEST}/etc || die install -m0644 /etc/mage.rc ${magerc} || die install -m0644 /etc/resolv.conf ${BINDIR}/${BUILDROOT_DEST}/etc || die sed -i "s:\(ARCH=\).*:\1\"${TARGET_ARCH}\":" ${magerc} || die MAGERC="${magerc}" \ MROOT="${BINDIR}/${BUILDROOT_DEST}" \ mage srcinstall base-files || die # essential symlinks for the toolchain mlink ${TARGET_DEST}/bin/bash ${BUILDROOT_DEST}/bin || die mlink ${TARGET_DEST}/bin/cat ${BUILDROOT_DEST}/bin || die mlink ${TARGET_DEST}/bin/echo ${BUILDROOT_DEST}/bin || die mlink ${TARGET_DEST}/bin/grep ${BUILDROOT_DEST}/bin || die mlink ${TARGET_DEST}/bin/pwd ${BUILDROOT_DEST}/bin || die mlink ${TARGET_DEST}/bin/rm ${BUILDROOT_DEST}/bin || die mlink ${TARGET_DEST}/bin/stty ${BUILDROOT_DEST}/bin || die mlink ${TARGET_DEST}/bin/file ${BUILDROOT_DEST}/usr/bin || die # x86_64 multilib support if [[ ${TARGET_ARCH} = x86_64 ]] then mlink ${TARGET_DEST}/lib/libgcc_s.so ${BUILDROOT_DEST}/usr/lib64 || die mlink ${TARGET_DEST}/lib/libgcc_s.so.1 ${BUILDROOT_DEST}/usr/lib64 || die mlink ${TARGET_DEST}/lib/libstd\* ${BUILDROOT_DEST}/usr/lib || die else mlink ${TARGET_DEST}/lib/libgcc_s.so ${BUILDROOT_DEST}/usr/lib || die mlink ${TARGET_DEST}/lib/libgcc_s.so.1 ${BUILDROOT_DEST}/usr/lib || die mlink ${TARGET_DEST}/lib/libstd\* ${BUILDROOT_DEST}/usr/lib || die fi mlink bash ${BUILDROOT_DEST}/bin/sh || die # basic passwd @ group file install -m0644 ${INITSCRIPTS_SRCDIR}/etc/group ${BINDIR}/${BUILDROOT_DEST}/etc || die install -m0644 ${INITSCRIPTS_SRCDIR}/etc/passwd ${BINDIR}/${BUILDROOT_DEST}/etc || die # essential files for logging memptyfile ${BUILDROOT_DEST}/var/run/utmp || die memptyfile ${BUILDROOT_DEST}/var/log/btmp || die memptyfile ${BUILDROOT_DEST}/var/log/lastlog || die memptyfile ${BUILDROOT_DEST}/var/log/wtmp || die # permissions mchown root:utmp ${BUILDROOT_DEST}/var/run/utmp || die mchown root:utmp ${BUILDROOT_DEST}/var/log/lastlog || die mchmod 0664 ${BUILDROOT_DEST}/var/run/utmp || die mchmod 0664 ${BUILDROOT_DEST}/var/log/lastlog || die mchmod 0600 ${BUILDROOT_DEST}/var/log/btmp || die } mage_stage2_src_install() { MAGERC="${BINDIR}/${BUILDROOT_DEST}/etc/mage.rc" \ MROOT="${BINDIR}/${BUILDROOT_DEST}" \ mage srcinstall mage || die minstalldir ${BUILDROOT_DEST}/${MAGEDIR} || die minstalldir ${BUILDROOT_DEST}/${SMAGESCRIPTSDIR} || die minstalldir ${BUILDROOT_DEST}/${BUILDDIR} || die # link default profile of the host system mlink $(readlink /etc/mage-profile) ${BUILDROOT_DEST}/etc/mage-profile || die chrooted /sbin/mage update chrooted /sbin/smage2 update } # linux_headers_stage2_src_prepare() # { # munpack ${LINUX_HEADERS_SRCFILE} || die # } # # linux_headers_stage2_src_compile() # { # cd ${LINUX_HEADERS_SRCDIR} # make mrproper || die # make ARCH=${ARCH/i*86/x86} headers_check || die # } # # linux_headers_stage2_src_install() # { # cd ${LINUX_HEADERS_SRCDIR} # make ARCH=${ARCH/i*86/x86} INSTALL_HDR_PATH=/usr headers_install || die # } linux_headers_stage2_src_install() { chrooted --mount --sources /sbin/mage srcinstall linux-libc-headers || die } # glibc_stage2_src_prepare() # { # munpack ${GLIBC_SRCFILE} ${BUILDROOT}/${BUILDDIR} || die # cd ${BUILDROOT}/${GLIBC_SRCDIR} # # # disable binutils -as-needed # sed -i 's/^have-as-needed.*/have-as-needed = no/' \ # ${BUILDROOT}/${GLIBC_SRCDIR}/config.make.in || die # # # fix segfault of localdef on arches beside x86-32 # mpatch glibc-2.3.5-localedef_segfault-1.patch || die # # # fix permissions on some of the scripts # chmod u+x ${BUILDROOT}/${GLIBC_SRCDIR}/scripts/*.sh || die # # install -d ${BUILDROOT}/${GLIBC_SRCDIR}/build || die # } # # glibc_stage2_src_compile() # { # cd ${GLIBC_SRCDIR}/build # # local my_glibc_CFLAGS # local my_glibc_CXXFLAGS # # glibc-2.6.1 and above needs march CFLAGS: -march=${ARCH} -mtune=generic # [[ ${TARGET_ARCH} = i*86 ]] && my_glibc_CFLAGS="${CFLAGS} -march=${TARGET_ARCH}" # only i*86 # my_glibc_CFLAGS="${my_glibc_CFLAGS} -mtune=generic" # all arches # # # force nptl support (may not detected always) # echo "libc_cv_forced_unwind=yes" > config.cache || die # echo "libc_cv_c_cleanup=yes" >> config.cache || die # # BUILD_CC="gcc" \ # CC="${TARGET_CHOST}-gcc" \ # AR="${TARGET_CHOST}-ar" \ # RANLIB="${TARGET_CHOST}-ranlib" \ # CFLAGS="${my_glibc_CFLAGS}" \ # ../configure \ # --host=${TARGET_CHOST} \ # --build=${CROSS_CHOST} \ # --prefix=${TARGET_DEST} \ # --disable-profile \ # --enable-add-ons=nptl --with-tls \ # --with-__thread \ # --enable-kernel=2.6.0 \ # --without-cvs \ # --with-headers=${TARGET_DEST}/include \ # --with-binutils=${CROSS_DEST}/bin \ # --cache-file=config.cache \ # || die # # make PARALLELMFLAGS="-j2" || die # } glibc_stage2_src_install() { chrooted --mount --sources NODEPS=true mage srcinstall glibc-nptl || die } stage2_adjusting_toolchain() { local linker local libdir local linker_adjusted linker=$(basename $(chrooted readelf -l ${TARGET_DEST}/bin/ls | grep interpreter | sed 's/.*interpreter: \(.*\)]/\1/')) case ${TARGET_ARCH} in x86_64) libdir=lib64 ;; *) libdir=lib ;; esac chrooted gcc -dumpspecs | \ sed -e "s:${TARGET_DEST}/${libdir}/${linker}:/${libdir}/${linker}:g" \ -e "/\*startfile_prefix_spec:/{n;s@.*@/usr/${libdir}/ @}" \ -e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' \ > ${BINDIR}/${BUILDROOT_DEST}/$(dirname $(chrooted gcc --print-libgcc-file-name))/specs \ || die # test it echo 'main(){}' > ${BINDIR}/${BUILDROOT_DEST}/dummy.c || die chrooted gcc /dummy.c -v -Wl,--verbose &> /dummy.log || die linker_adjusted=$(chrooted readelf -l /a.out | grep interpreter | sed 's/.*interpreter: \(.*\)]/\1/') if [[ ${linker_adjusted} != /${libdir}/${linker} ]] then die "broken toolchain: ${linker_adjusted} != /${libdir}/${linker}" fi } #binutils_stage2_src_prepare() { return 0; } #binutils_stage2_src_compile() { return 0; } binutils_stage2_src_install() { chrooted --mount --sources AR=ar NODEPS=true mage srcinstall binutils || die } #gcc_stage2_src_prepare() { return 0; } #gcc_stage2_src_compile() { return 0; } gcc_stage2_src_install() { # gcc is splitted into two packages: libstc++ and gcc chrooted --mount --sources NODEPS=true mage srcinstall libstdc++ || die chrooted --mount --sources NODEPS=true mage srcinstall gcc || die } buildroot_clean() { # prune packages # chrooted /sbin/mage update || die chrooted /sbin/mage clean || die # prune sources if [[ -d ${BUILDROOT_DEST}/${SOURCEDIR} ]] then rm -rf ${BUILDROOT_DEST}/${SOURCEDIR} || die fi # # prune install db # if [[ -d ${BUILDROOT_DEST}/${INSTALLDB} ]] # then # rm -rf ${BUILDROOT_DEST}/${INSTALLDB} || die # fi } buildroot_src_prepare() { if [[ -e ${TARGET_DEST} ]] || [[ -L ${TARGET_DEST} ]] then echo echo "Please uninstall any buildroot packages first." echo "To build the tools I'll create a fake symlink to ${TARGET_DEST}," echo "so this directory must not exist." echo die "${TARGET_DEST} exists." fi if [[ -e ${CROSS_DEST} ]] || [[ -L ${CROSS_DEST} ]] then echo echo "Please uninstall any buildroot packages first." echo "To build the tools I'll create a fake symlink to ${CROSS_DEST}," echo "so this directory must not exist." echo die "${CROSS_DEST} exists." fi if [[ ${CHOST} = ${TARGET_CHOST} ]] then echo echo "\$CHOST and \$TARGET_CHOST have the same values." echo " CHOST=${CHOST}" echo " TARGET_CHOST=${TARGET_CHOST}" echo echo "You cannot build a buildroot with these settings," echo "please use the native gcc-\${ARCH} builds." echo die "\$CHOST equal \$TARGET_CHOST." fi # create a fake build-root install -d ${BINDIR}${BUILDROOT_DEST}${TARGET_DEST} || die ln -snf ${BINDIR}${BUILDROOT_DEST}${TARGET_DEST} ${TARGET_DEST} || die # create a fake cross-root install -d ${BINDIR}${BUILDROOT_DEST}${CROSS_DEST} || die ln -snf ${BINDIR}${BUILDROOT_DEST}${CROSS_DEST} ${CROSS_DEST} || die } buildroot_src_compile() { # setup a proper build environment export PATH=${CROSS_DEST}/bin:${PATH} # setup cross-compilation tools #################################### # toolchain - cross: linux-headers # #################################### linux_headers_cross_src_prepare linux_headers_cross_src_compile linux_headers_cross_src_install ############################### # toolchain - cross: binutils # ############################### binutils_cross_src_prepare binutils_cross_src_compile binutils_cross_src_install # remove BINUTILS_SRCDIR rm -rf ${BINUTILS_SRCDIR} || die ################################# # toolchain - cross: gcc-static # ################################# gcc_static_cross_src_prepare gcc_static_cross_src_compile gcc_static_cross_src_install # remove GCC_SRCDIR rm -rf ${GCC_SRCDIR} || die ############################ # toolchain - cross: glibc # ############################ glibc_cross_src_prepare glibc_cross_src_compile glibc_cross_src_install ########################## # toolchain - cross: gcc # ########################## gcc_cross_src_prepare gcc_cross_src_compile gcc_cross_src_install # remove GCC_SRCDIR rm -rf ${GCC_SRCDIR} || die # export TOOLCHAIN Variables export CC="${TARGET_CHOST}-gcc" export CXX="${TARGET_CHOST}-g++" export AR="${TARGET_CHOST}-ar" export AS="${TARGET_CHOST}-as" export RANLIB="${TARGET_CHOST}-ranlib" export LD="${TARGET_CHOST}-ld" export STRIP="${TARGET_CHOST}-strip" ################################ # toolchain - stage1: binutils # ################################ binutils_stage1_src_prepare binutils_stage1_src_compile binutils_stage1_src_install ########################### # toolchain - stage1: gcc # ########################### gcc_stage1_src_prepare gcc_stage1_src_compile gcc_stage1_src_install ############################### # toolchain - stage1: ncurses # ############################### ncurses_stage1_src_prepare ncurses_stage1_src_compile ncurses_stage1_src_install ############################ # toolchain - stage1: bash # ############################ bash_stage1_src_prepare bash_stage1_src_compile bash_stage1_src_install ############################# # toolchain - stage1: bzip2 # ############################# bzip2_stage1_src_prepare bzip2_stage1_src_compile bzip2_stage1_src_install ################################# # toolchain - stage1: coreutils # ################################# coreutils_stage1_src_prepare coreutils_stage1_src_compile coreutils_stage1_src_install ################################# # toolchain - stage1: diffutils # ################################# diffutils_stage1_src_prepare diffutils_stage1_src_compile diffutils_stage1_src_install ################################# # toolchain - stage1: findutils # ################################# findutils_stage1_src_prepare findutils_stage1_src_compile findutils_stage1_src_install ############################ # toolchain - stage1: zlib # ############################ zlib_stage1_src_prepare zlib_stage1_src_compile zlib_stage1_src_install ############################ # toolchain - stage1: file # ############################ file_stage1_src_prepare file_stage1_src_compile file_stage1_src_install ############################ # toolchain - stage1: gawk # ############################ gawk_stage1_src_prepare gawk_stage1_src_compile gawk_stage1_src_install ############################### # toolchain - stage1: gettext # ############################### gettext_stage1_src_prepare gettext_stage1_src_compile gettext_stage1_src_install ############################ # toolchain - stage1: grep # ############################ grep_stage1_src_prepare grep_stage1_src_compile grep_stage1_src_install ############################ # toolchain - stage1: gzip # ############################ gzip_stage1_src_prepare gzip_stage1_src_compile gzip_stage1_src_install ############################ # toolchain - stage1: make # ############################ make_stage1_src_prepare make_stage1_src_compile make_stage1_src_install ############################# # toolchain - stage1: patch # ############################# patch_stage1_src_prepare patch_stage1_src_compile patch_stage1_src_install ########################### # toolchain - stage1: sed # ########################### sed_stage1_src_prepare sed_stage1_src_compile sed_stage1_src_install ########################### # toolchain - stage1: tar # ########################### tar_stage1_src_prepare tar_stage1_src_compile tar_stage1_src_install ############################### # toolchain - stage1: texinfo # ############################### texinfo_stage1_src_prepare texinfo_stage1_src_compile texinfo_stage1_src_install ################################# # toolchain - stage1: e2fsprogs # ################################# e2fsprogs_stage1_src_prepare e2fsprogs_stage1_src_compile e2fsprogs_stage1_src_install ################################## # toolchain - stage1: util-linux # ################################## util_linux_stage1_src_prepare util_linux_stage1_src_compile util_linux_stage1_src_install ############################ # toolchain - stage1: wget # ############################ wget_stage1_src_prepare wget_stage1_src_compile wget_stage1_src_install ############################# # toolchain - stage1: rsync # ############################# rsync_stage1_src_prepare rsync_stage1_src_compile rsync_stage1_src_install ########################### # toolchain - stage1: cvs # ########################### cvs_stage1_src_prepare cvs_stage1_src_compile cvs_stage1_src_install #################################### # toolchain - stage1: perl minimal # #################################### # perl is needed by the final glibc perl_minimal_stage1_src_prepare perl_minimal_stage1_src_compile perl_minimal_stage1_src_install ########################## # toolchain - stage1: m4 # ########################## # m4 is needed by the final binutils m4_stage1_src_prepare m4_stage1_src_compile m4_stage1_src_install ############################# # toolchain - stage1: bison # ############################# # bison is needed by the final binutils bison_stage1_src_prepare bison_stage1_src_compile bison_stage1_src_install ############################ # toolchain - stage1: flex # ############################ # flex is needed by the final binutils flex_stage1_src_prepare flex_stage1_src_compile flex_stage1_src_install ######################################## # basesystem - stage2: base filesystem # ######################################## filesystem_stage2_src_prepare filesystem_stage2_src_install ############################# # basesystem - stage2: mage # ############################# mage_stage2_src_install ###################################### # basesystem - stage2: linux-headers # ###################################### # linux_headers_stage2_src_prepare # linux_headers_stage2_src_compile linux_headers_stage2_src_install ############################## # basesystem - stage2: glibc # ############################## #glibc_stage2_src_prepare #glibc_stage2_src_compile glibc_stage2_src_install ################################################ # basesystem - stage2: adjusting the toolchain # ################################################ stage2_adjusting_toolchain ################################# # basesystem - stage2: binutils # ################################# #binutils_stage2_src_prepare #binutils_stage2_src_compile binutils_stage2_src_install ############################ # basesystem - stage2: gcc # ############################ #gcc_stage2_src_prepare #gcc_stage2_src_compile gcc_stage2_src_install # cleanup # buildroot_clean } buildroot_src_install() { # remove unneeded man and info pages to save some space local dir for dir in info man do [ -d ${BINDIR}/${dir} ] && { rm -rf ${BINDIR}/${dir} || die; } done # remove ${TARGET_DEST} fake root symlink [[ -L ${TARGET_DEST} ]] && { rm ${TARGET_DEST} || die; } [[ -L ${CROSS_DEST} ]] && { rm ${CROSS_DEST} || die; } # # setup environment # install -d ${BINDIR}/etc/env.d || die # # echo "PATH=${TARGET_DEST}/bin" > ${BINDIR}/etc/env.d/99cross-${TARGET_ARCH} || die # echo "ROOTPATH=${TARGET_DEST}/bin" >> ${BINDIR}/etc/env.d/99cross-${TARGET_ARCH} || die # echo "LDPATH=${TARGET_DEST}/lib" >> ${BINDIR}/etc/env.d/99cross-${TARGET_ARCH} || die # # enter buildroot script #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 echo "Building of ${PNAME}-toolchain finished ..." } export_inherits buildroot src_prepare src_compile src_install