Statistics
| Branch: | Tag: | Revision:

mongoose / examples / nRF51 / http / boards / pca10028 / armgcc / Makefile @ eaef5bd1

History | View | Annotate | Download (11 KB)

1
PROJECT_NAME := iot_lwip_tcp_server_pca10028
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 = ../../../../nrf51_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
../../../../nrf51_iot_sdk/components/libraries/button/app_button.c \
41
../../../../nrf51_iot_sdk/components/libraries/util/app_error.c \
42
../../../../nrf51_iot_sdk/components/libraries/fifo/app_fifo.c \
43
../../../../nrf51_iot_sdk/components/libraries/scheduler/app_scheduler.c \
44
../../../../nrf51_iot_sdk/components/libraries/timer/app_timer.c \
45
../../../../nrf51_iot_sdk/components/libraries/timer/app_timer_appsh.c \
46
../../../../nrf51_iot_sdk/components/libraries/trace/app_trace.c \
47
../../../../nrf51_iot_sdk/components/libraries/mem_manager/mem_manager.c \
48
../../../../nrf51_iot_sdk/components/libraries/util/nrf_assert.c \
49
../../../../nrf51_iot_sdk/external/lwip/src/port/nrf_platform_port.c \
50
../../../../nrf51_iot_sdk/components/drivers_nrf/uart/app_uart_fifo.c \
51
../../../../nrf51_iot_sdk/components/drivers_nrf/hal/nrf_delay.c \
52
../../../../nrf51_iot_sdk/components/drivers_nrf/common/nrf_drv_common.c \
53
../../../../nrf51_iot_sdk/components/drivers_nrf/gpiote/nrf_drv_gpiote.c \
54
../../../../nrf51_iot_sdk/components/ble/common/ble_advdata.c \
55
../../../../nrf51_iot_sdk/components/ble/common/ble_srv_common.c \
56
../../../../nrf51_iot_sdk/components/iot/context_manager/iot_context_manager.c \
57
../../../../nrf51_iot_sdk/components/toolchain/system_nrf51.c \
58
../../../../nrf51_iot_sdk/components/softdevice/common/softdevice_handler/softdevice_handler.c \
59
../../../../nrf51_iot_sdk/components/softdevice/common/softdevice_handler/softdevice_handler_appsh.c \
60

    
61
C_SOURCE_FILES_APP = \
62
../../../main.c \
63
../../../bleconfig.c \
64
../../../rtt/RTT/SEGGER_RTT.c \
65
../../../rtt/RTT/SEGGER_RTT_printf.c \
66
../../../rtt/Syscalls/RTT_Syscalls_GCC.c \
67
../../../../../../mongoose.c \
68

    
69
C_SOURCE_FILES = $(C_SOURCE_FILES_SDK) $(C_SOURCE_FILES_APP)
70

    
71
#assembly files common to all targets
72
ASM_SOURCE_FILES  = ../../../../nrf51_iot_sdk/components/toolchain/gcc/gcc_startup_nrf51.s
73

    
74
#assembly files common to all targets
75
LIBS  = ../../../../nrf51_iot_sdk/external/lwip/lib/liblwip.a
76
LIBS += ../../../../nrf51_iot_sdk/components/iot/ble_6lowpan/lib/ble_6lowpan.a
77

    
78
#includes common to all targets
79
INC_PATHS  = -I../../../config
80
INC_PATHS += -I../../../../nrf51_iot_sdk/components/softdevice/s1xx_iot/headers
81
INC_PATHS += -I../../../../nrf51_iot_sdk/components/drivers_nrf/common
82
INC_PATHS += -I../../../../nrf51_iot_sdk/components/softdevice/common/softdevice_handler
83
INC_PATHS += -I../../../../nrf51_iot_sdk/external/lwip/src/include
84
INC_PATHS += -I../../../../nrf51_iot_sdk/components/iot/ble_6lowpan
85
INC_PATHS += -I../../../../nrf51_iot_sdk/components/drivers_nrf/hal
86
INC_PATHS += -I../../../../nrf51_iot_sdk/components/ble/common
87
INC_PATHS += -I../../../../nrf51_iot_sdk/external/lwip/src/port
88
INC_PATHS += -I../../../../nrf51_iot_sdk/components/libraries/fifo
89
INC_PATHS += -I../../../../nrf51_iot_sdk/components/libraries/trace
90
INC_PATHS += -I../../../../nrf51_iot_sdk/components/device
91
INC_PATHS += -I../../../../nrf51_iot_sdk/components/drivers_nrf/config
92
INC_PATHS += -I../../../../nrf51_iot_sdk/components/libraries/mem_manager
93
INC_PATHS += -I../../../../nrf51_iot_sdk/components/drivers_nrf/uart
94
INC_PATHS += -I../../../../nrf51_iot_sdk/components/iot/ble_ipsp
95
INC_PATHS += -I../../../../nrf51_iot_sdk/components/libraries/scheduler
96
INC_PATHS += -I../../../../nrf51_iot_sdk/external/lwip/src/include/netif
97
INC_PATHS += -I../../../../nrf51_iot_sdk/components/iot/include
98
INC_PATHS += -I../../..
99
INC_PATHS += -I../../../../../..
100
INC_PATHS += -I../../../rtt/RTT
101
INC_PATHS += -I../../../../nrf51_iot_sdk/components/iot/context_manager
102
INC_PATHS += -I../../../../nrf51_iot_sdk/components/toolchain/gcc
103
INC_PATHS += -I../../../../nrf51_iot_sdk/components/drivers_nrf/gpiote
104
INC_PATHS += -I../../../../nrf51_iot_sdk/components/libraries/timer
105
INC_PATHS += -I../../../../nrf51_iot_sdk/external/lwip/src/port/arch
106
INC_PATHS += -I../../../../nrf51_iot_sdk/components/libraries/button
107
INC_PATHS += -I../../../../nrf51_iot_sdk/components/libraries/util
108
INC_PATHS += -I../../../../nrf51_iot_sdk/examples/bsp
109
INC_PATHS += -I../../../../nrf51_iot_sdk/components/toolchain
110

    
111
OBJECT_DIRECTORY = _build
112
LISTING_DIRECTORY = $(OBJECT_DIRECTORY)
113
OUTPUT_BINARY_DIRECTORY = $(OBJECT_DIRECTORY)
114

    
115
# Sorting removes duplicates
116
BUILD_DIRECTORIES := $(sort $(OBJECT_DIRECTORY) $(OUTPUT_BINARY_DIRECTORY) $(LISTING_DIRECTORY) )
117

    
118
# Mongoose features
119
MG_FEATURES_TINY = \
120
                   -DMG_DISABLE_HTTP_DIGEST_AUTH \
