Factorize makefile

This commit is contained in:
Glenn Y. Rolland 2021-04-04 14:55:38 +02:00
parent 207b417c3d
commit ff62ecae0c
2 changed files with 25 additions and 7 deletions

View File

@ -1,13 +1,15 @@
BINARIES=hodler
hodler_FILES=$(wildcard src/*.cr src/**/*.cr)
all: build
build: bin/hodler
build: ## Build binaries
bin/hodler: $(wildcard src/*.cr)
shards build hodler
clean: ## Clean binaries
completion: bin/hodler
$< --completion --development
.PHONY: clean build all
## Add targets for crystal
include tasks/crystal.mk
clean:
rm bin/hodler

16
tasks/crystal.mk Normal file
View File

@ -0,0 +1,16 @@
define BINARY_template
ALL_FILES += $($(1)_FILES)
build: build-$(1)
build-$(1): bin/$(1)
bin/$(1): $($(1)_FILES)
shards build $(1)
clean: clean-$(1)
clean-$(1):
rm -f bin/$(1)
endef
$(foreach binary,$(BINARIES),$(eval $(call BINARY_template,$(binary))))