Jelajahi Sumber

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 tahun lalu
induk
melakukan
ff88b47383
1 mengubah file dengan 7 tambahan dan 0 penghapusan
  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