3.2. 'Makefile' Syntax

'Makefile's have a rather particular syntax that can trouble new users. There are many implementations of make, some of which provide non-portable extensions. An abridged description of the syntax follows. For portability, this syntax may be stricter than you might be used to.

Comments start with a '#' and continue until the end of line. They may appear anywhere except in command sequences—if they do, they will be interpreted by the shell running the command. The following Makefile shows three individual targets with dependencies on each:

target1:  dep1 dep2 ... depN
<tab>   cmd1
<tab>   cmd2
<tab>   ...
<tab>   cmdN

target2:  dep4 dep5
<tab>   cmd1
<tab>   cmd2

dep4 dep5:
<tab>   cmd1

Target rules start at the beginning of a line and ...

Get GNU Autoconf, Automake, and Libtool now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.