2 # Copyright (C) 2015, The LibrePilot Project, http://www.librepilot.org
3 # Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 ifndef FLIGHT_MAKEFILE
21 $(error Top level Makefile must be used to build this target
)
27 BOARDINC
= $(TOPDIR
)/..
28 OPSYSTEMINC
= $(OPSYSTEM
)/inc
30 PIOSCOMMON
= $(PIOS
)/common
31 FLIGHTLIBINC
= $(FLIGHTLIB
)/inc
33 ## UAVTalk and UAVObject manager
34 OPUAVOBJINC
= $(OPUAVOBJ
)/inc
35 OPUAVTALKINC
= $(OPUAVTALK
)/inc
38 MAVLINKINC
= $(FLIGHTLIB
)/mavlink
/v1.0
/common
42 PIDLIB
=$(FLIGHTLIB
)/pid
43 PIDLIBINC
=$(FLIGHTLIB
)/pid
46 MATHLIB
= $(FLIGHTLIB
)/math
47 MATHLIBINC
= $(FLIGHTLIB
)/math
50 FREERTOS_DIR
= $(PIOSCOMMON
)/libraries
/FreeRTOS
51 include $(FREERTOS_DIR
)/library.mk
54 OPTESTS
= $(TOPDIR
)/Tests
57 ifneq (,$(findstring STM32F10
,$(CHIP
)))
58 include $(PIOS
)/stm32f10x
/library.mk
59 else ifneq (,$(findstring STM32F4
,$(CHIP
)))
60 include $(PIOS
)/stm32f4xx
/library.mk
61 else ifneq (,$(findstring STM32F30
,$(CHIP
)))
62 include $(PIOS
)/stm32f30x
/library.mk
63 else ifneq (,$(findstring STM32F0
,$(CHIP
)))
64 include $(PIOS
)/stm32f0x
/library.mk
66 $(error Unsupported CHIP
: $(CHIP
))
69 # List C source files here (C dependencies are automatically generated).
70 # Use file-extension c for "c-only"-files
71 ifneq ($(PIOS_APPS_MINIMAL
),YES
)
72 ## PIOS Hardware (Common Peripherals)
73 SRC
+= $(PIOSCOMMON
)/pios_adxl345.c
74 SRC
+= $(PIOSCOMMON
)/pios_bma180.c
75 SRC
+= $(PIOSCOMMON
)/pios_bmp085.c
76 SRC
+= $(PIOSCOMMON
)/pios_etasv3.c
77 SRC
+= $(PIOSCOMMON
)/pios_gcsrcvr.c
78 SRC
+= $(PIOSCOMMON
)/pios_hcsr04.c
79 SRC
+= $(PIOSCOMMON
)/pios_hmc5843.c
80 SRC
+= $(PIOSCOMMON
)/pios_hmc5x83.c
81 SRC
+= $(PIOSCOMMON
)/pios_i2c_esc.c
82 SRC
+= $(PIOSCOMMON
)/pios_l3gd20.c
83 SRC
+= $(PIOSCOMMON
)/pios_mpu6000.c
84 SRC
+= $(PIOSCOMMON
)/pios_mpu9250.c
85 SRC
+= $(PIOSCOMMON
)/pios_mpxv.c
86 SRC
+= $(PIOSCOMMON
)/pios_ms4525do.c
87 SRC
+= $(PIOSCOMMON
)/pios_ms56xx.c
88 SRC
+= $(PIOSCOMMON
)/pios_bmp280.c
89 SRC
+= $(PIOSCOMMON
)/pios_oplinkrcvr.c
90 SRC
+= $(PIOSCOMMON
)/pios_video.c
91 SRC
+= $(PIOSCOMMON
)/pios_wavplay.c
92 SRC
+= $(PIOSCOMMON
)/pios_rfm22b.c
93 SRC
+= $(PIOSCOMMON
)/pios_rfm22b_com.c
94 SRC
+= $(PIOSCOMMON
)/pios_rcvr.c
95 SRC
+= $(PIOSCOMMON
)/pios_dsm.c
96 SRC
+= $(PIOSCOMMON
)/pios_sbus.c
97 SRC
+= $(PIOSCOMMON
)/pios_hott.c
98 SRC
+= $(PIOSCOMMON
)/pios_srxl.c
99 SRC
+= $(PIOSCOMMON
)/pios_exbus.c
100 SRC
+= $(PIOSCOMMON
)/pios_ibus.c
101 SRC
+= $(PIOSCOMMON
)/pios_sdcard.c
102 SRC
+= $(PIOSCOMMON
)/pios_sensors.c
103 SRC
+= $(PIOSCOMMON
)/pios_servo.c
104 SRC
+= $(PIOSCOMMON
)/pios_openlrs.c
105 SRC
+= $(PIOSCOMMON
)/pios_openlrs_rcvr.c
106 SRC
+= $(PIOSCOMMON
)/pios_board_io.c
107 SRC
+= $(PIOSCOMMON
)/pios_board_sensors.c
109 ## Misc library functions
110 SRC
+= $(FLIGHTLIB
)/sanitycheck.c
111 SRC
+= $(FLIGHTLIB
)/CoordinateConversions.c
112 SRC
+= $(MATHLIB
)/sin_lookup.c
114 ## PID library functions
115 SRC
+= $(MATHLIB
)/pid.c
116 CPPSRC
+= $(PIDLIB
)/pidcontroldown.
cpp
118 ## PIOS Hardware (Common)
119 SRC
+= $(PIOSCOMMON
)/pios_debuglog.c
122 SRC
+= $(PIOSCOMMON
)/pios_iap.c
123 SRC
+= $(PIOSCOMMON
)/pios_com.c
124 SRC
+= $(PIOSCOMMON
)/pios_com_msg.c
125 SRC
+= $(PIOSCOMMON
)/pios_crc.c
126 SRC
+= $(PIOSCOMMON
)/pios_deltatime.c
127 SRC
+= $(PIOSCOMMON
)/pios_led.c
128 SRC
+= $(PIOSCOMMON
)/pios_semaphore.c
129 SRC
+= $(PIOSCOMMON
)/pios_thread.c
131 ifneq ($(PIOS_OMITS_USB
),YES
)
132 ## PIOS USB related files
133 SRC
+= $(PIOSCOMMON
)/pios_usb_desc_hid_cdc.c
134 SRC
+= $(PIOSCOMMON
)/pios_usb_desc_hid_only.c
135 SRC
+= $(PIOSCOMMON
)/pios_usb_util.c
138 SRC
+= $(PIOSCOMMON
)/pios_task_monitor.c
139 SRC
+= $(PIOSCOMMON
)/pios_callbackscheduler.c
140 SRC
+= $(PIOSCOMMON
)/pios_notify.c
141 SRC
+= $(PIOSCOMMON
)/pios_instrumentation.c
142 SRC
+= $(PIOSCOMMON
)/pios_mem.c
143 ## Misc library functions
144 SRC
+= $(FLIGHTLIB
)/fifo_buffer.c
146 SRC
+= $(MATHLIB
)/mathmisc.c
147 SRC
+= $(MATHLIB
)/butterworth.c
148 SRC
+= $(FLIGHTLIB
)/printf-stdarg.c
149 SRC
+= $(FLIGHTLIB
)/optypes.c
152 ifeq ($(USE_CXX
),YES
)
153 CPPSRC
+= $(FLIGHTLIB
)/mini_cpp.
cpp
157 SRC
+= $(FLIGHTLIB
)/dcc_stdio.c
158 SRC
+= $(FLIGHTLIB
)/cm3_fault_handlers.c
162 SRC
+= $(foreach mod
, $(MODULES
), $(sort $(wildcard $(OPMODULEDIR
)/$(mod
)/*.c
)))
163 CPPSRC
+= $(foreach mod
, $(MODULES
), $(sort $(wildcard $(OPMODULEDIR
)/$(mod
)/*.
cpp)))
164 SRC
+= $(foreach mod
, $(OPTMODULES
), $(sort $(wildcard $(OPMODULEDIR
)/$(mod
)/*.c
)))
166 # Declare all non-optional modules as built-in to force inclusion.
167 # Built-in modules are always enabled and cannot be disabled.
168 MODNAMES
:= $(notdir $(subst /revolution
,,$(MODULES
)))
169 MODULES_BUILTIN
:= $(foreach mod
, $(MODNAMES
), -DMODULE_
$(shell echo
$(mod
) | tr
'[:lower:]' '[:upper:]')_BUILTIN
)
170 CDEFS
+= $(MODULES_BUILTIN
)
172 MODNAMES_ALL
:= $(notdir $(subst /revolution
,,$(OPTMODULES
) $(MODULES
)))
173 MODULES_ALL
:= $(foreach mod
, $(MODNAMES_ALL
), -DHAS_
$(shell echo
$(mod
) | tr
'[:lower:]' '[:upper:]')_MODULE
)
174 CDEFS
+= $(MODULES_ALL
)
176 # List C source files here which must be compiled in ARM-Mode (no -mthumb).
177 # Use file-extension c for "c-only"-files
180 # List C++ source files here.
181 # Use file-extension .cpp for C++-files (not .C)
184 # List C++ source files here which must be compiled in ARM-Mode.
185 # Use file-extension .cpp for C++-files (not .C)
188 # List Assembler source files here.
189 # Make them always end in a capital .S. Files ending in a lowercase .s
190 # will not be considered source files but generated files (assembler
191 # output from the compiler), and will be deleted upon "make clean"!
192 # Even though the DOS/Win* filesystem matches both .s and .S the same,
193 # it will preserve the spelling of the filenames, and gcc itself does
194 # care about how the name is spelled on its command-line.
197 # List Assembler source files here which must be assembled in ARM-Mode.
200 # List any extra directories to look for include files here.
201 # Each directory must be seperated by a space.
202 EXTRAINCDIRS
+= $(PIOS
)
203 EXTRAINCDIRS
+= $(PIOSINC
)
204 EXTRAINCDIRS
+= $(BOARDINC
)
205 EXTRAINCDIRS
+= $(FLIGHTLIBINC
)
206 EXTRAINCDIRS
+= $(PIOSCOMMON
)
207 EXTRAINCDIRS
+= $(OPSYSTEMINC
)
208 EXTRAINCDIRS
+= $(MATHLIBINC
)
209 EXTRAINCDIRS
+= $(PIDLIBINC
)
210 EXTRAINCDIRS
+= $(OPUAVOBJINC
)
211 EXTRAINCDIRS
+= $(OPUAVTALKINC
)
212 EXTRAINCDIRS
+= $(FLIGHT_UAVOBJ_DIR
)
213 EXTRAINCDIRS
+= $(MAVLINKINC
)
216 EXTRAINCDIRS
+= $(foreach mod
, $(OPTMODULES
) $(MODULES
), $(OPMODULEDIR
)/$(mod
)/inc
) $(OPMODULEDIR
)/System
/inc
218 # List any extra directories to look for library files here.
219 # Also add directories where the linker should search for
220 # includes from linker-script to the list
221 # Each directory must be seperated by a space.
225 # Each library-name must be seperated by a space.
226 # i.e. to link with libxyz.a, libabc.a and libefsl.a:
227 # EXTRA_LIBS = xyz abc efsl
228 # for newlib-lpc (file: libnewlibc-lpc.a):
229 # EXTRA_LIBS = newlib-lpc
235 # Set linker-script name depending on selected submodel name
236 ifeq ($(MCU
),cortex-m3
)
237 LDFLAGS
+= -T
$(LINKER_SCRIPTS_PATH
)/link_
$(BOARD
)_memory.
ld
238 LDFLAGS
+= -T
$(LINKER_SCRIPTS_PATH
)/link_
$(BOARD
)_sections.
ld
239 else ifeq ($(MCU
),cortex-m4
)
240 LDFLAGS
+= $(addprefix -T
,$(LINKER_SCRIPTS_APP
))
241 else ifeq ($(MCU
),cortex-m0
)
242 LDFLAGS
+= -T
$(LINKER_SCRIPTS_PATH
)/link_
$(BOARD
)_memory.
ld
243 LDFLAGS
+= -T
$(LINKER_SCRIPTS_PATH
)/link_
$(BOARD
)_sections.
ld
246 # Add jtag targets (program and wipe)
247 $(eval
$(call JTAG_TEMPLATE
,$(OUTDIR
)/$(TARGET
).bin
,$(FW_BANK_BASE
),$(FW_BANK_SIZE
),$(OPENOCD_JTAG_CONFIG
),$(OPENOCD_CONFIG
)))