Skip to content

Commit fa2f2f0

Browse files
committed
Merge branch 'jk/curl-ldflags'
The way -lcurl library gets linked has been simplified by taking advantage of the fact that we can just ask curl-config command how. * jk/curl-ldflags: build: link with curl-defined linker flags
2 parents 95a3ef5 + 23c4bbe commit fa2f2f0

File tree

3 files changed

+22
-28
lines changed

3 files changed

+22
-28
lines changed

Makefile

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ all::
5959
# Define CURL_CONFIG to curl's configuration program that prints information
6060
# about the library (e.g., its version number). The default is 'curl-config'.
6161
#
62+
# Define CURL_LDFLAGS to specify flags that you need to link when using libcurl,
63+
# if you do not want to rely on the libraries provided by CURL_CONFIG. The
64+
# default value is a result of `curl-config --libs`. An example value for
65+
# CURL_LDFLAGS is as follows:
66+
#
67+
# CURL_LDFLAGS=-lcurl
68+
#
6269
# Define NO_EXPAT if you do not have expat installed. git-http-push is
6370
# not built, and you cannot push using http:// and https:// transports (dumb).
6471
#
@@ -183,10 +190,6 @@ all::
183190
#
184191
# Define NEEDS_SSL_WITH_CRYPTO if you need -lssl when using -lcrypto (Darwin).
185192
#
186-
# Define NEEDS_SSL_WITH_CURL if you need -lssl with -lcurl (Minix).
187-
#
188-
# Define NEEDS_IDN_WITH_CURL if you need -lidn when using -lcurl (Minix).
189-
#
190193
# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
191194
#
192195
# Define NEEDS_LIBINTL_BEFORE_LIBICONV if you need libintl before libiconv.
@@ -1309,20 +1312,17 @@ else
13091312
ifdef CURLDIR
13101313
# Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
13111314
BASIC_CFLAGS += -I$(CURLDIR)/include
1312-
CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib) -lcurl
1315+
CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib)
13131316
else
1314-
CURL_LIBCURL = -lcurl
1315-
endif
1316-
ifdef NEEDS_SSL_WITH_CURL
1317-
CURL_LIBCURL += -lssl
1318-
ifdef NEEDS_CRYPTO_WITH_SSL
1319-
CURL_LIBCURL += -lcrypto
1320-
endif
1321-
endif
1322-
ifdef NEEDS_IDN_WITH_CURL
1323-
CURL_LIBCURL += -lidn
1317+
CURL_LIBCURL =
13241318
endif
13251319

1320+
ifdef CURL_LDFLAGS
1321+
CURL_LIBCURL += $(CURL_LDFLAGS)
1322+
else
1323+
CURL_LIBCURL += $(shell $(CURL_CONFIG) --libs)
1324+
endif
1325+
13261326
REMOTE_CURL_PRIMARY = git-remote-http$X
13271327
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
13281328
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)

config.mak.uname

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,6 @@ ifeq ($(uname_S),Minix)
430430
NO_NSEC = YesPlease
431431
NEEDS_LIBGEN =
432432
NEEDS_CRYPTO_WITH_SSL = YesPlease
433-
NEEDS_IDN_WITH_CURL = YesPlease
434-
NEEDS_SSL_WITH_CURL = YesPlease
435433
NEEDS_RESOLV =
436434
NO_HSTRERROR = YesPlease
437435
NO_MMAP = YesPlease
@@ -457,7 +455,6 @@ ifeq ($(uname_S),NONSTOP_KERNEL)
457455
# Missdetected, hence commented out, see below.
458456
#NO_CURL = YesPlease
459457
# Added manually, see above.
460-
NEEDS_SSL_WITH_CURL = YesPlease
461458
HAVE_LIBCHARSET_H = YesPlease
462459
HAVE_STRINGS_H = YesPlease
463460
NEEDS_LIBICONV = YesPlease

configure.ac

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -600,17 +600,14 @@ AC_CHECK_PROG([CURL_CONFIG], [curl-config],
600600

601601
if test $CURL_CONFIG != no; then
602602
GIT_CONF_SUBST([CURL_CONFIG])
603-
if test -z "${NO_OPENSSL}"; then
604-
AC_MSG_CHECKING([if Curl supports SSL])
605-
if test $(curl-config --features|grep SSL) = SSL; then
606-
NEEDS_SSL_WITH_CURL=YesPlease
607-
AC_MSG_RESULT([yes])
608-
else
609-
NEEDS_SSL_WITH_CURL=
610-
AC_MSG_RESULT([no])
611-
fi
612-
GIT_CONF_SUBST([NEEDS_SSL_WITH_CURL])
603+
604+
if test -z "$CURL_CONFIG_OPTS"; then
605+
CURL_CONFIG_OPTS="--libs"
613606
fi
607+
608+
CURL_LDFLAGS=$($CURL_CONFIG $CURL_CONFIG_OPTS)
609+
AC_MSG_NOTICE([Setting CURL_LDFLAGS to '$CURL_LDFLAGS'])
610+
GIT_CONF_SUBST([CURL_LDFLAGS], [$CURL_LDFLAGS])
614611
fi
615612

616613
fi

0 commit comments

Comments
 (0)