Skip to content

Commit bbfc63d

Browse files
author
Junio C Hamano
committed
gcc does not necessarily pass runtime libpath with -R
Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7c20b82 commit bbfc63d

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

Makefile

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ all:
7979
#
8080
# Define NO_ICONV if your libc does not properly support iconv.
8181
#
82+
# Define NO_R_TO_GCC if your gcc does not like "-R/path/lib" that
83+
# tells runtime paths to dynamic libraries; "-Wl,-rpath=/path/lib"
84+
# is used instead.
85+
#
8286
# Define USE_NSEC below if you want git to care about sub-second file mtimes
8387
# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
8488
# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
@@ -422,11 +426,19 @@ ifeq ($(uname_S),Darwin)
422426
endif
423427
endif
424428

429+
ifdef NO_R_TO_GCC_LINKER
430+
# Some gcc does not accept and pass -R to the linker to specify
431+
# the runtime dynamic library path.
432+
CC_LD_DYNPATH = -Wl,-rpath=
433+
else
434+
CC_LD_DYNPATH = -R
435+
endif
436+
425437
ifndef NO_CURL
426438
ifdef CURLDIR
427-
# This is still problematic -- gcc does not always want -R.
439+
# Try "-Wl,-rpath=$(CURLDIR)/lib" in such a case.
428440
BASIC_CFLAGS += -I$(CURLDIR)/include
429-
CURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl
441+
CURL_LIBCURL = -L$(CURLDIR)/lib $(CC_LD_DYNPATH)$(CURLDIR)/lib -lcurl
430442
else
431443
CURL_LIBCURL = -lcurl
432444
endif
@@ -445,9 +457,8 @@ endif
445457
ifndef NO_OPENSSL
446458
OPENSSL_LIBSSL = -lssl
447459
ifdef OPENSSLDIR
448-
# Again this may be problematic -- gcc does not always want -R.
449460
BASIC_CFLAGS += -I$(OPENSSLDIR)/include
450-
OPENSSL_LINK = -L$(OPENSSLDIR)/lib -R$(OPENSSLDIR)/lib
461+
OPENSSL_LINK = -L$(OPENSSLDIR)/lib $(CC_LD_DYNPATH)$(OPENSSLDIR)/lib
451462
else
452463
OPENSSL_LINK =
453464
endif
@@ -463,9 +474,8 @@ else
463474
endif
464475
ifdef NEEDS_LIBICONV
465476
ifdef ICONVDIR
466-
# Again this may be problematic -- gcc does not always want -R.
467477
BASIC_CFLAGS += -I$(ICONVDIR)/include
468-
ICONV_LINK = -L$(ICONVDIR)/lib -R$(ICONVDIR)/lib
478+
ICONV_LINK = -L$(ICONVDIR)/lib $(CC_LD_DYNPATH)$(ICONVDIR)/lib
469479
else
470480
ICONV_LINK =
471481
endif

0 commit comments

Comments
 (0)