See :
make by default, uses the makefile found in the directory from which it is called.
Options :
-B : unconditionally make/run all target rules.
-d : debug or trace, reports what's happening as it's happening.
-C dir : change to specified dir and run make in it. Can be used to chain multiple makes.
-n : (dry run), prints rules that will run without actually running them.
Other options available for finer control.
The rules are composed of :
target: [prerequisite] [prerequisite] [\] [prerequisite] ... [<tab>recipe] [<tab>recipe] ...target:
starget: st1 st2 st3 # Prerequisites must exist as either an actual file or a rule or both. # If rule but no file, # rule will always run, even if it doesn't create file. # If file in current directory but no rule, # it will be treated as a true test condition for current rule. # If no file and no rule # it will be treated as a make error. # # All prerequisite rules must run successfully to complete. # # make -k (keep on) will NOT override failure prerequisite rules. # touch starget st1: # st2b must be created externally. # Because there is no st1 target file, ^ this line will aways be displayed. st2: st2b st2a st2c touch st2 # This will run if either st2a, st2b, or st2c is newer than st2. # # st2b is not created by make, so it is assumed to be created externally. # If no st2b target, make will stop/fail if st2b doesn't exist # before running st2a # -k (keep on) will force make to continue to evaluate the rest # of prerequisites for this rule. # # Because st2c target exists but no file is created, this recipe will always # run. And because this recipe runs and touch st2, the main target's recipe # also runs st2a: touch st2a # This will only run if st2a does not exist. st2c: echo "I'm not making st2c, I will always run" # This rule does not actually create anything st3: ls -l st* # This will run every time. sweep: rm st* # remember to recreate st2b # this must be specifically invoked. |
CC = gcc objects = pgm1.o util.o myio.o pgm1 : $(CC) -o pgm1 $(objects) |
foo = $(bar) bar = $(ugh) ugh = Huh? all:;echo $(foo) |
next := and a two start := one $(next) next := and a one two three |
statter.o: |
bs_for_gcc = -lgnu normal_libs = foo: $(objects) ifeq ($(CC),gcc) $(CC) -o foo $(objects) $(libs_for_gcc) else $(CC) -o foo $(objects) $(normal_libs) endif |