Skip to content

Commit e425521

Browse files
committed
Merge branch 'db/make-with-curl'
Ask curl-config how to link with the curl library, instead of having only a limited configurability knobs in the Makefile. * db/make-with-curl: Makefile: allow static linking against libcurl Makefile: use curl-config to determine curl flags
2 parents 779792a + d506711 commit e425521

File tree

1 file changed

+33
-12
lines changed

1 file changed

+33
-12
lines changed

Makefile

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,15 @@ 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+
#
40+
# Define CURL_STATIC to statically link libcurl. Only applies if
41+
# CURL_CONFIG is used.
42+
#
3743
# Define CURLDIR=/foo/bar if your curl header and library files are in
38-
# /foo/bar/include and /foo/bar/lib directories.
44+
# /foo/bar/include and /foo/bar/lib directories. This overrides CURL_CONFIG,
45+
# but is less robust.
3946
#
4047
# Define NO_EXPAT if you do not have expat installed. git-http-push is
4148
# not built, and you cannot push using http:// and https:// transports (dumb).
@@ -143,9 +150,11 @@ all::
143150
#
144151
# Define NEEDS_SSL_WITH_CRYPTO if you need -lssl when using -lcrypto (Darwin).
145152
#
146-
# Define NEEDS_SSL_WITH_CURL if you need -lssl with -lcurl (Minix).
153+
# Define NEEDS_SSL_WITH_CURL if you need -lssl with -lcurl (Minix). Only used
154+
# if CURLDIR is set.
147155
#
148-
# Define NEEDS_IDN_WITH_CURL if you need -lidn when using -lcurl (Minix).
156+
# Define NEEDS_IDN_WITH_CURL if you need -lidn when using -lcurl (Minix). Only
157+
# used if CURLDIR is set.
149158
#
150159
# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
151160
#
@@ -1121,18 +1130,30 @@ else
11211130
# Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
11221131
BASIC_CFLAGS += -I$(CURLDIR)/include
11231132
CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib) -lcurl
1133+
ifdef NEEDS_SSL_WITH_CURL
1134+
CURL_LIBCURL += -lssl
1135+
ifdef NEEDS_CRYPTO_WITH_SSL
1136+
CURL_LIBCURL += -lcrypto
1137+
endif
1138+
endif
1139+
ifdef NEEDS_IDN_WITH_CURL
1140+
CURL_LIBCURL += -lidn
1141+
endif
11241142
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
1143+
CURL_CONFIG ?= curl-config
1144+
BASIC_CFLAGS += $(shell $(CURL_CONFIG) --cflags)
1145+
ifdef CURL_STATIC
1146+
CURL_LIBCURL = $(shell $(CURL_CONFIG) --static-libs)
1147+
ifeq "$(CURL_LIBCURL)" ""
1148+
$(error libcurl not detected or not compiled with static support)
1149+
endif
1150+
else
1151+
CURL_LIBCURL = $(shell $(CURL_CONFIG) --libs)
1152+
ifeq "$(CURL_LIBCURL)" ""
1153+
$(error libcurl not detected; try setting CURLDIR)
1154+
endif
11311155
endif
11321156
endif
1133-
ifdef NEEDS_IDN_WITH_CURL
1134-
CURL_LIBCURL += -lidn
1135-
endif
11361157

11371158
REMOTE_CURL_PRIMARY = git-remote-http$X
11381159
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X

0 commit comments

Comments
 (0)