4.2 Makefile syntax

back: targets and dependencies
forward: macros
fastback: macros
up: introducing makefiles
fastforward: a minimal gnu autotools project
top: autoconf, automake, and libtool
contents: table of contents
index: index
about: about this document

`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 which, for portability, may be stricter than you may 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 are followed by a colon. Following the colon is a whitespace separated list of dependencies. A series of lines follow which contain shell commands to be run by a sub-shell (the default is the Bourne shell). Each of these lines must be prefixed by a horizontal tab character. This is the most common mistake made by new make users.

These commands may be prefixed by an `@' character to prevent make from echoing the command line prior to executing it. They may also optionally be prefixed by a `-' character to allow the rule to continue if the command returns a non-zero exit code. The combination of both characters is permitted.

This document was generated by Gary V. Vaughan on May, 24 2001 using texi2html

GNU Autoconf, Automake and Libtool
GNU Autoconf, Automake, and Libtool
ISBN: 1578701902
EAN: 2147483647
Year: 2002
Pages: 290

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net