From eaaab502c1a10032f4533ca013a39f1a83a7f82b Mon Sep 17 00:00:00 2001 From: johannst Date: Fri, 18 Sep 2020 19:26:48 +0000 Subject: deploy: e4db48ab1528771851bc7260fd1cb56fcb3cc6c9 --- print.html | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) (limited to 'print.html') diff --git a/print.html b/print.html index d318063..3d8d34d 100644 --- a/print.html +++ b/print.html @@ -83,7 +83,7 @@ @@ -1398,6 +1398,7 @@ the .rodata section as follows:

  • c++
  • glibc
  • gcc
  • +
  • [make] (./make.md)
  • ld.so
  • c++filt(1)

    @@ -1496,6 +1497,97 @@ run1: xor eax, eax jmp bar +

    make(1)

    +

    Anatomy of make rules

    +
    target .. : prerequisite ..
    +	recipe
    +	..
    +
    + +
    +

    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:

    + +
    # 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 ..)
    +

    ld.so(8)

    Environment Variables

      LD_PRELOAD=<l_so>       colon separated list of libso's to be pre loaded
    -- 
    cgit v1.2.3