forked from MEGA65/mega65-libc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile_cc65
84 lines (70 loc) · 1.8 KB
/
Makefile_cc65
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
73
74
75
76
77
78
79
80
81
82
83
SHELL:=/bin/bash
XEMU=xmega65
TESTS_DIR := tests
TESTS_SRCS := $(wildcard $(TESTS_DIR)/*.c)
TESTS_PRGS := $(TESTS_SRCS:.c=.prg)
ifdef USE_LOCAL_CC65
# use locally installed binary (requires 'cc65,ld65,etc' to be in the $PATH)
CC65_PREFIX=
else
# use the binary built from the submodule
CC65_PREFIX=$(PWD)/cc65/bin/
endif
CC65=$(CC65_PREFIX)cc65
CL65=$(CC65_PREFIX)cl65
CA65=$(CC65_PREFIX)ca65 --cpu 4510
AR65=$(CC65_PREFIX)ar65
CFLAGS=-O -t c64 -I include/
LIB_OBJECTS = \
src/cc65/dirent.o \
src/cc65/fileio.o \
src/cc65/memory_asm.o \
src/conio.o \
src/debug.o \
src/fat32.o \
src/fcio.o \
src/hal.o \
src/math.o \
src/memory.o \
src/mouse.o \
src/random.o \
src/sdcard.o \
src/targets.o \
src/tests.o \
src/time.o
.PHONY: all clean cleanall test
all: libmega65.a ${TESTS_PRGS}
libmega65.a: $(LIB_OBJECTS)
$(AR65) a $@ $^
clean:
rm -f $(LIB_OBJECTS) $(TESTS_PRGS) tests/*.o
rm -rf work
cleanall: clean
rm -f libmega65.a
src/cc65/%.o: src/cc65/%.s
$(CA65) -o $@ $<
src/%.o: src/%.c
@if [[ ! -d work ]]; then \
mkdir work; \
fi
$(CC65) $(CFLAGS) -o work/$*.s $<
$(CA65) -o $@ work/$*.s
# Unit tests using Xemu in "testing" mode
#
# - Xemu `xmega65` must be in your path
# - Xemu's return code is controlled by register 0xD6CF
# - All tests are in the `tests/` directory
tests/%.prg: tests/%.c libmega65.a
$(CL65) $(CFLAGS) $< -o $@ libmega65.a
test: | $(TESTS_PRGS)
@if ! command -v $(XEMU) &> /dev/null; then \
echo "Cannot run tests as xmega65 (Xemu) is not in your path."; \
else \
for test in $(TESTS_PRGS); do \
if $(XEMU) -testing -hyperserialascii -sleepless -headless -model 3 -prg $$test &> /dev/null; then \
echo "Test passed: $$test"; \
else \
echo "Test FAILED: $$test"; \
fi; \
done; \
fi