This repository was archived by the owner on Sep 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmakefile
193 lines (144 loc) · 5.53 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
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
PROCESSOR = LPC17xx
#Enable when debugging on MBED to swap serial and USB
#and select direct ld script
#MBED = true
BUILD_DIR = ./build
FREERTOS_DIR = ./FreeRTOS
REPRAPFIRMWARE_DIR = ./RepRapFirmware
RRFLIBRARIES_DIR = ./RRFLibraries
CORELPC_DIR = ./CoreLPC2
#BUILD = Debug
BUILD = Release
#Enable only one
NETWORKING = true
#ESP8266WIFI = true
#SBC = true
#Comment out to show compilation commands (verbose)
V=@
$(info Building RepRapFirmware for LPC1768/1769 based boards:)
OUTPUT_NAME=firmware
## Cross-compilation commands
CC = arm-none-eabi-gcc
CXX = arm-none-eabi-g++
LD = arm-none-eabi-gcc
AR = arm-none-eabi-ar
AS = arm-none-eabi-as
OBJCOPY = arm-none-eabi-objcopy
OBJDUMP = arm-none-eabi-objdump
SIZE = arm-none-eabi-size
MKDIR = mkdir -p
#function to get unique values from a list from bobbogo (https://stackoverflow.com/questions/16144115/makefile-remove-duplicate-words-without-sorting)
uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
include LPCCore.mk
include FreeRTOS.mk
include RRFLibraries.mk
include RepRapFirmware.mk
ifeq ($(BUILD),Debug)
DEBUG_FLAGS = -Og -g -DLPC_DEBUG
$(info - Build: Debug)
else
DEBUG_FLAGS = -Os
$(info - Build: Release)
endif
#select correct linker script
ifeq ($(MBED), true)
#No bootloader for MBED
LINKER_SCRIPT_BASE = $(CORE)/variants/LPC/linker_scripts/gcc/LPC17xx_direct
else
#Linker script to avoid Smoothieware Bootloader
LINKER_SCRIPT_BASE = $(CORE)/variants/LPC/linker_scripts/gcc/LPC17xx_smoothie
endif
#Path to the linker Script
LINKER_SCRIPT = $(LINKER_SCRIPT_BASE)_combined.ld
$(info - Linker Script used: $(LINKER_SCRIPT))
#Flags common for Core in c and c++
FLAGS = -D__$(PROCESSOR)__ -D_XOPEN_SOURCE
ifeq ($(MBED), true)
$(info - Building for MBED)
FLAGS += -D__MBED__
ifeq ($(ESP8266WIFI), true)
FLAGS += -DENABLE_UART3 -DENABLE_UART2 -DENABLE_UART1
endif
endif
#lpcopen Defines
FLAGS += -DCORE_M3
#RTOS + enable mods to RTOS+TCP for RRF
FLAGS += -DRTOS -DFREERTOS_USED -DRRF_RTOSPLUS_MOD
FLAGS += -DDEVICE_USBDEVICE=1 -DTARGET_LPC1768
FLAGS += -Wall -c -mcpu=cortex-m3 -mthumb -ffunction-sections -fdata-sections -march=armv7-m
FLAGS += -nostdlib -Wdouble-promotion -fsingle-precision-constant -fstack-usage
#FLAGS += -Wfloat-equal
#FLAGS += -Wundef
FLAGS += $(DEBUG_FLAGS)
FLAGS += -MMD -MP
ifeq ($(NETWORKING), true)
$(info - Networking: Ethernet)
FLAGS += -DLPC_NETWORKING
else ifeq ($(ESP8266WIFI), true)
$(info - Networking: ESP8266 WIFI)
FLAGS += -DESP8266WIFI
else ifeq ($(SBC), true)
$(info - SBC Interface Enabled)
FLAGS += -DLPC_SBC
else
$(info - Networking: None)
endif
ifeq ($(TMC22XX), true)
$(info - Smart Drivers: TMC22XX)
FLAGS += -DSUPPORT_TMC22xx
else
$(info - Smart Drivers: None)
endif
CFLAGS = $(FLAGS) -std=gnu11 -fgnu89-inline
#Ignore noexcepts in c
CFLAGS += -Dnoexcept=
CXXFLAGS = $(FLAGS) -std=gnu++17 -fno-threadsafe-statics -fexceptions -fno-rtti -Wno-register
#all Includes (RRF + Core)
INCLUDES = $(CORE_INCLUDES) $(RRFLIBRARIES_INCLUDES) $(RRF_INCLUDES) $(RRFLIBC_INCLUDES)
DEPS = $(CORE_OBJS:.o=.d)
DEPS += $(RRF_OBJS:.o=.d)
DEPS += $(RRFLIBC_OBJS:.o=.d)
DEPS += $(RRFLIBRARIES_OBJS:.o=.d)
default: all
all: firmware
-include $(DEPS)
firmware: $(BUILD_DIR)/$(OUTPUT_NAME).elf
coreLPC: $(BUILD_DIR)/core.a
$(BUILD_DIR)/libLPCCore.a: $(CORE_OBJS)
$(V)$(AR) rcs $@ $(CORE_OBJS)
@echo "\nBuilt LPCCore\n"
$(BUILD_DIR)/libRRFLibraries.a: $(RRFLIBRARIES_OBJS)
$(V)$(AR) rcs $@ $(RRFLIBRARIES_OBJS)
@echo "\nBuilt RRF Libraries\n"
$(BUILD_DIR)/$(OUTPUT_NAME).elf: $(BUILD_DIR)/libLPCCore.a $(BUILD_DIR)/libRRFLibraries.a $(RRFLIBC_OBJS) $(RRF_OBJS)
@echo "\nCreating $(OUTPUT_NAME).bin"
$(V)$(MKDIR) $(dir $@)
$(V)$(LD) -L$(BUILD_DIR)/ -L$(CORE)/variants/LPC/linker_scripts/gcc/ --specs=nosys.specs -Os -Wl,--warn-section-align -Wl,--fatal-warnings -march=armv7-m -mcpu=cortex-m3 -T$(LINKER_SCRIPT) -Wl,-Map,$(BUILD_DIR)/$(OUTPUT_NAME).map -o $(BUILD_DIR)/$(OUTPUT_NAME).elf -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group $(BUILD_DIR)/$(CORE)/cores/arduino/syscalls.o $(RRFLIBC_OBJS) -lLPCCore $(RRF_OBJS) -lsupc++ -lRRFLibraries -Wl,--end-group -lm
$(V)$(OBJCOPY) --strip-unneeded -O binary $(BUILD_DIR)/$(OUTPUT_NAME).elf $(BUILD_DIR)/$(OUTPUT_NAME).bin
$(V)$(SIZE) $(BUILD_DIR)/$(OUTPUT_NAME).elf
-@./staticMemStats.sh $(BUILD_DIR)/$(OUTPUT_NAME).elf
$(BUILD_DIR)/%.o: %.c
@echo "[$<]"
$(V)$(MKDIR) $(dir $@)
$(V)$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -MMD -MP -MM -MF $(patsubst %.o,%.d,$@) $<
$(V)$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -MMD -MP -o $@ $<
$(BUILD_DIR)/%.o: %.cpp
@echo "[$<]"
$(V)$(MKDIR) $(dir $@)
$(V)$(CXX) $(CXXFLAGS) $(DEFINES) $(INCLUDES) -MMD -MP -MM -MF $(patsubst %.o,%.d,$@) $<
$(V)$(CXX) $(CXXFLAGS) $(DEFINES) $(INCLUDES) -MMD -MP -o $@ $<
$(BUILD_DIR)/%.o: %.cc
@echo "[$<]"
$(V)$(MKDIR) $(dir $@)
$(V)$(CXX) $(CXXFLAGS) $(DEFINES) $(INCLUDES) -MMD -MP -MM -MF $(patsubst %.o,%.d,$@) $<
$(V)$(CXX) $(CXXFLAGS) $(DEFINES) $(INCLUDES) -MMD -MP -o $@ $<
cleanrrf:
-rm -f $(RRF_OBJS) $(BUILD_DIR)/libRRFLibraries.a
cleancore:
-rm -f $(CORE_OBJS) $(BUILD_DIR)/libLPCCore.a
cleanrrflibraries:
-rm -f $(RRFLIBRARIES_OBJS) $(BUILD_DIR)/libRRFLibraries.a
clean: distclean
distclean:
-rm -rf $(BUILD_DIR)/
.PHONY: all firmware clean distclean $(BUILD_DIR)/$(OUTPUT_NAME).elf