diff mbox series

[2/2] Makefile: simplify output of the libpath_template

Message ID 20240131174220.4160560-3-gitster@pobox.com (mailing list archive)
State New
Headers show
Series CC_LD_DYNPATH improvements | expand

Commit Message

Junio C Hamano Jan. 31, 2024, 5:42 p.m. UTC
If a platform lacks the support to specify the dynamic library path,
there is no suitable value to give to the CC_LD_DYNPATH variable.
Allow them to be set to an empty string to signal that they do not
need to add the usual -Wl,-rpath, or -R or whatever option followed
by a directory name.  This way,

    $(call libpath_tempate,$(SOMELIBDIR))

would expand to just a single mention of that directory, i.e.

    -L$(SOMELIBDIR)

when CC_LD_DYNPATH is set to an empty string (or a "-L", which
would have repeated the same "-L$(SOMELIBDIR)" twice without any
ill effect).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * This obviously makes it impossible to set CC_LD_DYNPATH to an
   empty string to say "-L /usr/local/lib /usr/local/lib" on the
   linker's command line.  I do not think it would serve any useful
   purpose to be able to have just a directory name on the command
   line of the linker there, so it would not regress anything on
   exotic platforms, I hope ;-).

 shared.mak | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Junio C Hamano Jan. 31, 2024, 10:59 p.m. UTC | #1
Junio C Hamano <gitster@pobox.com> writes:

> by a directory name.  This way,
>
>     $(call libpath_tempate,$(SOMELIBDIR))

"libpath_template" obviously.
diff mbox series

Patch

diff --git a/shared.mak b/shared.mak
index f33cab8a4e..c59cea75a1 100644
--- a/shared.mak
+++ b/shared.mak
@@ -112,5 +112,5 @@  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)
+-L$(1) $(if $(filter-out -L,$(CC_LD_DYNPATH)),$(CC_LD_DYNPATH)$(1))
 endef