@matheusbsbs / matheus-bagliano / commits / 798a945002
Fork 0

configure: auto detect dynamic library path switches

Most systems (e.g. Linux gcc) use "-Wl,-rpath," to pass to the linker the runtime dynamic library paths. Some other systems (e.g. Sun, some BSD) use "-R" etc. This patch adds tests in configure for the three most common switches (to my best knowledge) which should cover all current platforms where Git is used. Signed-Off-By: Giovanni Funchal <gafunchal@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Giovanni Funchal committed Aug 16, 2008 at 15:01 UTC 798a94500230e4d2a1a18f005fe9592454fe451b
2 files changed +33
config.mak.in
+1
@@ -3,6 +3,7 @@
3
4 CC = @CC@
5 CFLAGS = @CFLAGS@
6 +CC_LD_DYNPATH = @CC_LD_DYNPATH@
7 AR = @AR@
8 TAR = @TAR@
9 #INSTALL = @INSTALL@ # needs install-sh or install.sh in sources
configure.ac
+32
@@ -103,6 +103,38 @@ GIT_PARSE_WITH(tcltk))
103 AC_MSG_NOTICE([CHECKS for programs])
104 #
105 AC_PROG_CC([cc gcc])
106 +# which switch to pass runtime path to dynamic libraries to the linker
107 +AC_CACHE_CHECK([if linker supports -R], ld_dashr, [
108 + SAVE_LDFLAGS="${LDFLAGS}"
109 + LDFLAGS="${SAVE_LDFLAGS} -R /"
110 + AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [ld_dashr=yes], [ld_dashr=no])
111 + LDFLAGS="${SAVE_LDFLAGS}"
112 +])
113 +if test "$ld_dashr" = "yes"; then
114 + AC_SUBST(CC_LD_DYNPATH, [-R])
115 +else
116 + AC_CACHE_CHECK([if linker supports -Wl,-rpath,], ld_wl_rpath, [
117 + SAVE_LDFLAGS="${LDFLAGS}"
118 + LDFLAGS="${SAVE_LDFLAGS} -Wl,-rpath,/"
119 + AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [ld_wl_rpath=yes], [ld_wl_rpath=no])
120 + LDFLAGS="${SAVE_LD_FLAGS}"
121 + ])
122 + if test "$ld_wl_rpath" = "yes"; then
123 + AC_SUBST(CC_LD_DYNPATH, [-Wl,-rpath,])
124 + else
125 + AC_CACHE_CHECK([if linker supports -rpath], ld_rpath, [
126 + SAVE_LDFLAGS="${LDFLAGS}"
127 + LDFLAGS="${SAVE_LDFLAGS} -rpath /"
128 + AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [ld_rpath=yes], [ld_rpath=no])
129 + LDFLAGS="${SAVE_LD_FLAGS}"
130 + ])
131 + if test "$ld_rpath" = "yes"; then
132 + AC_SUBST(CC_LD_DYNPATH, [-rpath])
133 + else
134 + AC_MSG_WARN([linker does not support runtime path to dynamic libraries])
135 + fi
136 + fi
137 +fi
138 #AC_PROG_INSTALL # needs install-sh or install.sh in sources
139 AC_CHECK_TOOLS(AR, [gar ar], :)
140 AC_CHECK_PROGS(TAR, [gtar tar])