1 ###############################################################
5 # NOTE: These are not tied to the default goals
6 # and must be invoked manually
8 ###############################################################
10 ##############################
12 # Check that environmental variables are sane
14 ##############################
16 # Set up ARM (STM32) SDK
17 ARM_SDK_DIR
:= $(TOOLS_DIR
)/gcc-arm-none-eabi-5_4-2016q3
18 # Checked below, Should match the output of $(shell arm-none-eabi-gcc -dumpversion)
19 GCC_REQUIRED_VERSION
:= 5.4.1
21 ## arm_sdk_install : Install Arm SDK
22 .PHONY
: arm_sdk_install
24 ARM_SDK_URL_BASE
:= https
://launchpad.net
/gcc-arm-embedded
/5.0/5-2016-q3-update
/+download
/gcc-arm-none-eabi-5_4-2016q3-20160926
26 # source: https://launchpad.net/gcc-arm-embedded/5.0/
28 ARM_SDK_URL
:= $(ARM_SDK_URL_BASE
)-linux.
tar.bz2
32 ARM_SDK_URL
:= $(ARM_SDK_URL_BASE
)-mac.
tar.bz2
36 ARM_SDK_URL
:= $(ARM_SDK_URL_BASE
)-win32.zip
39 ARM_SDK_FILE
:= $(notdir $(ARM_SDK_URL
))
41 SDK_INSTALL_MARKER
:= $(ARM_SDK_DIR
)/bin
/arm-none-eabi-gcc-
$(GCC_REQUIRED_VERSION
)
43 # order-only prereq on directory existance:
44 arm_sdk_install
: |
$(TOOLS_DIR
)
46 arm_sdk_install
: arm_sdk_download
$(SDK_INSTALL_MARKER
)
48 $(SDK_INSTALL_MARKER
):
49 ifneq ($(OSFAMILY
), windows
)
50 # binary only release so just extract it
51 $(V1
) tar -C
$(TOOLS_DIR
) -xjf
"$(DL_DIR)/$(ARM_SDK_FILE)"
53 $(V1
) unzip
-q
-d
$(ARM_SDK_DIR
) "$(DL_DIR)/$(ARM_SDK_FILE)"
56 .PHONY
: arm_sdk_download
57 arm_sdk_download
: |
$(DL_DIR
)
58 arm_sdk_download
: $(DL_DIR
)/$(ARM_SDK_FILE
)
59 $(DL_DIR
)/$(ARM_SDK_FILE
):
60 # download the source only if it's newer than what we already have
61 $(V1
) curl
-L
-k
-o
"$(DL_DIR)/$(ARM_SDK_FILE)" -z
"$(DL_DIR)/$(ARM_SDK_FILE)" "$(ARM_SDK_URL)"
64 ## arm_sdk_clean : Uninstall Arm SDK
67 $(V1
) [ ! -d
"$(ARM_SDK_DIR)" ] ||
$(RM
) -r
$(ARM_SDK_DIR
)
68 $(V1
) [ ! -d
"$(DL_DIR)" ] ||
$(RM
) -r
$(DL_DIR
)
70 .PHONY
: openocd_win_install
72 openocd_win_install
: |
$(DL_DIR
) $(TOOLS_DIR
)
73 openocd_win_install
: OPENOCD_URL
:= git
://git.code.sf.net
/p
/openocd
/code
74 openocd_win_install
: OPENOCD_REV
:= cf1418e9a85013bbf8dbcc2d2e9985695993d9f4
75 openocd_win_install
: OPENOCD_OPTIONS
:=
77 ifeq ($(OPENOCD_FTDI
), yes
)
78 openocd_win_install
: OPENOCD_OPTIONS
:= $(OPENOCD_OPTIONS
) --enable-ft2232_ftd2xx
--with-ftd2xx-win32-zipdir
=$(FTD2XX_DIR
)
81 openocd_win_install
: openocd_win_clean libusb_win_install ftd2xx_install
83 $(V0
) @echo
" DOWNLOAD $(OPENOCD_URL) @ $(OPENOCD_REV)"
84 $(V1
) [ ! -d
"$(OPENOCD_BUILD_DIR)" ] ||
$(RM
) -rf
"$(OPENOCD_BUILD_DIR)"
85 $(V1
) mkdir
-p
"$(OPENOCD_BUILD_DIR)"
86 $(V1
) git clone
--no-checkout
$(OPENOCD_URL
) "$(DL_DIR)/openocd-build"
88 cd
$(OPENOCD_BUILD_DIR
) ; \
89 git checkout
-q
$(OPENOCD_REV
) ; \
93 $(V0
) @echo
" PATCH $(OPENOCD_BUILD_DIR)"
95 cd
$(OPENOCD_BUILD_DIR
) ; \
96 git apply
< $(ROOT_DIR
)/flight
/Project
/OpenOCD
/0003-freertos-cm4f-fpu-support.patch
; \
97 git apply
< $(ROOT_DIR
)/flight
/Project
/OpenOCD
/0004-st-icdi-disable.patch
; \
101 $(V0
) @echo
" BUILD $(OPENOCD_WIN_DIR)"
102 $(V1
) mkdir
-p
"$(OPENOCD_WIN_DIR)"
104 cd
$(OPENOCD_BUILD_DIR
) ; \
106 .
/configure
--enable-maintainer-mode
--prefix="$(OPENOCD_WIN_DIR)" \
107 --build
=i686-pc-linux-gnu
--host
=i586-mingw32msvc \
108 CPPFLAGS
=-I
$(LIBUSB_WIN_DIR
)/include \
109 LDFLAGS
=-L
$(LIBUSB_WIN_DIR
)/lib
/gcc \
117 # delete the extracted source when we're done
118 $(V1
) [ ! -d
"$(OPENOCD_BUILD_DIR)" ] ||
$(RM
) -rf
"$(OPENOCD_BUILD_DIR)"
120 .PHONY
: openocd_win_clean
122 $(V0
) @echo
" CLEAN $(OPENOCD_WIN_DIR)"
123 $(V1
) [ ! -d
"$(OPENOCD_WIN_DIR)" ] ||
$(RM
) -r
"$(OPENOCD_WIN_DIR)"
125 # Set up openocd tools
126 OPENOCD_DIR
:= $(TOOLS_DIR
)/openocd
127 OPENOCD_WIN_DIR
:= $(TOOLS_DIR
)/openocd_win
128 OPENOCD_BUILD_DIR
:= $(DL_DIR
)/openocd-build
130 .PHONY
: openocd_install
132 openocd_install
: |
$(DL_DIR
) $(TOOLS_DIR
)
133 openocd_install
: OPENOCD_URL
:= git
://git.code.sf.net
/p
/openocd
/code
134 openocd_install
: OPENOCD_TAG
:= v0.9
.0
135 openocd_install
: OPENOCD_OPTIONS
:= --enable-maintainer-mode
--prefix="$(OPENOCD_DIR)" --enable-buspirate
--enable-stlink
137 ifeq ($(OPENOCD_FTDI
), yes
)
138 openocd_install
: OPENOCD_OPTIONS
:= $(OPENOCD_OPTIONS
) --enable-ftdi
141 ifeq ($(UNAME
), Darwin
)
142 openocd_install
: OPENOCD_OPTIONS
:= $(OPENOCD_OPTIONS
) --disable-option-checking
145 openocd_install
: openocd_clean
146 # download the source
147 $(V0
) @echo
" DOWNLOAD $(OPENOCD_URL) @ $(OPENOCD_TAG)"
148 $(V1
) [ ! -d
"$(OPENOCD_BUILD_DIR)" ] ||
$(RM
) -rf
"$(OPENOCD_BUILD_DIR)"
149 $(V1
) mkdir
-p
"$(OPENOCD_BUILD_DIR)"
150 $(V1
) git clone
--no-checkout
$(OPENOCD_URL
) "$(OPENOCD_BUILD_DIR)"
152 cd
$(OPENOCD_BUILD_DIR
) ; \
153 git checkout
-q
tags/$(OPENOCD_TAG
) ; \
157 $(V0
) @echo
" BUILD $(OPENOCD_DIR)"
158 $(V1
) mkdir
-p
"$(OPENOCD_DIR)"
160 cd
$(OPENOCD_BUILD_DIR
) ; \
162 .
/configure
$(OPENOCD_OPTIONS
) ; \
167 # delete the extracted source when we're done
168 $(V1
) [ ! -d
"$(OPENOCD_BUILD_DIR)" ] ||
$(RM
) -rf
"$(OPENOCD_BUILD_DIR)"
170 .PHONY
: openocd_clean
172 $(V0
) @echo
" CLEAN $(OPENOCD_DIR)"
173 $(V1
) [ ! -d
"$(OPENOCD_DIR)" ] ||
$(RM
) -r
"$(OPENOCD_DIR)"
175 STM32FLASH_DIR
:= $(TOOLS_DIR
)/stm32flash
177 .PHONY
: stm32flash_install
178 stm32flash_install
: STM32FLASH_URL
:= http
://stm32flash.googlecode.com
/svn
/trunk
179 stm32flash_install
: STM32FLASH_REV
:= 61
180 stm32flash_install
: stm32flash_clean
181 # download the source
182 $(V0
) @echo
" DOWNLOAD $(STM32FLASH_URL) @ r$(STM32FLASH_REV)"
183 $(V1
) svn
export -q
-r
"$(STM32FLASH_REV)" "$(STM32FLASH_URL)" "$(STM32FLASH_DIR)"
186 $(V0
) @echo
" BUILD $(STM32FLASH_DIR)"
187 $(V1
) $(MAKE
) --silent
-C
$(STM32FLASH_DIR
) all
189 .PHONY
: stm32flash_clean
191 $(V0
) @echo
" CLEAN $(STM32FLASH_DIR)"
192 $(V1
) [ ! -d
"$(STM32FLASH_DIR)" ] ||
$(RM
) -r
"$(STM32FLASH_DIR)"
194 DFUUTIL_DIR
:= $(TOOLS_DIR
)/dfu-util
196 .PHONY
: dfuutil_install
197 dfuutil_install
: DFUUTIL_URL
:= http
://dfu-util.sourceforge.net
/releases
/dfu-util-0.8.
tar.gz
198 dfuutil_install
: DFUUTIL_FILE
:= $(notdir $(DFUUTIL_URL
))
199 dfuutil_install
: |
$(DL_DIR
) $(TOOLS_DIR
)
200 dfuutil_install
: dfuutil_clean
201 # download the source
202 $(V0
) @echo
" DOWNLOAD $(DFUUTIL_URL)"
203 $(V1
) curl
-L
-k
-o
"$(DL_DIR)/$(DFUUTIL_FILE)" "$(DFUUTIL_URL)"
206 $(V0
) @echo
" EXTRACT $(DFUUTIL_FILE)"
207 $(V1
) [ ! -d
"$(DL_DIR)/dfuutil-build" ] ||
$(RM
) -r
"$(DL_DIR)/dfuutil-build"
208 $(V1
) mkdir
-p
"$(DL_DIR)/dfuutil-build"
209 $(V1
) tar -C
$(DL_DIR
)/dfuutil-build
-xf
"$(DL_DIR)/$(DFUUTIL_FILE)"
212 $(V0
) @echo
" BUILD $(DFUUTIL_DIR)"
213 $(V1
) mkdir
-p
"$(DFUUTIL_DIR)"
215 cd
$(DL_DIR
)/dfuutil-build
/dfu-util-0.8
; \
216 .
/configure
--prefix="$(DFUUTIL_DIR)" ; \
221 .PHONY
: dfuutil_clean
223 $(V0
) @echo
" CLEAN $(DFUUTIL_DIR)"
224 $(V1
) [ ! -d
"$(DFUUTIL_DIR)" ] ||
$(RM
) -r
"$(DFUUTIL_DIR)"
226 # Set up uncrustify tools
227 UNCRUSTIFY_DIR
:= $(TOOLS_DIR
)/uncrustify-0.61
228 UNCRUSTIFY_BUILD_DIR
:= $(DL_DIR
)/uncrustify
230 .PHONY
: uncrustify_install
231 uncrustify_install
: |
$(DL_DIR
) $(TOOLS_DIR
)
232 uncrustify_install
: UNCRUSTIFY_URL
:= http
://downloads.sourceforge.net
/project
/uncrustify
/uncrustify
/uncrustify-0.61
/uncrustify-0.61.
tar.gz
233 uncrustify_install
: UNCRUSTIFY_FILE
:= uncrustify-0.61.
tar.gz
234 uncrustify_install
: UNCRUSTIFY_OPTIONS
:= prefix=$(UNCRUSTIFY_DIR
)
235 uncrustify_install
: uncrustify_clean
236 ifneq ($(OSFAMILY
), windows
)
237 $(V0
) @echo
" DOWNLOAD $(UNCRUSTIFY_URL)"
238 $(V1
) curl
-L
-k
-o
"$(DL_DIR)/$(UNCRUSTIFY_FILE)" "$(UNCRUSTIFY_URL)"
241 $(V0
) @echo
" EXTRACT $(UNCRUSTIFY_FILE)"
242 $(V1
) tar -C
$(TOOLS_DIR
) -xf
"$(DL_DIR)/$(UNCRUSTIFY_FILE)"
244 $(V0
) @echo
" BUILD $(UNCRUSTIFY_DIR)"
246 cd
$(UNCRUSTIFY_DIR
) ; \
247 .
/configure
--prefix="$(UNCRUSTIFY_DIR)" ; \
251 # delete the extracted source when we're done
252 $(V1
) [ ! -d
"$(UNCRUSTIFY_BUILD_DIR)" ] ||
$(RM
) -r
"$(UNCRUSTIFY_BUILD_DIR)"
254 .PHONY
: uncrustify_clean
256 $(V0
) @echo
" CLEAN $(UNCRUSTIFY_DIR)"
257 $(V1
) [ ! -d
"$(UNCRUSTIFY_DIR)" ] ||
$(RM
) -r
"$(UNCRUSTIFY_DIR)"
258 $(V0
) @echo
" CLEAN $(UNCRUSTIFY_BUILD_DIR)"
259 $(V1
) [ ! -d
"$(UNCRUSTIFY_BUILD_DIR)" ] ||
$(RM
) -r
"$(UNCRUSTIFY_BUILD_DIR)"
262 zip_install
: ZIP_URL
:= http
://pkgs.fedoraproject.org
/repo
/pkgs
/zip
/zip30.
tar.gz
/7b74551e63f8ee6aab6fbc86676c0d37
/zip30.
tar.gz
264 zip_install
: ZIP_FILE
:= $(notdir $(ZIP_URL
))
266 ZIP_DIR
= $(TOOLS_DIR
)/zip30
268 # order-only prereq on directory existance:
269 zip_install
: |
$(DL_DIR
) $(TOOLS_DIR
)
270 zip_install
: zip_clean
271 $(V1
) curl
-L
-k
-o
"$(DL_DIR)/$(ZIP_FILE)" "$(ZIP_URL)"
272 $(V1
) tar --force-local
-C
$(TOOLS_DIR
) -xzf
"$(DL_DIR)/$(ZIP_FILE)"
273 ifneq ($(OSFAMILY
), windows
)
274 $(V1
) cd
"$(ZIP_DIR)" && $(MAKE
) -f unix
/Makefile generic_gcc
276 $(V1
) cd
"$(ZIP_DIR)" && $(MAKE
) -f win32
/makefile.gcc
281 $(V1
) [ ! -d
"$(ZIP_DIR)" ] ||
$(RM
) -rf
$(ZIP_DIR
)
283 ##############################
285 # Set up paths to tools
287 ##############################
289 GCC_VERSION
=$(shell arm-none-eabi-gcc
-dumpversion
)
290 ifeq ($(shell [ -d
"$(ARM_SDK_DIR)" ] && echo
"exists"), exists
)
291 ARM_SDK_PREFIX
:= $(ARM_SDK_DIR
)/bin
/arm-none-eabi-
292 else ifeq (,$(findstring _install
,$(MAKECMDGOALS
)))
293 ifeq ($(GCC_VERSION
),)
294 $(error
**ERROR
** arm-none-eabi-gcc not in the PATH. Run
'make arm_sdk_install' to
install automatically in the tools folder of this repo
)
295 else ifneq ($(GCC_VERSION
), $(GCC_REQUIRED_VERSION
))
296 $(error
**ERROR
** your arm-none-eabi-gcc is
'$(GCC_VERSION)', but
'$(GCC_REQUIRED_VERSION)' is expected. Override with
'GCC_REQUIRED_VERSION' in make
/local.mk or run
'make arm_sdk_install' to
install the right version automatically in the tools folder of this repo
)
298 # not installed, hope it's in the path...
299 ARM_SDK_PREFIX ?
= arm-none-eabi-
302 ifeq ($(shell [ -d
"$(ZIP_DIR)" ] && echo
"exists"), exists
)
303 export ZIPBIN
:= $(ZIP_DIR
)/zip
308 ifeq ($(shell [ -d
"$(OPENOCD_DIR)" ] && echo
"exists"), exists
)
309 OPENOCD
:= $(OPENOCD_DIR
)/bin
/openocd
311 # not installed, hope it's in the path...
315 ifeq ($(shell [ -d
"$(UNCRUSTIFY_DIR)" ] && echo
"exists"), exists
)
316 UNCRUSTIFY
:= $(UNCRUSTIFY_DIR
)/bin
/uncrustify
318 # not installed, hope it's in the path...
319 UNCRUSTIFY ?
= uncrustify
323 DUMP_SYMBOLS_TOOL
:= $(TOOLS_DIR
)/breakpad
/$(OSFAMILY
)-$(ARCHFAMILY
)/dump_syms
324 BREAKPAD_URL
:= http
://dronin.tracer.nz
/tools
/breakpad.zip
325 BREAKPAD_DL_FILE
:= $(DL_DIR
)/$(notdir $(BREAKPAD_URL
))
326 BREAKPAD_DIR
:= $(TOOLS_DIR
)/breakpad
328 .PHONY
: breakpad_install
329 breakpad_install
: |
$(DL_DIR
) $(TOOLS_DIR
)
330 breakpad_install
: breakpad_clean
331 $(V0
) @echo
" DOWNLOAD $(BREAKPAD_URL)"
332 $(V1
) $(V1
) curl
-L
-k
-z
"$(BREAKPAD_DL_FILE)" -o
"$(BREAKPAD_DL_FILE)" "$(BREAKPAD_URL)"
333 $(V0
) @echo
" EXTRACT $(notdir $(BREAKPAD_DL_FILE))"
334 $(V1
) mkdir
-p
"$(BREAKPAD_DIR)"
335 $(V1
) unzip
-q
-d
$(BREAKPAD_DIR
) "$(BREAKPAD_DL_FILE)"
336 ifeq ($(OSFAMILY
), windows
)
337 $(V1
) ln
-s
"$(TOOLS_DIR)/breakpad/$(OSFAMILY)-i686" "$(TOOLS_DIR)/breakpad/$(OSFAMILY)-x86_64"
340 .PHONY
: breakpad_clean
342 $(V0
) @echo
" CLEAN $(BREAKPAD_DIR)"
343 $(V1
) [ ! -d
"$(BREAKPAD_DIR)" ] ||
$(RM
) -rf
$(BREAKPAD_DIR
)
344 $(V0
) @echo
" CLEAN $(BREAKPAD_DL_FILE)"
345 $(V1
) $(RM
) -f
$(BREAKPAD_DL_FILE
)