aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: b04fce7e6cf5e3ab42094ba44234fda397e29088 (plain)
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
V =
ifeq ($(strip $(V)),)
	E = @echo
	Q = @
else
	E = @\#
	Q =
endif

# CC65 is set to `xa65` if that exists, otherwise we resort to `cl65` by default.
XA65_BIN := $(shell command -v xa65 2>/dev/null)
ifneq ($(XA65_BIN),)
	CC65   ?= xa65
else
	CC65   ?= cl65
endif

# NOTE: you can configure `CC65` and `CCOPTS` with the compiler and its options
# that you might require.
CCOPTS ?= --target nes

# Be strict when using xa65, and extra verbose if V=1.
ifeq ($(CC65),xa65)
	CCOPTS += --strict --stats
endif

##
# all: clean the workspace and build the ROM file.

.PHONY: all
all: clean deps build

##
# clean & deps: clean the workspace and check that all dependencies are met.

.PHONY: clean
clean:
	$(Q) rm -rf out
	$(Q) find . -type f -name "*.nes" -delete
	$(Q) rm -rf .nasm/
	$(Q) mkdir -p out/

.PHONY: deps
deps:
	@which $(CC65) >/dev/null 2>/dev/null || (echo "ERROR: '$(CC65)' not found." && false)

##
# build: create the ROM file.

.PHONY: build
build:
	$(Q) $(CC65) $(CCOPTS) src/btree.s -C config/mmc1.cfg -o out/btree.nes 1>/dev/null