For the most part, Makefiles work really well for a lot of what I do. For the most part, I can just paste commands I'd use in the shell into them. (Here's Mike Bostock's Why Use Make?
for a longer explanation of why it's good.)
But it is weird and confusing about some things. I needed to conditionally set some variables just now, based on the value of another variable. Here's the documentation on that:
The syntax of the conditional-directive is the same whether the conditional is simple or complex. There are four different directives that test different conditions. Here is a table of them:
ifeq (arg1, arg2)
ifeq 'arg1' 'arg2'
ifeq "arg1" "arg2"
ifeq "arg1" 'arg2'
ifeq 'arg1' "arg2"
I read that as, "if you want to compare something to a string literal", put the string literal in quotes."
As in:ifeq ($(TARGET), 'prod')
Where, if the TARGET variable's value was 'prod', the code in the block following that would execute. Turns out they were just throwing the quotes into the syntax documentation to tell you that it was a string literal, but they didn't actually mean you should use quotes. All strings not enclosed by $()
are literals in make.
So, this is what I wanted:ifeq ($(TARGET), prod)