From da792f6afb36c4a03f51e618b64e6bd5e27fb3fd Mon Sep 17 00:00:00 2001 From: johannst Date: Tue, 26 Mar 2024 23:15:06 +0000 Subject: deploy: 0ccba0943d477b71cdccd2505eb81b95f091263a --- print.html | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 113 insertions(+), 7 deletions(-) (limited to 'print.html') diff --git a/print.html b/print.html index d6958f5..df3cdad 100644 --- a/print.html +++ b/print.html @@ -4423,7 +4423,7 @@ target_link_libraries(main liba)

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

-

Pattern rules & Automatic variables

+

Pattern rules & variables

Pattern rules

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

%.o : %.c
@@ -4476,6 +4476,19 @@ bbb:
 
  • $(CURDIR): Path of current working dir after using make -C path
+

Multi-line variables

+
define my_var
+@echo foo
+@echo bar
+endef
+
+all:
+	$(my_var)
+
+

Running above Makefile gives:

+
foo
+bar
+

Arguments

Arguments specified on the command line override ordinary variable assignments in the makefile (overriding variables).

@@ -4518,12 +4531,105 @@ out := $(filter-out %.b %.c, $(in))

abspath

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

$(abspath fname1 fname2 ..)
+
+

realpath

+

Resolve each file name as canonical path.

+
$(realpath fname1 fname2 ..)
+
+

call (ref)

+

Invoke parametrized function, which is an expression saved in a variable.

+
swap = $(2) $(1)
+
+all:
+	@echo "call swap first second -> $(call swap,first,second)"
+
+

Outputs:

+
call swap first second -> second first
+
+

eval (ref)

+

Allows to define new makefile constructs by evaluating the result of a variable +or function.

+
define new_rule
+$(1):
+	@echo "$(1) -> $(2)"
+endef
+
+default: rule1 rule2
 
-### `realpath`
-Resolve each file name as canonical path.
-```make
-$(realpath fname1 fname2 ..)
+$(eval $(call new_rule,rule1,foo))
+$(eval $(call new_rule,rule2,bar))
 
+

Outputs:

+
rule1 -> foo
+rule2 -> bar
+
+

foreach (ref)

+

Repeat a piece of text for a list of values, given the syntax $(foreach var,list,text).

+
myfn = x$(1)x
+
+default:
+	@echo $(foreach V,foo bar baz,$(call myfn,$(V)))
+
+

Outputs:

+
xfoox xbarx xbazx
+
+

Examples

+

Config based settings

+
conf-y      := default
+conf-$(FOO) := $(conf-y) foo
+conf-$(BAR) := $(conf-y) bar
+
+libs-y      := libdef
+libs-$(FOO) += libfoo
+libs-$(BAR) += libbar
+
+all:
+	@echo "conf-y: $(conf-y)"
+	@echo "libs-y: $(libs-y)"
+
+

Yields the following results.

+
$ make
+conf-y: default
+libs-y: libdef
+
+$ make FOO=y
+conf-y: default foo
+libs-y: libdef libfoo
+
+$ make BAR=y
+conf-y: default bar
+libs-y: libdef libbar
+
+$ make FOO=y BAR=y
+conf-y: default foo bar
+libs-y: libdef libfoo libbar
+
+

Using foreach / eval / call to generate new rules

+
define new_rule
+$(1):
+	@echo "$(1) -> $(2)"
+endef
+
+arg-rule1 = foo
+arg-rule2 = bar
+
+RULES = rule1 rule2
+
+all: $(RULES)
+
+$(foreach R,$(RULES),$(eval $(call new_rule,$(R),$(arg-$(R)))))
+
+# equivalent to
+#   $(eval $(call new_rule,rule1,foo))
+#   $(eval $(call new_rule,rule2,bar))
+
+

Outputs:

+
rule1 -> foo
+rule2 -> bar
+
+
+

Use make -R -p to print the make database including the rules.

+

ld.so(8)

Environment Variables

  LD_PRELOAD=<l_so>       colon separated list of libso's to be pre loaded
@@ -5879,7 +5985,7 @@ tcp/udp/icmp            Filter for protocol.
 

Use and/or/not and () to build filter expressions.

-

Examples

+

Examples

Capture packets from remote host

# -k: Start capturing immediately.
 ssh <host> tcpdump -i any -w - | sudo wireshark -k -i -
@@ -5911,7 +6017,7 @@ tcp/udp/ssh/wg/...             Filter for protocol.
 

Use tshak -G to list all fields that can be used in display filters.

-

Examples

+

Examples

Capture and filter packet to file

# Capture TCP traffic with port 80 on interface eth0 to file.
 sudo tshark -i eht0 -f 'tcp and port 80' -w tx.pcap
-- 
cgit v1.2.3