Commit 768df7e9 authored by Michael Shigorin's avatar Michael Shigorin

main.mk: target refactoring

The issue with the original hasty code that stuck around was that it bluntly ignored any ifdef/ifeq constructs due to an obvious reason of being essentially a grep, not a makefile interpreter. It's now fixed so that e.g. arch-specific targets won't pop up for no good reason. Thanks ldv@ for discussion and a reminder about the dump mode (make -p).
parent a18295f2
......@@ -40,14 +40,17 @@ $(shell mkdir -p $(IMAGEDIR))
IMAGEDIR := $(wildcard $(IMAGEDIR))
endif
# FIXME: this is buggy since *.mk can expose parts conditionally
# (e.g. test.mk does DEBUG-only bits) and these will fail
DISTRO_TARGETS := $(shell sed -n 's,^\(distro/[^:.]\+\):.*$$,\1,p' \
lib/distro.mk $(wildcard conf.d/*.mk) | sort -u)
VE_TARGETS := $(shell sed -n 's,^\(ve/[^:.]\+\):.*$$,\1,p' \
lib/ve.mk $(wildcard conf.d/*.mk) | sort -u)
VM_TARGETS := $(shell sed -n 's,^\(vm/[^:.]\+\):.*$$,\1,p' \
lib/vm.mk $(wildcard conf.d/*.mk) | sort -u)
# conf.d/*.mk can expose parts conditionally (e.g. DEBUG-only bits)
targets = $(shell \
for i in conf.d/*.mk; do \
make IMAGE_CLASS=$(1) -s -r -p -f $$i 2>/dev/null; \
done \
| sed -rn 's,^($(1)/[^.:]+):.*,\1,p' \
| sort -u)
DISTRO_TARGETS := $(call targets,distro)
VE_TARGETS := $(call targets,ve)
VM_TARGETS := $(call targets,vm)
DISTROS := $(call addsuffices,$(DISTRO_EXTS),$(DISTRO_TARGETS))
VES := $(call addsuffices,$(VE_EXTS),$(VE_TARGETS))
VMS := $(call addsuffices,$(VM_EXTS),$(VM_TARGETS))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment