Reputation: 18201
I have Makefile that contains tabified line echo $(foo)
and untabified line ifneq (,$(findstring i, $(MAKEFLAGS)))
:
bar =
foo = $(bar)
all:
echo $(foo)
ifneq (,$(findstring i, $(MAKEFLAGS)))
echo "i was passed to MAKEFLAGS"
endif
If I untabify echo $(foo)
I got error:
Makefile:5: *** missing separator. Stop.
Why some lines should be tabified while other ones - not?
Upvotes: 0
Views: 1371
Reputation: 181104
Why some lines should be tabified while other ones - not?
Every line of each recipe must begin with a tab. Every line that is not part of a recipe should not begin with a tab. The crux of the issue is that in the example makefile, your ifneq
and endif
directives are not part of a recipe. They are processed by make
, during makefile parsing, not passed to a shell when the recipe is run. In some ways, this is the same kind of distinction as between C preprocessing directives and the surrounding source code.
Upvotes: 0
Reputation: 100946
Because, that's the syntax makefiles use. Why do you have to indent the body of methods in Python? Because that's the syntax.
Makefiles consist of two different "languages" in the same file. Lines that are not indented by TAB are makefile format. Lines that are indented by TAB are shell scripts. Make uses TAB to differentiate the two.
See the GNU make manual for more info.
Upvotes: 3