make the hooks usable by the whole catalogue

- hooks load the _stack files of every directory between the stack path root
  and the stack, outermost first: make included both $(dir)/*.mk and
  $(dir)/*/*.mk, so a stack in a subdirectory saw its parent's settings
- a group may be declared in <group>/<group>.env, where the stack lives
- MYOS_STACK_DIR lets a hook read a file it ships next to itself
- myos_filter no longer confuses a literal * in a make pattern with a wildcard,
  and the list helpers no longer let the shell expand a * into filenames
- MACHINE, SYSTEM, HOST and DOMAINNAME join the framework variables a hook sees
- the make shim gains $(call myos-var,NAME), so a .mk target can read a
  setting that now lives in a hook, and it picks up the .mk of every stack
  directory rather than only the project's
This commit is contained in:
Yann Autissier
2026-09-03 22:30:01 +02:00
parent 6192d73cbe
commit 084a25c627
7 changed files with 136 additions and 40 deletions
+11 -3
View File
@@ -19,21 +19,29 @@
MYOS ?= $(patsubst %/share/make/shim.mk,%,$(lastword $(MAKEFILE_LIST)))
MYOS_BIN ?= $(MYOS)/bin/myos
STACK_DIR_NAME ?= stack
STACK_DIR ?= $(wildcard $(CURDIR)/$(STACK_DIR_NAME))
## every directory myos looks for stacks in, so the .mk of a stack installed
## system wide brings its targets along too
STACK_DIR ?= $(subst :, ,$(shell $(MYOS_BIN) env MYOS_PATH --color=never 2>/dev/null | awk '{print $$2}'))
# variable MYOS_ARGS: variables set on the make command line, forwarded to myos
MYOS_ARGS ?= $(foreach v,$(MAKEOVERRIDES),$(v))
.DEFAULT_GOAL := help
## the stack files of the project may add their own targets and variables
include $(wildcard $(STACK_DIR)/*.mk $(STACK_DIR)/*/*.mk)
## the stack files may add their own targets: that is what make is kept for
include $(foreach dir,$(STACK_DIR),$(wildcard $(dir)/*.mk $(dir)/*/*.mk))
# function make: run a myos command, for the stack .mk files that call it
define make
$(MYOS_BIN) $(MYOS_ARGS) $(1)
endef
# function myos-var: the value myos resolves for a variable.
# A stack keeps its settings in hooks that only myos reads, so a .mk target
# asks for them rather than defining them itself:
# $(call myos-var,HOST_DOCKER_VOLUME)
myos-var = $(shell $(MYOS_BIN) --color=never $(MYOS_ARGS) env $(1) | awk '{print $$2}')
# target help: List the myos commands
.PHONY: help
help: