瀏覽代碼

In addition to “show”, also do a “dump” target

Similar to MirBSD commitid 1004B2E19EE11E297EC – although this
is a kind of “masterpiece” of freakin’ GNU make hackery. Here,
quoting is achieved manually by the formula of “replace ‘'’ by
‘'\''’ and wrap the whole thing in ‘'…'’” instead of the easier
variable expansion suffix :Q which BSD make has. Compare:

• GNU make

ifneq (${dump},)
__shquote=		'$(subst ','\'',$(1))'
__dumpvar=		echo $(call __shquote,$(1)=$(call __shquote,${$(1)}))
.DEFAULT_GOAL:=		show
show:
	@$(foreach _s,${dump},$(call __dumpvar,${_s});)
endif

• BSD make

.ifdef dump
.MAIN: show
show:
.  for _s in ${dump}
	@echo ${_s:Q:Q}=${${_s}:Q:Q}
.  endfor
.endif

Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
Thorsten Glaser 14 年之前
父節點
當前提交
ff88b47383
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      rules.mk

+ 7 - 0
rules.mk

@@ -43,8 +43,15 @@ TARGET_CFLAGS:=		$(strip -fwrapv -fno-ident ${TARGET_CFLAGS})
 TARGET_CC:=		$(strip ${TARGET_CC})
 TARGET_CXX:=		$(strip ${TARGET_CXX})
 
+# I hate GNU make!	--mirabilos
 ifneq (${show},)
 .DEFAULT_GOAL:=		show
 show:
 	@$(info ${${show}})
+else ifneq (${dump},)
+__shquote=		'$(subst ','\'',$(1))'
+__dumpvar=		echo $(call __shquote,$(1)=$(call __shquote,${$(1)}))
+.DEFAULT_GOAL:=		show
+show:
+	@$(foreach _s,${dump},$(call __dumpvar,${_s});)
 endif