Statistics
| Branch: | Tag: | Revision:

mongoose / examples / nRF52 / http / boards / pca10040 / armgcc / Makefile @ eaef5bd1

History | View | Annotate | Download (15.2 KB)

1
PROJECT_NAME := iot_lwip_tcp_server_pca10040
2

    
3
export OUTPUT_FILENAME
4
#MAKEFILE_NAME := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
5
MAKEFILE_NAME := $(MAKEFILE_LIST)
6
MAKEFILE_DIR := $(dir $(MAKEFILE_NAME) ) 
7

    
8
TEMPLATE_PATH = ../../../../nrf5_iot_sdk/components/toolchain/gcc
9
ifeq ($(OS),Windows_NT)
10
include $(TEMPLATE_PATH)/Makefile.windows
11
else
12
include $(TEMPLATE_PATH)/Makefile.posix
13
endif
14

    
15
MK := mkdir
16
RM := rm -rf
17

    
18
#echo suspend
19
ifeq ("$(VERBOSE)","1")
20
NO_ECHO := 
21
else
22
NO_ECHO := @
23
endif
24

    
25
# Toolchain commands
26
CC              := '$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-gcc'
27
AS              := '$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-as'
28
AR              := '$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-ar' -r
29
LD              := '$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-ld'
30
NM              := '$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-nm'
31
OBJDUMP         := '$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-objdump'
32
OBJCOPY         := '$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-objcopy'
33
SIZE            := '$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-size'
34

    
35
#function for removing duplicates in a list
36
remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-out $(firstword $1),$1))))
37

    
38
#source common to all targets
39
C_SOURCE_FILES_SDK = \
40
$(abspath ../../../../nrf5_iot_sdk/components/libraries/button/app_button.c) \
41
$(abspath ../../../../nrf5_iot_sdk/components/libraries/util/app_error.c) \
42
$(abspath ../../../../nrf5_iot_sdk/components/libraries/fifo/app_fifo.c) \
43
$(abspath ../../../../nrf5_iot_sdk/components/libraries/scheduler/app_scheduler.c) \
44
$(abspath ../../../../nrf5_iot_sdk/components/libraries/timer/app_timer.c) \
45
$(abspath ../../../../nrf5_iot_sdk/components/libraries/timer/app_timer_appsh.c) \
46
$(abspath ../../../../nrf5_iot_sdk/components/libraries/trace/app_trace.c) \
47
$(abspath ../../../../nrf5_iot_sdk/components/libraries/mem_manager/mem_manager.c) \
48
$(abspath ../../../../nrf5_iot_sdk/components/libraries/util/nrf_assert.c) \
49
$(abspath ../../../../nrf5_iot_sdk/components/libraries/uart/retarget.c) \
50
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/def.c) \
51
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/dhcp.c) \
52
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/ipv6/dhcp6.c) \
53
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/dns.c) \
54
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/ipv4/icmp.c) \
55
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/ipv6/icmp6.c) \
56
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/ipv6/inet6.c) \
57
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/inet_chksum.c) \
58
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/init.c) \
59
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/ipv4/ip4.c) \
60
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/ipv4/ip4_addr.c) \
61
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/ipv6/ip6.c) \
62
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/ipv6/ip6_addr.c) \
63
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/memp.c) \
64
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/ipv6/mld6.c) \
65
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/ipv6/nd6.c) \
66
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/netif.c) \
67
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/port/nrf_platform_port.c) \
68
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/pbuf.c) \
69
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/raw.c) \
70
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/sys.c) \
71
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/tcp.c) \
72
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/tcp_in.c) \
73
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/tcp_out.c) \
74
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/timers.c) \
75
$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/core/udp.c) \
76
$(abspath ../../../../nrf5_iot_sdk/components/libraries/uart/app_uart_fifo.c) \
77
$(abspath ../../../../nrf5_iot_sdk/components/drivers_nrf/delay/nrf_delay.c) \
78
$(abspath ../../../../nrf5_iot_sdk/components/drivers_nrf/common/nrf_drv_common.c) \
79
$(abspath ../../../../nrf5_iot_sdk/components/drivers_nrf/gpiote/nrf_drv_gpiote.c) \
80
$(abspath ../../../../nrf5_iot_sdk/components/drivers_nrf/uart/nrf_drv_uart.c) \
81
$(abspath ../../../../nrf5_iot_sdk/components/drivers_nrf/pstorage/pstorage.c) \
82
$(abspath ../../../../nrf5_iot_sdk/examples/bsp/bsp.c) \
83
$(abspath ../../../../nrf5_iot_sdk/components/ble/common/ble_advdata.c) \
84
$(abspath ../../../../nrf5_iot_sdk/components/ble/common/ble_conn_params.c) \
85
$(abspath ../../../../nrf5_iot_sdk/components/ble/common/ble_srv_common.c) \
86
$(abspath ../../../../nrf5_iot_sdk/components/iot/errno/errno.c) \
87
$(abspath ../../../../nrf5_iot_sdk/components/iot/context_manager/iot_context_manager.c) \
88
$(abspath ../../../../nrf5_iot_sdk/components/iot/iot_timer/iot_timer.c) \
89
$(abspath ../../../../nrf5_iot_sdk/components/iot/medium/ipv6_medium_ble.c) \
90
$(abspath ../../../../nrf5_iot_sdk/components/iot/common/ipv6_parse.c) \
91
$(abspath ../../../../nrf5_iot_sdk/components/toolchain/system_nrf52.c) \
92
$(abspath ../../../../nrf5_iot_sdk/components/iot/medium/ble_ncfgs/ble_ncfgs.c) \
93
$(abspath ../../../../nrf5_iot_sdk/components/iot/medium/commissioning/commissioning.c) \
94
$(abspath ../../../../nrf5_iot_sdk/components/softdevice/common/softdevice_handler/softdevice_handler.c) \
95
$(abspath ../../../../nrf5_iot_sdk/components/softdevice/common/softdevice_handler/softdevice_handler_appsh.c) \
96

    
97
C_SOURCE_FILES_APP = \
98
$(abspath ../../../main.c) \
99
$(abspath ../../../bleconfig.c) \
100
$(abspath ../../../../../../mongoose.c) \
101
$(abspath ../../../rtt/RTT/SEGGER_RTT.c) \
102
$(abspath ../../../rtt/RTT/SEGGER_RTT_printf.c) \
103
$(abspath ../../../rtt/Syscalls/RTT_Syscalls_GCC.c) \
104

    
105
C_SOURCE_FILES = $(C_SOURCE_FILES_APP) $(C_SOURCE_FILES_SDK)
106

    
107
#assembly files common to all targets
108
ASM_SOURCE_FILES  = $(abspath ../../../../nrf5_iot_sdk/components/toolchain/gcc/gcc_startup_nrf52.s)
109

    
110
#assembly files common to all targets
111
LIBS  = $(abspath ../../../../nrf5_iot_sdk/components/iot/ble_6lowpan/lib/ble_6lowpan.a)
112

    
113
#includes common to all targets
114
INC_PATHS  = -I$(abspath ../../../config)
115
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/iot/errno)
116
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/softdevice/s1xx_iot/headers)
117
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/drivers_nrf/common)
118
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/softdevice/common/softdevice_handler)
119
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/include)
120
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/iot/ble_6lowpan)
121
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/drivers_nrf/hal)
122
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/ble/common)
123
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/port)
124
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/libraries/fifo)
125
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/libraries/trace)
126
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/device)
127
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/libraries/uart)
128
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/iot/medium)
129
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/drivers_nrf/config)
130
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/libraries/mem_manager)
131
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/drivers_nrf/uart)
132
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/iot/ble_ipsp)
133
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/libraries/scheduler)
134
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/iot/iot_timer)
135
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/include/netif)
136
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/iot/medium/commissioning)
137
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/iot/include)
138
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/drivers_nrf/pstorage)
139
INC_PATHS += -I$(abspath ../../..)
140
INC_PATHS += -I$(abspath ../../../../../..)
141
INC_PATHS += -I$(abspath ../../../rtt/RTT)
142
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/iot/context_manager)
143
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/toolchain/gcc)
144
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/drivers_nrf/delay)
145
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/iot/medium/ble_ncfgs)
146
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/drivers_nrf/gpiote)
147
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/softdevice/s1xx_iot/headers/nrf52)
148
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/include/lwip)
149
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/iot/common)
150
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/libraries/timer)
151
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/external/lwip/src/port/arch)
152
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/libraries/button)
153
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/libraries/util)
154
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/examples/bsp)
155
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/toolchain)
156
INC_PATHS += -I$(abspath ../../../../nrf5_iot_sdk/components/iot/medium/include)
157

    
158
OBJECT_DIRECTORY = _build
159
LISTING_DIRECTORY = $(OBJECT_DIRECTORY)
160
OUTPUT_BINARY_DIRECTORY = $(OBJECT_DIRECTORY)
161

    
162
# Sorting removes duplicates
163
BUILD_DIRECTORIES := $(sort $(OBJECT_DIRECTORY) $(OUTPUT_BINARY_DIRECTORY) $(LISTING_DIRECTORY) )
164

    
165
# Mongoose features
166
MG_FEATURES_TINY = \
167
                   -DMG_DISABLE_HTTP_DIGEST_AUTH \
