-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
69 lines (55 loc) · 1.63 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
Q ?= @
CC = arm-none-eabi-gcc
AR = arm-none-eabi-ar
RANLIB = arm-none-eabi-ranlib
NWLINK = npx --yes -- [email protected]
LINK_GC = 1
LTO = 1
LIBS_PATH=$(shell pwd)/output/libs
CFLAGS += $(shell $(NWLINK) eadk-cflags)
CFLAGS += -Os
CPPFLAGS += -I$(LIBS_PATH)/include
CFLAGS += -fno-exceptions -fno-unwind-tables
LDFLAGS += --specs=nano.specs
LDFLAGS += -L$(LIBS_PATH)/lib
ifeq ($(LINK_GC),1)
CFLAGS += -fdata-sections -ffunction-sections
LDFLAGS += -Wl,-e,main -Wl,-u,eadk_app_name -Wl,-u,eadk_app_icon -Wl,-u,eadk_api_level
LDFLAGS += -Wl,--gc-sections
endif
ifeq ($(LTO),1)
AR = arm-none-eabi-gcc-ar
RANLIB = arm-none-eabi-gcc-ranlib
CFLAGS += -flto -fno-fat-lto-objects
CFLAGS += -fwhole-program
CFLAGS += -fvisibility=internal
LDFLAGS += -flinker-output=nolto-rel
endif
.PHONY: build
build: output/peanutgb.nwa
.PHONY: check
check: output/peanutgb.bin
.PHONY: run
run: output/peanutgb.nwa src/flappyboy.gb
@echo "INSTALL $<"
$(Q) $(NWLINK) install-nwa --external-data src/flappyboy.gb $<
output/%.bin: output/%.nwa src/flappyboy.gb
@echo "BIN $@"
$(Q) $(NWLINK) nwa-bin --external-data src/flappyboy.gb $< $@
output/%.elf: output/%.nwa src/flappyboy.gb
@echo "ELF $@"
$(Q) $(NWLINK) nwa-elf --external-data src/flappyboy.gb $< $@
output/peanutgb.nwa: output/main.o output/icon.o
@echo "LD $@"
$(Q) $(CC) $(CPPFLAGS) $(CFLAGS) -Wl,--relocatable -nostartfiles $(LDFLAGS) $^ -o $@
$(addprefix output/,%.o): src/%.c
@mkdir -p $(@D)
@echo "CC $@"
$(Q) $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
output/icon.o: src/icon.png
@echo "ICON $<"
$(Q) $(NWLINK) png-icon-o $< $@
.PHONY: clean
clean:
@echo "CLEAN"
$(Q) rm -rf output