From a94d74d9c875b4a1c07945bf9af282221d0178b3 Mon Sep 17 00:00:00 2001
From: Waldemar Brodkorb <wbx@openadk.org>
Date: Sun, 13 Dec 2015 17:18:40 +0100
Subject: rework prereq check

The new prereq check is completely implemented in
POSIX shell in scripts/prereq.sh.

It combines the old features from Makefile, scan-tools.sh,
scan-pkgs.sh, reloc.sh and some wrappers for tools.

The big benefit is to have all portability stuff in one place.
Furthermore we can compile GNU make and bash on the fly, for
systems lacking the required tools.
All changes on the host are detected on the fly, no make
prereq required anymore.

The build process is separated in following three phases:
1. small wrapper Makefile is used for BSD make or GNU make
2. prereq.sh is called, doing all checking, calling Makefile.adk
3. old logic in Makefile.adk or mk/build.mk is used

Tested successfully on Linux, MacOS X, Cygwin, FreeBSD, OpenBSD
and NetBSD.

An old depmaker bug was fixed, only optional host tools are compiled.
For example, even when a host provides xz, a local xz was compiled
in the past, because other packages had a build dependency on it.

Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
---
 toolchain/Makefile | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

(limited to 'toolchain/Makefile')

diff --git a/toolchain/Makefile b/toolchain/Makefile
index b1c24f78c..7b24b9a4c 100644
--- a/toolchain/Makefile
+++ b/toolchain/Makefile
@@ -61,11 +61,13 @@ gcc-install: $(ELF2FLT) $(CLIB)-install
 gcc-final: gcc-install $(GDB)
 
 %-download:
-	$(TRACE) toolchain/$(patsubst %-download,%,$@)/download
+	$(START_TRACE) "toolchain/$(patsubst %-download,%,$@)/download.. "
 	$(MAKE) -C $(patsubst %-download,%,$@) fetch
+	$(CMD_TRACE) " done"
+	$(END_TRACE)
 
 %-prepare:
-	$(TRACE) toolchain/$(patsubst %-prepare,%,$@)/prepare
+	$(START_TRACE) "toolchain/$(patsubst %-prepare,%,$@)/prepare.. "
 	@if test x"$(patsubst %-prepare,%,$@)" = x"$(CLIB)"; then \
 		$(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
 		    $(MAKE_TRACE); \
@@ -73,9 +75,11 @@ gcc-final: gcc-install $(GDB)
 		$(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
 		    CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
 	fi
+	$(CMD_TRACE) " done"
+	$(END_TRACE)
 
 %-configure: %-prepare
-	$(TRACE) toolchain/$(patsubst %-configure,%,$@)/configure
+	$(START_TRACE) "toolchain/$(patsubst %-configure,%,$@)/configure.. "
 	@if test x"$(patsubst %-configure,%,$@)" = x"$(CLIB)"; then \
 		$(MAKE) -C $(patsubst %-configure,%,$@) configure \
 		    $(MAKE_TRACE); \
@@ -83,9 +87,11 @@ gcc-final: gcc-install $(GDB)
 		$(MAKE) -C $(patsubst %-configure,%,$@) configure \
 		    CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
 	fi
+	$(CMD_TRACE) " done"
+	$(END_TRACE)
 
 %-compile: %-configure
-	$(TRACE) toolchain/$(patsubst %-compile,%,$@)/compile
+	$(START_TRACE) "toolchain/$(patsubst %-compile,%,$@)/compile.. "
 	@if test x"$(patsubst %-compile,%,$@)" = x"$(CLIB)"; then \
 		$(MAKE) -C $(patsubst %-compile,%,$@) compile \
 		    $(MAKE_TRACE); \
@@ -93,9 +99,11 @@ gcc-final: gcc-install $(GDB)
 		$(MAKE) -C $(patsubst %-compile,%,$@) compile \
 		    CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
 	fi
+	$(CMD_TRACE) " done"
+	$(END_TRACE)
 
 %-install: %-compile
-	$(TRACE) toolchain/$(patsubst %-install,%,$@)/install
+	$(START_TRACE) "toolchain/$(patsubst %-install,%,$@)/install.. "
 	@if test x"$(patsubst %-install,%,$@)" = x"$(CLIB)"; then \
 		$(MAKE) -C $(patsubst %-install,%,$@) install \
 		    $(MAKE_TRACE); \
@@ -103,11 +111,17 @@ gcc-final: gcc-install $(GDB)
 		$(MAKE) -C $(patsubst %-install,%,$@) install \
 		    CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
 	fi
+	$(CMD_TRACE) " done"
+	$(END_TRACE)
 
 %-final: %-install
-	$(TRACE) toolchain/$(patsubst %-final,%,$@)/final
+	$(START_TRACE) "toolchain/$(patsubst %-final,%,$@)/final.. "
 	@$(MAKE) -C $(patsubst %-final,%,$@) final $(MAKE_TRACE)
+	$(CMD_TRACE) " done"
+	$(END_TRACE)
 
 %-clean:
-	$(TRACE) toolchain/$(patsubst %-clean,%,$@)/clean
+	$(START_TRACE) "toolchain/$(patsubst %-clean,%,$@)/clean.. "
 	@$(MAKE) -C $(patsubst %-clean,%,$@) clean $(MAKE_TRACE)
+	$(CMD_TRACE) " done"
+	$(END_TRACE)
-- 
cgit v1.2.3