|
From: | Brian Vandenberg |
Subject: | Re: use of math.h / libmath discouraged? |
Date: | Wed, 25 Jul 2018 14:25:56 -0600 |
However, I'm not sure that this function is sufficiently generic to be
added as a built-in function. Can you provide use-cases for it?
$ cat makefile
F1 = ${${1}}
F2 = $(call ${0}_,$(strip ${1}))
F2_ = ${${1}}
TEXT = something
# note: the space before the word TEXT is helpful for readability but causes a problem
$(info $(call F1, TEXT))
$(warning $(call F2, TEXT))
$ make --warn-undefined-variables
makefile:6: warning: undefined variable ' TEXT'
makefile:7: something
# Recursion:
F1 = $(strip $(if $(filter 16,${3}),${2},$(call ${0},${1},${${1}} ${2},$(words ${2}))))
TEST = something
# prints the word "something" 16 times
$(info $(call F1,TEST,,))
# Automatically generate a target
define MAKE_TARGET
$(eval ${1}.o := $(addsuffix .o, $(basename $(wildcard ${2}))))
# evals needed because of ${${1}.o}
$(eval ${1} : ${${1}.o})
# ... whatever other strange contrivance comes to mind ...
endef
# recursively expanded variable (B) with partial expansion.
A = a
B = ${A}
$(eval B=$(value B) ${B})
# prints: ${A} a
$(info $(value B))
# variable reflection
THING = $(call ${0}_,$(filter $(firstword $(notdir $(basename ${1}))).$(strip ${2}),${.VARIABLES}),$(strip ${2}))
THING_ = ${$(strip $(if ${1},${1},${2}))}
# Depending on its existence either bar.CFLAGS or CFLAGS gets evaluated
bar : ; ${CC} $(call THING, address@hidden, CFLAGS) ${^} -o address@hidden
# Conditional evaluation of macro arguments; ifdef/ifndef is from our plugin
F = $(ifndef 3,$(error ${0} requires 3 arguments))...stuff...
NOW = $(shell date +%s%N)
before := ${NOW}
${_expression_}
after := ${NOW}
$(info difference: $(shell expr ${after} - ${before}))
[Prev in Thread] | Current Thread | [Next in Thread] |