-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmake.mk
195 lines (163 loc) · 5.66 KB
/
make.mk
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
##############################################################################
BUILD = ./build
BIN = firmware
include $(GOSSAMER_PATH)/boards/$(BOARD)/board.mk
##############################################################################
.PHONY: all directory clean size
# OS detection, adapted from https://gist.github.com/sighingnow/deee806603ec9274fd47
DETECTED_OS :=
ifeq ($(OS),Windows_NT)
DETECTED_OS = WINDOWS
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
DETECTED_OS = LINUX
endif
ifeq ($(UNAME_S),Darwin)
DETECTED_OS = OSX
endif
endif
$(if ${VERBOSE},$(info OS detected: $(DETECTED_OS)))
ifeq ($(OS), Windows_NT)
MKDIR = gmkdir
else
MKDIR = mkdir
endif
INCLUDES += \
-I$(GOSSAMER_PATH)/common/ \
ifndef EMSCRIPTEN
# Settings and flags for building on hardware
ifeq ($(DETECTED_OS), LINUX)
MAKEFLAGS += -j $(shell nproc)
endif
ifeq ($(DETECTED_OS), OSX)
NPROCS = $(shell sysctl hw.ncpu | grep -o '[0-9]\+')
MAKEFLAGS += -j $(NPROCS)
endif
ifeq ($(DETECTED_OS), WINDOWS)
MAKEFLAGS += -j $(NUMBER_OF_PROCESSORS)
endif
CC = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy
SIZE = arm-none-eabi-size
UF2 = python3 $(GOSSAMER_PATH)/utils/uf2/uf2conv.py
DFU_CONV = $(GOSSAMER_PATH)/utils/dfu/dx1elf2dfu
DFU_UTIL = dfu-util
CFLAGS += -W -Wall -Wextra -Wmissing-prototypes -Wmissing-declarations
CFLAGS += --std=c99 -Os
CFLAGS += -fno-diagnostics-show-caret
CFLAGS += -fdata-sections -ffunction-sections
CFLAGS += -funsigned-char -funsigned-bitfields
CFLAGS += -mcpu=cortex-m0plus -mthumb
CFLAGS += -MD -MP -MT $(BUILD)/$(*F).o -MF $(BUILD)/$(@F).d
LDFLAGS += -mcpu=cortex-m0plus -mthumb
LDFLAGS += -Wl,--gc-sections
LDFLAGS += -Wl,--script=$(GOSSAMER_PATH)/chips/$(CHIP)/linker/$(LDSCRIPT).ld
LDFLAGS += -specs=nosys.specs
LIBS += -lm
INCLUDES += \
-I$(GOSSAMER_PATH)/peripherals/ \
-I$(GOSSAMER_PATH)/chips/$(CHIP)/include/ \
SRCS += \
$(GOSSAMER_PATH)/chips/$(CHIP)/startup_$(CHIP).c \
$(GOSSAMER_PATH)/chips/$(CHIP)/system_$(CHIP).c \
$(GOSSAMER_PATH)/common/delay.c \
$(GOSSAMER_PATH)/peripherals/adc.c \
$(GOSSAMER_PATH)/peripherals/dac.c \
$(GOSSAMER_PATH)/peripherals/dma.c \
$(GOSSAMER_PATH)/peripherals/eic.c \
$(GOSSAMER_PATH)/peripherals/evsys.c \
$(GOSSAMER_PATH)/peripherals/i2c.c \
$(GOSSAMER_PATH)/peripherals/i2s.c \
$(GOSSAMER_PATH)/peripherals/opamp.c \
$(GOSSAMER_PATH)/peripherals/ptc.c \
$(GOSSAMER_PATH)/peripherals/rtc.c \
$(GOSSAMER_PATH)/peripherals/sercom.c \
$(GOSSAMER_PATH)/peripherals/slcd.c \
$(GOSSAMER_PATH)/peripherals/spi.c \
$(GOSSAMER_PATH)/peripherals/tc.c \
$(GOSSAMER_PATH)/peripherals/tcc.c \
$(GOSSAMER_PATH)/peripherals/uart.c \
else
# Settings and flags for building with Emscripten
BUILD = ./build-sim
CC = emcc
INCLUDES += \
-I$(GOSSAMER_PATH)/dummy/peripherals/ \
-I$(GOSSAMER_PATH)/dummy/chips/$(CHIP)/include/ \
SRCS += \
$(GOSSAMER_PATH)/chips/$(CHIP)/startup_$(CHIP).c \
$(GOSSAMER_PATH)/dummy/system_$(CHIP).c \
$(GOSSAMER_PATH)/dummy/emscripten_loop.c \
$(GOSSAMER_PATH)/dummy/peripherals/adc.c \
$(GOSSAMER_PATH)/dummy/peripherals/dac.c \
$(GOSSAMER_PATH)/dummy/peripherals/dma.c \
$(GOSSAMER_PATH)/dummy/peripherals/eic.c \
$(GOSSAMER_PATH)/dummy/peripherals/evsys.c \
$(GOSSAMER_PATH)/dummy/peripherals/i2c.c \
$(GOSSAMER_PATH)/dummy/peripherals/i2s.c \
$(GOSSAMER_PATH)/dummy/peripherals/opamp.c \
$(GOSSAMER_PATH)/dummy/peripherals/ptc.c \
$(GOSSAMER_PATH)/dummy/peripherals/rtc.c \
$(GOSSAMER_PATH)/dummy/peripherals/sercom.c \
$(GOSSAMER_PATH)/dummy/peripherals/slcd.c \
$(GOSSAMER_PATH)/dummy/peripherals/spi.c \
$(GOSSAMER_PATH)/dummy/peripherals/tc.c \
$(GOSSAMER_PATH)/dummy/peripherals/tcc.c \
$(GOSSAMER_PATH)/dummy/peripherals/uart.c \
$(GOSSAMER_PATH)/dummy/peripherals/usb.c \
endif
INCLUDES += \
-I$(GOSSAMER_PATH)/drivers/ \
-I$(GOSSAMER_PATH)/boards/$(BOARD)/ \
SRCS += \
$(GOSSAMER_PATH)/main.c \
ifndef EMSCRIPTEN
# Do not compile tinyusb for Emscripten
ifdef TINYUSB_CDC
CFLAGS += -DAPP_USES_TINYUSB -DCFG_TUD_CDC=$(TINYUSB_CDC)
TINYUSB = 1
endif
ifdef TINYUSB_MSC
CFLAGS += -DAPP_USES_TINYUSB -DCFG_TUD_MSC=$(TINYUSB_MSC)
TINYUSB = 1
endif
ifdef TINYUSB_HID
CFLAGS += -DAPP_USES_TINYUSB -DCFG_TUD_HID=$(TINYUSB_HID)
TINYUSB = 1
endif
ifdef TINYUSB_MIDI
CFLAGS += -DAPP_USES_TINYUSB -DCFG_TUD_MIDI=$(TINYUSB_MIDI)
TINYUSB = 1
endif
ifdef TINYUSB_VENDOR
CFLAGS += -DAPP_USES_TINYUSB -DCFG_TUD_VENDOR=$(TINYUSB_VENDOR)
TINYUSB = 1
endif
ifdef TINYUSB
CFLAGS += -DAPP_USES_TINYUSB
INCLUDES += \
-I$(GOSSAMER_PATH)/drivers/tinyusb/src/ \
SRCS += \
$(GOSSAMER_PATH)/drivers/tinyusb/src/tusb.c \
$(GOSSAMER_PATH)/drivers/tinyusb/src/common/tusb_fifo.c \
$(GOSSAMER_PATH)/drivers/tinyusb/src/device/usbd.c \
$(GOSSAMER_PATH)/drivers/tinyusb/src/device/usbd_control.c \
$(GOSSAMER_PATH)/drivers/tinyusb/src/class/audio/audio_device.c \
$(GOSSAMER_PATH)/drivers/tinyusb/src/class/cdc/cdc_device.c \
$(GOSSAMER_PATH)/drivers/tinyusb/src/class/dfu/dfu_device.c \
$(GOSSAMER_PATH)/drivers/tinyusb/src/class/dfu/dfu_rt_device.c \
$(GOSSAMER_PATH)/drivers/tinyusb/src/class/hid/hid_device.c \
$(GOSSAMER_PATH)/drivers/tinyusb/src/class/midi/midi_device.c \
$(GOSSAMER_PATH)/drivers/tinyusb/src/class/msc/msc_device.c \
$(GOSSAMER_PATH)/drivers/tinyusb/src/class/net/ecm_rndis_device.c \
$(GOSSAMER_PATH)/drivers/tinyusb/src/class/net/ncm_device.c \
$(GOSSAMER_PATH)/drivers/tinyusb/src/class/usbtmc/usbtmc_device.c \
$(GOSSAMER_PATH)/drivers/tinyusb/src/class/video/video_device.c \
$(GOSSAMER_PATH)/drivers/tinyusb/src/class/vendor/vendor_device.c \
$(GOSSAMER_PATH)/drivers/tinyusb/src/portable/microchip/samd/dcd_samd.c \
$(GOSSAMER_PATH)/peripherals/usb.c \
endif
endif # End of tinyusb exclusion
DEFINES += \
-DDONT_USE_CMSIS_INIT