-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMakefile
More file actions
156 lines (128 loc) · 3.96 KB
/
Copy pathMakefile
File metadata and controls
156 lines (128 loc) · 3.96 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
ifdef USE_LOCAL_CC65
# use locally installed binary (requires cc65 to be in the $PATH)
CC65=cc65
CL65=cl65
else
# use the binary built from the submodule
CC65=cc65/bin/cc65
CL65=cc65/bin/cl65
endif
# check if we are building against the old version of libc, still having cc65 as a toplevel dir
ifneq ($(wildcard ../mega65-libc/cc65/*),)
MEGA65LIBCDIR= ../mega65-libc/cc65
MEGA65LIBCLIB= $(MEGA65LIBCDIR)/libmega65.a
MEGA65LIBCINC= -I$(MEGA65LIBCDIR)/include
else
MEGA65LIBCDIR= ../mega65-libc
MEGA65LIBCLIB= $(MEGA65LIBCDIR)/libmega65.a
MEGA65LIBCINC= -I$(MEGA65LIBCDIR)/include/mega65
endif
COPTS= -t c64 -O -Or -Oi -Os --cpu 65c02 -Icc65/include $(MEGA65LIBCINC)
LOPTS= --asm-include-dir cc65/asminc --config memory.cfg --lib-path cc65/lib -L$(MEGA65LIBCDIR)
PNGCFLAGS=`pkg-config --cflags libpng`
PNGLIBS= `pkg-config --libs libpng`
FILES= m65fdisk.prg
GTESTDIR=gtest
GTESTBINDIR=$(GTESTDIR)/bin
# For now, disable g++ compile warnings on tests (there's so many :))
GTESTOPTS=-w -DTESTING
GTESTFILES=$(GTESTBINDIR)/m65fdisk.test
GTESTFILESEXE=$(GTESTBINDIR)/m65fdisk.test.exe
M65IDESOURCES= fdisk.c \
fdisk_screen.c \
fdisk_fat32.c \
fdisk_hal_mega65.c
ASSFILES= fdisk.s \
fdisk_screen.s \
fdisk_fat32.s \
fdisk_hal_mega65.s \
charset.s
HEADERS= Makefile \
fdisk_screen.h \
fdisk_fat32.h \
fdisk_hal.h \
ascii.h
DATAFILES= ascii8x8.bin
%.s: %.c $(HEADERS) $(DATAFILES) $(CC65)
$(warning ======== Making: $@)
$(CC65) $(COPTS) --add-source -o $@ $<
all: $(FILES)
format:
submodules=""; for sm in `git submodule | awk '{ print "./" $$2 }'`; do \
submodules="$$submodules -o -path $$sm"; \
done; \
find . -type d \( $${submodules:3} \) -prune -false -o \( -iname '*.h' -o -iname '*.c' -o -iname '*.cpp' \) -print0 | xargs -0 clang-format --style=file -i --verbose
.PHONY: format
$(CL65):
$(CC65):
$(warning ======== Making: $@)
ifdef USE_LOCAL_CC65
@echo "Using local installed CC65."
else
git submodule init
git submodule update
(cd cc65 && make -j 8 )
endif
ascii8x8.bin: ascii00-ff.png pngprepare
$(warning ======== Making: $@)
./pngprepare charrom ascii00-ff.png ascii8x8.bin
asciih: asciih.c
$(warning ======== Making: $@)
$(CC) -o asciih asciih.c
ascii.h: asciih
$(warning ======== Making: $@)
./asciih
pngprepare: pngprepare.c
$(warning ======== Making: $@)
$(CC) $(PNGCFLAGS) -o pngprepare pngprepare.c $(PNGLIBS)
m65fdisk.prg: $(ASSFILES) $(DATAFILES) $(CC65)
$(warning ======== Making: $@)
$(CL65) $(COPTS) $(LOPTS) -vm -m m65fdisk.map --listing m65fdisk.list -Ln m65fdisk.label -o m65fdisk.prg $(ASSFILES) $(MEGA65LIBCLIB)
UNIX_M65FDISK_SRC = fdisk.c \
fdisk_fat32.c \
fdisk_hal_unix.c \
fdisk_screen.c
m65fdisk: $(HEADERS) Makefile $(UNIX_M65FDISK_SRC)
$(warning ======== Making: $@)
gcc -Wall -Wno-pointer-to-int-cast -Wno-char-subscripts -g -O0 -o m65fdisk $(UNIX_M65FDISK_SRC)
define LINUX_AND_MINGW_GTEST_TARGETS
$(1): $(2)
$$(CXX) $$(COPT) $$(GTESTOPTS) -Iinclude -o $$@ $$(filter %.c %.cpp,$$^) -lgtest_main -lgtest -lpthread $(3)
$(1).exe: $(2)
$$(CXX) $$(WINCOPT) $$(GTESTOPTS) -Iinclude $(LIBUSBINC) -o $$@ $$(filter %.c %.cpp,$$^) -lgtest_main -lgtest -lpthread $(3)
endef
# Gives two targets of:
# - gtest/bin/m65fdisk.test
# - gtest/bin/m65fdisk.test.exe
$(eval $(call LINUX_AND_MINGW_GTEST_TARGETS, $(GTESTBINDIR)/m65fdisk.test, $(GTESTDIR)/m65fdisk_test.cpp $(UNIX_M65FDISK_SRC) Makefile, -fpermissive -std=gnu++14 -g -O0))
# testing
test: $(GTESTFILES)
@for test in $+; do \
name=$${test%%.test}; \
name=$${name##*/}; \
echo ""; \
echo "TESTING: $$name..."; \
echo "======================"; \
$$test; \
done
test.exe: $(GTESTFILESEXE)
@for test in $+; do \
name=$${test%%.test.exe}; \
name=$${name##*/}; \
path=$${test%/*}; \
echo ""; \
echo "TESTING: $$name..."; \
echo "======================"; \
cd $$path; ./$${test##*/}; \
done
clean:
rm -f $(FILES) m65fdisk.map \
pngprepare \
*.o \
fdisk*.s \
ascii.h asciih \
ascii8x8.bin \
*.prg \
gtest/bin/m65fdisk.test
cleangen:
rm ascii8x8.bin