make: Rule Example
1
1 4.1 Rule Example
1 ================
1
1 Here is an example of a rule:
1
1 foo.o : foo.c defs.h # module for twiddling the frobs
1 cc -c -g foo.c
1
1 Its target is 'foo.o' and its prerequisites are 'foo.c' and 'defs.h'.
1 It has one command in the recipe: 'cc -c -g foo.c'. The recipe starts
1 with a tab to identify it as a recipe.
1
1 This rule says two things:
1
1 * How to decide whether 'foo.o' is out of date: it is out of date if
1 it does not exist, or if either 'foo.c' or 'defs.h' is more recent
1 than it.
1
1 * How to update the file 'foo.o': by running 'cc' as stated. The
1 recipe does not explicitly mention 'defs.h', but we presume that
1 'foo.c' includes it, and that that is why 'defs.h' was added to the
1 prerequisites.
1