Build-system support for creating host tools

This commit is contained in:
Norman Feske 2014-05-15 12:09:16 +02:00
parent de65c3f7cc
commit bcbb0dabf5
4 changed files with 21 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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 $@

View File

@ -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)