build: use -iremap feature to replace __FILE__ absolute path names in packages with...
authorFelix Fietkau <nbd@openwrt.org>
Mon, 25 Jan 2016 15:49:31 +0000 (15:49 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 25 Jan 2016 15:49:31 +0000 (15:49 +0000)
improves reproducible builds

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
SVN-Revision: 48489

include/package.mk
rules.mk

index 1dfbd68d33f7ee35c413791b01eb3e4a5ca0c312..ca315b59acee8e1c729fe9ae3080603796f61800 100644 (file)
@@ -14,6 +14,7 @@ PKG_INSTALL_DIR ?= $(PKG_BUILD_DIR)/ipkg-install
 PKG_MD5SUM ?= unknown
 PKG_BUILD_PARALLEL ?=
 PKG_USE_MIPS16 ?= 1
+PKG_IREMAP ?= 1
 
 ifneq ($(CONFIG_PKG_BUILD_USE_JOBSERVER),)
   MAKE_J:=$(if $(MAKE_JOBSERVER),$(MAKE_JOBSERVER) -j)
@@ -33,6 +34,10 @@ ifdef CONFIG_USE_MIPS16
     TARGET_CFLAGS += -mips16 -minterlink-mips16
   endif
 endif
+ifeq ($(strip $(PKG_IREMAP)),1)
+  IREMAP_CFLAGS = $(call iremap,$(PKG_BUILD_DIR),$(notdir $(PKG_BUILD_DIR)))
+  TARGET_CFLAGS += $(IREMAP_CFLAGS)
+endif
 
 include $(INCLUDE_DIR)/hardening.mk
 include $(INCLUDE_DIR)/prereq.mk
index 11ed80950a786ef2856059f8e353f4798b8e0e8b..b4bdc0dd6eb4eafa20e2d4b02865c1868995b688 100644 (file)
--- a/rules.mk
+++ b/rules.mk
@@ -118,6 +118,10 @@ else
   TOOLCHAIN_DIR_NAME:=toolchain-$(GNU_TARGET_NAME)
 endif
 
+ifeq ($(or $(CONFIG_EXTERNAL_TOOLCHAIN),$(CONFIG_GCC_VERSION_4_8)),)
+  iremap = -iremap $(1):$(2)
+endif
+
 PACKAGE_DIR:=$(BIN_DIR)/packages
 BUILD_DIR:=$(BUILD_DIR_BASE)/$(TARGET_DIR_NAME)
 STAGING_DIR:=$(TOPDIR)/staging_dir/$(TARGET_DIR_NAME)