forked from akanyuk/mbf_zx128
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
72 lines (50 loc) · 1.86 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Project name
PROJECT_NAME = tbf
# Listing the parts that should be assembled automatically
PARTS=part.box part.houses part.chunks1 part.12anim part.4slow part.anim2
NAME_SUFFIX = $(shell date +%Y%m%d)-$(shell git log --format="%h" -n 1)
.PHONY: all build clean clean-% help
all: build
build: build/part.intro.bin build/part.outro.bin $(PARTS:%=build/%.bin.zx0) ## Default: build project
@printf "\033[32mBuilding '$(PROJECT_NAME)'\033[0m\n"
rm -f build/$(PROJECT_NAME)*.sna
rm -f build/*.trd
rm -f build/*.c
sjasmplus --fullpath --color=off --inc=src/. \
-DSNA_FILENAME=\"build/$(PROJECT_NAME)-$(NAME_SUFFIX).sna\" \
-DTRD_FILENAME=\"build/$(PROJECT_NAME).trd\" \
src/main.asm
ifneq ($(COPY_SNAPSHOT_TO),)
cp --force build/$(PROJECT_NAME)-$(NAME_SUFFIX).sna $(COPY_SNAPSHOT_TO)
endif
@printf "\033[32mDone\033[0m\n"
ifneq ($(EMULATOR_BINARY),)
$(EMULATOR_BINARY) build/$(PROJECT_NAME)-$(NAME_SUFFIX).sna
endif
build/%.bin.zx0: build/%.bin
@printf "\033[32mBuilding '$@'\033[0m\n"
rm -f $@
zx0 $(subst .zx0,,$@)
@printf "\033[32mdone\033[0m\n\n"
build/%.bin: clean-%
@printf "\033[32mCompiling '$(patsubst build/%.bin,%,$@)'\033[0m\n"
@echo $(subst part.,,$@)
@echo $@
mkdir -p build
sjasmplus --fullpath --color=off \
-DSNA_FILENAME=\"$(patsubst %.bin,%,$@)-$(NAME_SUFFIX).sna\" \
-DBIN_FILENAME=\"$@\" \
src/$(patsubst build/%.bin,%,$@)/main.asm
ifneq ($(COPY_SNAPSHOT_TO),)
cp --force $(patsubst %.bin,%,$@)-$(NAME_SUFFIX).sna $(COPY_SNAPSHOT_TO)
endif
@printf "\033[32mdone\033[0m\n\n"
ifneq ($(EMULATOR_BINARY),)
$(EMULATOR_BINARY) $(patsubst %.bin,%,$@)-$(NAME_SUFFIX).sna
endif
clean-%:
rm -f build/$(subst clean-,,$@)*
clean: ## Remove all artifacts
rm -f build/*
help: ## Display available commands
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-8s\033[0m %s\n", $$1, $$2}'