]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Makefile: use curl-config --cflags
authorJeff King <peff@peff.net>
Thu, 26 Mar 2020 08:08:55 +0000 (04:08 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Mar 2020 22:11:54 +0000 (15:11 -0700)
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>
Makefile

index eaf56e23aa3c35659407566fe59489fb35c73fc5..3d90488dab7f28b37a96a81ff6f402455ed7322e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1358,9 +1358,10 @@ ifdef NO_CURL
 else
        ifdef CURLDIR
                # Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
-               BASIC_CFLAGS += -I$(CURLDIR)/include
+               CURL_CFLAGS = -I$(CURLDIR)/include
                CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib)
        else
+               CURL_CFLAGS =
                CURL_LIBCURL =
        endif
 
@@ -1369,6 +1370,11 @@ else
        endif
        CURL_LIBCURL += $(CURL_LDFLAGS)
 
+       ifndef CURL_CFLAGS
+               CURL_CFLAGS := $(shell $(CURL_CONFIG) --cflags)
+       endif
+       BASIC_CFLAGS += $(CURL_CFLAGS)
+
        REMOTE_CURL_PRIMARY = git-remote-http$X
        REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
        REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)