2010-09-13 18:22:05 +04:00
# NB: don"t use ANY quotes ('/") for put()/add()/set() arguments!
# shell will get confused by ' or args get spammed with "
2011-05-11 23:40:47 +04:00
# pay attention to the context functions get called in:
2010-09-18 18:46:32 +04:00
# e.g. features.in/syslinux/config.mk introduces conditionals
2010-09-13 18:22:05 +04:00
# this one adds whatever is given as an argument
put = $( and $( 1) ,$( put_body) )
d e f i n e p u t _ b o d y
2010-09-18 18:46:32 +04:00
{ $( log_body ) ; \
p r i n t f '%s\n' '$(1)' > > "$(CONFIG)" ; }
2010-09-13 18:22:05 +04:00
e n d e f
2010-09-27 23:02:57 +04:00
# these three take two args
2010-09-13 18:22:05 +04:00
# add() just appends an additive rule...
add = $( and $( 1) ,$( 2) ,$( add_body) )
d e f i n e a d d _ b o d y
2011-09-14 00:51:22 +04:00
$( if $ ( filter GLOBAL_ % INFO_ %,$ ( 1) ) ,$ ( warning add ,$ ( 1) might be a problem ) ) \
2010-09-18 18:46:32 +04:00
{ $( log_body ) ; \
p r i n t f '%s += %s\n' '$(1)' '$(2)' > > "$(CONFIG)" ; }
2010-09-13 18:22:05 +04:00
e n d e f
# ...set() comments out any previous definition
2010-09-27 23:02:57 +04:00
# and then appends an assigning rule...
2014-09-18 01:39:37 +04:00
# NB: $(2) could be empty
set = $( and $( 1) ,$( set_body) )
2010-09-13 18:22:05 +04:00
d e f i n e s e t _ b o d y
2010-09-18 18:46:32 +04:00
{ $( log_body ) ; \
2011-12-26 20:20:12 +04:00
s e d - i 's|^$(1)[ ]*[+?]*=.*$$|#& # overridden by $@|' "$(CONFIG)" ; \
2010-09-18 18:46:32 +04:00
p r i n t f '%s = %s\n' '$(1)' '$(2)' > > "$(CONFIG)" ; }
2010-09-13 18:22:05 +04:00
e n d e f
2010-09-27 23:02:57 +04:00
# try() appends a conditionally-assigning rule
try = $( and $( 1) ,$( 2) ,$( try_body) )
d e f i n e t r y _ b o d y
{ $( log_body ) ; \
p r i n t f '%s ?= %s\n' '$(1)' '$(2)' > > "$(CONFIG)" ; }
e n d e f
2012-06-26 02:10:12 +04:00
# xport() requests a variable to be exported to the scripts
xport = $( and $( 1) ,$( xport_body) )
d e f i n e x p o r t _ b o d y
{ $( log_body ) ; \
v = '$(1:GLOBAL_%=%)' ; \
p r i n t f 'export GLOBAL_%s = $$(%s)\n' "$$v" "$$v" > > "$(CONFIG)" ; }
e n d e f
2010-09-27 23:02:57 +04:00
# if the rule being executed isn't logged yet, log it
2010-09-13 18:22:05 +04:00
d e f i n e l o g _ b o d y
2011-10-06 12:46:31 +04:00
{ [ - s "$(CONFIG)" ] & & \
grep -q '^# $@$$' " $( CONFIG) " || printf '# %s\n' '$@' >> " $( CONFIG) " ; }
2010-09-13 18:22:05 +04:00
e n d e f
2011-11-16 19:58:42 +04:00
# in a use/feature/particularly target, we need a "feature" bit
add_feature = $( call add,FEATURES,$( word 2,$( subst /, ,$@ ) ) )
2010-10-29 13:11:03 +04:00
# convert tag list into a list of relative package list paths
2011-10-06 12:46:31 +04:00
# NB: tags can do boolean expressions: (tag1 && !(tag2 || tag3))
2012-04-06 21:13:32 +04:00
tags = $( and $( strip $( 1) ) ,$( addprefix tagged/,$( shell echo " $( 1) " \
| tags2lists pkg.in/lists/tagged) ) )
2011-10-06 12:46:31 +04:00
# toplevel Makefile convenience
addsuffices = $( foreach s,$( 1) ,$( call addsuffix,$s ,$( 2) ) )