From eaaab502c1a10032f4533ca013a39f1a83a7f82b Mon Sep 17 00:00:00 2001 From: johannst Date: Fri, 18 Sep 2020 19:26:48 +0000 Subject: deploy: e4db48ab1528771851bc7260fd1cb56fcb3cc6c9 --- development/c++.html | 2 +- development/c++filt.html | 2 +- development/gcc.html | 6 +- development/glibc.html | 2 +- development/index.html | 3 +- development/ld.so.html | 6 +- development/make.html | 310 +++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 321 insertions(+), 10 deletions(-) create mode 100644 development/make.html (limited to 'development') diff --git a/development/c++.html b/development/c++.html index c7edb5f..8ea732b 100644 --- a/development/c++.html +++ b/development/c++.html @@ -81,7 +81,7 @@ diff --git a/development/c++filt.html b/development/c++filt.html index f24e61f..e7f273c 100644 --- a/development/c++filt.html +++ b/development/c++filt.html @@ -81,7 +81,7 @@ diff --git a/development/gcc.html b/development/gcc.html index 8be1ffc..2500391 100644 --- a/development/gcc.html +++ b/development/gcc.html @@ -81,7 +81,7 @@ @@ -210,7 +210,7 @@ run1: - @@ -228,7 +228,7 @@ run1: - diff --git a/development/glibc.html b/development/glibc.html index ae61758..534e211 100644 --- a/development/glibc.html +++ b/development/glibc.html @@ -81,7 +81,7 @@ diff --git a/development/index.html b/development/index.html index 44e01d4..4cdf909 100644 --- a/development/index.html +++ b/development/index.html @@ -81,7 +81,7 @@ @@ -154,6 +154,7 @@
  • c++
  • glibc
  • gcc
  • +
  • [make] (./make.md)
  • ld.so
  • diff --git a/development/ld.so.html b/development/ld.so.html index 83acd03..12370b9 100644 --- a/development/ld.so.html +++ b/development/ld.so.html @@ -81,7 +81,7 @@ @@ -265,7 +265,7 @@ As we can see the offset from relocation at index 0 points to - @@ -283,7 +283,7 @@ As we can see the offset from relocation at index 0 points to - diff --git a/development/make.html b/development/make.html new file mode 100644 index 0000000..dba1c02 --- /dev/null +++ b/development/make.html @@ -0,0 +1,310 @@ + + + + + + make - Notes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + + + +
    +
    +

    make(1)

    +

    Anatomy of make rules

    +
    target .. : prerequisite ..
    +	recipe
    +	..
    +
    +
      +
    • target: an output generated by the rule
    • +
    • prerequisite: an input that is used to generate the target
    • +
    • recipe: list of actions to generate the output from the input
    • +
    +
    +

    Use make -p to print all rules and variables (implicitly + explicitly defined).

    +
    +

    Pattern rules & Automatic variables

    +

    Pattern rules

    +

    A pattern rule contains the % char (exactly one of them) and look like this example:

    +
    %.o : %.c
    +	$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
    +
    +

    The target matches files of the pattern %.o, where % matches any none-empty +substring and other character match just them self.

    +

    The substring matched by % is called the stem.

    +

    % in the prerequisite stands for the matched stem in the target.

    +

    Automatic variables

    +

    As targets and prerequisites in pattern rules can't be spelled explicitly in +the recipe, make provides a set of automatic variables to work with:

    +
      +
    • $@: Name of the target that triggered the rule.
    • +
    • $<: Name of the first prerequisite.
    • +
    • $^: Names of all prerequisites (without duplicates).
    • +
    • $+: Names of all prerequisites (with duplicates).
    • +
    • $*: Stem of the pattern rule.
    • +
    +
    # file: Makefile
    +
    +all: foobar blabla
    +
    +foo% bla%: aaa bbb bbb
    +	@echo "@ = $@"
    +	@echo "< = $<"
    +	@echo "^ = $^"
    +	@echo "+ = $+"
    +	@echo "* = $*"
    +	@echo "----"
    +
    +aaa:
    +bbb:
    +
    +

    Running above Makefile gives:

    +
    @ = foobar
    +< = aaa
    +^ = aaa bbb
    ++ = aaa bbb bbb
    +* = bar
    +----
    +@ = blabla
    +< = aaa
    +^ = aaa bbb
    ++ = aaa bbb bbb
    +* = bla
    +----
    +
    +

    Useful functions

    +

    Substitution references

    +

    Substitute strings matching pattern in a list.

    +
    in  := a.o l.a c.o
    +out := $(in:.o=.c)
    +# => out = a.c l.a c.c
    +
    +

    filter

    +

    Keep strings matching a pattern in a list.

    +
    in  := a.a b.b c.c d.d
    +out := $(filter %.b %.c, $(in))
    +# => out = b.b c.c
    +
    +

    filter-out

    +

    Remove strings matching a pattern from a list.

    +
    in  := a.a b.b c.c d.d
    +out := $(filter-out %.b %.c, $(in))
    +# => out = a.a d.d
    +
    +

    abspath

    +

    Resolve each file name as absolute path (don't resolve symlinks).

    +
    $(abspath fname1 fname2 ..)
    +
    +### `realpath`
    +Resolve each file name as canonical path.
    +```make
    +$(realpath fname1 fname2 ..)
    +
    + +
    + + +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3