Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

makefile:4: *** missing separator. Stop

Tags:

c

makefile

This is my makefile:

all:ll  ll:ll.c      gcc  -c  -Wall -Werror -02 c.c ll.c  -o  ll  $@  $<  clean :   \rm -fr ll 

When I try to make clean or make make, I get this error:

:makefile:4: *** missing separator.  Stop. 

How can I fix it?

like image 262
Rahul Reddy Avatar asked Jun 05 '13 04:06

Rahul Reddy


People also ask

Are tabs or spaces used to indent the commands after the rule in a makefile?

Recipes in makefile rules must start with a tab (per definition). If a single tab (interpreted as 8 spaces wide) is not enough to put the recipe clearly indented (meaning at least 4 spaces difference) from the code around it, use additional tabs.

What is in makefile?

What Makefiles Contain. Makefiles contain five kinds of things: explicit rules , implicit rules , variable definitions , directives , and comments . Rules, variables, and directives are described at length in later chapters. An explicit rule says when and how to remake one or more files, called the rule's targets.


1 Answers

make has a very stupid relationship with tabs. All actions of every rule are identified by tabs. And, no, four spaces don't make a tab. Only a tab makes a tab.

To check, I use the command cat -e -t -v makefile_name.

It shows the presence of tabs with ^I and line endings with $. Both are vital to ensure that dependencies end properly and tabs mark the action for the rules so that they are easily identifiable to the make utility.

Example:

Kaizen ~/so_test $ cat -e -t -v  mk.t all:ll$      ## here the $ is end of line ...                    $ ll:ll.c   $ ^Igcc  -c  -Wall -Werror -02 c.c ll.c  -o  ll  $@  $<$  ## the ^I above means a tab was there before the action part, so this line is ok .  $ clean :$    \rm -fr ll$ ## see here there is no ^I which means , tab is not present ....  ## in this case you need to open the file again and edit/ensure a tab  ## starts the action part 
like image 108
AppleBee12 Avatar answered Oct 19 '22 23:10

AppleBee12