Skip to content

Commit cd50988

Browse files
committed
Merge branch 'jc/cc-ld-dynpath'
* jc/cc-ld-dynpath: configure: auto detect dynamic library path switches Makefile: Allow CC_LD_DYNPATH to be overriden Conflicts: Makefile config.mak.in
2 parents fdfb4cf + 798a945 commit cd50988

File tree

3 files changed

+42
-8
lines changed

3 files changed

+42
-8
lines changed

Makefile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,7 @@ ifeq ($(uname_S),NetBSD)
697697
NEEDS_LIBICONV = YesPlease
698698
endif
699699
BASIC_CFLAGS += -I/usr/pkg/include
700-
BASIC_LDFLAGS += -L/usr/pkg/lib
701-
ALL_LDFLAGS += -Wl,-rpath,/usr/pkg/lib
700+
BASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib
702701
THREADED_DELTA_SEARCH = YesPlease
703702
endif
704703
ifeq ($(uname_S),AIX)
@@ -793,12 +792,14 @@ ifeq ($(uname_S),Darwin)
793792
endif
794793
endif
795794

796-
ifdef NO_R_TO_GCC_LINKER
797-
# Some gcc does not accept and pass -R to the linker to specify
798-
# the runtime dynamic library path.
799-
CC_LD_DYNPATH = -Wl,-rpath=
800-
else
801-
CC_LD_DYNPATH = -R
795+
ifndef CC_LD_DYNPATH
796+
ifdef NO_R_TO_GCC_LINKER
797+
# Some gcc does not accept and pass -R to the linker to specify
798+
# the runtime dynamic library path.
799+
CC_LD_DYNPATH = -Wl,-rpath,
800+
else
801+
CC_LD_DYNPATH = -R
802+
endif
802803
endif
803804

804805
ifdef NO_CURL

config.mak.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
CC = @CC@
55
CFLAGS = @CFLAGS@
66
LDFLAGS = @LDFLAGS@
7+
CC_LD_DYNPATH = @CC_LD_DYNPATH@
78
AR = @AR@
89
TAR = @TAR@
910
#INSTALL = @INSTALL@ # needs install-sh or install.sh in sources

configure.ac

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,38 @@ GIT_PARSE_WITH(tcltk))
103103
AC_MSG_NOTICE([CHECKS for programs])
104104
#
105105
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
106138
#AC_PROG_INSTALL # needs install-sh or install.sh in sources
107139
AC_CHECK_TOOLS(AR, [gar ar], :)
108140
AC_CHECK_PROGS(TAR, [gtar tar])

0 commit comments

Comments
 (0)