From bcbb0dabf55d8b82a0b856c6e39458d42e933444 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Thu, 15 May 2014 12:09:16 +0200 Subject: [PATCH] Build-system support for creating host tools --- repos/base/mk/generic.mk | 9 +++++---- repos/base/mk/global.mk | 2 ++ repos/base/mk/lib.mk | 9 +++++++++ repos/base/mk/prg.mk | 5 +++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/repos/base/mk/generic.mk b/repos/base/mk/generic.mk index 8f865ead13..aa2a897cb7 100644 --- a/repos/base/mk/generic.mk +++ b/repos/base/mk/generic.mk @@ -24,20 +24,21 @@ $(SUB_DIRS): $(VERBOSE)mkdir -p $@ # -# Make sure, that we rebuild object files after Makefile changes +# Make sure that we rebuild object files and host tools after Makefile changes # -$(wildcard $(OBJECTS)): $(filter-out $(LIB_PROGRESS_LOG),$(MAKEFILE_LIST)) +$(wildcard $(OBJECTS)) $(HOST_TOOLS): $(filter-out $(LIB_PROGRESS_LOG),$(MAKEFILE_LIST)) INCLUDES := $(addprefix -I,$(wildcard $(ALL_INC_DIR))) # # If one of the 3rd-party ports used by the target changed, we need to rebuild -# all object files because they may include headers from the 3rd-party port. +# all object files and host tools because they may include sources from the +# 3rd-party port. # # The 'PORT_HASH_FILES' variable is populated as side effect of calling the # 'select_from_ports' function. # -$(OBJECTS): $(PORT_HASH_FILES) +$(OBJECTS) $(HOST_TOOLS): $(PORT_HASH_FILES) # # Include dependency files for the corresponding object files except diff --git a/repos/base/mk/global.mk b/repos/base/mk/global.mk index 08b7adbc88..3d95ebcc3d 100644 --- a/repos/base/mk/global.mk +++ b/repos/base/mk/global.mk @@ -21,6 +21,7 @@ CUSTOM_NM ?= $(CROSS_DEV_PREFIX)nm CUSTOM_OBJCOPY ?= $(CROSS_DEV_PREFIX)objcopy CUSTOM_RANLIB ?= $(CROSS_DEV_PREFIX)ranlib CUSTOM_STRIP ?= $(CROSS_DEV_PREFIX)strip +CUSTOM_HOST_CC ?= gcc # # GNU utilities @@ -45,6 +46,7 @@ NM = $(CUSTOM_NM) OBJCOPY = $(CUSTOM_OBJCOPY) RANLIB = $(CUSTOM_RANLIB) STRIP = $(CUSTOM_STRIP) +HOST_CC = $(CUSTOM_HOST_CC) # # Compiler and Linker options diff --git a/repos/base/mk/lib.mk b/repos/base/mk/lib.mk index 7db6a655dc..d51d7a1757 100644 --- a/repos/base/mk/lib.mk +++ b/repos/base/mk/lib.mk @@ -109,6 +109,15 @@ message: # all: $(LIB_TAG) +# +# Trigger the build of host tools +# +# We make '$(LIB_TAG)' depend on the host tools to support building host tools +# from pseudo libraries with no actual source code. In this case '$(OBJECTS)' +# is empty. +# +$(LIB_TAG) $(OBJECTS): $(HOST_TOOLS) + $(LIB_TAG): $(LIB_A) $(LIB_SO) $(INSTALL_SO) @touch $@ diff --git a/repos/base/mk/prg.mk b/repos/base/mk/prg.mk index 82e5d6de0a..3ca2cc8b61 100644 --- a/repos/base/mk/prg.mk +++ b/repos/base/mk/prg.mk @@ -181,6 +181,11 @@ endif LINK_ITEMS := $(OBJECTS) $(STATIC_LIBS) $(SHARED_LIBS) SHORT_LINK_ITEMS := $(subst $(LIB_CACHE_DIR),$$libs,$(LINK_ITEMS)) +# +# Trigger the build of host tools +# +$(LINK_ITEMS) $(TARGET): $(HOST_TOOLS) + LD_CMD += -Wl,--whole-archive -Wl,--start-group LD_CMD += $(SHORT_LINK_ITEMS) LD_CMD += $(EXT_OBJECTS)