2 # Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 # You should have received a copy of the GNU General Public License along
15 # with this program; if not, write to the Free Software Foundation, Inc.,
16 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ifndef OPENPILOT_IS_COOL
20 $(error Top level Makefile must be used to build this target
)
26 BOARDINC
= $(TOPDIR
)/..
27 OPSYSTEMINC
= $(OPSYSTEM
)/inc
29 PIOSCOMMON
= $(PIOS
)/common
30 FLIGHTLIBINC
= $(FLIGHTLIB
)/inc
32 ## UAVTalk and UAVObject manager
33 OPUAVOBJINC
= $(OPUAVOBJ
)/inc
34 OPUAVTALKINC
= $(OPUAVTALK
)/inc
37 MATHLIB
= $(FLIGHTLIB
)/math
38 MATHLIBINC
= $(FLIGHTLIB
)/math
41 FREERTOS_DIR
= $(PIOSCOMMON
)/libraries
/FreeRTOS
42 include $(FREERTOS_DIR
)/library.mk
45 OPTESTS
= $(TOPDIR
)/Tests
48 ifeq ($(MCU
),cortex-m3
)
49 include $(PIOS
)/stm32f10x
/library.mk
50 else ifeq ($(MCU
),cortex-m4
)
51 include $(PIOS
)/stm32f4xx
/library.mk
53 $(error Unsupported MCU
: $(MCU
))
56 # List C source files here (C dependencies are automatically generated).
57 # Use file-extension c for "c-only"-files
59 ## PIOS Hardware (Common Peripherals)
60 SRC
+= $(PIOSCOMMON
)/pios_adxl345.c
61 SRC
+= $(PIOSCOMMON
)/pios_bma180.c
62 SRC
+= $(PIOSCOMMON
)/pios_bmp085.c
63 SRC
+= $(PIOSCOMMON
)/pios_etasv3.c
64 SRC
+= $(PIOSCOMMON
)/pios_gcsrcvr.c
65 SRC
+= $(PIOSCOMMON
)/pios_hcsr04.c
66 SRC
+= $(PIOSCOMMON
)/pios_hmc5843.c
67 SRC
+= $(PIOSCOMMON
)/pios_hmc5x83.c
68 SRC
+= $(PIOSCOMMON
)/pios_i2c_esc.c
69 SRC
+= $(PIOSCOMMON
)/pios_l3gd20.c
70 SRC
+= $(PIOSCOMMON
)/pios_mpu6000.c
71 SRC
+= $(PIOSCOMMON
)/pios_mpxv.c
72 SRC
+= $(PIOSCOMMON
)/pios_ms4525do.c
73 SRC
+= $(PIOSCOMMON
)/pios_ms5611.c
74 SRC
+= $(PIOSCOMMON
)/pios_oplinkrcvr.c
75 SRC
+= $(PIOSCOMMON
)/pios_video.c
76 SRC
+= $(PIOSCOMMON
)/pios_wavplay.c
78 ## PIOS Hardware (Common)
79 SRC
+= $(PIOSCOMMON
)/pios_iap.c
80 SRC
+= $(PIOSCOMMON
)/pios_com.c
81 SRC
+= $(PIOSCOMMON
)/pios_com_msg.c
82 SRC
+= $(PIOSCOMMON
)/pios_crc.c
83 SRC
+= $(PIOSCOMMON
)/pios_flashfs_logfs.c
84 SRC
+= $(PIOSCOMMON
)/pios_flash_jedec.c
85 SRC
+= $(PIOSCOMMON
)/pios_debuglog.c
86 SRC
+= $(PIOSCOMMON
)/pios_deltatime.c
87 SRC
+= $(PIOSCOMMON
)/pios_rcvr.c
88 SRC
+= $(PIOSCOMMON
)/pios_rfm22b.c
89 SRC
+= $(PIOSCOMMON
)/pios_rfm22b_com.c
90 SRC
+= $(PIOSCOMMON
)/pios_sbus.c
91 SRC
+= $(PIOSCOMMON
)/pios_sdcard.c
92 SRC
+= $(PIOSCOMMON
)/pios_led.c
94 ## PIOS USB related files
95 SRC
+= $(PIOSCOMMON
)/pios_usb_desc_hid_cdc.c
96 SRC
+= $(PIOSCOMMON
)/pios_usb_desc_hid_only.c
97 SRC
+= $(PIOSCOMMON
)/pios_usb_util.c
100 SRC
+= $(PIOSCOMMON
)/pios_task_monitor.c
101 SRC
+= $(PIOSCOMMON
)/pios_callbackscheduler.c
102 SRC
+= $(PIOSCOMMON
)/pios_notify.c
103 SRC
+= $(PIOSCOMMON
)/pios_instrumentation.c
104 SRC
+= $(PIOSCOMMON
)/pios_mem.c
105 ## Misc library functions
106 SRC
+= $(FLIGHTLIB
)/fifo_buffer.c
107 SRC
+= $(FLIGHTLIB
)/sanitycheck.c
108 SRC
+= $(FLIGHTLIB
)/CoordinateConversions.c
109 SRC
+= $(MATHLIB
)/sin_lookup.c
110 SRC
+= $(MATHLIB
)/pid.c
111 SRC
+= $(MATHLIB
)/mathmisc.c
112 SRC
+= $(MATHLIB
)/butterworth.c
113 SRC
+= $(FLIGHTLIB
)/printf-stdarg.c
116 SRC
+= $(foreach mod
, $(MODULES
), $(sort $(wildcard $(OPMODULEDIR
)/$(mod
)/*.c
)))
117 SRC
+= $(foreach mod
, $(OPTMODULES
), $(sort $(wildcard $(OPMODULEDIR
)/$(mod
)/*.c
)))
119 # Declare all non-optional modules as built-in to force inclusion.
120 # Built-in modules are always enabled and cannot be disabled.
121 MODNAMES
:= $(notdir $(subst /revolution
,,$(MODULES
)))
122 MODULES_BUILTIN
:= $(foreach mod
, $(MODNAMES
), -DMODULE_
$(shell $(ECHO
) $(mod
) | tr
'[:lower:]' '[:upper:]')_BUILTIN
)
123 CDEFS
+= $(MODULES_BUILTIN
)
125 # List C source files here which must be compiled in ARM-Mode (no -mthumb).
126 # Use file-extension c for "c-only"-files
129 # List C++ source files here.
130 # Use file-extension .cpp for C++-files (not .C)
133 # List C++ source files here which must be compiled in ARM-Mode.
134 # Use file-extension .cpp for C++-files (not .C)
137 # List Assembler source files here.
138 # Make them always end in a capital .S. Files ending in a lowercase .s
139 # will not be considered source files but generated files (assembler
140 # output from the compiler), and will be deleted upon "make clean"!
141 # Even though the DOS/Win* filesystem matches both .s and .S the same,
142 # it will preserve the spelling of the filenames, and gcc itself does
143 # care about how the name is spelled on its command-line.
146 # List Assembler source files here which must be assembled in ARM-Mode.
149 # List any extra directories to look for include files here.
150 # Each directory must be seperated by a space.
151 EXTRAINCDIRS
+= $(PIOS
)
152 EXTRAINCDIRS
+= $(PIOSINC
)
153 EXTRAINCDIRS
+= $(BOARDINC
)
154 EXTRAINCDIRS
+= $(FLIGHTLIBINC
)
155 EXTRAINCDIRS
+= $(PIOSCOMMON
)
156 EXTRAINCDIRS
+= $(OPSYSTEMINC
)
157 EXTRAINCDIRS
+= $(MATHLIBINC
)
158 EXTRAINCDIRS
+= $(OPUAVOBJINC
)
159 EXTRAINCDIRS
+= $(OPUAVTALKINC
)
160 EXTRAINCDIRS
+= $(OPUAVSYNTHDIR
)
163 EXTRAINCDIRS
+= $(foreach mod
, $(OPTMODULES
) $(MODULES
), $(OPMODULEDIR
)/$(mod
)/inc
) $(OPMODULEDIR
)/System
/inc
165 # List any extra directories to look for library files here.
166 # Also add directories where the linker should search for
167 # includes from linker-script to the list
168 # Each directory must be seperated by a space.
172 # Each library-name must be seperated by a space.
173 # i.e. to link with libxyz.a, libabc.a and libefsl.a:
174 # EXTRA_LIBS = xyz abc efsl
175 # for newlib-lpc (file: libnewlibc-lpc.a):
176 # EXTRA_LIBS = newlib-lpc
182 # Set linker-script name depending on selected submodel name
183 ifeq ($(MCU
),cortex-m3
)
184 LDFLAGS
+= -T
$(LINKER_SCRIPTS_PATH
)/link_
$(BOARD
)_memory.
ld
185 LDFLAGS
+= -T
$(LINKER_SCRIPTS_PATH
)/link_
$(BOARD
)_sections.
ld
186 else ifeq ($(MCU
),cortex-m4
)
187 LDFLAGS
+= $(addprefix -T
,$(LINKER_SCRIPTS_APP
))
190 # Add jtag targets (program and wipe)
191 $(eval
$(call JTAG_TEMPLATE
,$(OUTDIR
)/$(TARGET
).bin
,$(FW_BANK_BASE
),$(FW_BANK_SIZE
),$(OPENOCD_JTAG_CONFIG
),$(OPENOCD_CONFIG
)))