-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
53 lines (44 loc) · 1.28 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
BUILD_PATH?=
BUILD_MAKE_FLAGS?= -j
DOCKER?= docker
DOCKER_IMAGE?= ijacquez/yaul:latest
DOCKER_NAME?= dev
ifeq ($(strip $(SILENT)),)
ECHO=
else
ECHO=@
endif
export ECHO
NOCOLOR?=
# $1 -> BUILD_PATH
define macro-check-progname
@set -e; \
test -n "$1" || { printf -- "Undefined BUILD_PATH.\n" >&2; exit 1; }; \
test -e "$1" || { printf -- "\"$1\" does not exist\n" >&2; exit 1; }; \
test -d "$1" || { printf -- "\"$1\" is not a directory\n" >&2; exit 1; }
endef
# $@ -> Command ...
define macro-run-project
$(ECHO)$(DOCKER) run --volume=$(shell pwd)/$(BUILD_PATH):/work --rm --name=$(DOCKER_NAME) -it \
-e SILENT=$(SILENT) \
-e NOCOLOR=$(NOCOLOR) \
$(DOCKER_IMAGE)
endef
.PHONY: all
all:
@$(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) : 2>/dev/null | \
awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | \
sort | \
grep -E -v -e '^[^[:alnum:]]' -e '^$@$$'
.PHONY: copy-template
copy-template:
@$(call macro-check-progname,$(BUILD_PATH))
$(call macro-run-project) cp -v -r /opt/yaul-examples/_template/. ./
.PHONY: clean
clean:
@$(call macro-check-progname,$(BUILD_PATH))
$(call macro-run-project) make clean
.PHONY: build
build:
@$(call macro-check-progname,$(BUILD_PATH))
$(call macro-run-project) make $(BUILD_MAKE_FLAGS)