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 "
2010-09-18 18:46:32 +04:00
# pay attention to the context in which functions get called:
# 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
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...
2010-09-13 18:22:05 +04:00
set = $( and $( 1) ,$( 2) ,$( set_body) )
d e f i n e s e t _ b o d y
2010-09-18 18:46:32 +04:00
{ $( log_body ) ; \
2010-09-27 23:02:57 +04:00
s u b s t '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
# 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
2010-09-18 18:46:32 +04:00
{ g r e p - q '^# $@$$' "$(CONFIG)" | | p r i n t f '# %s\n' '$@' > > "$(CONFIG)" ; }
2010-09-13 18:22:05 +04:00
e n d e f
2010-10-11 13:36:41 +04:00
tags = $( addprefix tagged/,$( shell echo " $( 1) " | bin/tags2lists) )