Build GNU make-4.2 if the system make is the wrong version (issue #88).

Change all of the builds to use $(MAKE) instead of the /usr/bin/make.

Download and build GNU make-4.2 if the wrong version is installed
on the system.

Re-invoke build/make-4.2/make with the target that was passed in once
the correct make has been built.
This commit is contained in:
Trammell Hudson 2017-01-27 16:17:03 -05:00 committed by Trammell Hudson
parent 7294fa9438
commit 24e54a65f6
Failed to extract signature
6 changed files with 59 additions and 10 deletions

View File

@ -5,6 +5,14 @@ build := $(pwd)/build
config := $(pwd)/build
INSTALL := $(pwd)/install
# Check that we have a correct version of make
LOCAL_MAKE_VERSION := $(shell $(MAKE) --version | head -1 | cut -d' ' -f3)
include modules/make
ifeq "$(LOCAL_MAKE_VERSION)" "$(make_version)"
# We are running our own version of make,
# proceed with the build.
# Currently supported targets are x230, chell and qemu
BOARD ?= qemu
@ -12,6 +20,7 @@ BOARD ?= qemu
# variable to point to it.
musl_dep := musl
heads_cc := $(INSTALL)/bin/musl-gcc
#heads_cc := $(HOME)/install/x86_64-linux-musl/x86_64-linux-musl/bin/gcc
all: $(BOARD).rom
@ -108,7 +117,7 @@ define define_module =
$(foreach d,$($1_depends),$(call outputs,$d)) \
$(foreach d,$($1_depends),$d.intermediate) \
$(build)/$($1_dir)/.configured
make -C "$(build)/$($1_dir)" $($1_target)
$(MAKE) -C "$(build)/$($1_dir)" $($1_target)
.INTERMEDIATE: $1.intermediate
endef
@ -168,7 +177,7 @@ initrd_bins += initrd/bin/busybox
initrd/bin/busybox: $(build)/$(busybox_dir)/busybox
cmp --quiet "$@" "$^" || \
make \
$(MAKE) \
-C $(build)/$(busybox_dir) \
CC="$(heads_cc)" \
CONFIG_PREFIX="$(pwd)/initrd" \
@ -184,7 +193,7 @@ initrd/bin/cbmem: $(build)/$(coreboot_dir)/util/cbmem/cbmem
$(build)/$(coreboot_dir)/util/cbmem/cbmem: \
$(build)/$(coreboot_dir)/.canary \
musl.intermediate
make -C "$(dir $@)" CC="$(heads_cc)"
$(MAKE) -C "$(dir $@)" CC="$(heads_cc)"
# Update all of the libraries in the initrd based on the executables
@ -262,6 +271,33 @@ qemu.rom: $(build)/$(coreboot_dir)/qemu/coreboot.rom
clean-modules:
for dir in busybox-1.25.0 cryptsetup-1.7.3 gnupg-1.4.21 kexec-tools-2.0.12 libuuid-1.0.3 LVM2.2.02.168 mbedtls-2.3.0 popt-1.16 qrencode-3.4.4 tpmtotp-git ; do \
make -C build/$$dir clean; \
$(MAKE) -C build/$$dir clean; \
rm build/$$dir/.configured; \
done
else
# Wrong make version detected -- build our local version
# and re-invoke the Makefile with it instead.
$(info Wrong make detected: $(LOCAL_MAKE_VERSION))
HEADS_MAKE := $(build)/$(make_dir)/make
# Once we have a proper Make, we can just pass arguments into it
%: $(HEADS_MAKE)
LANG=C MAKE=$(HEADS_MAKE) $(HEADS_MAKE) $@
all:
# How to download and build the correct version of make
$(HEADS_MAKE): $(build)/$(make_dir)/Makefile
make -C "`dirname $@`" -j8
$(build)/$(make_dir)/Makefile: $(packages)/$(make_tar)
tar xf "$<" -C build/
cd "`dirname $@`" ; ./configure
$(packages)/$(make_tar):
wget -O "$@" "$(make_url)"
if ! echo "$(make_hash) $@" | sha256sum --check -; then \
$(MV) "$@" "$@.failed"; \
false; \
fi
endif

View File

@ -6,7 +6,7 @@ busybox_tar := busybox-$(busybox_version).tar.bz2
busybox_url := https://busybox.net/downloads/$(busybox_tar)
busybox_hash := 5a0fe06885ee1b805fb459ab6aaa023fe4f2eccee4fb8c0fd9a6c17c0daca2fc
busybox_configure := make CC=$(heads_cc) oldconfig
busybox_configure := $(MAKE) CC=$(heads_cc) oldconfig
busybox_config := busybox.config
busybox_output := busybox
busybox_target := \

View File

@ -14,7 +14,7 @@ coreboot_repo := https://github.com/osresearch/coreboot
#coreboot_config := coreboot-$(TARGET).config
coreboot_configure := \
make oldconfig obj=./$(BOARD) DOTCONFIG=../../config/coreboot-$(BOARD).config
$(MAKE) oldconfig obj=./$(BOARD) DOTCONFIG=../../config/coreboot-$(BOARD).config
coreboot_target := \
obj=./$(BOARD) DOTCONFIG=../../config/coreboot-$(BOARD).config -j 8
@ -26,9 +26,9 @@ coreboot_output := $(BOARD)/coreboot.rom
$(build)/$(coreboot_dir)/.configured: $(build)/$(coreboot_dir)/util/crossgcc/xgcc/bin/i386-elf-gcc
$(build)/$(coreboot_dir)/util/crossgcc/xgcc/bin/i386-elf-gcc:
echo '******* Building crossgcc-i386 (this might take a while) ******'
make -C "$(build)/$(coreboot_dir)" crossgcc-i386
$(MAKE) -C "$(build)/$(coreboot_dir)" crossgcc-i386
#echo '******* Building crossgcc-arm (this might take a while) ******'
#make -C "$(build)/$(coreboot_dir)" crossgcc-arm
#$(MAKE) -C "$(build)/$(coreboot_dir)" crossgcc-arm
# The coreboot-blobs must be unpacked before we can build coreboot
# if we are using a tar file; git checkout will clone the submodule.

View File

@ -13,7 +13,7 @@ kexec_configure := ./configure \
--prefix="$(INSTALL)" \
--without-zlib \
--without-lzma \
&& make clean
&& $(MAKE) clean
kexec_target := \
install \

View File

@ -11,7 +11,7 @@ linux-4.9_hash := 029098dcffab74875e086ae970e3828456838da6e0ba22ce3f64ef764f3d7f
linux_hash := $(linux-$(linux_version)_hash)
linux_configure := make oldconfig
linux_configure := $(MAKE) oldconfig
linux_output := arch/x86/boot/bzImage
linux_config := linux.config
linux_target := -j 8 bzImage

13
modules/make Normal file
View File

@ -0,0 +1,13 @@
# This is not added to the module list since it is a special case
# of things that need to be built for the host system, instead of the
# target platform.
#modules += make
make_version := 4.2
make_dir := make-$(make_version)
make_tar := make-$(make_version).tar.bz2
make_url := http://gnu.mirror.constant.com/make/$(make_tar)
make_hash := 4e5ce3b62fe5d75ff8db92b7f6df91e476d10c3aceebf1639796dc5bfece655f
# This is built for the local machine, not the target, so it doesn't have any
# of the build instructions.