168
                   -DMG_DISABLE_MD5 \
169
                   -DMG_DISABLE_HTTP_KEEP_ALIVE \
170
                   -DMG_ENABLE_HTTP_SSI=0 \
171
                   -DMG_ENABLE_HTTP_STREAMING_MULTIPART
172

    
173
#flags common to all targets
174
CFLAGS  = -D__HEAP_SIZE=4096
175
#CFLAGS += -DCOMMISSIONING_ENABLED
176
CFLAGS += -DSWI_DISABLE0
177
CFLAGS += -DSOFTDEVICE_PRESENT
178
CFLAGS += -DBOARD_PCA10040
179
CFLAGS += -DNRF52
180
CFLAGS += -DCONFIG_GPIO_AS_PINRESET
181
CFLAGS += -DBLE_STACK_SUPPORT_REQD
182
CFLAGS += -Ds1xx
183
CFLAGS += -mcpu=cortex-m4
184
CFLAGS += -mthumb -mabi=aapcs --std=gnu99
185
CFLAGS += -g3 -O3
186
CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
187
# keep every function in separate section. This will allow linker to dump unused functions
188
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
189
CFLAGS += -fno-builtin --short-enums
190

    
191
CFLAGS += -DCS_ENABLE_STDIO
192

    
193
# This macro is needed for stdout to be retargeted to either UART or RTT
194
CFLAGS += -DENABLE_DEBUG_LOG_SUPPORT
195

    
196
# Don't retarget stdout to UART; it'll be retargeted to RTT
197
CFLAGS += -DNRF_LOG_USES_RTT
198

    
199
# Mongoose flags
200
CFLAGS += -DCS_PLATFORM=CS_P_NRF52 $(MG_FEATURES_TINY) -DMG_MODULE_LINES
201

    
202
# keep every function in separate section. This will allow linker to dump unused functions
203
LDFLAGS += -Xlinker -Map=$(LISTING_DIRECTORY)/$(OUTPUT_FILENAME).map
204
LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT)
205
LDFLAGS += -mcpu=cortex-m4
206
LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
207
# let linker to dump unused sections
208
LDFLAGS += -Wl,--gc-sections
209
# use newlib in nano version
210
LDFLAGS += --specs=nano.specs -lc -lnosys
211

    
212
# Assembler flags
213
ASMFLAGS += -x assembler-with-cpp
214
ASMFLAGS += -D__HEAP_SIZE=4096
215
ASMFLAGS += -DSWI_DISABLE0
216
ASMFLAGS += -DSOFTDEVICE_PRESENT
217
ASMFLAGS += -DBOARD_PCA10040
218
ASMFLAGS += -DNRF52
219
ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET
220
ASMFLAGS += -DENABLE_DEBUG_LOG_SUPPORT
221
ASMFLAGS += -DBLE_STACK_SUPPORT_REQD
222
ASMFLAGS += -Ds1xx
223
ASMFLAGS += -g3
224

    
225
#building all targets
226
all: nrf52832_xxaa_s1xx_iot
227

    
228
#target for printing all targets
229
help:
230
	@echo following targets are available:
