{"thread":{"id":"6131","subject":"gcc -L/path/lib -R/path/lib","startedAt":"2006-12-27T22:13:39Z","lastAt":"2006-12-27T22:13:39Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"30367","messageId":"7v1wml56ng.fsf@assigned-by-dhcp.cox.net","threadId":"6131","inReplyTo":null,"subject":"gcc -L/path/lib -R/path/lib","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-27T22:13:39Z","receivedAt":"2006-12-27T22:13:39Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"While trying git with cURL 7.16.0, I found that in my\nenvironment (Debian x86-64, mostly testing, with gcc 4.1.2\nprerelease), gcc does not seem to like -R/path/lib to be used to\nspecify the runtime library paths.\n\nI am a bit surprised if nobody had this issue before, so I might\nbe reinventing the wheel and in a wrong/suboptimal way, but this\npatch seems to work around the issue for me.\n\nComments?\n\n\ndiff --git a/Makefile b/Makefile\nindex 52d4a3a..7b24323 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -79,6 +79,10 @@ all:\n #\n # Define NO_ICONV if your libc does not properly support iconv.\n #\n+# Define NO_R_TO_GCC if your gcc does not like \"-R/path/lib\" that\n+# tells runtime paths for dynamic libraries; \"-Wl,-rpath=/path/lib\"\n+# is used instead.\n+#\n # Define USE_NSEC below if you want git to care about sub-second file mtimes\n # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and\n # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely\n@@ -422,11 +426,19 @@ ifeq ($(uname_S),Darwin)\n \tendif\n endif\n \n+ifdef NO_R_TO_GCC_LINKER\n+\t# Some gcc does not accept and pass -R to the linker to specify\n+\t# the runtime dynamic library path.\n+\tCC_LD_DYNPATH = -Wl,-rpath=\n+else\n+\tCC_LD_DYNPATH = -R\n+endif\n+\n ifndef NO_CURL\n \tifdef CURLDIR\n-\t\t# This is still problematic -- gcc does not always want -R.\n+\t\t# Try \"-Wl,-rpath=$(CURLDIR)/lib\" in such a case.\n \t\tBASIC_CFLAGS += -I$(CURLDIR)/include\n-\t\tCURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl\n+\t\tCURL_LIBCURL = -L$(CURLDIR)/lib $(CC_LD_DYNPATH)$(CURLDIR)/lib -lcurl\n \telse\n \t\tCURL_LIBCURL = -lcurl\n \tendif\n@@ -445,9 +457,8 @@ endif\n ifndef NO_OPENSSL\n \tOPENSSL_LIBSSL = -lssl\n \tifdef OPENSSLDIR\n-\t\t# Again this may be problematic -- gcc does not always want -R.\n \t\tBASIC_CFLAGS += -I$(OPENSSLDIR)/include\n-\t\tOPENSSL_LINK = -L$(OPENSSLDIR)/lib -R$(OPENSSLDIR)/lib\n+\t\tOPENSSL_LINK = -L$(OPENSSLDIR)/lib $(CC_LD_DYNPATH)$(OPENSSLDIR)/lib\n \telse\n \t\tOPENSSL_LINK =\n \tendif\n@@ -463,9 +474,8 @@ else\n endif\n ifdef NEEDS_LIBICONV\n \tifdef ICONVDIR\n-\t\t# Again this may be problematic -- gcc does not always want -R.\n \t\tBASIC_CFLAGS += -I$(ICONVDIR)/include\n-\t\tICONV_LINK = -L$(ICONVDIR)/lib -R$(ICONVDIR)/lib\n+\t\tICONV_LINK = -L$(ICONVDIR)/lib $(CC_LD_DYNPATH)$(ICONVDIR)/lib\n \telse\n \t\tICONV_LINK =\n \tendif\n"}]}