Skip to content

Commit 0573831

Browse files
peffgitster
authored andcommitted
Makefile: avoid running curl-config unnecessarily
Commit 94a88e2 (Makefile: avoid running curl-config multiple times, 2020-03-26) put the call to $(CURL_CONFIG) into a "simple" variable which is expanded immediately, rather than expanding it each time it's needed. However, that also means that we expand it whenever the Makefile is parsed, whether we need it or not. This is wasteful, but also breaks the ci/test-documentation.sh job, as it does not have curl at all and complains about the extra messages to stderr. An easy way to see it is just: $ make CURL_CONFIG=does-not-work check-builtins make: does-not-work: Command not found make: does-not-work: Command not found GIT_VERSION = 2.26.0.108.gb3f3f45f29 make: does-not-work: Command not found make: does-not-work: Command not found ./check-builtins.sh We can get the best of both worlds if we're willing to accept a little Makefile hackery. Courtesy of the article at: http://make.mad-scientist.net/deferred-simple-variable-expansion/ this patch uses a lazily-evaluated recursive variable which replaces its contents with an immediately assigned simple one on first use. Reported-by: Johannes Schindelin <[email protected]> Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 897d68e commit 0573831

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,12 +1366,12 @@ else
13661366
endif
13671367

13681368
ifndef CURL_LDFLAGS
1369-
CURL_LDFLAGS := $(shell $(CURL_CONFIG) --libs)
1369+
CURL_LDFLAGS = $(eval CURL_LDFLAGS := $$(shell $$(CURL_CONFIG) --libs))$(CURL_LDFLAGS)
13701370
endif
13711371
CURL_LIBCURL += $(CURL_LDFLAGS)
13721372

13731373
ifndef CURL_CFLAGS
1374-
CURL_CFLAGS := $(shell $(CURL_CONFIG) --cflags)
1374+
CURL_CFLAGS = $(eval CURL_CFLAGS := $$(shell $$(CURL_CONFIG) --cflags))$(CURL_CFLAGS)
13751375
endif
13761376
BASIC_CFLAGS += $(CURL_CFLAGS)
13771377

0 commit comments

Comments
 (0)