231
	@echo 	nrf52832_xxaa_s1xx_iot
232

    
233
C_SOURCE_FILE_NAMES = $(notdir $(C_SOURCE_FILES))
234
C_PATHS = $(call remduplicates, $(dir $(C_SOURCE_FILES) ) )
235
C_OBJECTS = $(addprefix $(OBJECT_DIRECTORY)/, $(C_SOURCE_FILE_NAMES:.c=.o) )
236

    
237
C_SOURCE_FILE_NAMES_SDK = $(notdir $(C_SOURCE_FILES_SDK))
238
C_SOURCE_FILE_NAMES_APP = $(notdir $(C_SOURCE_FILES_APP))
239
C_OBJECTS_SDK = $(addprefix $(OBJECT_DIRECTORY)/, $(C_SOURCE_FILE_NAMES_SDK:.c=.o) )
240
C_OBJECTS_APP = $(addprefix $(OBJECT_DIRECTORY)/, $(C_SOURCE_FILE_NAMES_APP:.c=.o) )
241

    
242
# Disable all warnings for SDK sources since we have no control of them
243
$(C_OBJECTS_SDK): CFLAGS += -w
244

    
245
# Enable all warnings for the application's files
246
$(C_OBJECTS_APP): CFLAGS += -Wall
247

    
248
ASM_SOURCE_FILE_NAMES = $(notdir $(ASM_SOURCE_FILES))
249
ASM_PATHS = $(call remduplicates, $(dir $(ASM_SOURCE_FILES) ))
250
ASM_OBJECTS = $(addprefix $(OBJECT_DIRECTORY)/, $(ASM_SOURCE_FILE_NAMES:.s=.o) )
251

    
252
vpath %.c $(C_PATHS)
253
vpath %.s $(ASM_PATHS)
254

    
255
OBJECTS = $(C_OBJECTS) $(ASM_OBJECTS)
256

    
257
nrf52832_xxaa_s1xx_iot: OUTPUT_FILENAME := nrf52832_xxaa_s1xx_iot
258
nrf52832_xxaa_s1xx_iot: LINKER_SCRIPT=iot_lwip_tcp_server_gcc_nrf52.ld
259

    
260
nrf52832_xxaa_s1xx_iot: $(BUILD_DIRECTORIES) $(OBJECTS)
261
	@echo Linking target: $(OUTPUT_FILENAME).out
