criu/scripts/nmk/scripts/macro.mk
Cyrill Gorcunov 3ddf271a5b nmk: scritps/macro.mk -- Enhance gen-built-in
Add ability to specify prerequsites and phony targets.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-23 13:10:45 +03:00

35 lines
659 B
Makefile

ifndef ____nmk_defined__macro
#
# Helper to include makefile only once.
#
define include-once
ifndef $(join ____nmk_defined__,$(1:.mk=))
include $(__nmk_dir)$(1)
endif
endef
# Helper to build built-in target in directory.
# $(eval $(call gen-built-in,<dir>,<prerequsite>,<phony>))
define gen-built-in
$(1)/%: $(2)
$$(Q) $$(MAKE) $$(build)=$(1) $$@
ifneq ($(3),)
$(3): $(2)
$$(Q) $$(MAKE) $$(build)=$(1) all
.PHONY: $(3)
$(1)/built-in.o: $(3)
else
$(1): $(2)
$$(Q) $$(MAKE) $$(build)=$(1) all
.PHONY: $(1)
$(1)/built-in.o: $(1)
endif
endef
#
# Footer.
$(__nmk_dir)scripts/macro.mk:
@true
____nmk_defined__macro = y
endif