121
                   -DMG_DISABLE_MD5 \
122
                   -DMG_DISABLE_HTTP_KEEP_ALIVE \
123
                   -DMG_ENABLE_HTTP_SSI=0 \
124
                   -DMG_ENABLE_HTTP_STREAMING_MULTIPART
125

    
126
#flags common to all targets
127
CFLAGS  = -D__HEAP_SIZE=512
128
CFLAGS += -DSWI_DISABLE0
129
CFLAGS += -DBOARD_PCA10028
130
CFLAGS += -DSOFTDEVICE_PRESENT
131
CFLAGS += -DNRF51
132
CFLAGS += -DS110
133
CFLAGS += -DBLE_STACK_SUPPORT_REQD
134
CFLAGS += -DBSP_DEFINES_ONLY
135
CFLAGS += -mcpu=cortex-m0
136
CFLAGS += -mthumb -mabi=aapcs --std=gnu99
137
CFLAGS += -g3 -O3
138
CFLAGS += -mfloat-abi=soft
139
# keep every function in separate section. This will allow linker to dump unused functions
140
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
141
CFLAGS += -fno-builtin --short-enums
142

    
143
CFLAGS += -DCS_ENABLE_STDIO
144

    
145
# This macro is needed for stdout to be retargeted to either UART or RTT
146
CFLAGS += -DENABLE_DEBUG_LOG_SUPPORT
147

    
148
# Mongoose flags
149
CFLAGS += -DCS_PLATFORM=CS_P_NRF51 $(MG_FEATURES_TINY) -DMG_MODULE_LINES
150

    
151
# keep every function in separate section. This will allow linker to dump unused functions
152
LDFLAGS += -Xlinker -Map=$(LISTING_DIRECTORY)/$(OUTPUT_FILENAME).map
153
LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT)
154
LDFLAGS += -mcpu=cortex-m0
155
# let linker to dump unused sections
156
LDFLAGS += -Wl,--gc-sections
157
# use newlib in nano version
158
LDFLAGS += --specs=nano.specs -lc -lnosys
159

    
160
# Assembler flags
161
ASMFLAGS += -x assembler-with-cpp
162
ASMFLAGS += -D__HEAP_SIZE=512
163
ASMFLAGS += -DSWI_DISABLE0
164
ASMFLAGS += -DBOARD_PCA10028
165
ASMFLAGS += -DSOFTDEVICE_PRESENT
166
ASMFLAGS += -DNRF51
167
ASMFLAGS += -DS110
168
ASMFLAGS += -DBLE_STACK_SUPPORT_REQD
169
ASMFLAGS += -DBSP_DEFINES_ONLY
170
#default target - first one defined
171
default: clean nrf51422_xxac_s1xx_iot
172

    
173
#building all targets
174
all: clean
175
	$(NO_ECHO)$(MAKE) -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e cleanobj
176
	$(NO_ECHO)$(MAKE) -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e nrf51422_xxac_s1xx_iot
