Copyright © tutorialspoint.com
The general syntax of a Makefile Target Rule is
Items in brackets are optional, ellipsis means one or more. Note the tab to preface each command is required.
NOTE: In this example you would have to give rules to make all object files also from the source files The semantics is pretty simple. When you say "make target" make finds the target rule that applies and, if any of the dependents are newer than the target, make executes the commands one at a time (after macro substitution). If any dependents have to be made, that happens first (so you have a recursion). A make will terminate if any command returns a failure status. That's why you see rules like:
Make will echo the commands, after macro substition to show you what's happening as it happens. Sometimes you might want to turn that off. For example:
People have come to expect certain targets in Makefiles. You should always browse first, but it's reasonable to expect that the targets all (or just make), install, and clean will be found.
Makefile Implicit RulesThe command is one that ought to work in all cases where we build an executable x out of the source code x.cpp This can be stated as an implicit rule:
This Implicit rule says how to make x out of x.c -- run cc on x.c and call the output x. The rule is implicit because no particular target is mentioned. It can be used in all cases. Another common implicit rule is for the construction of .o (object) files out of .cpp (source files).
|
Copyright © tutorialspoint.com