Last active
August 29, 2015 14:21
-
-
Save lantins/e387dfb526f97f8804f7 to your computer and use it in GitHub Desktop.
_failing_ attempt at ECLFS with glibc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then | |
logFatal 'You _must_ `source env-setup.sh` this file, not execute it.' | |
fi | |
# --- Directories and paths ---------------------------------------------------- | |
export TITCHY=/opt/titchy | |
export PATH=${TITCHY}/toolchain/bin:/bin:/usr/bin | |
# --- Compiler settings -------------------------------------------------------- | |
# unset any flags that may be hanging around | |
export -n CFLAGS CC CXX AR AS LD RANLIB READELF STRIP | |
# host is the machine our cross-compile toolchain must execute on | |
export TITCHY_HOST=$(echo ${MACHTYPE} | sed "s/-[^-]*/-cross/") | |
# configure target and arch settings | |
export TITCHY_TARGET="arm-linux-gnueabihf" | |
export TITCHY_ARCH="arm" | |
export TITCHY_ARM_ARCH="armv7-a" | |
export TITCHY_FLOAT="hard" | |
export TITCHY_FPU="vfpv3" | |
# posix language handling | |
export LC_ALL=POSIX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Cut down build script with all my other cruft removed. | |
mkdir -pv ${TITCHY}/tmp | |
mkdir -pv ${TITCHY}/toolchain/${TITCHY_TARGET} | |
ln -sfv . ${TITCHY}/toolchain/${TITCHY_TARGET}/usr | |
# --- LINUX HEADERS | |
VERSION=4.0.3 | |
cd $TITCHY/tmp | |
rm -rf linux-$VERSION | |
tar xf $TITCHY/src/linux-$VERSION.tar.?z | |
cd linux-$VERSION | |
make mrproper | |
make ARCH=${TITCHY_ARCH} headers_check | |
make ARCH=${TITCHY_ARCH} INSTALL_HDR_PATH=${TITCHY}/toolchain/${TITCHY_TARGET} headers_install | |
cd $TITCHY/tmp | |
rm -rf linux-4.0.3 | |
# --- BINUTILS | |
VERSION=2.25 | |
cd $TITCHY/tmp | |
rm -rf binutils-$VERSION binutils-build | |
tar xf $TITCHY/src/binutils-$VERSION.tar.bz2 | |
mkdir -v binutils-build | |
cd binutils-build | |
AR=ar AS=as ../binutils-$VERSION/configure \ | |
--prefix=${TITCHY}/toolchain \ | |
--host=${TITCHY_HOST} \ | |
--target=${TITCHY_TARGET} \ | |
--with-sysroot=${TITCHY}/toolchain/${TITCHY_TARGET} \ | |
--with-lib-path=${TITCHY}/toolchain/${TITCHY_TARGET}/lib \ | |
--disable-nls \ | |
--disable-multilib | |
make configure-host | |
make -j6 | |
make install | |
cd $TITCHY/tmp | |
rm -rf binutils-$VERSION binutils-build | |
# --- GCC - INITIAL PASS | |
VERSION=5.1.0 | |
cd $TITCHY/tmp | |
rm -rf gcc-$VERSION gcc-build-static | |
mkdir -v gcc-build-static | |
tar xf $TITCHY/src/gcc-$VERSION.tar.bz2 | |
cd gcc-$VERSION | |
tar xf $TITCHY/src/mpfr-3.1.2.tar.xz | |
mv -v mpfr-3.1.2 mpfr | |
tar xf $TITCHY/src/gmp-6.0.0a.tar.bz2 | |
mv -v gmp-6.0.0 gmp | |
tar xf $TITCHY/src/mpc-1.0.3.tar.gz | |
mv -v mpc-1.0.3 mpc | |
cd ../gcc-build-static | |
../gcc-$VERSION/configure \ | |
--prefix=${TITCHY}/toolchain \ | |
--build=${TITCHY_HOST} \ | |
--host=${TITCHY_HOST} \ | |
--target=${TITCHY_TARGET} \ | |
--with-sysroot=${TITCHY}/toolchain/${TITCHY_TARGET} \ | |
--with-native-system-header-dir=${TITCHY}/toolchain/${TITCHY_TARGET}/include \ | |
--with-glibc-version=2.21 \ | |
--with-newlib \ | |
--without-headers \ | |
--disable-nls \ | |
--disable-shared \ | |
--disable-multilib \ | |
--disable-decimal-float \ | |
--disable-threads \ | |
--disable-libgomp \ | |
--disable-libssp \ | |
--disable-libatomic \ | |
--disable-libquadmath \ | |
--disable-libsanitizer \ | |
--disable-libssp \ | |
--disable-libvtv \ | |
--disable-libcilkrts \ | |
--disable-libstdc++-v3 \ | |
--enable-languages=c,c++ \ | |
--with-mpfr-include=$(pwd)/../gcc-$VERSION/mpfr/src \ | |
--with-mpfr-lib=$(pwd)/mpfr/src/.libs \ | |
--with-arch=${TITCHY_ARM_ARCH} \ | |
--with-float=${TITCHY_FLOAT} \ | |
--with-fpu=${TITCHY_FPU} | |
make configure-host | |
make -j6 | |
make install | |
cd $TITCHY/tmp | |
rm -rf gcc-$VERSION gcc-build-static | |
# --- GLIBC | |
VERSION=2.21 | |
cd $TITCHY/tmp | |
rm -rf glibc-$VERSION glibc-build | |
mkdir -v glibc-build | |
tar xf $TITCHY/src/glibc-$VERSION.tar.xz | |
cd glibc-build | |
BUILD_CC=gcc CC=${TITCHY_TARGET}-gcc AR=${TITCHY_TARGET}-ar RANLIB=${TITCHY_TARGET}-ranlib ../glibc-$VERSION/configure \ | |
--prefix=/usr \ | |
--host=${TITCHY_TARGET} \ | |
--build=${TITCHY_HOST} \ | |
--disable-profile \ | |
--with-binutils=${TITCHY}/toolchain/${TITCHY_TARGET}/bin \ | |
--with-headers=${TITCHY}/toolchain/${TITCHY_TARGET}/include \ | |
--enable-kernel=4.0.3 \ | |
libc_cv_forced_unwind=yes \ | |
libc_cv_ctors_header=yes \ | |
libc_cv_c_cleanup=yes | |
make | |
make install install_root=${TITCHY}/toolchain/${TITCHY_TARGET} | |
cd $TITCHY/tmp | |
rm -rf glibc-$VERSION glibc-build | |
# --- GCC - FINAL PASS | |
VERSION=5.1.0 | |
cd $TITCHY/tmp | |
rm -rf gcc-$VERSION gcc-build-final | |
mkdir -v gcc-build-final | |
tar xf $TITCHY/src/gcc-$VERSION.tar.bz2 | |
cd gcc-$VERSION | |
tar xf $TITCHY/src/mpfr-3.1.2.tar.xz | |
mv -v mpfr-3.1.2 mpfr | |
tar xf $TITCHY/src/gmp-6.0.0a.tar.bz2 | |
mv -v gmp-6.0.0 gmp | |
tar xf $TITCHY/src/mpc-1.0.3.tar.gz | |
mv -v mpc-1.0.3 mpc | |
cd ../gcc-build-final | |
../gcc-$VERSION/configure \ | |
--prefix=${TITCHY}/toolchain \ | |
--build=${TITCHY_HOST} \ | |
--host=${TITCHY_HOST} \ | |
--target=${TITCHY_TARGET} \ | |
--with-sysroot=${TITCHY}/toolchain/${TITCHY_TARGET} \ | |
--with-glibc-version=2.21 \ | |
--disable-nls \ | |
--disable-multilib \ | |
--disable-libstdcxx-pch \ | |
--disable-libsanitizer \ | |
--enable-languages=c,c++ \ | |
--enable-c99 \ | |
--enable-long-long \ | |
--enable-__cxa_atexit \ | |
--with-mpfr-include=$(pwd)/../gcc-$VERSION/mpfr/src \ | |
--with-mpfr-lib=$(pwd)/mpfr/src/.libs \ | |
--with-arch=${TITCHY_ARM_ARCH} \ | |
--with-float=${TITCHY_FLOAT} \ | |
--with-fpu=${TITCHY_FPU} | |
make -j6 | |
make install | |
cd $TITCHY/tmp | |
rm -rf gcc-$VERSION gcc-build-final | |
# --- SETUP BASE | |
mkdir -pv ${TITCHY}/system/{bin,boot,dev,etc,home,lib/{firmware,modules}} | |
mkdir -pv ${TITCHY}/system/{mnt,opt,proc,sbin,srv,sys} | |
mkdir -pv ${TITCHY}/system/var/{cache,lib,local,lock,log,opt,run,spool} | |
mkdir -pv ${TITCHY}/system/usr/{,local/}{bin,include,lib,sbin,share,src} | |
install -dv -m 0750 ${TITCHY}/system/root | |
install -dv -m 1777 ${TITCHY}/system/tmp | |
ln -svf ../proc/mounts ${TITCHY}/system/etc/mtab | |
cat > ${TITCHY}/system/etc/passwd << "EOF" | |
root::0:0:root:/root:/bin/ash | |
bin:x:1:1:bin:/bin:/bin/false | |
EOF | |
cat > ${TITCHY}/system/etc/group << "EOF" | |
root:x:0: | |
bin:x:1: | |
sys:x:2: | |
kmem:x:3: | |
tty:x:4: | |
tape:x:5: | |
daemon:x:6: | |
floppy:x:7: | |
disk:x:8: | |
lp:x:9: | |
dialout:x:10: | |
audio:x:11: | |
video:x:12: | |
utmp:x:13: | |
usb:x:14: | |
cdrom:x:15: | |
EOF | |
touch ${TITCHY}/system/var/run/utmp ${TITCHY}/system/var/log/{btmp,lastlog,wtmp} | |
chmod -v 664 ${TITCHY}/system/var/run/utmp ${TITCHY}/system/var/log/lastlog | |
# --- BUSYBOX | |
VERSION=1.23.2 | |
cd $TITCHY/tmp | |
rm -rf busybox-$VERSION | |
tar xf $TITCHY/src/busybox-$VERSION.tar.bz2 | |
cd busybox-$VERSION | |
make distclean | |
ARCH="${TITCHY_ARCH}" make defconfig | |
# disable building both ifplugd and inetd | |
sed -i 's/\(CONFIG_\)\(.*\)\(INETD\)\(.*\)=y/# \1\2\3\4 is not set/g' .config | |
sed -i 's/\(CONFIG_IFPLUGD\)=y/# \1 is not set/' .config | |
ARCH="${TITCHY_ARCH}" CROSS_COMPILE="${TITCHY_TARGET}-" make | |
ARCH="${TITCHY_ARCH}" CROSS_COMPILE="${TITCHY_TARGET}-" make CONFIG_PREFIX="${TITCHY}/system" install | |
cd $TITCHY/tmp | |
rm -rf busybox-$VERSION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment