]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
make.sh: Cleanup of polluted environment
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 20 Apr 2017 15:09:42 +0000 (17:09 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 18 May 2017 11:02:03 +0000 (12:02 +0100)
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>
27 files changed:
lfs/Config
lfs/backports
lfs/binutils
lfs/cdrom
lfs/clamav
lfs/core-updates
lfs/flash-images
lfs/gcc
lfs/glibc
lfs/gmp
lfs/gmp-compat
lfs/initscripts
lfs/installer
lfs/linux
lfs/memtest
lfs/openssl
lfs/pakfire
lfs/php
lfs/sources-iso
lfs/stage2
lfs/strongswan
lfs/unzip
lfs/vdr_dvbapi
lfs/xen-image
make.sh
src/scripts/archive.files
tools/make-functions

index 3101d8b5a67dc79d73f19e2b207c6f5426d508f4..c9f6a88ddde556cc4e9df6840ac2ae30ebcd3ea9 100644 (file)
@@ -30,6 +30,9 @@
 #                                                                             #
 ###############################################################################
 
+# Cleanup environment from any variables
+unexport BUILD_ARCH BUILD_PLATFORM BUILDTARGET CROSSTARGET TOOLCHAIN
+
 # URLs that are common sources of downloads.  If you're having trouble with
 # a site you should change its URL to that of a suitable mirror site.
 #
@@ -117,13 +120,13 @@ define POSTBUILD
        if [ -s "$(TARGET)_diff" ]; then \
                LFS_SCRIPT=$(firstword $(MAKEFILE_LIST))$(KCFG); \
                echo $(LFS_SCRIPT); \
-               ROOTFILE=$$(find $(DIR_SRC)/config/rootfiles/{common,packages}/{$(MACHINE),} -maxdepth 1 -type f -name $$LFS_SCRIPT 2>/dev/null | head -1); \
+               ROOTFILE=$$(find $(DIR_SRC)/config/rootfiles/{common,packages}/{$(BUILD_ARCH),} -maxdepth 1 -type f -name $$LFS_SCRIPT 2>/dev/null | head -1); \
                if [ "$$ROOTFILE" = "" ]; then \
                        touch $(TARGET)_missing_rootfile; \
                        ROOTFILE=$(TARGET)_missing_rootfile ; \
                        echo "error $$LFS_SCRIPT not found in config/rootfiles"; \
                fi; \
-               sed -e "s/BUILDTARGET/$(BUILDTARGET)/g" -e "s/KVER/$(KVER)/g" -e "s/MACHINE/$(MACHINE)/g" $$ROOTFILE > $(TARGET)_rootfile; \
+               sed -e "s/BUILDTARGET/$(BUILDTARGET)/g" -e "s/KVER/$(KVER)/g" -e "s/MACHINE/$(BUILD_ARCH)/g" $$ROOTFILE > $(TARGET)_rootfile; \
                for line in `cat $(TARGET)_diff`; do \
                        if grep -qG "^#$$line$$" $(TARGET)_rootfile; then echo "#$$line" >> $(TARGET); \
                        elif grep -qG "^$$line$$" $(TARGET)_rootfile ; then echo "$$line" >> $(TARGET); \
@@ -178,13 +181,13 @@ define PAK
                cp -f /usr/src/src/paks/default/{,un}install.sh /usr/src/src/paks/default/update.sh \
                /install/packages/package; \
        fi
-       for i in $(DIR_SRC)/config/rootfiles/packages/{$(MACHINE),}/$(PROG); do \
+       for i in $(DIR_SRC)/config/rootfiles/packages/{$(BUILD_ARCH),}/$(PROG); do \
                if [ -e "$${i}" ]; then \
                        cp -v $${i} /install/packages/package/ROOTFILES; \
                        break; \
                fi; \
        done
-       sed -e 's/BUILDTARGET/$(BUILDTARGET)/g' -e 's/KVER/$(KVER)/g' -e 's/MACHINE/$(MACHINE)/g' -i /install/packages/package/ROOTFILES
+       sed -e 's/BUILDTARGET/$(BUILDTARGET)/g' -e 's/KVER/$(KVER)/g' -e 's/MACHINE/$(BUILD_ARCH)/g' -i /install/packages/package/ROOTFILES
        sed -e 's/xxxKVERxxx/$(KVER)/g' -i /install/packages/package/install.sh
        chmod 755 /install/packages/package/{{,un}install,update}.sh
        cd / && tar cf /install/packages/package/files.tmp --files-from=/install/packages/package/ROOTFILES --exclude='#*' \
index 5706b753c0238b81a2cb0c1fb16cc85949668e67..5f43ff4d6f01c2ff340a888932aa9123c79c0b67 100644 (file)
@@ -34,7 +34,7 @@ DL_FROM    = $(URL_IPFIRE)
 DIR_APP    = $(DIR_SRC)/$(THISAPP)
 TARGET     = $(DIR_INFO)/$(THISAPP)-kmod-$(KVER)-$(VERSUFIX)
 
-#ifeq "$(MACHINE_TYPE)" "arm"
+#ifeq "$(BUILD_PLATFORM)" "arm"
 CFLAGS   += -fno-PIC
 #endif
 
@@ -87,7 +87,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/backports-3.18.1-1-ipfire-build.patch
        cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/backports-4.2.6-1-grsecurity.patch
        cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/backports-4.2.6-1-add_usbnet_modules.patch
-ifeq "$(MACHINE)" "x86_64"
+ifeq "$(BUILD_ARCH)" "x86_64"
        cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/backports-3.18.1-1_no_dma_sgtable_on_x86_64.patch
 endif
 
@@ -126,7 +126,7 @@ endif
        cd $(DIR_APP) && sed -i -e "s/CPTCFG_CFG80211_DEFAULT_PS=y/# CPTCFG_CFG80211_DEFAULT_PS is not set/g" .config
        cd $(DIR_APP) && sed -i -e "s/CPTCFG_NFC=m/# CPTCFG_NFC is not set/g" .config
 
-ifeq "$(MACHINE)" "x86_64"
+ifeq "$(BUILD_ARCH)" "x86_64"
        cd $(DIR_APP) && sed -i -e "s/CPTCFG_LIBERTAS_UAP=m/# CPTCFG_LIBERTAS_UAP is not set/g" .config
 endif
 
index 7f5ef79ec508c83cf102f08ca2b72954ed0010a3..be890a88a5091fa5c9c4c758302e2f490d4ade66 100644 (file)
@@ -72,7 +72,7 @@ else
 endif
 endif
 
-ifeq "$(MACHINE)" "armv5tel"
+ifeq "$(BUILD_ARCH)" "armv5tel"
        EXTRA_CONFIG += \
                --with-abi=aapcs-linux \
                --with-float=soft
@@ -124,15 +124,15 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        # Prevent installing libiberty to lib64.
        cd $(DIR_APP) && sed -i 's%\(^MULTIOSDIR = \).*%\1 ../lib%' libiberty/Makefile.in
 
-       cd $(DIR_SRC)/binutils-build && $(EXTRA_ENV) MACHINE= $(DIR_APP)/configure $(EXTRA_CONFIG)
-       cd $(DIR_SRC)/binutils-build && make $(EXTRA_MAKE) $(MAKETUNING) MACHINE=
-       cd $(DIR_SRC)/binutils-build && make $(EXTRA_INSTALL) install MACHINE=
+       cd $(DIR_SRC)/binutils-build && $(EXTRA_ENV) $(DIR_APP)/configure $(EXTRA_CONFIG)
+       cd $(DIR_SRC)/binutils-build && make $(EXTRA_MAKE) $(MAKETUNING)
+       cd $(DIR_SRC)/binutils-build && make $(EXTRA_INSTALL) install
 ifeq "$(ROOT)" ""
        cp -v $(DIR_APP)/include/libiberty.h /usr/include
 else
 ifeq "$(PASS)" "2"
-       cd $(DIR_SRC)/binutils-build && make -C ld clean MACHINE=
-       cd $(DIR_SRC)/binutils-build && make -C ld LIB_PATH=/usr/lib:/lib MACHINE=
+       cd $(DIR_SRC)/binutils-build && make -C ld clean
+       cd $(DIR_SRC)/binutils-build && make -C ld LIB_PATH=/usr/lib:/lib
        cd $(DIR_SRC)/binutils-build && cp -v ld/ld-new /tools/bin
 endif
 endif
index 79920b8ddbb787ad555ad4392e5822d09a08c12e..58e754f87b9db39c828994f100fcea7bb7dd1684 100644 (file)
--- a/lfs/cdrom
+++ b/lfs/cdrom
@@ -29,7 +29,7 @@ VER = ipfire
 THISAPP    = cdrom
 TARGET     = $(DIR_INFO)/$(THISAPP)
 
-ifeq "$(MACHINE_TYPE)" "arm"
+ifeq "$(BUILD_PLATFORM)" "arm"
        TAR_OPTIONS =
 else
        TAR_OPTIONS = --lzma
@@ -64,7 +64,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        echo > /etc/mtab
 
        # Create filelist for packaging.
-       BUILDTARGET="$(BUILDTARGET)" MACHINE="$(MACHINE)" KVER="$(KVER)" \
+       BUILDTARGET="$(BUILDTARGET)" BUILD_ARCH="$(BUILD_ARCH)" KVER="$(KVER)" \
                $(DIR_SRC)/src/scripts/archive.files \
                $(DIR_SRC)/config/rootfiles/common \
                > /tmp/ROOTFILES
@@ -89,7 +89,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        # Make the ISO
        mkdir -p /install/cdrom/boot/isolinux
        dd if=/dev/zero  bs=1k count=2            > /install/cdrom/boot/isolinux/boot.catalog
-ifneq "$(MACHINE_TYPE)" "arm"
+ifneq "$(BUILD_PLATFORM)" "arm"
        cp /boot/vmlinuz-$(KVER)-ipfire             /install/cdrom/boot/isolinux/vmlinuz
        dracut --force -a "installer" --strip --xz /install/cdrom/boot/isolinux/instroot $(KVER)-ipfire
        cp $(DIR_SRC)/config/syslinux/boot.png      /install/cdrom/boot/isolinux/boot.png
@@ -106,12 +106,12 @@ endif
                                                xargs md5sum > md5sum.txt
 
        mkdir -p /install/images
-ifeq "$(MACHINE_TYPE)" "arm"
+ifeq "$(BUILD_PLATFORM)" "arm"
        cd /install/cdrom && mkisofs -J -r -V "$(NAME)_$(VERSION)" \
-               . > /install/images/$(SNAME)-$(VERSION).$(MACHINE)-full-core$(CORE).iso
+               . > /install/images/$(SNAME)-$(VERSION).$(BUILD_ARCH)-full-core$(CORE).iso
 else
        cd /install/cdrom && mkisofs -J -r -V "$(NAME)_$(VERSION)" \
            -b boot/isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table \
-           -c boot/isolinux/boot.catalog . > /install/images/$(SNAME)-$(VERSION).$(MACHINE)-full-core$(CORE).iso
-       isohybrid /install/images/$(SNAME)-$(VERSION).$(MACHINE)-full-core$(CORE).iso
+           -c boot/isolinux/boot.catalog . > /install/images/$(SNAME)-$(VERSION).$(BUILD_ARCH)-full-core$(CORE).iso
+       isohybrid /install/images/$(SNAME)-$(VERSION).$(BUILD_ARCH)-full-core$(CORE).iso
 endif
index 650faecbebcf7c21983f17523feeb656e93f32f7..7ba8b8342f897880d7f7e82832b9965bd0b87f45 100644 (file)
@@ -36,7 +36,7 @@ PAK_VER    = 34
 
 DEPS       = ""
 
-ifeq "$(MACHINE_TYPE)" "arm"
+ifeq "$(BUILD_PLATFORM)" "arm"
 CONFIGURE_FLAGS = --disable-fanotify
 endif
 
index b40de13e06efffb68c984fc34e74c6d9c5132116..75a8415f6f42e8b955df4fb6bd2add546e4dfd09 100644 (file)
@@ -59,7 +59,7 @@ core/%:
        $(DIR_SRC)/src/scripts/archive.files \
                $(DIR_SRC)/config/rootfiles/$@/filelists \
                $(DIR_SRC)/config/rootfiles/$@/files \
-               $(DIR_SRC)/config/rootfiles/$@/files.$(MACHINE) \
+               $(DIR_SRC)/config/rootfiles/$@/files.$(BUILD_ARCH) \
                > /tmp/ROOTFILES.tmp
 
        #remove excluded files from ROOTFILES
index 4a1a4d6aab696277a65e5ddabee817cd25ef3373..554c0466212587faa6594a670abdc446d7c6a08b 100644 (file)
@@ -34,9 +34,9 @@ PART_BOOT  = /dev/mapper/$(patsubst /dev/%,%,$(DEVICE))p1
 PART_ROOT  = /dev/mapper/$(patsubst /dev/%,%,$(DEVICE))p3
 
 ifeq "$(SCON)" "1"
-       IMAGE_FILE = /install/images/$(SNAME)-$(VERSION).1gb-ext4-scon.$(MACHINE)-full-core$(CORE).img.gz
+       IMAGE_FILE = /install/images/$(SNAME)-$(VERSION).1gb-ext4-scon.$(BUILD_ARCH)-full-core$(CORE).img.gz
 else
-       IMAGE_FILE = /install/images/$(SNAME)-$(VERSION).1gb-ext4.$(MACHINE)-full-core$(CORE).img.gz
+       IMAGE_FILE = /install/images/$(SNAME)-$(VERSION).1gb-ext4.$(BUILD_ARCH)-full-core$(CORE).img.gz
 endif
 
 FSTAB_FMT = UUID=%s %-8s %-4s %-10s %d %d\n
@@ -60,7 +60,7 @@ MNThdd   := /install/harddisk
 IMG      := /install/images/image.img
 
 # All sizes in blocks
-ifeq "$(MACHINE_TYPE)" "arm"
+ifeq "$(BUILD_PLATFORM)" "arm"
  BOOTLOADER =
  S_OFFSET = 8192
 
@@ -117,7 +117,7 @@ endif
        mount $(PART_BOOT) $(MNThdd)/boot
 
        # Install Pandaboard MLO and uboot first
-ifeq "$(MACHINE_TYPE)" "arm"
+ifeq "$(BUILD_PLATFORM)" "arm"
        cp -v /boot/MLO $(MNThdd)/boot/
        cp -v /boot/u-boot.img $(MNThdd)/boot/
        cp -v /boot/zImage-ipfire-multi $(MNThdd)/boot/
@@ -135,7 +135,7 @@ ifeq "$(MACHINE_TYPE)" "arm"
 endif
 
        # Install IPFire
-ifneq "$(MACHINE_TYPE)" "arm"
+ifneq "$(BUILD_PLATFORM)" "arm"
        tar -x --lzma -C $(MNThdd)/ -f /install/cdrom/distro.img
 else
        tar -x -C $(MNThdd)/ -f /install/cdrom/distro.img
@@ -154,7 +154,7 @@ ifeq "$(SCON)" "1"
        sed -i -e "s|6:2345:respawn:|#6:2345:respawn:|g" $(MNThdd)/etc/inittab
        sed -i -e "s|#7:2345:respawn:|7:2345:respawn:|g" $(MNThdd)/etc/inittab
 
-ifeq "$(MACHINE_TYPE)" "arm"
+ifeq "$(BUILD_PLATFORM)" "arm"
        sed -i -e "s| console=tty1 | console=ttyAMA0,115200n8 |g" $(MNThdd)/boot/cmdline.txt
        sed -i -e "s| console=tty1 | console=ttyO2,115200n8 |g" $(MNThdd)/boot/uEnv.txt
 endif
@@ -228,7 +228,7 @@ endif
        # not copied to a block device)
        dd if=/dev/zero bs=1M count=$(PADDING) >> $(IMG)
 
-ifeq "$(MACHINE_TYPE)" "arm"
+ifeq "$(BUILD_PLATFORM)" "arm"
        # Install u-boot for LeMaker Banana Pi into image 8KB
        dd if=/usr/share/u-boot/banana_pi/u-boot-sunxi-with-spl.bin of=$(IMG) bs=1K seek=8 conv=notrunc
 endif
diff --git a/lfs/gcc b/lfs/gcc
index 3c6cb63cd9012e23a942995d1869a19a571e9113..e898d6a8fe6048831129865e40288b235ad78feb 100644 (file)
--- a/lfs/gcc
+++ b/lfs/gcc
@@ -133,24 +133,24 @@ endif
 endif
 endif
 
-ifeq "$(MACHINE)" "armv7hl"
+ifeq "$(BUILD_ARCH)" "armv7hl"
        EXTRA_CONFIG += \
                --with-float=hard
 endif
 
-ifeq "$(MACHINE)" "armv5tel"
+ifeq "$(BUILD_ARCH)" "armv5tel"
        EXTRA_CONFIG += \
                --with-float=soft \
                --disable-sjlj-exceptions
 endif
 
-ifeq "$(MACHINE)" "i586"
+ifeq "$(BUILD_ARCH)" "i586"
        EXTRA_CONFIG += \
                --with-arch=i586 \
                --with-tune=generic
 endif
 
-ifeq "$(MACHINE)" "x86_64"
+ifeq "$(BUILD_ARCH)" "x86_64"
        EXTRA_CONFIG += \
                --disable-multilib
 endif
index 67f13a3fb34138ff80c7d33971f112f2478cbd69..6cb73119fe6f0509934bfb669caed3d149c085ad 100644 (file)
--- a/lfs/glibc
+++ b/lfs/glibc
@@ -53,16 +53,16 @@ endif
 # Enable some extra optimization for the glibc code
 CFLAGS = -O3 -DNDEBUG -fasynchronous-unwind-tables -fPIC -DPIC
 
-ifeq "$(MACHINE)" "armv7hl"
+ifeq "$(BUILD_ARCH)" "armv7hl"
        CFLAGS += -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard
 endif
 
-ifeq "$(MACHINE)" "i586"
+ifeq "$(BUILD_ARCH)" "i586"
        CFLAGS += -march=i586 -mtune=generic -mno-tls-direct-seg-refs
 endif
 
 # Disable hardware FP for armv5tel
-ifeq "$(MACHINE)" "armv5tel"
+ifeq "$(BUILD_ARCH)" "armv5tel"
        EXTRA_CONFIG += \
                --without-fp
 endif
@@ -117,19 +117,21 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        @rm -rf $(DIR_APP) $(DIR_SRC)/glibc-build && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
        @mkdir $(DIR_SRC)/glibc-build
 
-ifeq "$(ROOT)" ""
-ifeq "$(MACHINE_TYPE)" "arm"
-       cd $(DIR_APP) && sed -i 's|libs -o|libs -L/usr/lib -Wl,-dynamic-linker=/lib/ld-linux.so.3 -o|' \
-               scripts/test-installation.pl
-else
-ifeq "$(MACHINE)" "x86_64"
+ifneq "$(TOOLCHAIN)" "1"
+ ifeq "$(BUILD_ARCH)" "x86_64"
        cd $(DIR_APP) && sed -i 's|libs -o|libs -L/usr/lib64 -Wl,-dynamic-linker=/lib64/ld-linux-x86-64.so.2 -o|' \
                scripts/test-installation.pl
-else
+ endif
+
+ ifeq "$(BUILD_ARCH)" "i586"
        cd $(DIR_APP) && sed -i 's|libs -o|libs -L/usr/lib -Wl,-dynamic-linker=/lib/ld-linux.so.2 -o|' \
                scripts/test-installation.pl
-endif
-endif
+ endif
+
+ ifeq "$(BUILD_ARCH)" "armv5tel"
+       cd $(DIR_APP) && sed -i 's|libs -o|libs -L/usr/lib -Wl,-dynamic-linker=/lib/ld-linux.so.3 -o|' \
+               scripts/test-installation.pl
+ endif
 endif
 
        cd $(DIR_SRC)/glibc-build && \
@@ -141,15 +143,16 @@ endif
 
        cd $(DIR_SRC)/glibc-build && make install
 
-ifeq "$(ROOT)" ""
+ifeq "$(TOOLCHAIN)" "1"
+       ln -svf lib /tools/lib64
+else
        # Creating the locales
        mkdir -p /usr/lib/locale
        cd $(DIR_SRC)/glibc-build && make localedata/install-locales
 
        # Timezone data will be shipped by tzdata.
        rm -rfv /usr/share/zoneinfo
-else
-       ln -svf lib /tools/lib64
 endif
+
        @rm -rf $(DIR_APP) $(DIR_SRC)/glibc-build
        @$(POSTBUILD)
diff --git a/lfs/gmp b/lfs/gmp
index f8dd6bb196c55862d9c28e868409801b80a23366..8dc9b73509cd69cc28dd775ef5f2b93ea591d146 100644 (file)
--- a/lfs/gmp
+++ b/lfs/gmp
@@ -32,9 +32,9 @@ DL_FROM    = $(URL_IPFIRE)
 DIR_APP    = $(DIR_SRC)/$(THISAPP)
 TARGET     = $(DIR_INFO)/$(THISAPP)
 
-ifeq "$(MACHINE)" "i586"
+ifeq "$(BUILD_ARCH)" "i586"
        CONFIGURE_ARGS = ABI=32
-       BUILDTARGET_PENTIUM4 = $(patsubst $(MACHINE)-%,pentium4-%,$(BUILDTARGET))
+       BUILDTARGET_PENTIUM4 = $(patsubst $(BUILD_ARCH)-%,pentium4-%,$(BUILDTARGET))
 endif
 
 CONFIGURE_OPTIONS = \
@@ -89,7 +89,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        cd $(DIR_APP) && make $(MAKETUNING)
        cd $(DIR_APP) && make install
 
-ifeq "$(MACHINE)" "i586"
+ifeq "$(BUILD_ARCH)" "i586"
        # Build SSE/SSE2 optimised version for x86
        cd $(DIR_APP) && make clean
        cd $(DIR_APP) && \
index 438e9578d3076b5f988088ebf81bd8367fd2fbf2..1e483f6c04a75045c5088c3de3cc64a72398087d 100644 (file)
@@ -32,7 +32,7 @@ DL_FROM    = $(URL_IPFIRE)
 DIR_APP    = $(DIR_SRC)/$(THISAPP)
 TARGET     = $(DIR_INFO)/$(THISAPP)
 
-ifeq "$(MACHINE)" "i586"
+ifeq "$(BUILD_ARCH)" "i586"
        CONFIGURE_ARGS = ABI=32
 endif
 
index ef7114c90eca0479d851db451df6d8314c058c38..7d07b8ab3934c7cfe65bad1dc580e92e44b72e63 100644 (file)
@@ -199,7 +199,7 @@ $(TARGET) :
        done
 
        # ARM does not need acpid, intel no swconfig
-ifeq "$(MACHINE_TYPE)" "arm"
+ifeq "$(BUILD_PLATFORM)" "arm"
        rm -vf /etc/rc.d/init.d/acpid
        ln -sf ../init.d/swconfig    /etc/rc.d/rcsysinit.d/S73swconfig
 else
index 3364a4d7fd9849790821521554737c0d0be09a8a..347d90e70bab6158e7571c7ea6a2c1c38243ca8f 100644 (file)
@@ -31,7 +31,7 @@ DIR_APP    = $(DIR_SRC)/$(THISAPP)
 TARGET     = $(DIR_INFO)/$(THISAPP)
 
 SLOGAN     = An Open Source Firewall Solution
-DOWNLOAD_URL = http://downloads.ipfire.org/releases/ipfire-2.x/$(VERSION)-core$(CORE)/$(SNAME)-$(VERSION).$(MACHINE)-full-core$(CORE).iso
+DOWNLOAD_URL = http://downloads.ipfire.org/releases/ipfire-2.x/$(VERSION)-core$(CORE)/$(SNAME)-$(VERSION).$(BUILD_ARCH)-full-core$(CORE).iso
 
 ###############################################################################
 # Top-level Rules
index 8ced5dda18c62be818dc9cd70823ebf1fe04a67b..5be7ab12523b1328c9c9939967d24ddf2a8c2175 100644 (file)
--- a/lfs/linux
+++ b/lfs/linux
@@ -40,10 +40,16 @@ CXXFLAGS   =
 PAK_VER    = 73
 DEPS      = ""
 
-ifeq "$(MACHINE)" "i586"
+ifeq "$(BUILD_ARCH)" "i586"
        KERNEL_ARCH = i386
 else
-       KERNEL_ARCH = $(MACHINE)
+       KERNEL_ARCH = $(BUILD_ARCH)
+endif
+
+ifeq "$(BUILD_ARCH)" "aarch64"
+       HEADERS_ARCH = arm64
+else
+       HEADERS_ARCH = $(BUILD_PLATFORM)
 endif
 
 VERSUFIX=ipfire$(KCFG)
@@ -56,26 +62,6 @@ else
        HEADERS_PREFIX = /usr
 endif
 
-ifeq "$(MACHINE)" "armv7hl"
-       HEADERS_ARCH=arm
-endif
-
-ifeq "$(MACHINE)" "armv5tel"
-       HEADERS_ARCH=arm
-endif
-
-ifeq "$(MACHINE)" "aarch64"
-       HEADERS_ARCH=arm64
-endif
-
-ifeq "$(MACHINE)" "x86_64"
-       HEADERS_ARCH=x86
-endif
-
-ifeq "$(MACHINE)" "i586"
-       HEADERS_ARCH=x86
-endif
-
 ifeq "$(KCFG)" ""
 LASTKERNEL=1
 endif
@@ -264,7 +250,7 @@ else
                drivers/video/logo/logo_linux_clut224.ppm
 
        # Cleanup kernel source
-       cp $(DIR_SRC)/config/kernel/kernel.config.$(MACHINE)-$(VERSUFIX) $(DIR_APP)/.config
+       cp $(DIR_SRC)/config/kernel/kernel.config.$(BUILD_ARCH)-$(VERSUFIX) $(DIR_APP)/.config
        cd $(DIR_APP) && make oldconfig
        cd $(DIR_APP) && make clean
        cd $(DIR_APP) && sed -i -e 's/EXTRAVERSION\ =.*/EXTRAVERSION\ =\ -$(VERSUFIX)/' Makefile
@@ -295,7 +281,7 @@ endif
        cd $(DIR_APP) && make $(MAKETUNING) modules_install
        cd $(DIR_APP) && make $(MAKETUNING) firmware_install
 
-ifeq "$(MACHINE_TYPE)" "arm"
+ifeq "$(BUILD_PLATFORM)" "arm"
        cd $(DIR_APP) && make $(MAKETUNING) dtbs
        cd $(DIR_APP) && for f in $$(find arch/arm/boot/dts/ -name *.dtb); do \
                                mkdir -p /boot/dtb-$(VER)-$(VERSUFIX) ; \
index c92fab63b54e994d101aee60d69ab3caf6158975..a1d6e2c5fee1afc7071dba4232b5c80622465490 100644 (file)
@@ -76,7 +76,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
 # gcc-4.9.3 produce a corrupted version of memtest
 # we use the precomp version at the moment
 
-#ifeq "$(MACHINE)" "i586"
+#ifeq "$(BUILD_ARCH)" "i586"
 #      # Enable SMP as default
 #      cd $(DIR_APP) && sed -i -e "s|CONSERVATIVE_SMP 1|CONSERVATIVE_SMP 0|g" config.h
 #      cd $(DIR_APP) && sed -i -e "s|scp |echo |g" Makefile
index cece0074ef228331146e8d62b536c6b5d0593d9c..2fc710dc2f5b0079ffb1e0e16c95a62a7b979b7e 100644 (file)
@@ -63,11 +63,11 @@ CONFIGURE_OPTIONS = \
        no-srp \
        -DSSL_FORBID_ENULL
 
-ifeq "$(MACHINE)" "x86_64"
+ifeq "$(BUILD_ARCH)" "x86_64"
        CONFIGURE_OPTIONS += linux-x86_64
 endif
 
-ifeq "$(MACHINE)" "i586"
+ifeq "$(BUILD_ARCH)" "i586"
        CONFIGURE_OPTIONS += linux-elf
 
 ifneq "$(KCFG)" "-sse2"
@@ -75,7 +75,7 @@ ifneq "$(KCFG)" "-sse2"
 endif
 endif
 
-ifeq "$(MACHINE)" "armv5tel"
+ifeq "$(BUILD_ARCH)" "armv5tel"
        CONFIGURE_OPTIONS += linux-generic32
 endif
 
@@ -123,7 +123,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/openssl-1.0.2g-disable-sslv2v3.patch
 
        # i586 specific patches
-ifeq "$(MACHINE)" "i586"
+ifeq "$(BUILD_ARCH)" "i586"
        cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/openssl-1.0.2a_auto_enable_padlock.patch
        cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/openssl-1.0.2a_disable_ssse3_for_amd.patch
 endif
index 00d1bb1c0d5b2bedba2a08aaaa5488258409e978..b584cc5611ee950bc5538773c038cc674a528726 100644 (file)
@@ -30,10 +30,10 @@ THISAPP    = pakfire
 DIR_APP    = /opt/$(THISAPP)
 TARGET     = $(DIR_INFO)/$(THISAPP)
 
-ifeq "$(MACHINE)" "i586"
+ifeq "$(BUILD_ARCH)" "i586"
        PAKFIRE_VERSION = $(VERSION)
 else
-       PAKFIRE_VERSION = $(VERSION)-$(MACHINE)
+       PAKFIRE_VERSION = $(VERSION)-$(BUILD_ARCH)
 endif
 
 ###############################################################################
diff --git a/lfs/php b/lfs/php
index 1f33f0d7ea4fe92dfb17ddd7eb0a316b8903f06e..8717ccac14c5c1dcbe1946bf600f92432e0187e1 100644 (file)
--- a/lfs/php
+++ b/lfs/php
@@ -32,7 +32,7 @@ DL_FROM    = $(URL_IPFIRE)
 DIR_APP    = $(DIR_SRC)/$(THISAPP)
 TARGET     = $(DIR_INFO)/$(THISAPP)
 
-ifeq "$(MACHINE_TYPE)" "arm"
+ifeq "$(BUILD_PLATFORM)" "arm"
        CFLAGS    := $(patsubst -march=%,,$(CFLAGS))
 endif
 
index 9df159e72c0e6e7426873fcf2696f17db81275e6..4f658cf540562b176d7ab4cd647ea0be83ff5420 100644 (file)
@@ -48,5 +48,5 @@ install : $(DIR_INFO)/_build.othersrc-list.log
        
        # make the sources CDROM iso
        cd /install/cdrom && mkisofs -J -r -V "$(NAME)_$(VERSION)" \
-               . > /install/images/$(SNAME)-sources-cd-$(VERSION).$(MACHINE).iso
+               . > /install/images/$(SNAME)-sources-cd-$(VERSION).$(BUILD_ARCH).iso
        rm -rf /install/cdrom/*
index 1256fd365ebadac5bcfaff416048e57765e3fc76..b548c0c6c7ba444a1b167574ec20ca2ab9202b93 100644 (file)
@@ -64,7 +64,7 @@ $(TARGET) :
        # Symlink /var/run -> /run.
        ln -svf ../run /var/run
 
-ifeq "$(MACHINE)" "x86_64"
+ifeq "$(BUILD_ARCH)" "x86_64"
        ln -svf lib /lib64
        ln -svf lib /usr/lib64
 endif
index 7f6a95b6e38c0589cd982d53bfb64f4b5c6d7ab2..32f549219b8e47a36db604f5cde0417b7e5fc13c 100644 (file)
@@ -32,7 +32,7 @@ DL_FROM    = $(URL_IPFIRE)
 DIR_APP    = $(DIR_SRC)/strongswan-$(VER)
 TARGET     = $(DIR_INFO)/$(THISAPP)
 
-ifeq "$(MACHINE)" "i586"
+ifeq "$(BUILD_ARCH)" "i586"
        CONFIGURE_OPTIONS = \
                --enable-padlock
 else
index 7853dd0b4fa27dd9e6ceb26cf74bfc58b27b6e69..793890d2871b56f93238abd8437b09938f714389 100644 (file)
--- a/lfs/unzip
+++ b/lfs/unzip
@@ -72,7 +72,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
        cd $(DIR_APP) && make -f unix/Makefile clean
        cd $(DIR_APP)/unix && ./configure
-ifeq "$(MACHINE)" "i586"
+ifeq "$(BUILD_ARCH)" "i586"
        cd $(DIR_APP) && make -f unix/Makefile LOCAL_UNZIP=-D_FILE_OFFSET_BITS=64 generic
 else
        # ARM/x86_64 cannot use the x86 32 bit assembly code.
index 2cf34e73dfe1012d6e457d90f235074d415fc31c..f9339e6b84be7784a9760dbd704d3666f325ef2f 100644 (file)
@@ -102,7 +102,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        @$(PREBUILD)
        @rm -rf $(DIR_APP)* && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
 
-ifeq "$(MACHINE)" "i586"
+ifeq "$(BUILD_ARCH)" "i586"
        # Build an SSE enabled version.
        $(call BUILD,-sse)
 endif
index d5a747bcd370cc770a15429f741d9edcf9dd315b..78c242bf82829efae53d8adc5f94339861c8bdad 100644 (file)
@@ -47,7 +47,7 @@ md5 :
 ###############################################################################
 # Installation Details
 ###############################################################################
-IMGinst  := /install/images/$(SNAME)-$(VERSION).xen.$(MACHINE)-downloader-core$(CORE).tar.bz2
+IMGinst  := /install/images/$(SNAME)-$(VERSION).xen.$(BUILD_ARCH)-downloader-core$(CORE).tar.bz2
 
 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        rm -rf /install/images/$(SNAME) $(IMGinst) && mkdir -p /install/images/$(SNAME)
diff --git a/make.sh b/make.sh
index 3a62c4f7715530f3153b16a4df72f7711f3875ea..7b0249928d9ebb09d847dc39be690b5959137544 100755 (executable)
--- a/make.sh
+++ b/make.sh
@@ -39,8 +39,7 @@ GIT_LASTCOMMIT=$(git log | head -n1 | cut -d" " -f2 |head -c8)        # Last commit
 TOOLCHAINVER=12
 
 # New architecture variables
-BUILD_ARCH="$(uname -m)"
-BUILDMACHINE="${BUILD_ARCH}"
+HOST_ARCH="$(uname -m)"
 
 # Debian specific settings
 if [ ! -e /etc/debian_version ]; then
@@ -69,10 +68,13 @@ if [ -f .config ]; then
        . .config
 fi
 
-if [ -n "${TARGET_ARCH}" ]; then
-       configure_target "${TARGET_ARCH}"
+if [ -n "${BUILD_ARCH}" ]; then
+       configure_build "${BUILD_ARCH}"
+elif [ -n "${TARGET_ARCH}" ]; then
+       configure_build "${TARGET_ARCH}"
+       unset TARGET_ARCH
 else
-       configure_target "default"
+       configure_build "default"
 fi
 
 if [ -z $EDITOR ]; then
@@ -221,13 +223,13 @@ prepareenv() {
     # Run LFS static binary creation scripts one by one
     export CCACHE_DIR=$BASEDIR/ccache
     export CCACHE_COMPRESS=1
-    export CCACHE_COMPILERCHECK="string:toolchain-${TOOLCHAINVER} ${TARGET_ARCH}"
+    export CCACHE_COMPILERCHECK="string:toolchain-${TOOLCHAINVER} ${BUILD_ARCH}"
 
     # Remove pre-install list of installed files in case user erase some files before rebuild
     rm -f $BASEDIR/build/usr/src/lsalr 2>/dev/null
 
     # Prepare string for /etc/system-release.
-    SYSTEM_RELEASE="${NAME} ${VERSION} (${MACHINE})"
+    SYSTEM_RELEASE="${NAME} ${VERSION} (${BUILD_ARCH})"
     if [ "$(git status -s | wc -l)" == "0" ]; then
        GIT_STATUS=""
     else
@@ -245,7 +247,7 @@ prepareenv() {
 
 buildtoolchain() {
     local error=false
-    case "${TARGET_ARCH}:${BUILD_ARCH}" in
+    case "${BUILD_ARCH}:${HOST_ARCH}" in
         # x86_64
         x86_64:x86_64)
              # This is working.
@@ -273,7 +275,7 @@ buildtoolchain() {
     esac
 
     ${error} && \
-        exiterror "Cannot build ${MACHINE} toolchain on $(uname -m). Please use the download if any."
+        exiterror "Cannot build ${BUILD_ARCH} toolchain on $(uname -m). Please use the download if any."
 
     local gcc=$(type -p gcc)
     if [ -z "${gcc}" ]; then
@@ -426,7 +428,7 @@ buildipfire() {
   ipfiremake libnetfilter_cttimeout
   ipfiremake iptables
 
-  case "${TARGET_ARCH}" in
+  case "${BUILD_ARCH}" in
        x86_64)
                ipfiremake linux                        KCFG=""
                ipfiremake backports                    KCFG=""
@@ -484,7 +486,7 @@ buildipfire() {
   esac
   ipfiremake xtables-addons                    USPACE="1"
   ipfiremake openssl
-  [ "${TARGET_ARCH}" = "i586" ] && ipfiremake openssl KCFG='-sse2'
+  [ "${BUILD_ARCH}" = "i586" ] && ipfiremake openssl KCFG='-sse2'
   ipfiremake libgpg-error
   ipfiremake libgcrypt
   ipfiremake libassuan
@@ -947,7 +949,7 @@ buildpackages() {
   cd $BASEDIR
 
   # remove not useable iso on armv5tel (needed to build flash images)
-  [ "${TARGET_ARCH}" = "armv5tel" ] && rm -rf *.iso
+  [ "${BUILD_ARCH}" = "armv5tel" ] && rm -rf *.iso
 
   for i in `ls *.bz2 *.img.gz *.iso`; do
        md5sum $i > $i.md5
@@ -978,7 +980,7 @@ ipfirepackages() {
        ipfiremake core-updates
 
        local i
-       for i in $(find $BASEDIR/config/rootfiles/packages{/${MACHINE},} -maxdepth 1 -type f); do
+       for i in $(find $BASEDIR/config/rootfiles/packages{/${BUILD_ARCH},} -maxdepth 1 -type f); do
                i=$(basename ${i})
                if [ -e $BASEDIR/lfs/$i ]; then
                        ipfiredist $i
@@ -1012,7 +1014,7 @@ done
 case "$1" in 
 build)
        clear
-       PACKAGE=`ls -v -r $BASEDIR/cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-$MACHINE.tar.gz 2> /dev/null | head -n 1`
+       PACKAGE=`ls -v -r $BASEDIR/cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.tar.gz 2> /dev/null | head -n 1`
        #only restore on a clean disk
        if [ ! -f log/cleanup-toolchain-2-tools ]; then
                if [ ! -n "$PACKAGE" ]; then
@@ -1106,7 +1108,7 @@ downloadsrc)
                        if [ -f "$i" -a "$i" != "Config" ]; then
                                lfsmakecommoncheck ${i} || continue
 
-                               make -s -f $i LFS_BASEDIR=$BASEDIR MACHINE=$MACHINE \
+                               make -s -f $i LFS_BASEDIR=$BASEDIR BUILD_ARCH="${BUILD_ARCH}" \
                                        MESSAGE="$i\t ($c/$MAX_RETRIES)" download >> $LOGFILE 2>&1
                                if [ $? -ne 0 ]; then
                                        beautify message FAIL
@@ -1124,7 +1126,7 @@ downloadsrc)
        for i in *; do
                if [ -f "$i" -a "$i" != "Config" ]; then
                        lfsmakecommoncheck ${i} > /dev/null || continue
-                       make -s -f $i LFS_BASEDIR=$BASEDIR MACHINE=$MACHINE \
+                       make -s -f $i LFS_BASEDIR=$BASEDIR BUILD_ARCH="${BUILD_ARCH}" \
                                MESSAGE="$i\t " md5 >> $LOGFILE 2>&1
                        if [ $? -ne 0 ]; then
                                echo -ne "MD5 difference in lfs/$i"
@@ -1147,25 +1149,25 @@ toolchain)
        prepareenv
        beautify build_stage "Toolchain compilation - Native GCC: `gcc --version | grep GCC | awk {'print $3'}`"
        buildtoolchain
-       echo "`date -u '+%b %e %T'`: Create toolchain tar.gz for $MACHINE" | tee -a $LOGFILE
+       echo "`date -u '+%b %e %T'`: Create toolchain tar.gz for ${BUILD_ARCH}" | tee -a $LOGFILE
        test -d $BASEDIR/cache/toolchains || mkdir -p $BASEDIR/cache/toolchains
-       cd $BASEDIR && tar -zc --exclude='log/_build.*.log' -f cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-$MACHINE.tar.gz \
+       cd $BASEDIR && tar -zc --exclude='log/_build.*.log' -f cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.tar.gz \
                build/tools build/bin/sh log >> $LOGFILE
-       md5sum cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-$MACHINE.tar.gz \
-               > cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-$MACHINE.md5
+       md5sum cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.tar.gz \
+               > cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.md5
        stdumount
        ;;
 gettoolchain)
        # arbitrary name to be updated in case of new toolchain package upload
-       PACKAGE=$SNAME-$VERSION-toolchain-$TOOLCHAINVER-$MACHINE
+       PACKAGE=$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}
        if [ ! -f $BASEDIR/cache/toolchains/$PACKAGE.tar.gz ]; then
                URL_TOOLCHAIN=`grep URL_TOOLCHAIN lfs/Config | awk '{ print $3 }'`
                test -d $BASEDIR/cache/toolchains || mkdir -p $BASEDIR/cache/toolchains
-               echo "`date -u '+%b %e %T'`: Load toolchain tar.gz for $MACHINE" | tee -a $LOGFILE
+               echo "`date -u '+%b %e %T'`: Load toolchain tar.gz for ${BUILD_ARCH}" | tee -a $LOGFILE
                cd $BASEDIR/cache/toolchains
                wget -U "IPFireSourceGrabber/2.x" $URL_TOOLCHAIN/$PACKAGE.tar.gz $URL_TOOLCHAIN/$PACKAGE.md5 >& /dev/null
                if [ $? -ne 0 ]; then
-                       echo "`date -u '+%b %e %T'`: error downloading $PACKAGE toolchain for $MACHINE machine" | tee -a $LOGFILE
+                       echo "`date -u '+%b %e %T'`: error downloading $PACKAGE toolchain for ${BUILD_ARCH} machine" | tee -a $LOGFILE
                else
                        if [ "`md5sum $PACKAGE.tar.gz | awk '{print $1}'`" = "`cat $PACKAGE.md5 | awk '{print $1}'`" ]; then
                                echo "`date -u '+%b %e %T'`: toolchain md5 ok" | tee -a $LOGFILE
@@ -1179,11 +1181,11 @@ gettoolchain)
        ;;
 othersrc)
        prepareenv
-       echo -ne "`date -u '+%b %e %T'`: Build sources iso for $MACHINE" | tee -a $LOGFILE
+       echo -ne "`date -u '+%b %e %T'`: Build sources iso for ${BUILD_ARCH}" | tee -a $LOGFILE
        chroot $LFS /tools/bin/env -i   HOME=/root \
        TERM=$TERM PS1='\u:\w\$ ' \
        PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \
-       VERSION=$VERSION NAME="$NAME" SNAME="$SNAME" MACHINE=$MACHINE \
+       VERSION=$VERSION NAME="$NAME" SNAME="$SNAME" BUILD_ARCH="${BUILD_ARCH}" \
        /bin/bash -x -c "cd /usr/src/lfs && make -f sources-iso LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
        mv $LFS/install/images/ipfire-* $BASEDIR >> $LOGFILE 2>&1
        if [ $? -eq "0" ]; then
index ca0ee51b6823c664e9c0a31571ac84177ce0ca80..0ed237bfcb7783ec1bcc43c10685096fd5592621 100755 (executable)
@@ -31,7 +31,7 @@ for dir in $@; do
                continue
        fi
 
-       for exclude in ${dir}/${MACHINE}/*; do
+       for exclude in ${dir}/${BUILD_ARCH}/*; do
                [ -f "${exclude}" ] || continue
                EXCLUDE="$EXCLUDE $exclude"
        done
@@ -52,4 +52,4 @@ for dir in $@; do
 done
 
 cat ${FILELIST} 2>/dev/null | grep -v ^# | sort | uniq | \
-       sed -e "s/KVER/${KVER}/g" -e "s/MACHINE/${MACHINE}/g" -e "s/BUILDTARGET/${BUILDTARGET}/g"
+       sed -e "s/KVER/${KVER}/g" -e "s/MACHINE/${BUILD_ARCH}/g" -e "s/BUILDTARGET/${BUILDTARGET}/g"
index 8ae50b4f074c4692dce5fdc185a59552ba58a49f..7417350a76d5b446560a3de5181675de1d3917e0 100644 (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