make.sh: Cleanup of polluted environment

The build environment is using a number of variables which
occasionally conflicted with some other build systems.

This patch cleans that up by renaming some variables and
later unexporting them in the lfs files.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Michael Tremer
2017-04-20 17:09:42 +02:00
parent 174498ef96
commit dc7d6b204d
27 changed files with 176 additions and 183 deletions

View File

@@ -60,65 +60,66 @@ WARN="\\033[1;35m"
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"
@@ -127,8 +128,8 @@ configure_target() {
CXXFLAGS="${CFLAGS}"
}
configure_target_guess() {
case "${BUILD_ARCH}" in
configure_build_guess() {
case "${HOST_ARCH}" in
x86_64|i686|i586)
echo "i586"
;;
@@ -146,7 +147,7 @@ configure_target_guess() {
;;
*)
exiterror "Cannot guess target architecture"
exiterror "Cannot guess build architecture"
;;
esac
}
@@ -359,7 +360,7 @@ fake_environ() {
env="${env} UTS_RELEASE=${KVER}"
# Fake machine version.
env="${env} UTS_MACHINE=${TARGET_ARCH}"
env="${env} UTS_MACHINE=${BUILD_ARCH}"
echo "${env}"
}
@@ -373,7 +374,7 @@ qemu_environ() {
fi
# Set default qemu options
case "${TARGET_ARCH}" in
case "${BUILD_ARCH}" in
arm*)
QEMU_CPU="${QEMU_CPU:-cortex-a9}"
@@ -388,13 +389,13 @@ qemu_environ() {
}
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
;;
@@ -448,11 +449,11 @@ qemu_install_helper() {
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"
;;
@@ -510,8 +511,7 @@ entershell() {
KVER=$KVER \
BUILDTARGET="$BUILDTARGET" \
CROSSTARGET="${CROSSTARGET}" \
MACHINE="$MACHINE" \
MACHINE_TYPE="$MACHINE_TYPE" \
BUILD_ARCH="${BUILD_ARCH}" \
$(fake_environ) \
$(qemu_environ) \
/tools/bin/bash -i
@@ -548,8 +548,8 @@ lfsmakecommoncheck()
# 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
@@ -567,15 +567,13 @@ lfsmakecommoncheck()
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"
@@ -590,17 +588,22 @@ lfsmake1() {
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`
@@ -637,8 +640,7 @@ lfsmake2() {
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 && \
@@ -680,8 +682,7 @@ ipfiremake() {
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 && \
@@ -721,8 +722,7 @@ ipfiredist() {
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 && \
@@ -761,8 +761,7 @@ installmake() {
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