-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (56 loc) · 1.49 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
CXX = arm-none-eabi-g++
BUILD_DIR = target
NWLINK = npx --yes -- [email protected]
LINK_GC = 1
LTO = 1
define object_for
$(addprefix $(BUILD_DIR)/,$(addsuffix .o,$(basename $(1))))
endef
src = $(addprefix src/,\
main.cpp \
)
CPPFLAGS = -std=c++14 -fno-exceptions
CPPFLAGS += -Os -Wall
CPPFLAGS += $(shell $(NWLINK) eadk-cflags)
LDFLAGS = -Wl,--relocatable
LDFLAGS += -nostartfiles
LDFLAGS += --specs=nano.specs
LDFLAGS += -lm
ifeq ($(LINK_GC),1)
CPPFLAGS += -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)
CPPFLAGS += -flto -fno-fat-lto-objects
CPPFLAGS += -fwhole-program
CPPFLAGS += -fvisibility=internal
LDFLAGS += -flinker-output=nolto-rel
endif
.PHONY: build
build: $(BUILD_DIR)/mandelbrot.bin
.PHONY: run
run: $(BUILD_DIR)/mandelbrot.nwa
@echo "INSTALL $<"
$(Q) $(NWLINK) install-nwa $<
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.nwa
@echo "BIN $@"
$(Q) $(NWLINK) nwa-bin $< $@
$(BUILD_DIR)/mandelbrot.nwa: $(call object_for,$(src)) $(BUILD_DIR)/icon.o
@echo "LD $@"
$(Q) $(CC) $(CPPFLAGS) $(LDFLAGS) $^ -lm -o $@
$(addprefix $(BUILD_DIR)/,%.o): %.cpp | $(BUILD_DIR)
@echo "CXX $^"
$(Q) $(CXX) $(CPPFLAGS) $(SFLAGS) -c $^ -o $@
$(BUILD_DIR)/icon.o: src/icon.png
@echo "ICON $<"
$(Q) $(NWLINK) png-icon-o $< $@
.PRECIOUS: $(BUILD_DIR)
$(BUILD_DIR):
$(Q) mkdir -p $@/src
.PHONY: clean
clean:
@echo "CLEAN"
$(Q) rm -rf $(BUILD_DIR)