git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] Makefile: default to -lcurl when no CURL_CONFIG or CURLDIR

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 30, 2014, 15:13 UTC
Message-ID
<xmqqk3a6hmv6.fsf@gitster.dls.corp.google.com>
In-Reply-To
<CABPQNSYDD7g3nOwb2ZaOQ9M9gQnjzQyKP4Zo-i8p4o-s30bk1Q@mail.gmail.com>
Erik Faye-Lund <kusmabite@gmail.com> writes:
Show 27 quoted lines
> This is wrong, no? With CURL_CONFIG not set, it currently *does* run
> curl-config, see below.
> ...
>>         ifdef CURLDIR
>> +               CURL_LIBCURL =
>> +       else
>> +               CURL_CONFIG = curl-config
>> +               ifeq "$(CURL_CONFIG)" ""
>> +                       CURL_LIBCURL =
>> +               else
>> +                       CURL_LIBCURL := $(shell $(CURL_CONFIG) --libs)
>> +               endif
>
> Doesn't that definition just define CURL_CONFIG unconditionally? How
> are the first condition ever supposed to get triggered?
>
> $ make
> make: curl-config: Command not found
> GIT_VERSION = 1.9.2.462.gf3f11fa
> make: curl-config: Command not found
>     * new build flags
>     * new link flags
>     * new prefix flags
>     GEN common-cmds.h
> ...
>
> Yuck.

An earlier iteration of the patch used "CURL_CONFIG ?= curl-config", but that would not have been much different:

        $ cat >Makefile <<\EOF
        CURL_CONFIG ?= curl-config
        ifeq "$(CURL_CONFIG)" ""
                X=Empty
        else
                X=NotEmpty
        endif
        ifdef CURL_CONFIG
                Z=Defined
        else
                Z=Undefined
        endif
        all::
                @echo "$(X) $(Z) CURL_CONFIG=<$(CURL_CONFIG)>"
        EOF
        $ make
        NotEmpty Defined CURL_CONFIG=<curl-config>
        $ make CURL_CONFIG=""
        Empty Undefined CURL_CONFIG=<>
        $ CURL_CONFIG="" make
        Empty Undefined CURL_CONFIG=<>

As the first one (the default) will still use curl-config and passing an explicit CURL_CONFIG="" on the command line would be the only way to squelch this unpleasantness. If you change

	CURL_CONFIG ?= curl-config
to
	CURL_CONFIG = curl-config

in the above illustration, the first two would be the same result as above, and the last one will behave the same as the first one---an environment set to empty is still protected from the default defined in the Makefile.

I think something along the lines of 
	ifdef CURLDIR
        	CURL_LIBCURL =
	else
		CURL_CONFIG = curl-config
		CURL_LIBCURL := $(shell sh -c '$(CURL_CONFIG) --libs' 2>/dev/null)
	fi
may be the right way to write this?

Note that $(shell $(CURL_CONFIG) --libs) when CURL_CONFIG is empty would barf when $(CURL_CONFIG) expands to an empty string.

Previous: Erik Faye-LundNext: Erik Faye-Lund
Message 5 of 7 in “Makefile: default to -lcurl when no CURL_CONFIG or CURLDIR”
  1. Makefile: default to -lcurl when no CURL_CONFIG or CURLDIRDave Borowitz, Apr 28, 2014
  2. Junio C HamanoApr 28, 2014
  3. Jonathan NiederApr 28, 2014
  4. Erik Faye-LundApr 30, 2014
  5. Junio C HamanoApr 30, 2014
  6. Erik Faye-LundApr 30, 2014
  7. Junio C HamanoApr 30, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.