Skip to content

Commit 3bd5c81

Browse files
author
Junio C Hamano
committed
Merge branch 'jc/make'
* jc/make: gcc does not necessarily pass runtime libpath with -R
2 parents b81ba57 + bbfc63d commit 3bd5c81

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
@@ -421,11 +425,19 @@ ifeq ($(uname_S),Darwin)
421425
endif
422426
endif
423427

428+
ifdef NO_R_TO_GCC_LINKER
429+
# Some gcc does not accept and pass -R to the linker to specify
430+
# the runtime dynamic library path.
431+
CC_LD_DYNPATH = -Wl,-rpath=
432+
else
433+
CC_LD_DYNPATH = -R
434+
endif
435+
424436
ifndef NO_CURL
425437
ifdef CURLDIR
426-
# This is still problematic -- gcc does not always want -R.
438+
# Try "-Wl,-rpath=$(CURLDIR)/lib" in such a case.
427439
BASIC_CFLAGS += -I$(CURLDIR)/include
428-
CURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl
440+
CURL_LIBCURL = -L$(CURLDIR)/lib $(CC_LD_DYNPATH)$(CURLDIR)/lib -lcurl
429441
else
430442
CURL_LIBCURL = -lcurl
431443
endif
@@ -444,9 +456,8 @@ endif
444456
ifndef NO_OPENSSL
445457
OPENSSL_LIBSSL = -lssl
446458
ifdef OPENSSLDIR
447-
# Again this may be problematic -- gcc does not always want -R.
448459
BASIC_CFLAGS += -I$(OPENSSLDIR)/include
449-
OPENSSL_LINK = -L$(OPENSSLDIR)/lib -R$(OPENSSLDIR)/lib
460+
OPENSSL_LINK = -L$(OPENSSLDIR)/lib $(CC_LD_DYNPATH)$(OPENSSLDIR)/lib
450461
else
451462
OPENSSL_LINK =
452463
endif
@@ -462,9 +473,8 @@ else
462473
endif
463474
ifdef NEEDS_LIBICONV
464475
ifdef ICONVDIR
465-
# Again this may be problematic -- gcc does not always want -R.
466476
BASIC_CFLAGS += -I$(ICONVDIR)/include
467-
ICONV_LINK = -L$(ICONVDIR)/lib -R$(ICONVDIR)/lib
477+
ICONV_LINK = -L$(ICONVDIR)/lib $(CC_LD_DYNPATH)$(ICONVDIR)/lib
468478
else
469479
ICONV_LINK =
470480
endif

0 commit comments

Comments
 (0)