Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using gnu make and in a Makefile I have, I see below rule. I want to add a similar rule with a recipe, but when I add a rule and its receipe on the next line by giving a tab or space for the recipe, I get make error.

dummy :
    @echo $(OBJS)

When i turned on the vim command :set list , i see:

dummy :$
^I@echo $(OBJS)$

What exactly are the characters before the recipe line(second line) which indent it from the start of line?

How do I enter them using keyboard (without having to copy paste the exisitng rule and then modifying it?

Where would I find information for various spaces/indents to be used in creating a Makefile from beginning, by hand(Not a automake/or other tool created makefile)?



share|improve this question

Recipies in a makefile must be preceeded by a single standard tab character, nothing else.

^I is the representation of the tab character (see the table on the Wikipedia ASCII page), and therefore this should be correct.

So you should be able to enter it using Tab or Ctrl+I.
(assuming these are not remapped by the software)


On further investigation it looks like you can change the character required to preceed all recipe lines from a tab by setting the .RECIPEPREFIX special variable.

If this value has been defined in your makefile all recipes after the definition must use that character instead of a tab.

share|improve this answer
But when I do so with a TAB, for the recipe line, I keep getting a error when I do make , which says "Makefile:50: *** missing separator. Stop." at that line. Only when I copy some existing rule and use it, it goes through. – goldenmean Dec 21 '10 at 12:07
@goldenmean Looking at the documentation and searching for "missing seperator" gives This means that make could not understand much of anything about the makefile line it just read. GNU make looks for various separators (:, =, recipe prefix characters, etc.) to indicate what kind of line it's parsing. This message means it couldn't find a valid one. - maybe you need to remove the space between the job name and the colon? – DMA57361 Dec 21 '10 at 12:11
@goldenmean - looking at the docs further it is apparently possibly to change the recipe prefix character from a tab by setting the .RECIPEPREFIX special variable - has these been defined in your makefile? – DMA57361 Dec 21 '10 at 12:21
up vote 0 down vote accepted

after picking some pointers from answer given by DMA57361 above, and some more fiddling, i noticed that long time back in my .vimrc I had this command set expandtab (It expands tabs into spaces) and I use vim.

This was spoiling the Tab character which I was enteringin my Makefile rules. Commenting that line in .vimrc helped and its working for me.



share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .