#!/bin/sh -e # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # mkchain # controls build of the tool chain system # part of the gn*nix conspiracy http://gnnix.org # Copyright (C) Linus Sphinx 2004 # # last mod: 1/17/04 12:13 # execute only in $GNNIX directory # . tool/gnxenv LC_ALL=POSIX export LC_ALL unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD umask 022 set +h if [ "$ROOT" = "" ]; then exit 1 fi DIST=${ROOT}/dist PREFIX=/tool PATH=/tool/bin:/tool/sbin:$PATH export PATH PREFIX echo $PATH > /tmp/path #------------------------------------------- KH=linux-libc-headers-2.6.5.1 BINUTILS=binutils-2.15.90.0.3 GCCTOOLS=gcc-3.4.0 GLIBZ=glibc-2.3.4-20040408 #GLIBZTHREADS=glibc-linuxthreads-2.3.2 TCL=tcl8.4.6 XPECT=expect-5.41 DEJA=dejagnu-1.4.4 GAWK=gawk-3.1.3 COREUT=coreutils-5.0 BZIP2=bzip2-1.0.2 GZIP=gzip-1.2.4a DIFF=diffutils-2.8.1 FIND=findutils-4.1.20 MAKE=make-3.80 GREP=grep-2.5 GETXT=gettext-0.13 SED=sed-4.0.9 NCURS=ncurses-5.4 PATC=patch-2.5.4 TAR=tar-1.14 TEX=texinfo-4.7 BASH=bash-2.05b UTIL=util-linux-2.12a PERLVER=5.8.4 PERL=perl-${PERLVER} FLEX=flex-2.5.31 MFOUR=m4-1.4 BISON=bison-1.875a UDEV=udev-025 #------------------------------------------- gnxfinish() { touch ${DIST}/var/gnx/${1}.done sleep 10 } gnxcheck() { if [ -f ${DIST}/var/gnx/${1}.done ]; then echo Skipping $1 false else true fi } gnxunwrap() { cd ${DIST}/usr/src if [ -d ${1} ]; then rm -rf ${1} fi cd ${ROOT} echo "unwrapping ${1}.tar.bz2" #${GNNIX}/tool/unwrap ${1} if [ -f $ROOT/parts/src/${1}.tar.gz ]; then gzip -d $ROOT/parts/src/${1}.tar.gz bzip2 -9 $ROOT/parts/src/$1.tar fi tar xfj $ROOT/parts/src/${1}.tar.bz2 -C $DIST/usr/src/ if [ "$?" != "0" ]; then echo unwrap $1 echo returned non zero exit 1 fi if [ -d ${DIST}/usr/src/${1} ]; then cd ${DIST}/usr/src/${1} fi } gnxconfigure() { ./configure $@ if [ "$?" != "0" ]; then echo configure $@ echo returned non zero exit 1 fi } gnxpatch() { for i in $@ do echo -n "patching with ${i} " patch -Np1 -i ${PATCH}/${i} done } gnxmake() { make $@ if [ "$?" != "0" ]; then echo make $@ echo returned non zero exit 1 fi } gnxsimple() { gnxunwrap ${1} gnxconfigure --prefix=${PREFIX} gnxmake if [ "${2}" == "check" ]; then gnxmake check fi gnxmake install gnxfinish ${1} } #------------------------------------------- gnxbinutils() { cd $DIST/usr/src rm -rf binutils mkdir -p binutils gnxunwrap $BINUTILS cd $DIST/usr/src/binutils ../$BINUTILS/configure --prefix=$PREFIX --disable-nls gnxmake configure-host gnxmake LDFLAGS="-all-static" gnxmake install gnxmake -C ld clean gnxmake -C ld LDFLAGS="-all-static" LIB_PATH=$PREFIX/lib gnxfinish $BINUTILS } gnxbinutilspasstwo() { cd $DIST/usr/src rm -rf binutils mkdir -p binutils cd $DIST/usr/src/binutils ../${BINUTILS}/configure --prefix=${PREFIX} --enable-shared --with-lib-path=${PREFIX}/lib gnxmake #gnxmake check gnxmake install gnxmake -C ld clean gnxmake -C ld LIB_PATH=/usr/lib:/lib gnxfinish $BINUTILS.passtwo } gnxgcc() { cd $DIST/usr/src rm -rf gcc mkdir -p gcc cd $ROOT gnxunwrap $GCCTOOLS cd $DIST/usr/src/gcc ../$GCCTOOLS/configure --prefix=${PREFIX} --libexecdir=${PREFIX}/lib --with-local-prefix=${PREFIX} \ --disable-nls --enable-shared --enable-languages=c gnxmake clean gnxmake BOOT_LDFLAGS="-static" bootstrap gnxmake install cd ${PREFIX}/bin ln -sf ${PREFIX}/bin/gcc cc gnxfinish $GCCTOOLS } gnxkernelheaders() { gnxunwrap $KH cp -R include/* ${PREFIX}/include/ cd ${PREFIX}/include touch linux/autoconf.h ln -sf asm-i386 asm rm -rf asm-s390 asm-s390x asm-sparc64 asm-arm gnxfinish kernelheaders } gnxglibc() { cd $DIST/usr/src rm -rf $GLIBZ rm -rf glibc mkdir -p glibc cd $ROOT gnxunwrap $GLIBZ #gnxunwrap $GLIBZTHREADS #mv $DIST/usr/src/linuxthreads* $DIST/usr/src/$GLIBZ cd $DIST/usr/src/$GLIBZ #patch -Np1 -i $PATCH/glibc-2.3.4nptltestx7.patch cd $DIST/usr/src/glibc ../${GLIBZ}/configure --prefix=${PREFIX} \ --disable-profile --enable-add-ons=nptl --with-tls \ --with-headers=${PREFIX}/include \ --with-binutils=${PREFIX}/bin \ --without-gd --without-cvs gnxmake clean gnxmake gnxmake check mkdir -p ${PREFIX}/etc touch ${PREFIX}/etc/ld.so.conf gnxmake install gnxmake localedata/install-locales # lock it in cd $DIST/usr/src/binutils gnxmake -C ld install SPECS=${PREFIX}/lib/gcc/*/*/specs sed -e 's@ /lib/ld-linux.so.2@ /tool/lib/ld-linux.so.2@g' $SPECS > /tmp/tempspec cd /tmp cp -f tempspec $SPECS mkdir -p /etc touch /etc/ld.so.conf echo 'main(){ puts("duh"); }' > duh.c $PREFIX/bin/gcc duh.c $PREFIX/bin/readelf -l a.out | grep tool if [ "$?" != "0" ]; then echo $GLIBZ readelf cant find its tool echo readelf grep tool returned non zero exit 1 fi rm duh.c a.out gnxfinish $GLIBZ } gnxtcl() { gnxunwrap $TCL-src cd $DIST/usr/src/$TCL/unix gnxconfigure --prefix=${PREFIX} gnxmake rm $DIST/usr/src/$TCL/tests/{http*,socket*,io*} gnxmake test gnxmake install cd ${PREFIX}/bin ln -s tclsh8.4 tclsh gnxfinish $TCL } gnxexpect() { gnxunwrap $XPECT gnxpatch expect-5.39.0-spawn.patch gnxconfigure --prefix=${PREFIX} --with-tcl=${PREFIX}/lib --with-x=no gnxmake gnxmake tests gnxmake SCRIPTS="" install gnxfinish $XPECT } gnxdeja() { gnxunwrap $DEJA gnxconfigure --prefix=${PREFIX} gnxmake install gnxfinish $DEJA } gnxgccpasstwo() { gnxunwrap $GCCTOOLS cd $DIST/usr/src/ rm -rf gcc mkdir -p gcc cd $DIST/usr/src/$GCCTOOLS echo protector dude tar jxf $DIST/parts/src/protector-3.4-1.tar.bz2 # uncomment protectonly to enable protector by default #patch -p0 < protectonly.dif patch -p0 < protector.dif echo fixincludes dude gnxpatch gcc-3.4.0-no-fixincludes-1.patch echo specs dude gnxpatch gcc-3.4.0-specs-1.patch # echo posix dude # gnxpatch gcc-3.4.0-posix-1.patch cd $DIST/usr/src/gcc ../$GCCTOOLS/configure --prefix=${PREFIX} \ --with-local-prefix=${PREFIX} --libexecdir=${PREFIX}/lib \ --enable-clocale=gnu --enable-shared \ --enable-threads=posix --enable-__cxa_atexit \ --enable-languages=c,c++ gnxmake clean gnxmake gnxmake install gnxfinish $GCCTOOLS.passtwo } gnxcoreut() { gnxunwrap $COREUT DEFAULT_POSIX2_VERSION=199209 ./configure --prefix=/tool gnxmake gnxmake RUN_EXPENSIVE_TESTS=yes check gnxmake install gnxfinish $COREUT } gnxbzip2() { gnxunwrap $BZIP2 gnxmake PREFIX=${PREFIX} install gnxfinish $BZIP2 } gnxgettext() { gnxunwrap $GETXT gnxconfigure --prefix=/tool --disable-libasprintf --disable-csharp gnxmake # gnxmake check 2 test fail no libasprintf gnxmake install gnxfinish $GETXT } gnxncurses() { gnxunwrap $NCURS #gnxpatch ncurses-5.3-vsscanf.patch ncurses-5.3-etip-2.patch gnxconfigure --prefix=${PREFIX} --with-shared --without-debug --without-ada --enable-overwrite gnxmake gnxmake install gnxfinish $NCURS } gnxbash() { gnxunwrap $BASH gnxpatch bash-2.05b-gnu-fixes-2.patch gnxpatch bash-2.05b-gcc34-1.patch gnxconfigure --prefix=${PREFIX} gnxmake gnxmake tests gnxmake install ln -s bash /tool/bin/sh gnxfinish $BASH } gnxutil() { gnxunwrap $UTIL gnxpatch util-linux-2.12a-kernel-headers-1.patch cp configure configure.bak sed "s@/usr/include@/${PREFIX}/include@g" configure.bak > configure gnxconfigure gnxmake -C lib gnxmake -C mount mount umount make -C text-utils more make -C sys-utils arch cp mount/{,u}mount text-utils/more sys-utils/arch ${PREFIX}/bin gnxfinish $UTIL } gnxperl() { gnxunwrap $PERL chmod u+w hints/linux.sh gnxpatch perl-5.8.0-libc-3.patch #echo 'static_ext="IO re Fcntl"' >> hints/linux.sh ./configure.gnu --prefix=${PREFIX} if [ "$?" != "0" ]; then echo $PERL configure.gnu echo returned non zero exit 1 fi gnxmake perl utilities cp perl pod/pod2man ${PREFIX}/bin mkdir -p ${PREFIX}/lib/perl5/${PERLVER} cp -R lib/* ${PREFIX}/lib/perl5/${PERLVER} gnxfinish $PERL } gnxgrep() { gnxunwrap $GREP CC="/tool/bin/gcc" LDFLAGS="-L/tool/lib" CFLAGS="-I/tool/include" export CC LDFLAGS CFLAGS gnxconfigure --prefix=${PREFIX} --disable-perl-regexp --with-included-regex gnxmake clean gnxmake #chmod +x /usr/local/gnnix/base/root/dist/usr/src/grep-2.5/tests/*.sh #gnxmake check gnxmake install gnxfinish $GREP } gnxudev() { gnxunwrap $UDEV sed -i 's:\/sbin\/udev:/tool&:' udevstart.c sed -i 's:\/etc:/tool&:' etc/udev/udev.conf.in make prefix=/tool etcdir=/tool/etc make udevdir=/dev etc/udev/udev.conf make DESTDIR=/tool install gnxfinish $UDEV } gnxstrip() { strip --strip-unneeded ${PREFIX}/{bin,sbin}/* strip --strip-debug ${PREFIX}/lib/* rm -rf ${PREFIX}/share/{doc,info,man,docs} rm -rf ${PREFIX}/{doc,info,man,docs} gnxfinish stripped } #------------------------------------------- # check dir structure if [ ! -d ${DIST} ]; then mkdir ${DIST} echo ${DIST} created fi if [ ! -d $PREFIX ]; then mkdir ${PREFIX} echo ${PREFIX} created fi if [ ! -d ${DIST}/usr ]; then mkdir -p ${DIST}/usr/src echo ${DIST}/usr created fi if [ ! -d ${DIST}/var ]; then mkdir -p ${DIST}/var/gnx echo ${DIST}/var/gnx created fi if [ ! -d ${DIST}/bin ]; then mkdir -p ${DIST}/bin echo ${DIST}/bin created fi if [ ! -d ${DIST}/include ]; then mkdir -p ${DIST}/include echo ${DIST}/include created fi if gnxcheck $BINUTILS; then gnxbinutils fi if gnxcheck $GCCTOOLS; then gnxgcc fi if gnxcheck kernelheaders; then gnxkernelheaders fi if gnxcheck $GLIBZ ; then gnxglibc fi if gnxcheck $TCL ; then gnxtcl fi if gnxcheck $XPECT ; then gnxexpect fi if gnxcheck $DEJA ; then gnxdeja fi if gnxcheck $GCCTOOLS.passtwo ; then gnxgccpasstwo fi if gnxcheck $BINUTILS.passtwo ; then gnxbinutilspasstwo fi if gnxcheck $GAWK ; then gnxsimple $GAWK check fi if gnxcheck $COREUT ; then gnxcoreut fi if gnxcheck $BZIP2 ; then gnxbzip2 fi if gnxcheck $GZIP ; then gnxsimple $GZIP fi if gnxcheck $DIFF ; then gnxsimple $DIFF fi if gnxcheck $FIND ; then gnxsimple $FIND check fi if gnxcheck $MAKE ; then gnxsimple $MAKE check fi if gnxcheck $GREP ; then gnxgrep fi if gnxcheck $SED ; then gnxsimple $SED check fi if gnxcheck $GETXT ; then gnxgettext fi if gnxcheck $NCURS ; then gnxncurses fi if gnxcheck $PATC ; then gnxsimple $PATC fi if gnxcheck $TAR ; then gnxsimple $TAR check fi if gnxcheck $TEX ; then gnxsimple $TEX check fi if gnxcheck $BASH ; then gnxbash fi if gnxcheck $MFOUR ; then gnxsimple $MFOUR fi if gnxcheck $BISON ; then gnxsimple $BISON fi if gnxcheck $FLEX ; then gnxunwrap $FLEX gnxpatch flex-2.5.31-debian-fixes-2.patch touch doc/*.1 gnxconfigure --prefix=${PREFIX} gnxmake gnxmake check gnxmake install gnxfinish $FLEX fi if gnxcheck $UTIL ; then gnxutil fi if gnxcheck $PERL ; then gnxperl fi if gnxcheck $UDEV ; then gnxudev fi #if gnxcheck stripped ; then # gnxstrip #fi #eof