FAIL="\\033[1;31m"
NORMAL="\\033[0;39m"
-configure_target() {
- local target_arch="${1}"
+configure_build() {
+ local build_arch="${1}"
- if [ "${target_arch}" = "default" ]; then
- target_arch="$(configure_target_guess)"
+ if [ "${build_arch}" = "default" ]; then
+ build_arch="$(configure_build_guess)"
fi
- case "${target_arch}" in
+ case "${build_arch}" in
x86_64)
- BUILDTARGET="${target_arch}-unknown-linux-gnu"
- CROSSTARGET="${target_arch}-cross-linux-gnu"
+ BUILDTARGET="${build_arch}-unknown-linux-gnu"
+ CROSSTARGET="${build_arch}-cross-linux-gnu"
+ BUILD_PLATFORM="x86"
CFLAGS_ARCH="-m64 -mtune=generic"
;;
i586)
- BUILDTARGET="${target_arch}-pc-linux-gnu"
- CROSSTARGET="${target_arch}-cross-linux-gnu"
+ BUILDTARGET="${build_arch}-pc-linux-gnu"
+ CROSSTARGET="${build_arch}-cross-linux-gnu"
+ BUILD_PLATFORM="x86"
CFLAGS_ARCH="-march=i586 -mtune=generic -fomit-frame-pointer"
;;
aarch64)
- BUILDTARGET="${target_arch}-unknown-linux-gnu"
- CROSSTARGET="${target_arch}-cross-linux-gnu"
+ BUILDTARGET="${build_arch}-unknown-linux-gnu"
+ CROSSTARGET="${build_arch}-cross-linux-gnu"
+ BUILD_PLATFORM="arm"
CFLAGS_ARCH=""
;;
armv7hl)
- BUILDTARGET="${target_arch}-unknown-linux-gnueabi"
- CROSSTARGET="${target_arch}-cross-linux-gnueabi"
+ BUILDTARGET="${build_arch}-unknown-linux-gnueabi"
+ CROSSTARGET="${build_arch}-cross-linux-gnueabi"
+ BUILD_PLATFORM="arm"
CFLAGS_ARCH="-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard"
;;
armv5tel)
- BUILDTARGET="${target_arch}-unknown-linux-gnueabi"
- CROSSTARGET="${target_arch}-cross-linux-gnueabi"
+ BUILDTARGET="${build_arch}-unknown-linux-gnueabi"
+ CROSSTARGET="${build_arch}-cross-linux-gnueabi"
+ BUILD_PLATFORM="arm"
CFLAGS_ARCH="-march=armv5te -mfloat-abi=soft -fomit-frame-pointer"
- MACHINE_TYPE="arm"
;;
*)
- exiterror "Cannot build for architure ${target_arch}"
+ exiterror "Cannot build for architure ${build_arch}"
;;
esac
# Check if the QEMU helper is available if needed.
- if qemu_is_required "${target_arch}"; then
- local qemu_target_helper="$(qemu_find_target_helper_name "${target_arch}")"
+ if qemu_is_required "${build_arch}"; then
+ local qemu_build_helper="$(qemu_find_build_helper_name "${build_arch}")"
- if [ -n "${qemu_target_helper}" ]; then
- QEMU_TARGET_HELPER="${qemu_target_helper}"
+ if [ -n "${qemu_build_helper}" ]; then
+ QEMU_TARGET_HELPER="${qemu_build_helper}"
else
- exiterror "Could not find a binfmt_misc helper entry for ${target_arch}"
+ exiterror "Could not find a binfmt_misc helper entry for ${build_arch}"
fi
fi
- TARGET_ARCH="${target_arch}"
-
- # Old variable names
- MACHINE="${TARGET_ARCH}"
+ BUILD_ARCH="${build_arch}"
# Enables hardening
HARDENING_CFLAGS="-Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4"
CXXFLAGS="${CFLAGS}"
}
-configure_target_guess() {
- case "${BUILD_ARCH}" in
+configure_build_guess() {
+ case "${HOST_ARCH}" in
x86_64|i686|i586)
echo "i586"
;;
;;
*)
- exiterror "Cannot guess target architecture"
+ exiterror "Cannot guess build architecture"
;;
esac
}
env="${env} UTS_RELEASE=${KVER}"
# Fake machine version.
- env="${env} UTS_MACHINE=${TARGET_ARCH}"
+ env="${env} UTS_MACHINE=${BUILD_ARCH}"
echo "${env}"
}
fi
# Set default qemu options
- case "${TARGET_ARCH}" in
+ case "${BUILD_ARCH}" in
arm*)
QEMU_CPU="${QEMU_CPU:-cortex-a9}"
}
qemu_is_required() {
- local target_arch="${1}"
+ local build_arch="${1}"
- if [ -z "${target_arch}" ]; then
- target_arch="${TARGET_ARCH}"
+ if [ -z "${build_arch}" ]; then
+ build_arch="${BUILD_ARCH}"
fi
- case "${BUILD_ARCH},${target_arch}" in
+ case "${HOST_ARCH},${build_arch}" in
x86_64,arm*|i?86,arm*|i?86,x86_64)
return 0
;;
exiterror "Could not find a statically-linked QEMU emulator: ${QEMU_TARGET_HELPER}"
}
-qemu_find_target_helper_name() {
- local target_arch="${1}"
+qemu_find_build_helper_name() {
+ local build_arch="${1}"
local magic
- case "${target_arch}" in
+ case "${build_arch}" in
arm*)
magic="7f454c4601010100000000000000000002002800"
;;
KVER=$KVER \
BUILDTARGET="$BUILDTARGET" \
CROSSTARGET="${CROSSTARGET}" \
- MACHINE="$MACHINE" \
- MACHINE_TYPE="$MACHINE_TYPE" \
+ BUILD_ARCH="${BUILD_ARCH}" \
$(fake_environ) \
$(qemu_environ) \
/tools/bin/bash -i
# Check if this package is supported by our architecture.
# If no SUP_ARCH is found, we assume the package can be built for all.
if grep "^SUP_ARCH" ${BASEDIR}/lfs/${1} >/dev/null; then
- # Check if package supports ${MACHINE} or all architectures.
- if ! grep -E "^SUP_ARCH.*${MACHINE}|^SUP_ARCH.*all" ${BASEDIR}/lfs/${1} >/dev/null; then
+ # Check if package supports ${BUILD_ARCH} or all architectures.
+ if ! grep -E "^SUP_ARCH.*${BUILD_ARCH}|^SUP_ARCH.*all" ${BASEDIR}/lfs/${1} >/dev/null; then
beautify result SKIP
return 1
fi
echo -ne "`date -u '+%b %e %T'`: Building $* " >> $LOGFILE
- cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MACHINE=$MACHINE \
- MACHINE_TYPE="$MACHINE_TYPE" \
+ cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR BUILD_ARCH="${BUILD_ARCH}" \
MESSAGE="$1\t " download >> $LOGFILE 2>&1
if [ $? -ne 0 ]; then
exiterror "Download error in $1"
fi
- cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MACHINE=$MACHINE \
- MACHINE_TYPE="$MACHINE_TYPE" \
+ cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR BUILD_ARCH="${BUILD_ARCH}" \
MESSAGE="$1\t md5sum" md5 >> $LOGFILE 2>&1
if [ $? -ne 0 ]; then
exiterror "md5sum error in $1, check file in cache or signature"
local PKG_TIME_START=`date +%s`
- cd $BASEDIR/lfs && \
+ cd $BASEDIR/lfs && env -i \
PATH="/tools/ccache/bin:/tools/bin:$PATH" \
- make -f $* TOOLCHAIN=1 BUILDTARGET=$BUILDTARGET \
- CROSSTARGET="${CROSSTARGET}" \
- MACHINE=$MACHINE \
- MACHINE_TYPE=$MACHINE_TYPE \
- LFS_BASEDIR=$BASEDIR \
- ROOT=$LFS \
- KVER=$KVER \
- MAKETUNING=$MAKETUNING \
- install >> $LOGFILE 2>&1
+ make -f $* \
+ TOOLCHAIN=1 \
+ CROSSTARGET="${CROSSTARGET}" \
+ BUILDTARGET="${BUILDTARGET}" \
+ BUILD_ARCH="${BUILD_ARCH}" \
+ BUILD_PLATFORM="${BUILD_PLATFORM}" \
+ CFLAGS="${CFLAGS}" \
+ CXXFLAGS="${CXXFLAGS}" \
+ LFS_BASEDIR="${BASEDIR}" \
+ ROOT="${LFS}" \
+ KVER="${KVER}" \
+ MAKETUNING="${MAKETUNING}" \
+ install >> $LOGFILE 2>&1
+
local COMPILE_SUCCESS=$?
local PKG_TIME_END=`date +%s`
KVER=$KVER MAKETUNING=$MAKETUNING \
BUILDTARGET="$BUILDTARGET" \
CROSSTARGET="${CROSSTARGET}" \
- MACHINE="$MACHINE" \
- MACHINE_TYPE="$MACHINE_TYPE" \
+ BUILD_ARCH="${BUILD_ARCH}" \
$(qemu_environ) \
$(fake_environ) \
/tools/bin/bash -x -c "cd /usr/src/lfs && \
KVER=$KVER MAKETUNING=$MAKETUNING \
BUILDTARGET="$BUILDTARGET" \
CROSSTARGET="${CROSSTARGET}" \
- MACHINE="$MACHINE" \
- MACHINE_TYPE="$MACHINE_TYPE" \
+ BUILD_ARCH="${BUILD_ARCH}" \
$(qemu_environ) \
$(fake_environ) \
/bin/bash -x -c "cd /usr/src/lfs && \
KVER=$KVER \
BUILDTARGET="$BUILDTARGET" \
CROSSTARGET="${CROSSTARGET}" \
- MACHINE="$MACHINE" \
- MACHINE_TYPE="$MACHINE_TYPE" \
+ BUILD_ARCH="${BUILD_ARCH}" \
$(qemu_environ) \
$(fake_environ) \
/bin/bash -x -c "cd /usr/src/lfs && \
KVER=$KVER \
BUILDTARGET="$BUILDTARGET" \
CROSSTARGET="${CROSSTARGET}" \
- MACHINE="$MACHINE" \
- MACHINE_TYPE="$MACHINE_TYPE" \
+ BUILD_ARCH="${BUILD_ARCH}" \
LD_LIBRARY_PATH=/tools/lib \
/tools/bin/bash -x -c "cd /usr/src/lfs && \
/tools/bin/make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1