diff --git a/make/environment-build.mk b/make/environment-build.mk index 7a28fc18..18fdd5e3 100644 --- a/make/environment-build.mk +++ b/make/environment-build.mk @@ -194,14 +194,6 @@ PKG_CONFIG_PATH = $(PKG_CONFIG_LIBDIR)/pkgconfig # ----------------------------------------------------------------------------- -# rewrite-"functions" -REWRITE_LIBTOOL_RULES = sed -i \ - -e "s,^libdir=.*,libdir='$(TARGET_LIB_DIR)'," \ - -e "s,\(^dependency_libs='\| \|-L\|^dependency_libs='\)/lib,\ $(TARGET_LIB_DIR),g" - -REWRITE_LIBTOOL = $(REWRITE_LIBTOOL_RULES) $(TARGET_LIB_DIR) -REWRITE_LIBTOOL_STATIC = $(REWRITE_LIBTOOL_RULES) $(STATIC_LIB_DIR) - REWRITE_CONFIG_RULES = sed -i \ -e "s,^prefix=.*,prefix='$(TARGET_DIR)'," \ -e "s,^exec_prefix=.*,exec_prefix='$(TARGET_DIR)'," \ diff --git a/make/helpers.mk b/make/helpers.mk index 990c5f8f..399f39f0 100644 --- a/make/helpers.mk +++ b/make/helpers.mk @@ -41,6 +41,32 @@ APPLY_PATCHES = $(call apply_patches, $(PKG_PATCHES_DIR)) # ----------------------------------------------------------------------------- +# rewrite libtool libraries +REWRITE_LIBTOOL_RULES = sed -i \ + -e "s,^libdir=.*,libdir='$(TARGET_LIB_DIR)'," \ + -e "s,\(^dependency_libs='\| \|-L\|^dependency_libs='\)/lib,\ $(TARGET_LIB_DIR),g" + +REWRITE_LIBTOOL = $(REWRITE_LIBTOOL_RULES) $(TARGET_LIB_DIR) +REWRITE_LIBTOOL_STATIC = $(REWRITE_LIBTOOL_RULES) $(STATIC_LIB_DIR) + +REWRITE_TAG = rewritten=1 + +define rewrite_libtool + cd $(TARGET_LIB_DIR); \ + for la in *.la; do \ + if ! grep -q "$(REWRITE_TAG)" $${la}; then \ + echo -e "$(TERM_YELLOW)Rewriting $${la}$(TERM_NORMAL)"; \ + $(REWRITE_LIBTOOL)/$${la}; \ + echo -e "\n# Adapted to buildsystem\n$(REWRITE_TAG)" >> $${la}; \ + fi; \ + done +endef + +# rewrite libtool libraries automatically +REWRITE_LIBTOOL_LA = $(call rewrite_libtool) + +# ----------------------------------------------------------------------------- + # # Manipulation of .config files based on the Kconfig infrastructure. # Used by the BusyBox package, the Linux kernel package, and more.