{"thread":{"id":"14985","subject":"[PATCH] Add tests for \"-R\" and \"-Wl,-rpath,\" switches in configure script.","startedAt":"2008-08-13T15:16:14Z","lastAt":"2008-08-13T15:16:14Z","messageCount":1,"participants":["Giovanni Funchal"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"87060","messageId":"1218640574-13181-1-git-send-email-gafunchal@gmail.com","threadId":"14985","inReplyTo":null,"subject":"[PATCH] Add tests for \"-R\" and \"-Wl,-rpath,\" switches in configure script.","fromName":"Giovanni Funchal","fromEmail":"gafunchal@gmail.com","sentAt":"2008-08-13T15:16:14Z","receivedAt":"2008-08-13T15:16:14Z","isPatch":true,"sender":{"key":"gafunchal@gmail.com","avatar":"https://gravatar.com/avatar/96f8068bdfb134f61682ec4a9741b71b582efa9d102055028a88643507644e9c?d=mp&s=160"},"body":"Add tests for \"-R\" and \"-Wl,-rpath,\" switches in configure script.\nReplace NO_R_TO_GCC_LINKER and CC_LD_DYNPATH by USE_RUNPATH and RUNPATH_SWITCH which have different semantics.\nAdd a warning if user must set LD_LIBRARY_PATH manually.\n\nSigned-Off-By: Giovanni Funchal <gafunchal@gmail.com>\n---\n Makefile      |   66 ++++++++++++++++++++++++++++++++++++++++----------------\n config.mak.in |    2 +\n configure.ac  |   28 ++++++++++++++++++++++++\n 3 files changed, 77 insertions(+), 19 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 90c5a13..aa9a6a5 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -111,9 +111,10 @@ all::\n #\n # Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.\n #\n-# Define NO_R_TO_GCC_LINKER if your gcc does not like \"-R/path/lib\"\n-# that tells runtime paths to dynamic libraries;\n-# \"-Wl,-rpath=/path/lib\" is used instead.\n+# USE_RUNPATH and RUNPATH_SWITCH define if and how to pass the runtime\n+# dynamic library paths to the linker. The default is \"-Wl,-rpath,\". If\n+# you don't use runpath, you will always need to set LD_LIBRARY_PATH\n+# manually before running git.\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@@ -217,6 +218,7 @@ GITWEB_SITE_FOOTER =\n \n export prefix bindir sharedir htmldir sysconfdir\n \n+# defaults, possibly overridden by config.mak.autogen\n CC = gcc\n AR = ar\n RM = rm -f\n@@ -226,6 +228,8 @@ INSTALL = install\n RPMBUILD = rpmbuild\n TCL_PATH = tclsh\n TCLTK_PATH = wish\n+USE_RUNPATH = yes\n+RUNPATH_SWITCH = -Wl,-rpath,\n \n export TCL_PATH TCLTK_PATH\n \n@@ -689,7 +693,6 @@ ifeq ($(uname_S),NetBSD)\n \tendif\n \tBASIC_CFLAGS += -I/usr/pkg/include\n \tBASIC_LDFLAGS += -L/usr/pkg/lib\n-\tALL_LDFLAGS += -Wl,-rpath,/usr/pkg/lib\n endif\n ifeq ($(uname_S),AIX)\n \tNO_STRCASESTR=YesPlease\n@@ -766,6 +769,13 @@ endif\n -include config.mak.autogen\n -include config.mak\n \n+ifeq ($(uname_S),NetBSD) # must go after the 'include'\n+\tifeq ($(USE_RUNPATH),no)\n+\t\tADD_RUNPATH += /usr/pkg/lib\n+\telse\n+\t\tALL_LDFLAGS += $(RUNPATH_SWITCH)/usr/pkg/lib\n+\tendif\n+endif\n ifeq ($(uname_S),Darwin)\n \tifndef NO_FINK\n \t\tifeq ($(shell test -d /sw/lib && echo y),y)\n@@ -781,24 +791,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 ifdef NO_CURL\n \tBASIC_CFLAGS += -DNO_CURL\n else\n \tifdef CURLDIR\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) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib) -lcurl\n-\telse\n-\t\tCURL_LIBCURL = -lcurl\n+\t\tCURL_LIBCURL = -L$(CURLDIR)/$(lib)\n+\t\tifeq ($(USE_RUNPATH),no)\n+\t\t\tADD_RUNPATH += $(CURLDIR)/$(lib)\n+\t\telse\n+\t\t\tCURL_LIBCURL += $(RUNPATH_SWITCH)$(CURLDIR)/$(lib)\n+\t\tendif\n \tendif\n+\tCURL_LIBCURL += -lcurl\n \tBUILTIN_OBJS += builtin-http-fetch.o\n \tEXTLIBS += $(CURL_LIBCURL)\n \tLIB_OBJS += http.o http-walker.o\n@@ -815,7 +820,12 @@ endif\n \n ifdef ZLIB_PATH\n \tBASIC_CFLAGS += -I$(ZLIB_PATH)/include\n-\tEXTLIBS += -L$(ZLIB_PATH)/$(lib) $(CC_LD_DYNPATH)$(ZLIB_PATH)/$(lib)\n+\tifeq ($(USE_RUNPATH),no)\n+\t\tADD_RUNPATH += $(ZLIB_PATH)/$(lib)\n+\t\tEXTLIBS += -L$(ZLIB_PATH)/$(lib)\n+\telse\n+\t\tEXTLIBS += -L$(ZLIB_PATH)/$(lib) $(RUNPATH_SWITCH)$(ZLIB_PATH)/$(lib)\n+\tendif\n endif\n EXTLIBS += -lz\n \n@@ -828,7 +838,12 @@ ifndef NO_OPENSSL\n \tOPENSSL_LIBSSL = -lssl\n \tifdef OPENSSLDIR\n \t\tBASIC_CFLAGS += -I$(OPENSSLDIR)/include\n-\t\tOPENSSL_LINK = -L$(OPENSSLDIR)/$(lib) $(CC_LD_DYNPATH)$(OPENSSLDIR)/$(lib)\n+\t\tOPENSSL_LINK = -L$(OPENSSLDIR)/$(lib)\n+\t\tifeq ($(USE_RUNPATH),no)\n+\t\t\tADD_RUNPATH += $(OPENSSLDIR)/$(lib)\n+\t\telse\n+\t\t\tOPENSSL_LINK += $(RUNPATH_SWITCH)$(OPENSSLDIR)/$(lib)\n+\t\tendif\n \telse\n \t\tOPENSSL_LINK =\n \tendif\n@@ -845,7 +860,12 @@ endif\n ifdef NEEDS_LIBICONV\n \tifdef ICONVDIR\n \t\tBASIC_CFLAGS += -I$(ICONVDIR)/include\n-\t\tICONV_LINK = -L$(ICONVDIR)/$(lib) $(CC_LD_DYNPATH)$(ICONVDIR)/$(lib)\n+\t\tICONV_LINK = -L$(ICONVDIR)/$(lib)\n+\t\tifeq ($(USE_RUNPATH),no)\n+\t\t\tADD_RUNPATH += $(ICONVDIR)/$(lib)\n+\t\telse\n+\t\t\tICONV_LINK = $(RUNPATH_SWITCH)$(ICONVDIR)/$(lib)\n+\t\tendif\n \telse\n \t\tICONV_LINK =\n \tendif\n@@ -1027,6 +1047,9 @@ endif\n ifdef ASCIIDOC8\n \texport ASCIIDOC8\n endif\n+ifdef ADD_RUNPATH\n+\texport ADD_RUNPATH\n+endif\n \n # Shell quote (do not use $(call) to accommodate ancient setups);\n \n@@ -1075,6 +1098,11 @@ endif\n \t$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all\n \t$(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)\n \n+ifeq ($(USE_RUNPATH),no)\n+all::\n+\t@echo WARNING: Remember to add $(ADD_RUNPATH) to your LD_LIBRARY_PATH before execution!\n+endif\n+\n please_set_SHELL_PATH_to_a_more_modern_shell:\n \t@$$(:)\n \ndiff --git a/config.mak.in b/config.mak.in\nindex b776149..f01be45 100644\n--- a/config.mak.in\n+++ b/config.mak.in\n@@ -7,6 +7,8 @@ AR = @AR@\n TAR = @TAR@\n #INSTALL = @INSTALL@\t\t# needs install-sh or install.sh in sources\n TCLTK_PATH = @TCLTK_PATH@\n+USE_RUNPATH = @USE_RUNPATH@\n+RUNPATH_SWITCH = @RUNPATH_SWITCH@\n \n prefix = @prefix@\n exec_prefix = @exec_prefix@\ndiff --git a/configure.ac b/configure.ac\nindex 7c2856e..c589cbc 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -103,6 +103,34 @@ GIT_PARSE_WITH(tcltk))\n AC_MSG_NOTICE([CHECKS for programs])\n #\n AC_PROG_CC([cc gcc])\n+# linker support for setting runtime path to dynamic libraries\n+AC_CACHE_VAL(git_cv_use_runpath, [\n+   AC_CACHE_CHECK([[if linker supports -R]], git_cv_ld_dashr, [\n+      SAVE_LDFLAGS=\"${LDFLAGS}\"\n+      LDFLAGS=\"${SAVE_LDFLAGS} -R /\"\n+      AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [git_cv_ld_dashr=yes], [git_cv_ld_dashr=no])\n+      LDFLAGS=\"${SAVE_LDFLAGS}\"\n+   ])\n+   if test \"$git_cv_ld_dashr\" = \"yes\"; then\n+      git_cv_use_runpath=yes\n+      AC_SUBST(RUNPATH_SWITCH, [-R])\n+   else\n+      AC_CACHE_CHECK([[if linker supports -Wl,rpath,]], git_cv_ld_wl_rpath, [\n+         SAVE_LDFLAGS=\"${LDFLAGS}\"\n+         LDFLAGS=\"${SAVE_LDFLAGS} -Wl,-rpath,/\"\n+         AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [git_cv_ld_wl_rpath=yes], [git_cv_ld_wl_rpath=no])\n+         LDFLAGS=\"${SAVE_LD_FLAGS}\"\n+      ])\n+      if test \"$ld_wl_rpath\" = \"yes\"; then\n+         git_cv_use_runpath=yes\n+         AC_SUBST(RUNPATH_SWITCH, [-Wl,-rpath,])\n+      else\n+         git_cv_use_runpath=no\n+         AC_MSG_WARN([linker does not support runtime path to dynamic libraries])\n+      fi\n+   fi\n+])\n+AC_SUBST(USE_RUNPATH, $git_cv_use_runpath)\n #AC_PROG_INSTALL\t\t# needs install-sh or install.sh in sources\n AC_CHECK_TOOLS(AR, [gar ar], :)\n AC_CHECK_PROGS(TAR, [gtar tar])\n-- \n1.5.4.3\n"}]}