Skip to content

Commit 897d68e

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 94a88e2 commit 897d68e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,9 +1358,10 @@ ifdef NO_CURL
13581358
else
13591359
ifdef CURLDIR
13601360
# Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
1361-
BASIC_CFLAGS += -I$(CURLDIR)/include
1361+
CURL_CFLAGS = -I$(CURLDIR)/include
13621362
CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib)
13631363
else
1364+
CURL_CFLAGS =
13641365
CURL_LIBCURL =
13651366
endif
13661367

@@ -1369,6 +1370,11 @@ else
13691370
endif
13701371
CURL_LIBCURL += $(CURL_LDFLAGS)
13711372

1373+
ifndef CURL_CFLAGS
1374+
CURL_CFLAGS := $(shell $(CURL_CONFIG) --cflags)
1375+
endif
1376+
BASIC_CFLAGS += $(CURL_CFLAGS)
1377+
13721378
REMOTE_CURL_PRIMARY = git-remote-http$X
13731379
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
13741380
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)

0 commit comments

Comments
 (0)