Makefile

make command line options:
-r Eliminate use of the built-in implicit rules. Also clear out the
default list of suffixes for suffix rules.
-s Silent operation; do not print the commands as they are executed.
-t Touch files (mark them up to date without really changing them)
instead of running their commands. This is used to pretend that
the commands were done, in order to fool future invocations of
make.
-n Print the commands that would be executed, but do not execute
them.
-k Continue as much as possible after an error. While the target
that failed, and those that depend on it, cannot be remade, the
other dependencies of these targets can be processed all the same.
-w Print a message containing the working directory before and after
other processing. This may be useful for tracking down errors
from complicated nests of recursive make commands.
-W file
Pretend that the target file has just been modified. When used
with the -n flag, this shows you what would happen if you were to
modify that file. Without -n, it is almost the same as running a
touch command on the given file before running make, except that
the modification time is changed only in the imagination of make.
-d
–debug[=options]
Print debugging information in addition to normal processing. Various levels
and types of output can be chosen. With no arguments, print the “basic”
level of debugging. Possible arguments are below; only the first character is
considered, and values must be comma- or space-separated.
all All types of debugging output is enabled. This is equivalent to
using `-d’.
basic Basic debugging prints each target that was found to be out-of-date,
and whether the build was successful or not.

makefile contents:
$(addprefix -L,$(LIBDIRS))
$(addprefix -I,$(INCDIRS))
$(filter debug, $(OSKIT_OPTIONS))
$(filter %.c,$(FILES))
$(filter-out $(OSKIT_EXCLUDE),$(CFILES))

applications:
ifneq “$(filter debug, $(OSKIT_OPTIONS))” “”
OSKIT_CFLAGS += -O -g
else
OSKIT_CFLAGS += -O2 -g
endif

ifeq (s,$(findstring s,$(MAKEFLAGS)))
OSKIT_QUIET_MAKE_INFORM=@echo
ARFLAGS=r ## drop the v from the default
else
OSKIT_QUIET_MAKE_INFORM=@true
endif

DEPENDLIBS = $(filter %.a, $(foreach DIR,$(LIBDIRS),$(wildcard $(DIR)/*)))

Double-Colon Rules
Double-colon rules are rules written with <strong>::</strong>' instead of:‘ after the target names. They
are handled differently from ordinary rules when the same target appears in more than one
rule.
When a target appears in multiple rules, all the rules must be the same type: all ordinary,
or all double-colon. If they are double-colon, each of them is independent of the others.
Each double-colon rule’s commands are executed if the target is older than any prerequisites
of that rule. This can result in executing none, any, or all of the double-colon rules.
Double-colon rules with the same target are in fact completely separate from one another.
Each double-colon rule is processed individually, just as rules with different targets are
processed.
eg:

all :: p1
echo “all : p1”

p1 :
echo “this is p1”

p2 :
echo “this is p2”

all :: p1 p2
echo “all : p1 p2”

“make -s” will output:

this is p1
all : p1
this is p2
all : p1 p2

chains of implicit rules
The second difference is that if make does create b in order to update something else,
it deletes b later on after it is no longer needed. Therefore, an intermediate file which did
not exist before make also does not exist after make. make reports the deletion to you by
printing a `rm -f’ command showing which file it is deleting.

the example is here.

从选项中filter-out不需要的:

CXXFLAGS := $(filter-out -fno-exceptions, $(CXXFLAGS))
CXXFLAGS := $(filter-out -fno-rtti, $(CXXFLAGS))

如果是shell script,则可以:
export CFLAGS=”${CFLAGS/-mtune=generic/}”
export CXXFLAGS=”${CXXFLAGS/-mtune=generic/}”

another example ( ‘include’ example )