Skip to content

Commit 23c4bbe

Browse files
jdknightgitster
authored andcommitted
build: link with curl-defined linker flags
Adjusting the build process to rely more on curl-config to populate linker flags instead of manually populating flags based off detected features. Originally, a configure-invoked build would check for SSL-support in the target curl library. If enabled, NEEDS_SSL_WITH_CURL would be set and used in the Makefile to append additional libraries to link against. As for systems building solely with make, the defines NEEDS_IDN_WITH_CURL and NEEDS_SSL_WITH_CURL could be set to indirectly enable respective linker flags. Since both configure.ac and Makefile already rely on curl-config utility to provide curl-related build information, adjusting the respective assets to populate required linker flags using the utility (unless explicitly configured). Signed-off-by: James Knight <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d582ea2 commit 23c4bbe

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.
@@ -1307,20 +1310,17 @@ else
13071310
ifdef CURLDIR
13081311
# Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
13091312
BASIC_CFLAGS += -I$(CURLDIR)/include
1310-
CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib) -lcurl
1313+
CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib)
13111314
else
1312-
CURL_LIBCURL = -lcurl
1313-
endif
1314-
ifdef NEEDS_SSL_WITH_CURL
1315-
CURL_LIBCURL += -lssl
1316-
ifdef NEEDS_CRYPTO_WITH_SSL
1317-
CURL_LIBCURL += -lcrypto
1318-
endif
1319-
endif
1320-
ifdef NEEDS_IDN_WITH_CURL
1321-
CURL_LIBCURL += -lidn
1315+
CURL_LIBCURL =
13221316
endif
13231317

1318+
ifdef CURL_LDFLAGS
1319+
CURL_LIBCURL += $(CURL_LDFLAGS)
1320+
else
1321+
CURL_LIBCURL += $(shell $(CURL_CONFIG) --libs)
1322+
endif
1323+
13241324
REMOTE_CURL_PRIMARY = git-remote-http$X
13251325
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
13261326
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
@@ -431,8 +431,6 @@ ifeq ($(uname_S),Minix)
431431
NO_NSEC = YesPlease
432432
NEEDS_LIBGEN =
433433
NEEDS_CRYPTO_WITH_SSL = YesPlease
434-
NEEDS_IDN_WITH_CURL = YesPlease
435-
NEEDS_SSL_WITH_CURL = YesPlease
436434
NEEDS_RESOLV =
437435
NO_HSTRERROR = YesPlease
438436
NO_MMAP = YesPlease
@@ -458,7 +456,6 @@ ifeq ($(uname_S),NONSTOP_KERNEL)
458456
# Missdetected, hence commented out, see below.
459457
#NO_CURL = YesPlease
460458
# Added manually, see above.
461-
NEEDS_SSL_WITH_CURL = YesPlease
462459
HAVE_LIBCHARSET_H = YesPlease
463460
HAVE_STRINGS_H = YesPlease
464461
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)