From 354dbf7d649ef75c2f83d0f1d7cc03d1e84279dc Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 31 Jan 2024 09:42:19 -0800 Subject: Makefile: reduce repetitive library paths When we take a library package we depend on (e.g., LIBPCRE) from a directory other than the default location of the system, we add the same directory twice on the linker command like, like so: EXTLIBS += -L$(LIBPCREDIR)/$(lib) $(CC_LD_DYNPATH)$(LIBPCREDIR)/$(lib) Introduce a template "libpath_template" that takes the path to the directory, which can be used like so: EXTLIBS += $(call libpath_template,$(LIBPCREDIR)/$(lib)) and expand it into the "-L$(DIR) $(CC_LD_DYNPATH)$(DIR)" form. Hopefully we can reduce the chance of typoes this way. Signed-off-by: Junio C Hamano --- shared.mak | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'shared.mak') diff --git a/shared.mak b/shared.mak index aeb80fc4d5..f33cab8a4e 100644 --- a/shared.mak +++ b/shared.mak @@ -108,3 +108,9 @@ endif define mkdir_p_parent_template $(if $(wildcard $(@D)),,$(QUIET_MKDIR_P_PARENT)$(shell mkdir -p $(@D))) endef + +## Getting sick of writing -L$(SOMELIBDIR) $(CC_LD_DYNPATH)$(SOMELIBDIR)? +## Write $(call libpath_template,$(SOMELIBDIR)) instead, perhaps? +define libpath_template +-L$(1) $(CC_LD_DYNPATH)$(1) +endef -- cgit v1.2.3