@matheusbsbs / matheus-bagliano / commits / 897d68e7af
Fork 0

Makefile: use curl-config --cflags

We add the result of "curl-config --libs" when linking curl programs, but we never bother calling "curl-config --cflags". Presumably nobody noticed because: - a system libcurl installed into /usr/include/curl wouldn't need any flags ("/usr/include" is already in the search path, and the #include lines all look <curl/curl.h>, etc). - using CURLDIR sets up both the includes and the library path However, if you prefer CURL_CONFIG to CURLDIR, something simple like: make CURL_CONFIG=/path/to/curl-config doesn't work. We'd link against the libcurl specified by that program, but not find its header files when compiling. Let's invoke "curl-config --cflags" similar to the way we do for "--libs". Note that we'll feed the result into BASIC_CFLAGS. The rest of the Makefile doesn't distinguish which files need curl support during compilation and which do not. That should be OK, though. At most this should be adding a "-I" directive, and this is how CURLDIR already behaves. And since we follow the immediate-variable pattern from CURL_LDFLAGS, we won't accidentally invoke curl-config once per compilation. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Mar 26, 2020 at 04:08 UTC 897d68e7af82824e0c9e15d3c4af1a8a71afc791
1 file changed +7 -1
Makefile
+7 -1
@@ -1358,9 +1358,10 @@ ifdef NO_CURL
1358 else
1359 ifdef CURLDIR
1360 # Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
1361 - BASIC_CFLAGS += -I$(CURLDIR)/include
1361 + CURL_CFLAGS = -I$(CURLDIR)/include
1362 CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib)
1363 else
1364 + CURL_CFLAGS =
1365 CURL_LIBCURL =
1366 endif
1367
@@ -1369,6 +1370,11 @@ else
1370 endif
1371 CURL_LIBCURL += $(CURL_LDFLAGS)
1372
1373 + ifndef CURL_CFLAGS
1374 + CURL_CFLAGS := $(shell $(CURL_CONFIG) --cflags)
1375 + endif
1376 + BASIC_CFLAGS += $(CURL_CFLAGS)
1377 +
1378 REMOTE_CURL_PRIMARY = git-remote-http$X
1379 REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
1380 REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)