Makefile rules introduced

Makefile

 

  1. A rule
    three elements: goals, dependence, command
        target: dependency

Command
1, the first rule is used to generate the ultimate goal rule
    if the rule is dependent not present, looking downwardly other rules

Update mechanism: the comparison is time-dependent files and object files

  1. Two functions

1) Find a specified directory, specify the type of file
    src = $ (wildcard ~ / aa / *. C)

2) Match the replacement function
    obj = $ (patsubst% .c, % .o, $ (src))

  1. Three automatic variables

1) $ <: first dependent rules

2) $ ^: all dependent rules

3) $ @: goals rule

Can only be used in the rule command

  1. Mode rule
    % .o:% .c

gcc -c $< -o $@

 

Guess you like

Origin www.cnblogs.com/wanghao-boke/p/11298058.html