262
	$(NO_ECHO)$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
263
	$(NO_ECHO)$(MAKE) -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e finalize
264

    
265
## Create build directories
266
$(BUILD_DIRECTORIES):
267
	echo $(MAKEFILE_NAME)
268
	$(MK) $@
269

    
270
# Create objects from C SRC files
271
$(OBJECT_DIRECTORY)/%.o: %.c
272
	@echo Compiling file: $(notdir $<)
273
	$(NO_ECHO)$(CC) $(CFLAGS) $(INC_PATHS) -c -o $@ $<
274

    
275
# Assemble files
276
$(OBJECT_DIRECTORY)/%.o: %.s
277
	@echo Assembly file: $(notdir $<)
278
	$(NO_ECHO)$(CC) $(ASMFLAGS) $(INC_PATHS) -c -o $@ $<
279
# Link
280
$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out: $(BUILD_DIRECTORIES) $(OBJECTS)
281
	@echo Linking target: $(OUTPUT_FILENAME).out
282
	$(NO_ECHO)$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
283
## Create binary .bin file from the .out file
284
$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
285
	@echo Preparing: $(OUTPUT_FILENAME).bin
286
	$(NO_ECHO)$(OBJCOPY) -O binary $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin
287

    
288
## Create binary .hex file from the .out file
289
$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
290
	@echo Preparing: $(OUTPUT_FILENAME).hex
291
	$(NO_ECHO)$(OBJCOPY) -O ihex $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex
292

    
293
finalize: genbin genhex echosize
294

    
295
genbin:
296
	@echo Preparing: $(OUTPUT_FILENAME).bin
297
	$(NO_ECHO)$(OBJCOPY) -O binary $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin
298

    
299
## Create binary .hex file from the .out file
300
genhex: 
301
	@echo Preparing: $(OUTPUT_FILENAME).hex
302
	$(NO_ECHO)$(OBJCOPY) -O ihex $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex
303
echosize:
304
	-@echo ''
305
	$(NO_ECHO)$(SIZE) $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
306
	-@echo ''
307

    
308
clean:
309
	$(RM) $(BUILD_DIRECTORIES)
310

    
311
cleanobj:
312
	$(RM) $(BUILD_DIRECTORIES)/*.o
313
flash: $(MAKECMDGOALS)
314
	@echo Flashing: $(OUTPUT_BINARY_DIRECTORY)/nrf52832_xxaa_s1xx_iot.hex
315
	nrfjprog --program $(OUTPUT_BINARY_DIRECTORY)/nrf52832_xxaa_s1xx_iot.hex -f nrf52 --sectorerase
316
	nrfjprog --reset -f nrf52
317

    
318
## Flash softdevice