René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

gmake rules

The order of the rules in a makefile is not important except that the first rule defines the default goal (The default goal defines which target to make if none is specified when make is invoked).
A rule looks like any of the following examples:
target : prerequisites
	command1
  command2
  ...
  commandN
or
target : prerequisites ; command
or
target : prerequisites ; command1
	command2
  ..
  commandN
Important: the commands must be prepended with a tabulator (except in the case with the semicolon).

Immediateness

immediate : immediate ; deferred
	deferred

Built-in target names

.PHONY

.SUFFIXES

.DEFAULT

.PRECIOUS

By default, gmake deletes the target it is about to make if it is killed (ctrl-c). This behaviour can be changed by making the target a prerequisite of .PRECIOUS.

.INTERMEDIATE

.DELETE_ON_ERROS

.IGNORE

.LOW_RESOLUTION_TIME

.SILENT

.SILENT is rarely used as the same effect can be achieved with @ commands which are more flexible.

.NOTPARALLEL

Multiple targets in a rule

The following two blocks are equivalent:
a b c d e : timestamp
	echo $@
a : timestamp
	echo $@

b : timestamp
	echo $@

c : timestamp
	echo $@

d : timestamp
	echo $@

e : timestamp
	echo $@

Multliple rules for one target

It is possible for one target to occur in multiple rules. YET TO BE FINISHED.

Static pattern rules

target_1 target_2 target_3 : %.suffix_to : %.suffix_from
	some_command $< > $@
	

Double colon rules

Double colon rules are quite rare. If a target occurs in multiple rules, it must either always be in a double colon rule or in a single colon rule.
Double colon rules are processed seperatly (as though they were different targets).
target :: prerequisite_1 prerequisite_2
	cmd foo ba

target :: prerequisite_1 prerequisite_2
	cmd foo ba

Phony targets

A phony target is not a name of a file. It is declared like so:
.PHONY : clean