Skip to content

Commit 61a64ff

Browse files
dborowitzgitster
authored andcommitted
Makefile: use curl-config to determine curl flags
curl-config should always be installed alongside a curl distribution, and its purpose is to provide flags for building against libcurl, so use it instead of guessing flags and dependent libraries. Allow overriding CURL_CONFIG to a custom path to curl-config, to compile against a curl installation other than the first in PATH. Depending on the set of features curl is compiled with, there may be more libraries required than the previous two options of -lssl and -lidn. For example, with a vanilla build of libcurl-7.36.0 on Mac OS X 10.9: $ ~/d/curl-out-7.36.0/lib/curl-config --libs -L/Users/dborowitz/d/curl-out-7.36.0/lib -lcurl -lgssapi_krb5 -lresolv -lldap -lz Use this only when CURLDIR is not explicitly specified, to continue supporting older builds. Signed-off-by: Dave Borowitz <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 68773ac commit 61a64ff

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

Makefile

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@ all::
3434
# git-http-push are not built, and you cannot use http:// and https://
3535
# transports (neither smart nor dumb).
3636
#
37+
# Define CURL_CONFIG to the path to a curl-config binary other than the
38+
# default 'curl-config'.
39+
#
3740
# Define CURLDIR=/foo/bar if your curl header and library files are in
38-
# /foo/bar/include and /foo/bar/lib directories.
41+
# /foo/bar/include and /foo/bar/lib directories. This overrides CURL_CONFIG,
42+
# but is less robust.
3943
#
4044
# Define NO_EXPAT if you do not have expat installed. git-http-push is
4145
# not built, and you cannot push using http:// and https:// transports (dumb).
@@ -143,9 +147,11 @@ all::
143147
#
144148
# Define NEEDS_SSL_WITH_CRYPTO if you need -lssl when using -lcrypto (Darwin).
145149
#
146-
# Define NEEDS_SSL_WITH_CURL if you need -lssl with -lcurl (Minix).
150+
# Define NEEDS_SSL_WITH_CURL if you need -lssl with -lcurl (Minix). Only used
151+
# if CURLDIR is set.
147152
#
148-
# Define NEEDS_IDN_WITH_CURL if you need -lidn when using -lcurl (Minix).
153+
# Define NEEDS_IDN_WITH_CURL if you need -lidn when using -lcurl (Minix). Only
154+
# used if CURLDIR is set.
149155
#
150156
# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
151157
#
@@ -1121,18 +1127,23 @@ else
11211127
# Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
11221128
BASIC_CFLAGS += -I$(CURLDIR)/include
11231129
CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib) -lcurl
1130+
ifdef NEEDS_SSL_WITH_CURL
1131+
CURL_LIBCURL += -lssl
1132+
ifdef NEEDS_CRYPTO_WITH_SSL
1133+
CURL_LIBCURL += -lcrypto
1134+
endif
1135+
endif
1136+
ifdef NEEDS_IDN_WITH_CURL
1137+
CURL_LIBCURL += -lidn
1138+
endif
11241139
else
1125-
CURL_LIBCURL = -lcurl
1126-
endif
1127-
ifdef NEEDS_SSL_WITH_CURL
1128-
CURL_LIBCURL += -lssl
1129-
ifdef NEEDS_CRYPTO_WITH_SSL
1130-
CURL_LIBCURL += -lcrypto
1140+
CURL_CONFIG ?= curl-config
1141+
BASIC_CFLAGS += $(shell $(CURL_CONFIG) --cflags)
1142+
CURL_LIBCURL = $(shell $(CURL_CONFIG) --libs)
1143+
ifeq "$(CURL_LIBCURL)" ""
1144+
$(error curl not detected; try setting CURLDIR)
11311145
endif
11321146
endif
1133-
ifdef NEEDS_IDN_WITH_CURL
1134-
CURL_LIBCURL += -lidn
1135-
endif
11361147

11371148
REMOTE_CURL_PRIMARY = git-remote-http$X
11381149
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X

0 commit comments

Comments
 (0)