Makefile: default to -lcurl when no CURL_CONFIG or CURLDIR
The original implementation of CURL_CONFIG support did not match the original behavior of using -lcurl when CURLDIR was not set. This broke implementations that were lacking curl-config but did have libcurl installed along system libraries, such as MSysGit. In other words, the assumption that curl-config is always installed was incorrect. Instead, if CURL_CONFIG is empty or returns an empty result (e.g. due to curl-config being missing), use the old behavior of falling back to -lcurl. Signed-off-by: Dave Borowitz <dborowitz@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Dave Borowitz committed
Apr 28, 2014 at 14:01 UTC
f3f11fa6a5cee5a90b3ca6a66a25a2beff6996a7
1 file changed
+28
-13
Makefile
+28
-13
@@ -35,14 +35,17 @@ all::
35
# transports (neither smart nor dumb).
36
#
37
# Define CURL_CONFIG to the path to a curl-config binary other than the
38
-# default 'curl-config'.
38
+# default 'curl-config'. If CURL_CONFIG is unset or points to a binary that
39
+# is not found, defaults to the CURLDIR behavior.
40
#
41
# Define CURL_STATIC to statically link libcurl. Only applies if
42
# CURL_CONFIG is used.
43
#
44
# Define CURLDIR=/foo/bar if your curl header and library files are in
44
-# /foo/bar/include and /foo/bar/lib directories. This overrides CURL_CONFIG,
45
-# but is less robust.
45
+# /foo/bar/include and /foo/bar/lib directories. This overrides
46
+# CURL_CONFIG, but is less robust. If not set, and CURL_CONFIG is not set,
47
+# uses -lcurl with no additional library detection (other than
48
+# NEEDS_*_WITH_CURL).
49
#
50
# Define NO_EXPAT if you do not have expat installed. git-http-push is
51
# not built, and you cannot push using http:// and https:// transports (dumb).
@@ -1127,9 +1130,27 @@ ifdef NO_CURL
1130
REMOTE_CURL_NAMES =
1131
else
1132
ifdef CURLDIR
1130
- # Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
1131
- BASIC_CFLAGS += -I$(CURLDIR)/include
1132
- CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib) -lcurl
1133
+ CURL_LIBCURL =
1134
+ else
1135
+ CURL_CONFIG = curl-config
1136
+ ifeq "$(CURL_CONFIG)" ""
1137
+ CURL_LIBCURL =
1138
+ else
1139
+ CURL_LIBCURL := $(shell $(CURL_CONFIG) --libs)
1140
+ endif
1141
+ endif
1142
+
1143
+ ifeq "$(CURL_LIBCURL)" ""
1144
+ ifdef CURL_STATIC
1145
+$(error "CURL_STATIC must be used with CURL_CONFIG")
1146
+ endif
1147
+ ifdef CURLDIR
1148
+ # Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
1149
+ BASIC_CFLAGS += -I$(CURLDIR)/include
1150
+ CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib) -lcurl
1151
+ else
1152
+ CURL_LIBCURL = -lcurl
1153
+ endif
1154
ifdef NEEDS_SSL_WITH_CURL
1155
CURL_LIBCURL += -lssl
1156
ifdef NEEDS_CRYPTO_WITH_SSL
@@ -1140,17 +1161,11 @@ else
1161
CURL_LIBCURL += -lidn
1162
endif
1163
else
1143
- CURL_CONFIG ?= curl-config
1164
BASIC_CFLAGS += $(shell $(CURL_CONFIG) --cflags)
1165
ifdef CURL_STATIC
1166
CURL_LIBCURL = $(shell $(CURL_CONFIG) --static-libs)
1167
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)
1168
+$(error libcurl not detected or not compiled with static support)
1169
endif
1170
endif
1171
endif