PROGRAMS = autoboard define PROGRAM_template = BIN_FILES += bin/$(1) $(1)_SRC = $(wildcard src/$(1)/*.cr) bin/$(1): $$($(1)_SRC) @echo "-- Building $(1)..." @shards build $(1) @echo "-- done" endef $(foreach program,$(PROGRAMS),$(eval $(call PROGRAM_template,$(program)))) all: build build: $(BIN_FILES) echo "Building $(BIN_FILES)" clean: @echo "-- Cleaning $(BIN_FILES)..." @rm -f $(BIN_FILES) @echo "-- done" .PHONY: build clean # Ref: https://www.gnu.org/software/make/manual/html_node/Eval-Function.html