-#!/bin/sh
+#!/bin/bash
+set -o errexit
source ~/.bashrc
source ../functions
source ../packages-list
-export LFS_PKG_DIR="$(dirname $(dirname $(pwd)))/packages/stage1"
+export LFS_PKG_DIR="$(dirname $(pwd))/packages/stage1"
export LFS_LOG_DIR=${LFS}/var/log/hvlinux-install/stage1
export LFS_LOG_FILE=${LFS_LOG_DIR}/install.log
export LFS_TMP="${LFS}/tmp"
init_log_file
-export CFLAGS="-pipe -march=${MACHINE_ARCHITECTURE} -O2"
-export CXXFLAGS=${CFLAGS}
-
-ipkg_ac ${GMP} "--enable-cxx --enable-mpbsd ABI=32"
-ipkg_ac ${MPFR} "--enable-shared"
-
-ipkg_mult ${BINUTILS} cis-binutils-pass1 "${BINUTILS}-pass1"
-ipkg_mult ${GCC_CORE} cis-gcc-pass1 "${GCC_CORE}-pass1"
-ipkg ${KERNEL} cis-linux-api-headers
-ipkg ${GLIBC} cis-glibc
-run_script_log "Toolchain-adjust-stage1" cis-toolchain-adjust
-ipkg_mult ${GCC_CORE} cis-gcc-pass2 "${GCC_CORE}-pass2"
-ipkg_mult ${BINUTILS} cis-binutils-pass2 "${BINUTILS}-pass2"
-ipkg_ac ${NCURSES} "--with-shared --without-debug --without-ada --enable-overwrite"
-ipkg ${BASH} cis-bash
-ipkg ${BZIP2} cis-bzip2
-ipkg_ac ${COREUTILS}
-ipkg_ac ${DIFFUTILS}
-ipkg_ac ${FINDUTILS}
-ipkg_ac ${GAWK}
-ipkg ${GETTEXT} cis-gettext
-ipkg_ac ${GREP} "--disable-perl-regexp"
-ipkg_ac ${GZIP}
-ipkg_ac ${MAKE_PACKAGE}
-ipkg_ac ${PATCH_PACKAGE}
-ipkg ${PERL} cis-perl
-ipkg_ac ${SED}
-ipkg_ac ${TAR_PACKAGE}
-ipkg_ac ${TEXINFO}
-ipkg ${UTIL_LINUX} cis-util-linux
-run_script_log "Stripping" cis-stripping
-
-echo "Total build time: $(get_total_build_time ${LFS_LOG_FILE})h"
+# Building temporary system
+export CC="${CLFS_TARGET}-gcc"
+export CXX="${CLFS_TARGET}-g++"
+export AR="${CLFS_TARGET}-ar"
+export AS="${CLFS_TARGET}-as"
+export RANLIB="${CLFS_TARGET}-ranlib"
+export LD="${CLFS_TARGET}-ld"
+export STRIP="${CLFS_TARGET}-strip"
+
+# Scripts directory
+export SCRDIR=$(pwd)
+
+HOST_CC=gcc CPPFLAGS=-fexceptions \
+ ipkg_ac ${GMP} "--enable-cxx"
+ipkg_ac ${MPFR} "--enable-shared"
+ipkg_ac ${MPC}
+ipkg_ac ${PPL} "\
+ --enable-shared \
+ --enable-interfaces=c,cxx \
+ --disable-optimization \
+ --with-libgmp-prefix=/tools \
+ --with-libgmpxx-prefix=/tools"
+ipkg_ac ${CLOOG_PPL} "\
+ --enable-shared \
+ --with-bits=gmp \
+ --with-gmp=/tools \
+ --with-ppl=/tools"
+ipkg_cust ${ZLIB} cis-zlib
+ipkg_ac ${BINUTILS} "\
+ --target=${CLFS_TARGET} \
+ --with-lib-path=/tools/lib \
+ --disable-nls \
+ --enable-shared \
+ --disable-multilib"
+ipkg_cust ${GCC} cis-gcc
+ipkg_ac ${NCURSES} "\
+ --with-shared \
+ --without-debug \
+ --without-ada \
+ --enable-overwrite \
+ --with-build-cc=gcc"
+ipkg_ac ${BASH} "--without-bash-malloc"
+ipkg_ac ${BISON}
+ipkg_cust ${BZIP2} cis-bzip2
+ipkg_ac ${COREUTILS} "--enable-install-program=hostname"
+ipkg_ac ${DIFFUTILS}
+ipkg_ac ${FINDUTILS}
+ipkg_ac ${FILE_PKG}
+ipkg_ac ${FLEX}
+ipkg_ac ${GAWK}
+ipkg_cust ${GETTEXT} cis-gettext
+ipkg_ac ${GREP} "\
+ --disable-perl-regexp \
+ --without-included-regex"
+ipkg_ac ${GZIP}
+ipkg_ac ${MFOUR}
+ipkg_ac ${MAKE_PACKAGE}
+ipkg_ac ${PATCH_PACKAGE}
+ipkg_ac ${SED}
+ipkg_ac ${TAR_PACKAGE}
+ipkg_ac ${TEXINFO}
+ipkg_ac ${XZ_UTILS}
+
+# Chapter 7
+rscr once "Creating directory structure" create-directories
+rscr once "Creating symbolic links" create-symlinks
+
+ipkg_ac ${NANO} "--enable-color --enable-multibuffer"
+ipkg_cust ${UTIL_LINUX_NG} cis-util-linux-ng
+ipkg_cust ${E2FSPROGS} cis-e2fsprogs
+ipkg_cust ${SYSVINIT} cis-sysvinit
+ipkg_cust ${MODULE_INIT_TOOLS} cis-module-init-tools
+ipkg_cust ${UDEV} cis-udev
+
+rscr once "Creating default users" create-users
+rscr once "Creating default groups" create-groups
+rscr once "Creating default log files" create-logfiles
+rscr once "Installing kernel sources" install-linux-minimal
+rscr once "Creating default config files" create-config-files
+rscr once "Installing bootscripts" cis-bootscripts
exit $?