177

    
178
#target for printing all targets
179
help:
180
	@echo following targets are available:
181
	@echo 	nrf51422_xxac_s1xx_iot
182

    
183

    
184
C_SOURCE_FILE_NAMES = $(notdir $(C_SOURCE_FILES))
185
C_PATHS = $(call remduplicates, $(dir $(C_SOURCE_FILES) ) )
186
C_OBJECTS = $(addprefix $(OBJECT_DIRECTORY)/, $(C_SOURCE_FILE_NAMES:.c=.o) )
187

    
188
C_SOURCE_FILE_NAMES_SDK = $(notdir $(C_SOURCE_FILES_SDK))
189
C_SOURCE_FILE_NAMES_APP = $(notdir $(C_SOURCE_FILES_APP))
190
C_OBJECTS_SDK = $(addprefix $(OBJECT_DIRECTORY)/, $(C_SOURCE_FILE_NAMES_SDK:.c=.o) )
191
C_OBJECTS_APP = $(addprefix $(OBJECT_DIRECTORY)/, $(C_SOURCE_FILE_NAMES_APP:.c=.o) )
192

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

    
196
# Enable all warnings for the application's files
197
$(C_OBJECTS_APP): CFLAGS += -Wall
198

    
199
ASM_SOURCE_FILE_NAMES = $(notdir $(ASM_SOURCE_FILES))
200
ASM_PATHS = $(call remduplicates, $(dir $(ASM_SOURCE_FILES) ))
201
ASM_OBJECTS = $(addprefix $(OBJECT_DIRECTORY)/, $(ASM_SOURCE_FILE_NAMES:.s=.o) )
202

    
203
vpath %.c $(C_PATHS)
204
vpath %.s $(ASM_PATHS)
205

    
206
OBJECTS = $(C_OBJECTS) $(ASM_OBJECTS)
207

    
208
nrf51422_xxac_s1xx_iot: OUTPUT_FILENAME := nrf51422_xxac_s1xx_iot
209
nrf51422_xxac_s1xx_iot: LINKER_SCRIPT=iot_lwip_tcp_server_gcc_nrf51.ld
210
nrf51422_xxac_s1xx_iot: $(BUILD_DIRECTORIES) $(OBJECTS)
211
	@echo Linking target: $(OUTPUT_FILENAME).out
212
	$(NO_ECHO)$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
213
	$(NO_ECHO)$(MAKE) -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e finalize
214

    
215
## Create build directories
216
$(BUILD_DIRECTORIES):
217
	echo $(MAKEFILE_NAME)
218
	$(MK) $@
219

    
220
# Create objects from C SRC files
221
$(OBJECT_DIRECTORY)/%.o: %.c
222
	@echo Compiling file: $(notdir $<)
223
	$(NO_ECHO)$(CC) $(CFLAGS) $(INC_PATHS) -c -o $@ $<
224

    
225
# Assemble files
226
$(OBJECT_DIRECTORY)/%.o: %.s
227
	@echo Compiling file: $(notdir $<)
228
	$(NO_ECHO)$(CC) $(ASMFLAGS) $(INC_PATHS) -c -o $@ $<
229

    
230

    
231
# Link
232
$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out: $(BUILD_DIRECTORIES) $(OBJECTS)
233
	@echo Linking target: $(OUTPUT_FILENAME).out
234
	$(NO_ECHO)$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
235

    
236

    
237
## Create binary .bin file from the .out file
238
$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
239
	@echo Preparing: $(OUTPUT_FILENAME).bin
240
	$(NO_ECHO)$(OBJCOPY) -O binary $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin
241

    
242
## Create binary .hex file from the .out file
243
$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
244
	@echo Preparing: $(OUTPUT_FILENAME).hex
245
	$(NO_ECHO)$(OBJCOPY) -O ihex $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex
246

    
247
finalize: genbin genhex echosize
248

    
249
genbin:
250
	@echo Preparing: $(OUTPUT_FILENAME).bin
251
	$(NO_ECHO)$(OBJCOPY) -O binary $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin
252

    
253
## Create binary .hex file from the .out file
254
genhex: 
255
	@echo Preparing: $(OUTPUT_FILENAME).hex
256
	$(NO_ECHO)$(OBJCOPY) -O ihex $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex
257

    
258
echosize:
259
	-@echo ""
260
	$(NO_ECHO)$(SIZE) $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
261
	-@echo ""
262

    
263
clean:
264
	$(RM) $(BUILD_DIRECTORIES)
265

    
266
cleanobj:
267
	$(RM) $(BUILD_DIRECTORIES)/*.o
268

    
269
flash: $(MAKECMDGOALS)
270
	@echo Flashing: $(OUTPUT_BINARY_DIRECTORY)/$<.hex
271
	nrfjprog --reset --program $(OUTPUT_BINARY_DIRECTORY)/$<.hex
272

    
273
## Flash softdevice