LP-92 Reduce Actuator stack size - Increase System stack size for diags
[librepilot.git] / make / tools.mk
blobaded93fbe0234d6bdfeded4300a74c083e4070e7
2 # Installers for tools required by the OpenPilot build system.
3 # Copyright (c) 2015, The LibrePilot Project, http://www.librepilot.org
4 # Copyright (c) 2010-2013, The OpenPilot Team, http://www.openpilot.org
6 # NOTE: install targets are not tied to the default goals and must
7 # be invoked manually. But tool paths set by this file are used
8 # across the build system.
10 # Ready to use:
11 # arm_sdk_install
12 # qt_sdk_install
13 # nsis_install (Windows only)
14 # sdl_install (Windows only)
15 # openssl_install (Windows only)
16 # mesawin_install (Windows only)
17 # uncrustify_install
18 # doxygen_install
19 # gtest_install
20 # ccache_install
22 # TODO:
23 # openocd_install
24 # ftd2xx_install
25 # libusb_win_install
26 # openocd_git_win_install
27 # openocd_git_install
28 # stm32flash_install
29 # dfuutil_install
30 # android_sdk_install
32 # TODO:
33 # help in the top Makefile
35 # This program is free software; you can redistribute it and/or modify
36 # it under the terms of the GNU General Public License as published by
37 # the Free Software Foundation; either version 3 of the License, or
38 # (at your option) any later version.
40 # This program is distributed in the hope that it will be useful, but
41 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
42 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
43 # for more details.
45 # You should have received a copy of the GNU General Public License along
46 # with this program; if not, write to the Free Software Foundation, Inc.,
47 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
50 ifndef TOP_LEVEL_MAKEFILE
51 $(error $(notdir $(lastword $(MAKEFILE_LIST))) should be included by the top level Makefile)
52 endif
54 ##############################
56 # Toolchain URLs and directories
58 ##############################
60 ifeq ($(UNAME), Linux)
61 ifeq ($(ARCH), x86_64)
62 ARM_SDK_URL := https://launchpad.net/gcc-arm-embedded/4.9/4.9-2014-q4-major/+download/gcc-arm-none-eabi-4_9-2014q4-20141203-linux.tar.bz2
63 ARM_SDK_MD5_URL:= https://launchpad.net/gcc-arm-embedded/4.9/4.9-2014-q4-major/+download/gcc-arm-none-eabi-4_9-2014q4-20141203-linux.tar.bz2/+md5
64 QT_SDK_URL := http://download.qt.io/official_releases/qt/5.4/5.4.1/qt-opensource-linux-x64-5.4.1.run
65 QT_SDK_MD5_URL := http://download.qt.io/official_releases/qt/5.4/5.4.1/qt-opensource-linux-x64-5.4.1.run.md5
66 QT_SDK_ARCH := gcc_64
67 else
68 ARM_SDK_URL := https://launchpad.net/gcc-arm-embedded/4.9/4.9-2014-q4-major/+download/gcc-arm-none-eabi-4_9-2014q4-20141203-linux.tar.bz2
69 ARM_SDK_MD5_URL := https://launchpad.net/gcc-arm-embedded/4.9/4.9-2014-q4-major/+download/gcc-arm-none-eabi-4_9-2014q4-20141203-linux.tar.bz2/+md5
70 QT_SDK_URL := http://download.qt.io/official_releases/qt/5.4/5.4.1/qt-opensource-linux-x86-5.4.1.run
71 QT_SDK_MD5_URL := http://download.qt.io/official_releases/qt/5.4/5.4.1/qt-opensource-linux-x86-5.4.1.run.md5
72 QT_SDK_ARCH := gcc
73 endif
74 UNCRUSTIFY_URL := http://librepilot.github.io/tools/uncrustify-0.60.tar.gz
75 DOXYGEN_URL := http://librepilot.github.io/tools/doxygen-1.8.3.1.src.tar.gz
76 else ifeq ($(UNAME), Darwin)
77 ARM_SDK_URL := https://launchpad.net/gcc-arm-embedded/4.9/4.9-2014-q4-major/+download/gcc-arm-none-eabi-4_9-2014q4-20141203-mac.tar.bz2
78 ARM_SDK_MD5_URL:= https://launchpad.net/gcc-arm-embedded/4.9/4.9-2014-q4-major/+download/gcc-arm-none-eabi-4_9-2014q4-20141203-mac.tar.bz2/+md5
79 QT_SDK_URL := http://download.qt.io/official_releases/qt/5.4/5.4.1/qt-opensource-mac-x64-clang-5.4.1.dmg
80 QT_SDK_MD5_URL := http://download.qt.io/official_releases/qt/5.4/5.4.1/qt-opensource-mac-x64-clang-5.4.1.dmg.md5
81 QT_SDK_ARCH := clang_64
82 QT_SDK_MAINTENANCE_TOOL := /Volumes/qt-opensource-mac-x64-clang-5.4.1/qt-opensource-mac-x64-clang-5.4.1.app/Contents/MacOS/qt-opensource-mac-x64-clang-5.4.1
83 QT_SDK_MOUNT_DIR := /Volumes/qt-opensource-mac-x64-clang-5.4.1
84 QT_SDK_INSTALLER_DAT := /Volumes/qt-opensource-mac-x64-clang-5.4.1/qt-opensource-mac-x64-clang-5.4.1.app/Contents/Resources/installer.dat
85 UNCRUSTIFY_URL := http://librepilot.github.io/tools/uncrustify-0.60.tar.gz
86 DOXYGEN_URL := http://librepilot.github.io/tools/doxygen-1.8.3.1.src.tar.gz
87 else ifeq ($(UNAME), Windows)
88 ARM_SDK_URL := https://launchpad.net/gcc-arm-embedded/4.9/4.9-2014-q4-major/+download/gcc-arm-none-eabi-4_9-2014q4-20141203-win32.zip
89 ARM_SDK_MD5_URL:= https://launchpad.net/gcc-arm-embedded/4.9/4.9-2014-q4-major/+download/gcc-arm-none-eabi-4_9-2014q4-20141203-win32.zip/+md5
90 QT_SDK_URL := http://download.qt.io/official_releases/qt/5.4/5.4.1/qt-opensource-windows-x86-mingw491_opengl-5.4.1.exe
91 QT_SDK_MD5_URL := http://download.qt.io/official_releases/qt/5.4/5.4.1/qt-opensource-windows-x86-mingw491_opengl-5.4.1.exe.md5
92 QT_SDK_ARCH := mingw491_32
93 NSIS_URL := http://librepilot.github.io/tools/nsis-2.46-unicode.tar.bz2
94 SDL_URL := http://librepilot.github.io/tools/SDL-devel-1.2.15-mingw32.tar.gz
95 OPENSSL_URL := http://librepilot.github.io/tools/openssl-1.0.1e-win32.tar.bz2
96 UNCRUSTIFY_URL := http://librepilot.github.io/tools/uncrustify-0.60-windows.tar.bz2
97 DOXYGEN_URL := http://librepilot.github.io/tools/doxygen-1.8.3.1-windows.tar.bz2
98 MESAWIN_URL := http://librepilot.github.io/tools/mesawin.tar.gz
99 CMAKE_URL := http://www.cmake.org/files/v2.8/cmake-2.8.12.2-win32-x86.zip
100 CMAKE_MD5_URL := http://librepilot.github.io/tools/cmake-2.8.12.2-win32-x86.zip.md5
101 MSYS_URL := http://librepilot.github.io/tools/MSYS-1.0.11.zip
102 endif
104 GTEST_URL := http://librepilot.github.io/tools/gtest-1.6.0.zip
105 CCACHE_URL := http://samba.org/ftp/ccache/ccache-3.2.2.tar.bz2
106 CCACHE_MD5_URL := http://librepilot.github.io/tools/ccache-3.2.2.tar.bz2.md5
108 ARM_SDK_DIR := $(TOOLS_DIR)/gcc-arm-none-eabi-4_9-2014q4
109 QT_SDK_DIR := $(TOOLS_DIR)/qt-5.4.1
110 UNCRUSTIFY_DIR := $(TOOLS_DIR)/uncrustify-0.60
111 DOXYGEN_DIR := $(TOOLS_DIR)/doxygen-1.8.3.1
112 GTEST_DIR := $(TOOLS_DIR)/gtest-1.6.0
113 CCACHE_DIR := $(TOOLS_DIR)/ccache
115 ifeq ($(UNAME), Linux)
116 else ifeq ($(UNAME), Darwin)
117 else ifeq ($(UNAME), Windows)
118 MINGW_DIR := $(QT_SDK_DIR)/Tools/$(QT_SDK_ARCH)
119 # When changing PYTHON_DIR, you must also update it in ground/gcs/src/python.pri
120 PYTHON_DIR := $(QT_SDK_DIR)/Tools/$(QT_SDK_ARCH)/opt/bin
121 NSIS_DIR := $(TOOLS_DIR)/nsis-2.46-unicode
122 # When changing SDL_DIR or OPENSSL_DIR, you must also update them in ground/gcs/gcs.pri
123 SDL_DIR := $(TOOLS_DIR)/SDL-1.2.15
124 OPENSSL_DIR := $(TOOLS_DIR)/openssl-1.0.1e-win32
125 MESAWIN_DIR := $(TOOLS_DIR)/mesawin
126 CMAKE_DIR := $(TOOLS_DIR)/cmake-2.8.12.2-win32-x86
127 MSYS_DIR := $(TOOLS_DIR)/msys
128 endif
130 QT_SDK_PREFIX := $(QT_SDK_DIR)
132 ##############################
134 # Build only and all toolchains available for the platform
136 ##############################
138 BUILD_SDK_TARGETS := arm_sdk qt_sdk
139 ifeq ($(UNAME), Windows)
140 BUILD_SDK_TARGETS += sdl nsis mesawin openssl ccache
141 endif
142 ALL_SDK_TARGETS := $(BUILD_SDK_TARGETS) gtest uncrustify doxygen
144 define GROUP_SDK_TEMPLATE
145 .PHONY: $(1)_install $(1)_clean $(1)_distclean $(1)_version
146 $(1)_install: $(addsuffix _install,$(2))
147 $(1)_clean: $(addsuffix _clean,$(2))
148 $(1)_distclean: $(addsuffix _distclean,$(2))
149 $(1)_version: $(addsuffix _version,$(2))
150 endef
152 $(eval $(call GROUP_SDK_TEMPLATE,build_sdk,$(BUILD_SDK_TARGETS)))
153 $(eval $(call GROUP_SDK_TEMPLATE,all_sdk,$(ALL_SDK_TARGETS)))
155 ##############################
157 # Misc host tools
159 ##############################
161 # Used by other makefiles
162 export MKDIR := mkdir
163 export CP := cp
164 export RM := rm
165 export LN := ln
166 export CAT := cat
167 export CUT := cut
168 export SED := sed
170 # Used only by this Makefile
171 GIT := git
172 CURL := curl
173 TAR := tar
174 UNZIP := unzip
175 ZIP := gzip
176 OPENSSL := openssl
177 ANT := ant
178 JAVAC := javac
179 JAR := jar
180 CD := cd
181 GREP := grep
182 ifneq ($(UNAME), Windows)
183 SEVENZIP := 7za
184 else
185 SEVENZIP := 7za.exe
186 ifneq ($(shell $(SEVENZIP) --version >/dev/null 2>&1 && $(ECHO) "found"), found)
187 # no $(SEVENZIP) found in path. hope is in bin...
188 SEVENZIP = $(TOOLS_DIR)/bin/7za.exe
189 endif
190 endif
192 # Echo in recipes is a bit tricky in a Windows Git Bash window in some cases.
193 # It does not work if make started under msysGit installed into a path with spaces.
194 ifneq ($(UNAME), Windows)
195 export ECHO := echo
196 else
197 # export ECHO := $(PYTHON) -c "import sys; print(' '.join(sys.argv[1:]))"
198 export ECHO := echo
199 endif
201 # Test if quotes are needed for the echo command
202 ifeq ($(shell $(ECHO) "test"), test)
203 export QUOTE := '
204 # This line is just to clear out the single quote above '
205 else
206 export QUOTE :=
207 endif
209 # Command to extract version info data from the repository and source tree
210 export VERSION_INFO = $(PYTHON) $(ROOT_DIR)/make/scripts/version-info.py --path=$(ROOT_DIR)
212 export CCACHE
214 ##############################
216 # Misc settings
218 ##############################
220 # Define messages
221 MSG_VERIFYING = $(QUOTE) VERIFY $(QUOTE)
222 MSG_DOWNLOADING = $(QUOTE) DOWNLOAD $(QUOTE)
223 MSG_CHECKSUMMING = $(QUOTE) MD5 $(QUOTE)
224 MSG_EXTRACTING = $(QUOTE) EXTRACT $(QUOTE)
225 MSG_CONFIGURING = $(QUOTE) CONFIGURE $(QUOTE)
226 MSG_BUILDING = $(QUOTE) BUILD $(QUOTE)
227 MSG_INSTALLING = $(QUOTE) INSTALL $(QUOTE)
228 MSG_CLEANING = $(QUOTE) CLEAN $(QUOTE)
229 MSG_DISTCLEANING = $(QUOTE) DISTCLEAN $(QUOTE)
230 MSG_NOTICE = $(QUOTE) NOTE $(QUOTE)
232 # Verbosity level
233 ifeq ($(V), 1)
234 MAKE_SILENT :=
235 UNZIP_SILENT :=
236 else
237 MAKE_SILENT := --silent
238 UNZIP_SILENT := -q
239 endif
241 # Batch mode
242 ifeq ($(BATCH), 1)
243 CURL_OPTIONS := --silent -L
244 else
245 CURL_OPTIONS := -L
246 endif
248 # MSYS tar workaround
249 ifeq ($(UNAME), Windows)
250 TAR_OPTIONS := --force-local
251 else
252 TAR_OPTIONS :=
253 endif
255 # Print some useful notes for *_install targets
256 ifneq ($(strip $(filter $(addsuffix _install,all_sdk $(ALL_SDK_TARGETS)),$(MAKECMDGOALS))),)
257 ifneq ($(shell $(CURL) --version >/dev/null 2>&1 && $(ECHO) "found"), found)
258 $(error Please install curl first ('apt-get install curl' or similar))
259 endif
260 $(info $(EMPTY) NOTE Use 'make all_sdk_distclean' to remove installation files)
261 $(info $(EMPTY) NOTE Use 'make all_sdk_version' to check toolchain versions)
262 $(info $(EMPTY) NOTE Add 'V=1' to make command line to diagnose make problems)
263 $(info $(EMPTY) NOTE Add 'BATCH=1' to make command line to disable progress reporting during downloads)
264 endif
266 ##############################
268 # Cross-platform MD5 check template
269 # $(1) = file name without quotes
270 # $(2) = string compare operator, e.g. = or !=
272 ##############################
274 define MD5_CHECK_TEMPLATE
275 "`test -f \"$(1)\" && $(OPENSSL) dgst -md5 \"$(1)\" | $(CUT) -f2 -d' '`" $(2) "`$(CUT) -f1 -d' ' < \"$(1).md5\"`"
276 endef
278 ##############################
280 # Cross-platform MD5 generation template
281 # $(1) = file name without quotes
283 ##############################
285 ifeq ($(UNAME), Darwin)
287 define MD5_GEN_TEMPLATE
288 md5 -r $(1) > $(1).md5
289 endef
291 else
293 define MD5_GEN_TEMPLATE
294 $(OPENSSL) dgst -r -md5 $(1) > $(1).md5
295 endef
297 endif
299 ##############################
301 # Cross platform download template
302 # $(1) = Package URL
303 # $(2) = Package file
304 # $(3) = URL for .md5 file to be tested against Package
306 ##############################
308 define DOWNLOAD_TEMPLATE
309 @$(ECHO) $(MSG_VERIFYING) $$(call toprel, $(DL_DIR)/$(2))
310 $(V1) ( \
311 cd "$(DL_DIR)" && \
312 $(CURL) $(CURL_OPTIONS) --silent -o "$(DL_DIR)/$(2).md5" "$(3)" && \
313 if [ $(call MD5_CHECK_TEMPLATE,$(DL_DIR)/$(2),!=) ]; then \
314 $(ECHO) $(MSG_DOWNLOADING) $(1) && \
315 $(CURL) $(CURL_OPTIONS) -o "$(DL_DIR)/$(2)" "$(1)" && \
316 $(ECHO) $(MSG_CHECKSUMMING) $$(call toprel, $(DL_DIR)/$(2)) && \
317 [ $(call MD5_CHECK_TEMPLATE,$(DL_DIR)/$(2),=) ]; \
318 fi; \
320 endef
322 ##############################
324 # Common tool install template
325 # $(1) = tool name
326 # $(2) = tool extract/build directory
327 # $(3) = tool distribution URL
328 # $(4) = tool distribution MD5 URL
329 # $(5) = tool distribution file
330 # $(6) = optional extra build recipes template
331 # $(7) = optional extra clean recipes template
333 ##############################
335 define TOOL_INSTALL_TEMPLATE
337 .PHONY: $(addprefix $(1)_, install clean distclean)
339 $(1)_install: $(1)_clean | $(DL_DIR) $(TOOLS_DIR)
341 $(if $(4), $(call DOWNLOAD_TEMPLATE,$(3),$(5),$(4)),$(call DOWNLOAD_TEMPLATE,$(3),$(5),"$(3).md5"))
343 @$(ECHO) $(MSG_EXTRACTING) $$(call toprel, $(2))
344 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(2)))
346 $(if $(filter $(suffix $(5)), .zip),
347 $(V1) $(UNZIP) $(UNZIP_SILENT) -d $$(call toprel, $(dir $(2))) $$(call toprel, $(DL_DIR)/$(5)),
348 $(V1) $(TAR) $(TAR_OPTIONS) -C $$(call toprel, $(dir $(2))) -xf $$(call toprel, $(DL_DIR)/$(5))
351 $(6)
353 $(1)_clean:
354 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(2))
355 $(V1) [ ! -d "$(2)" ] || $(RM) -rf "$(2)"
357 $(7)
359 $(1)_distclean:
360 @$(ECHO) $(MSG_DISTCLEANING) $$(call toprel, $(DL_DIR)/$(5))
361 $(V1) [ ! -f "$(DL_DIR)/$(5)" ] || $(RM) "$(DL_DIR)/$(5)"
362 $(V1) [ ! -f "$(DL_DIR)/$(5).md5" ] || $(RM) "$(DL_DIR)/$(5).md5"
364 endef
366 ##############################
368 # Windows QT install template
369 # $(1) = tool temp extract/build directory
370 # $(2) = tool install directory
371 # $(3) = tool distribution URL
372 # $(4) = tool distribution .md5 URL
373 # $(5) = tool distribution file
374 # $(6) = QT architecture
375 # $(7) = optional extra build recipes template
376 # $(8) = optional extra clean recipes template
378 ##############################
380 define WIN_QT_INSTALL_TEMPLATE
382 .PHONY: $(addprefix qt_sdk_, install clean distclean)
384 qt_sdk_install: qt_sdk_clean | $(DL_DIR) $(TOOLS_DIR)
385 $(V1) if ! $(SEVENZIP) >/dev/null 2>&1; then \
386 $(ECHO) $(MSG_NOTICE) "Missing 7zip. Run ./make/scripts/win_sdk_install.sh [<OpenPilot tools dir>] to get it." && \
387 exit 1; \
389 $(call DOWNLOAD_TEMPLATE,$(3),$(5),"$(4)")
390 # Explode .run file into install packages
391 @$(ECHO) $(MSG_EXTRACTING) $$(call toprel, $(1))
392 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(1)))
393 $(V1) chmod +x $(DL_DIR)/$(5)
394 $(V1) $(DL_DIR)/$(5) --dump-binary-data -o $(1)
395 # Extract packages under tool directory
396 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(2)))
397 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.54.win32_mingw491/5.4.1-0qt5_essentials.7z" | grep -v Extracting
398 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.54.win32_mingw491/5.4.1-0i686-4.9.1-release-posix-dwarf-rt_v3-rev2-runtime.7z" | grep -v Extracting
399 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.54.win32_mingw491/5.4.1-0icu_53_1_mingw_builds_4_9_1_posix_dwarf_32.7z" | grep -v Extracting
400 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.54.win32_mingw491/5.4.1-0qt5_addons.7z" | grep -v Extracting
401 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.tools.win32_mingw491/4.9.1-2i686-4.9.1-release-posix-dwarf-rt_v3-rev2.7z" | grep -v Extracting
402 # Run patcher
403 @$(ECHO)
404 @$(ECHO) "Executing QtPatch in" $$(call toprel, $(QT_SDK_PREFIX))
405 $(V1) $(CD) $(QT_SDK_PREFIX)
406 $(V1) $(DL_DIR)/$(5) --runoperation QtPatch windows $(QT_SDK_PREFIX) qt5
408 # Execute post build templates
409 $(7)
411 # Clean up temporary files
412 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
413 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
415 qt_sdk_clean:
416 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
417 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
418 @$(ECHO) $(MSG_CLEANING) $$(call toprel, "$(2)")
419 $(V1) [ ! -d "$(2)" ] || $(RM) -rf "$(2)"
421 $(8)
423 qt_sdk_distclean:
424 @$(ECHO) $(MSG_DISTCLEANING) $$(call toprel, $(DL_DIR)/$(5))
425 $(V1) [ ! -f "$(DL_DIR)/$(5)" ] || $(RM) "$(DL_DIR)/$(5)"
426 $(V1) [ ! -f "$(DL_DIR)/$(5).md5" ] || $(RM) "$(DL_DIR)/$(5).md5"
428 endef
430 ##############################
432 # Linux QT install template
433 # $(1) = tool temp extract/build directory
434 # $(2) = tool install directory
435 # $(3) = tool distribution URL
436 # $(4) = tool distribution .md5 URL
437 # $(5) = tool distribution file
438 # $(6) = QT architecture
439 # $(7) = optional extra build recipes template
440 # $(8) = optional extra clean recipes template
442 ##############################
444 define LINUX_QT_INSTALL_TEMPLATE
446 .PHONY: $(addprefix qt_sdk_, install clean distclean)
448 qt_sdk_install: qt_sdk_clean | $(DL_DIR) $(TOOLS_DIR)
449 $(V1) if ! $(SEVENZIP) >/dev/null 2>&1; then \
450 $(ECHO) $(MSG_NOTICE) "Please install the p7zip for your distribution. i.e.: sudo apt-get install p7zip-full" && \
451 exit 1; \
453 $(call DOWNLOAD_TEMPLATE,$(3),$(5),"$(4)")
454 # Explode .run file into install packages
455 @$(ECHO) $(MSG_EXTRACTING) $$(call toprel, $(1))
456 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(1)))
457 $(V1) chmod +x $(DL_DIR)/$(5)
458 $(V1) $(DL_DIR)/$(5) --dump-binary-data -o $(1)
459 # Extract packages under tool directory
460 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(2)))
461 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.54.$(6)/5.4.1-0qt5_essentials.7z" | grep -v Extracting
462 $(V1) if [ -f "$(1)/qt.54.$(6)/5.4.1-0icu_53_1_ubuntu_11_10_64.7z" ]; then $(SEVENZIP) -y -o$(2) x "$(1)/qt.54.$(6)/5.4.1-0icu_53_1_ubuntu_11_10_64.7z" | grep -v Extracting; fi
463 $(V1) if [ -f "$(1)/qt.54.$(6)/5.4.1-0icu_53_1_ubuntu_11_10_32.7z" ]; then $(SEVENZIP) -y -o$(2) x "$(1)/qt.54.$(6)/5.4.1-0icu_53_1_ubuntu_11_10_32.7z" | grep -v Extracting; fi
464 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.54.$(6)/5.4.1-0qt5_addons.7z" | grep -v Extracting
465 # Run patcher
466 @$(ECHO)
467 @$(ECHO) "Executing QtPatch in" $$(call toprel, $(QT_SDK_PREFIX))
468 $(V1) $(CD) $(QT_SDK_PREFIX)
469 $(V1) $(DL_DIR)/$(5) --runoperation QtPatch linux $(QT_SDK_PREFIX) qt5
471 # Execute post build templates
472 $(7)
474 # Clean up temporary files
475 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
476 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
478 qt_sdk_clean:
479 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
480 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
481 @$(ECHO) $(MSG_CLEANING) $$(call toprel, "$(2)")
482 $(V1) [ ! -d "$(2)" ] || $(RM) -rf "$(2)"
484 $(8)
486 qt_sdk_distclean:
487 @$(ECHO) $(MSG_DISTCLEANING) $$(call toprel, $(DL_DIR)/$(5))
488 $(V1) [ ! -f "$(DL_DIR)/$(5)" ] || $(RM) "$(DL_DIR)/$(5)"
489 $(V1) [ ! -f "$(DL_DIR)/$(5).md5" ] || $(RM) "$(DL_DIR)/$(5).md5"
491 endef
493 ##############################
495 # Mac QT install template
496 # $(1) = tool temp extract/build directory
497 # $(2) = tool install directory
498 # $(3) = tool distribution URL
499 # $(4) = tool distribution .md5 URL
500 # $(5) = tool distribution file
501 # $(6) = QT architecture
502 # $(7) = optional extra build recipes template
503 # $(8) = optional extra clean recipes template
505 ##############################
507 define MAC_QT_INSTALL_TEMPLATE
509 .PHONY: $(addprefix qt_sdk_, install clean distclean)
511 qt_sdk_install: qt_sdk_clean | $(DL_DIR) $(TOOLS_DIR)
512 $(V1) if ! $(SEVENZIP) >/dev/null 2>&1; then \
513 $(ECHO) $(MSG_NOTICE) "Please install the p7zip for your distribution. i.e.: brew install p7zip." && \
514 exit 1; \
516 $(call DOWNLOAD_TEMPLATE,$(3),$(5),"$(4)")
517 # Mount .dmg file
518 $(V1) hdiutil attach -nobrowse $(DL_DIR)/$(5)
519 # Explode .dmg file into install packages
520 @$(ECHO) $(MSG_EXTRACTING) $$(call toprel, $(1))
521 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(1)))
522 $(V1) $(QT_SDK_MAINTENANCE_TOOL) --dump-binary-data -i $(QT_SDK_INSTALLER_DAT) -o $(1)
523 # Extract packages under tool directory
524 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(2)))
525 #$(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.readme/1.0.0-0qt-project-url.7z" | grep -v Extracting
526 #$(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt/5.4.1ThirdPartySoftware_Listing.7z" | grep -v Extracting
527 #$(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.readme/1.0.0-0readme.7z" | grep -v Extracting
528 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.54.$(6)/5.4.1-0qt5_essentials.7z" | grep -v Extracting
529 # $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.54.$(6).essentials/5.4.1icu_path_patcher.sh.7z" | grep -v Extracting
530 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.54.$(6)/5.4.1-0qt5_addons.7z" | grep -v Extracting
533 # go to OpenPilot/tools/5.4/gcc_64 and call patcher.sh
534 @$(ECHO)
535 @$(ECHO) "Running patcher in" $$(call toprel, $(QT_SDK_PREFIX))
536 $(V1) $(CD) $(QT_SDK_PREFIX)
537 # $(V1) "$(QT_SDK_PREFIX)/patcher.sh" $(QT_SDK_PREFIX)
538 # call qmake patcher
539 @$(ECHO) "Executing QtPatch in" $$(call toprel, $(QT_SDK_PREFIX))
540 $(V1) $(QT_SDK_MAINTENANCE_TOOL) --runoperation QtPatch mac $(QT_SDK_PREFIX) qt5
542 #Unmount the .dmg file
543 $(V1) hdiutil detach $(QT_SDK_MOUNT_DIR)
545 # Execute post build templates
546 $(7)
548 # Clean up temporary files
549 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
550 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
552 qt_sdk_clean:
553 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
554 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
555 @$(ECHO) $(MSG_CLEANING) $$(call toprel, "$(2)")
556 $(V1) [ ! -d "$(2)" ] || $(RM) -rf "$(2)"
558 $(8)
560 qt_sdk_distclean:
561 @$(ECHO) $(MSG_DISTCLEANING) $$(call toprel, $(DL_DIR)/$(5))
562 $(V1) [ ! -f "$(DL_DIR)/$(5)" ] || $(RM) "$(DL_DIR)/$(5)"
563 $(V1) [ ! -f "$(DL_DIR)/$(5).md5" ] || $(RM) "$(DL_DIR)/$(5).md5"
565 endef
567 ##############################
569 # ARM SDK
571 ##############################
573 ifeq ($(UNAME), Windows)
575 # unfortunately zip package for this release is missing root directory, so adding / at the end of the path
576 # so that template interpret last part as directory and use the full path
577 $(eval $(call TOOL_INSTALL_TEMPLATE,arm_sdk,$(ARM_SDK_DIR)/,$(ARM_SDK_URL),$(ARM_SDK_MD5_URL),$(notdir $(ARM_SDK_URL))))
579 else
581 $(eval $(call TOOL_INSTALL_TEMPLATE,arm_sdk,$(ARM_SDK_DIR),$(ARM_SDK_URL),$(ARM_SDK_MD5_URL),$(notdir $(ARM_SDK_URL))))
583 endif
585 ifeq ($(shell [ -d "$(ARM_SDK_DIR)" ] && $(ECHO) "exists"), exists)
586 export ARM_SDK_PREFIX := $(ARM_SDK_DIR)/bin/arm-none-eabi-
587 else
588 # not installed, hope it's in the path...
589 # $(info $(EMPTY) WARNING $(call toprel, $(ARM_SDK_DIR)) not found (make arm_sdk_install), using system PATH)
590 export ARM_SDK_PREFIX ?= arm-none-eabi-
591 endif
593 .PHONY: arm_sdk_version
594 arm_sdk_version:
595 -$(V1) $(ARM_SDK_PREFIX)gcc --version | head -n1
597 # Template to check ARM toolchain version before building targets
598 define ARM_GCC_VERSION_CHECK_TEMPLATE
599 if ! $(ARM_SDK_PREFIX)gcc --version --specs=nano.specs >/dev/null 2>&1; then \
600 $(ECHO) $(MSG_NOTICE) Please install ARM toolchain 4.8 2014q1 using \'make arm_sdk_install\' && \
601 $(ECHO) $(MSG_NOTICE) Older ARM SDKs do not support new \'--specs=nano.specs\' option && \
602 exit 1; \
604 endef
606 ##############################
608 # Qt SDK
610 ##############################
612 ifeq ($(UNAME), Windows)
614 QT_SDK_PREFIX := $(QT_SDK_DIR)/5.4/$(QT_SDK_ARCH)
616 # This additional configuration step should not be necessary
617 # but it is needed as a workaround to https://bugreports.qt-project.org/browse/QTBUG-33254
618 define QT_SDK_CONFIGURE_TEMPLATE
619 @$(ECHO) $(MSG_CONFIGURING) $(call toprel, $(QT_SDK_DIR))
620 $(V1) $(ECHO) $(QUOTE)[Paths]$(QUOTE) > $(QT_SDK_PREFIX)/bin/qt.conf
621 $(V1) $(ECHO) $(QUOTE)Prefix = $(QT_SDK_PREFIX)$(QUOTE) >> $(QT_SDK_PREFIX)/bin/qt.conf
622 endef
624 QT_BUILD_DIR := $(BUILD_DIR)/QT_BUILD
625 $(eval $(call WIN_QT_INSTALL_TEMPLATE,$(QT_BUILD_DIR),$(QT_SDK_DIR),$(QT_SDK_URL),$(QT_SDK_MD5_URL),$(notdir $(QT_SDK_URL)),$(QT_SDK_ARCH),$(QT_SDK_CONFIGURE_TEMPLATE)))
627 else ifeq ($(UNAME), Linux)
629 QT_SDK_PREFIX := "$(QT_SDK_DIR)/5.4/$(QT_SDK_ARCH)"
630 QT_BUILD_DIR := $(BUILD_DIR)/QT_BUILD
631 $(eval $(call LINUX_QT_INSTALL_TEMPLATE,$(QT_BUILD_DIR),$(QT_SDK_DIR),$(QT_SDK_URL),$(QT_SDK_MD5_URL),$(notdir $(QT_SDK_URL)),$(QT_SDK_ARCH)))
633 else ifeq ($(UNAME), Darwin)
635 QT_SDK_PREFIX := "$(QT_SDK_DIR)/5.4/$(QT_SDK_ARCH)"
636 QT_BUILD_DIR := $(BUILD_DIR)/QT_BUILD
637 $(eval $(call MAC_QT_INSTALL_TEMPLATE,$(QT_BUILD_DIR),$(QT_SDK_DIR),$(QT_SDK_URL),$(QT_SDK_MD5_URL),$(notdir $(QT_SDK_URL)),$(QT_SDK_ARCH)))
639 else
641 QT_SDK_PREFIX := $(QT_SDK_DIR)
643 .PHONY: qt_sdk_install
644 qt_sdk_install:
645 @$(ECHO) $(MSG_NOTICE) --------------------------------------------------------
646 @$(ECHO) $(MSG_NOTICE) Please install native Qt 5.4.x SDK using package manager
647 @$(ECHO) $(MSG_NOTICE) --------------------------------------------------------
649 .PHONY: qt_sdk_clean
650 qt_sdk_clean:
652 .PHONY: qt_sdk_distclean
653 qt_sdk_distclean:
655 endif
657 ifeq ($(shell [ -d "$(QT_SDK_DIR)" ] && $(ECHO) "exists"), exists)
658 export QMAKE := $(QT_SDK_PREFIX)/bin/qmake
660 # set Qt library search path
661 ifeq ($(UNAME), Windows)
662 export PATH := $(QT_SDK_PREFIX)/bin:$(PATH)
663 else
664 export LD_LIBRARY_PATH := $(QT_SDK_DIR)/lib:$(LD_LIBRARY_PATH)
665 endif
666 else
667 # not installed, hope it's in the path...
668 # $(info $(EMPTY) WARNING $(call toprel, $(QT_SDK_DIR)) not found (make qt_sdk_install), using system PATH)
669 QMAKE ?= qmake
670 endif
672 .PHONY: qt_sdk_version
673 qt_sdk_version:
674 -$(V1) $(QMAKE) --version | tail -1
676 ##############################
678 # MinGW
680 ##############################
682 ifeq ($(UNAME), Windows)
684 ifeq ($(shell [ -d "$(MINGW_DIR)" ] && $(ECHO) "exists"), exists)
685 # set MinGW binary and library paths (QTMINGW is used by qmake, do not rename)
686 export QTMINGW := $(MINGW_DIR)/bin
687 export PATH := $(QTMINGW):$(PATH)
688 else
689 # not installed, use host gcc compiler
690 # $(info $(EMPTY) WARNING $(call toprel, $(MINGW_DIR)) not found, using system PATH)
691 endif
693 .PHONY: mingw_version
694 mingw_version: gcc_version
696 else # Linux or Mac
698 all_sdk_version: gcc_version
700 endif
702 .PHONY: gcc_version
703 gcc_version:
704 -$(V1) gcc --version | head -n1
706 ##############################
708 # Python
710 ##############################
712 ifeq ($(shell [ -d "$(PYTHON_DIR)" ] && $(ECHO) "exists"), exists)
713 export PYTHON := $(PYTHON_DIR)/python
714 export PATH := $(PYTHON_DIR):$(PATH)
715 else
716 # not installed, hope it's in the path...
717 # $(info $(EMPTY) WARNING $(call toprel, $(PYTHON_DIR)) not found, using system PATH)
718 ifeq ($(findstring Python 2,$(shell python --version 2>&1)), Python 2)
719 export PYTHON := python
720 else
721 export PYTHON := python2
722 endif
723 endif
725 .PHONY: python_version
726 python_version:
727 -$(V1) $(PYTHON) --version
729 ##############################
731 # NSIS Unicode (Windows only)
733 ##############################
735 ifeq ($(UNAME), Windows)
737 $(eval $(call TOOL_INSTALL_TEMPLATE,nsis,$(NSIS_DIR),$(NSIS_URL),,$(notdir $(NSIS_URL))))
739 ifeq ($(shell [ -d "$(NSIS_DIR)" ] && $(ECHO) "exists"), exists)
740 export NSIS := $(NSIS_DIR)/makensis
741 else
742 # not installed, hope it's in the path...
743 # $(info $(EMPTY) WARNING $(call toprel, $(NSIS_DIR)) not found (make nsis_install), using system PATH)
744 export NSIS ?= makensis
745 endif
747 .PHONY: nsis_version
748 nsis_version:
749 -$(V1) $(NSIS) | head -n1
751 endif
753 ##############################
755 # SDL (Windows only)
757 ##############################
759 ifeq ($(UNAME), Windows)
761 $(eval $(call TOOL_INSTALL_TEMPLATE,sdl,$(SDL_DIR),$(SDL_URL),,$(notdir $(SDL_URL))))
763 ifeq ($(shell [ -d "$(SDL_DIR)" ] && $(ECHO) "exists"), exists)
764 export SDL_DIR := $(SDL_DIR)
765 else
766 # not installed, hope it's in the path...
767 $(info $(EMPTY) WARNING $(call toprel, $(SDL_DIR)) not found (make sdl_install), using system PATH)
768 endif
770 .PHONY: sdl_version
771 sdl_version:
772 -$(V1) $(ECHO) "SDL 1.2.15"
774 endif
776 ##################################
778 # Mesa OpenGL DLL (Windows only)
780 ##################################
782 ifeq ($(UNAME), Windows)
784 $(eval $(call TOOL_INSTALL_TEMPLATE,mesawin,$(MESAWIN_DIR),$(MESAWIN_URL),,$(notdir $(MESAWIN_URL))))
786 ifeq ($(shell [ -d "$(MESAWIN_DIR)" ] && $(ECHO) "exists"), exists)
787 export MESAWIN_DIR := $(MESAWIN_DIR)
788 else
789 # not installed, hope it's in the path...
790 #$(info $(EMPTY) WARNING $(call toprel, $(MESA_WIN_DIR)) not found (make mesawin_install), using system PATH)
791 endif
793 .PHONY: mesawin_version
794 mesawin_version:
795 -$(V1) $(ECHO) "MesaOpenGL vXX"
797 endif
799 ##############################
801 # OpenSSL (Windows only)
803 ##############################
805 ifeq ($(UNAME), Windows)
807 $(eval $(call TOOL_INSTALL_TEMPLATE,openssl,$(OPENSSL_DIR),$(OPENSSL_URL),,$(notdir $(OPENSSL_URL))))
809 ifeq ($(shell [ -d "$(OPENSSL_DIR)" ] && $(ECHO) "exists"), exists)
810 export OPENSSL := $(OPENSSL_DIR)/bin/openssl
811 export OPENSSL_CONF := $(OPENSSL_DIR)/bin/openssl.cfg
812 export OPENSSL_DIR
813 else
814 # not installed, hope it's in the path...
815 # $(info $(EMPTY) WARNING $(call toprel, $(OPENSSL_DIR)) not found (make openssl_install), using system PATH)
816 endif
818 .PHONY: openssl_version
819 openssl_version:
820 -$(V1) $(ECHO) "OpenSSL `$(OPENSSL) version`"
822 endif
824 ##############################
826 # Uncrustify
828 ##############################
830 ifeq ($(UNAME), Windows)
832 $(eval $(call TOOL_INSTALL_TEMPLATE,uncrustify,$(UNCRUSTIFY_DIR),$(UNCRUSTIFY_URL),,$(notdir $(UNCRUSTIFY_URL))))
834 else # Linux or Mac
836 UNCRUSTIFY_BUILD_DIR := $(BUILD_DIR)/$(notdir $(UNCRUSTIFY_DIR))
838 define UNCRUSTIFY_BUILD_TEMPLATE
839 $(V1) ( \
840 $(ECHO) $(MSG_CONFIGURING) $(call toprel, $(UNCRUSTIFY_BUILD_DIR)) && \
841 cd $(UNCRUSTIFY_BUILD_DIR) && \
842 ./configure --prefix="$(UNCRUSTIFY_DIR)" && \
843 $(ECHO) $(MSG_BUILDING) $(call toprel, $(UNCRUSTIFY_BUILD_DIR)) && \
844 $(MAKE) $(MAKE_SILENT) && \
845 $(ECHO) $(MSG_INSTALLING) $(call toprel, $(UNCRUSTIFY_DIR)) && \
846 $(MAKE) $(MAKE_SILENT) install-strip \
848 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(UNCRUSTIFY_BUILD_DIR))
849 -$(V1) [ ! -d "$(UNCRUSTIFY_BUILD_DIR)" ] || $(RM) -rf "$(UNCRUSTIFY_BUILD_DIR)"
850 endef
852 define UNCRUSTIFY_CLEAN_TEMPLATE
853 -$(V1) [ ! -d "$(UNCRUSTIFY_DIR)" ] || $(RM) -rf "$(UNCRUSTIFY_DIR)"
854 endef
856 $(eval $(call TOOL_INSTALL_TEMPLATE,uncrustify,$(UNCRUSTIFY_BUILD_DIR),$(UNCRUSTIFY_URL),,$(notdir $(UNCRUSTIFY_URL)),$(UNCRUSTIFY_BUILD_TEMPLATE),$(UNCRUSTIFY_CLEAN_TEMPLATE)))
858 endif
860 ifeq ($(shell [ -d "$(UNCRUSTIFY_DIR)" ] && $(ECHO) "exists"), exists)
861 export UNCRUSTIFY := $(UNCRUSTIFY_DIR)/bin/uncrustify
862 else
863 # not installed, hope it's in the path...
864 # $(info $(EMPTY) WARNING $(call toprel, $(UNCRUSTIFY_DIR)) not found (make uncrustify_install), using system PATH)
865 export UNCRUSTIFY := uncrustify
866 endif
868 .PHONY: uncrustify_version
869 uncrustify_version:
870 -$(V1) $(UNCRUSTIFY) --version
872 ##############################
874 # Doxygen
876 ##############################
878 ifeq ($(UNAME), Windows)
880 $(eval $(call TOOL_INSTALL_TEMPLATE,doxygen,$(DOXYGEN_DIR),$(DOXYGEN_URL),,$(notdir $(DOXYGEN_URL))))
882 else # Linux or Mac
884 DOXYGEN_BUILD_DIR := $(BUILD_DIR)/$(notdir $(DOXYGEN_DIR))
886 define DOXYGEN_BUILD_TEMPLATE
887 $(V1) ( \
888 $(ECHO) $(MSG_CONFIGURING) $(call toprel, $(DOXYGEN_BUILD_DIR)) && \
889 cd $(DOXYGEN_BUILD_DIR) && \
890 ./configure --prefix "$(DOXYGEN_DIR)" --english-only && \
891 $(ECHO) $(MSG_BUILDING) $(call toprel, $(DOXYGEN_BUILD_DIR)) && \
892 $(MAKE) $(MAKE_SILENT) && \
893 $(ECHO) $(MSG_INSTALLING) $(call toprel, $(DOXYGEN_DIR)) && \
894 $(MAKE) $(MAKE_SILENT) install \
896 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(DOXYGEN_BUILD_DIR))
897 -$(V1) [ ! -d "$(DOXYGEN_BUILD_DIR)" ] || $(RM) -rf "$(DOXYGEN_BUILD_DIR)"
898 endef
900 define DOXYGEN_CLEAN_TEMPLATE
901 -$(V1) [ ! -d "$(DOXYGEN_DIR)" ] || $(RM) -rf "$(DOXYGEN_DIR)"
902 endef
904 $(eval $(call TOOL_INSTALL_TEMPLATE,doxygen,$(DOXYGEN_BUILD_DIR),$(DOXYGEN_URL),,$(notdir $(DOXYGEN_URL)),$(DOXYGEN_BUILD_TEMPLATE),$(DOXYGEN_CLEAN_TEMPLATE)))
906 endif
908 ifeq ($(shell [ -d "$(DOXYGEN_DIR)" ] && $(ECHO) "exists"), exists)
909 export DOXYGEN := $(DOXYGEN_DIR)/bin/doxygen
910 else
911 # not installed, hope it's in the path...
912 # $(info $(EMPTY) WARNING $(call toprel, $(DOXYGEN_DIR)) not found (make doxygen_install), using system PATH)
913 export DOXYGEN := doxygen
914 endif
916 .PHONY: doxygen_version
917 doxygen_version:
918 -$(V1) $(ECHO) "Doxygen `$(DOXYGEN) --version`"
920 ##############################
922 # GoogleTest
924 ##############################
926 $(eval $(call TOOL_INSTALL_TEMPLATE,gtest,$(GTEST_DIR),$(GTEST_URL),,$(notdir $(GTEST_URL))))
928 export GTEST_DIR
930 .PHONY: gtest_version
931 gtest_version:
932 -$(V1) $(SED) -n "s/^PACKAGE_STRING='\(.*\)'/\1/p" < $(GTEST_DIR)/configure
934 ##############################
936 # CMake
938 ##############################
940 $(eval $(call TOOL_INSTALL_TEMPLATE,cmake,$(CMAKE_DIR),$(CMAKE_URL),$(CMAKE_MD5_URL),$(notdir $(CMAKE_URL))))
942 ifeq ($(shell [ -d "$(CMAKE_DIR)" ] && $(ECHO) "exists"), exists)
943 export CMAKE := $(CMAKE_DIR)/bin/cmake
944 export PATH := $(CMAKE_DIR)/bin:$(PATH)
945 else
946 # not installed, hope it's in the path...
947 #$(info $(EMPTY) WARNING $(call toprel, $(CMAKE_DIR)) not found (make cmake_install), using system PATH)
948 export CMAKE := cmake
949 endif
951 .PHONY: cmake_version
952 cmake_version:
953 -$(V1) $(CMAKE) --version
955 ##############################
957 # MSYS
959 ##############################
961 ifeq ($(UNAME), Windows)
963 $(eval $(call TOOL_INSTALL_TEMPLATE,msys,$(MSYS_DIR),$(MSYS_URL),,$(notdir $(MSYS_URL))))
965 ifeq ($(shell [ -d "$(MSYS_DIR)" ] && $(ECHO) "exists"), exists)
966 export MSYS_DIR
967 else
968 # not installed, hope it's in the path...
969 #$(info $(EMPTY) WARNING $(call toprel, $(MSYS_DIR)) not found (make msys_install), using system PATH)
970 endif
972 .PHONY: msys_version
973 msys_version:
975 endif
977 ##############################
979 # CCACHE
981 ##############################
983 CCACHE_BUILD_DIR := $(BUILD_DIR)/ccache-3.2.2
985 define CCACHE_BUILD_TEMPLATE
986 $(V1) ( \
987 $(ECHO) $(MSG_CONFIGURING) $(call toprel, $(CCACHE_BUILD_DIR)) && \
988 cd $(CCACHE_BUILD_DIR) && \
989 ./configure --prefix="$(CCACHE_DIR)" && \
990 $(ECHO) $(MSG_BUILDING) $(call toprel, $(CCACHE_BUILD_DIR)) && \
991 $(MAKE) $(MAKE_SILENT) && \
992 $(ECHO) $(MSG_INSTALLING) $(call toprel, $(CCACHE_DIR)) && \
993 $(MAKE) $(MAKE_SILENT) install \
995 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(CCACHE_BUILD_DIR))
996 -$(V1) [ ! -d "$(CCACHE_BUILD_DIR)" ] || $(RM) -rf "$(CCACHE_BUILD_DIR)"
998 @$(ECHO)
999 @$(ECHO) "Setting up CCACHE configuration:"
1001 $(V1) [ -d "$(ROOT_DIR)/.ccache" ] || mkdir $(ROOT_DIR)/.ccache
1002 $(V1) [ -d "$(CCACHE_DIR)/etc" ] || mkdir $(CCACHE_DIR)/etc
1004 $(V1) $(ECHO) $(QUOTE)cache_dir = $(ROOT_DIR)/.ccache $(QUOTE) > $(CCACHE_DIR)/etc/ccache.conf
1005 $(V1) $(ECHO) $(QUOTE)max_size = 250M$(QUOTE) >> $(CCACHE_DIR)/etc/ccache.conf
1006 $(V1) $(CAT) $(CCACHE_DIR)/etc/ccache.conf
1007 endef
1009 define CCACHE_CLEAN_TEMPLATE
1010 -$(V1) [ ! -d "$(CCACHE_DIR)" ] || $(RM) -rf "$(CCACHE_DIR)"
1011 endef
1013 $(eval $(call TOOL_INSTALL_TEMPLATE,ccache,$(CCACHE_BUILD_DIR),$(CCACHE_URL),$(CCACHE_MD5_URL),$(notdir $(CCACHE_URL)),$(CCACHE_BUILD_TEMPLATE),$(CCACHE_CLEAN_TEMPLATE)))
1015 ##############################
1017 # TODO: code below is not revised yet
1019 ##############################
1021 # Set up openocd tools
1022 OPENOCD_DIR := $(TOOLS_DIR)/openocd
1023 OPENOCD_WIN_DIR := $(TOOLS_DIR)/openocd_win
1024 OPENOCD_BUILD_DIR := $(DL_DIR)/openocd-build
1026 .PHONY: openocd_install
1027 openocd_install: | $(DL_DIR) $(TOOLS_DIR)
1028 openocd_install: OPENOCD_URL := http://sourceforge.net/projects/openocd/files/openocd/0.6.1/openocd-0.6.1.tar.bz2/download
1029 openocd_install: OPENOCD_FILE := openocd-0.6.1.tar.bz2
1030 openocd_install: openocd_clean
1031 # download the source only if it's newer than what we already have
1032 $(V1) $(WGET) -N -P "$(DL_DIR)" --trust-server-name "$(OPENOCD_URL)"
1034 # extract the source
1035 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -r "$(OPENOCD_BUILD_DIR)"
1036 $(V1) mkdir -p "$(OPENOCD_BUILD_DIR)"
1037 $(V1) tar -C $(OPENOCD_BUILD_DIR) -xjf "$(DL_DIR)/$(OPENOCD_FILE)"
1039 # apply patches
1040 $(V0) @echo " PATCH $(OPENOCD_DIR)"
1041 $(V1) ( \
1042 cd $(OPENOCD_BUILD_DIR)/openocd-0.6.1 ; \
1043 patch -p1 < $(ROOT_DIR)/flight/Project/OpenOCD/0001-armv7m-remove-dummy-FP-regs-for-new-gdb.patch ; \
1044 patch -p1 < $(ROOT_DIR)/flight/Project/OpenOCD/0002-rtos-add-stm32_stlink-to-FreeRTOS-targets.patch ; \
1047 # build and install
1048 $(V1) mkdir -p "$(OPENOCD_DIR)"
1049 $(V1) ( \
1050 cd $(OPENOCD_BUILD_DIR)/openocd-0.6.1 ; \
1051 ./configure --prefix="$(OPENOCD_DIR)" --enable-ft2232_libftdi --enable-stlink ; \
1052 $(MAKE) --silent ; \
1053 $(MAKE) --silent install ; \
1056 # delete the extracted source when we're done
1057 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1059 .PHONY: ftd2xx_install
1061 FTD2XX_DIR := $(DL_DIR)/ftd2xx
1063 ftd2xx_install: | $(DL_DIR)
1064 ftd2xx_install: FTD2XX_URL := http://www.ftdichip.com/Drivers/CDM/Beta/CDM20817.zip
1065 ftd2xx_install: FTD2XX_FILE := CDM20817.zip
1066 ftd2xx_install: ftd2xx_clean
1067 # download the file only if it's newer than what we already have
1068 $(V0) @echo " DOWNLOAD $(FTD2XX_URL)"
1069 $(V1) $(WGET) -q -N -P "$(DL_DIR)" "$(FTD2XX_URL)"
1071 # extract the source
1072 $(V0) @echo " EXTRACT $(FTD2XX_FILE) -> $(FTD2XX_DIR)"
1073 $(V1) mkdir -p "$(FTD2XX_DIR)"
1074 $(V1) unzip -q -d "$(FTD2XX_DIR)" "$(DL_DIR)/$(FTD2XX_FILE)"
1076 .PHONY: ftd2xx_clean
1077 ftd2xx_clean:
1078 $(V0) @echo " CLEAN $(FTD2XX_DIR)"
1079 $(V1) [ ! -d "$(FTD2XX_DIR)" ] || $(RM) -r "$(FTD2XX_DIR)"
1081 .PHONY: ftd2xx_install
1083 LIBUSB_WIN_DIR := $(DL_DIR)/libusb-win32-bin-1.2.6.0
1085 libusb_win_install: | $(DL_DIR)
1086 libusb_win_install: LIBUSB_WIN_URL := http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.6.0/libusb-win32-bin-1.2.6.0.zip/download
1087 libusb_win_install: LIBUSB_WIN_FILE := libusb-win32-bin-1.2.6.0.zip
1088 libusb_win_install: libusb_win_clean
1089 # download the file only if it's newer than what we already have
1090 $(V0) @echo " DOWNLOAD $(LIBUSB_WIN_URL)"
1091 $(V1) $(WGET) -q -N -P "$(DL_DIR)" --trust-server-name "$(LIBUSB_WIN_URL)"
1093 # extract the source
1094 $(V0) @echo " EXTRACT $(LIBUSB_WIN_FILE) -> $(LIBUSB_WIN_DIR)"
1095 $(V1) mkdir -p "$(LIBUSB_WIN_DIR)"
1096 $(V1) unzip -q -d "$(DL_DIR)" "$(DL_DIR)/$(LIBUSB_WIN_FILE)"
1098 # fixup .h file needed by openocd build
1099 $(V0) @echo " FIXUP $(LIBUSB_WIN_DIR)"
1100 $(V1) ln -s "$(LIBUSB_WIN_DIR)/include/lusb0_usb.h" "$(LIBUSB_WIN_DIR)/include/usb.h"
1102 .PHONY: libusb_win_clean
1103 libusb_win_clean:
1104 $(V0) @echo " CLEAN $(LIBUSB_WIN_DIR)"
1105 $(V1) [ ! -d "$(LIBUSB_WIN_DIR)" ] || $(RM) -r "$(LIBUSB_WIN_DIR)"
1107 .PHONY: openocd_git_win_install
1109 openocd_git_win_install: | $(DL_DIR) $(TOOLS_DIR)
1110 openocd_git_win_install: OPENOCD_URL := git://openocd.git.sourceforge.net/gitroot/openocd/openocd
1111 openocd_git_win_install: OPENOCD_REV := f1c0133321c8fcadadd10bba5537c0a634eb183b
1112 openocd_git_win_install: openocd_win_clean libusb_win_install ftd2xx_install
1113 # download the source
1114 $(V0) @echo " DOWNLOAD $(OPENOCD_URL) @ $(OPENOCD_REV)"
1115 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1116 $(V1) mkdir -p "$(OPENOCD_BUILD_DIR)"
1117 $(V1) git clone --no-checkout $(OPENOCD_URL) "$(DL_DIR)/openocd-build"
1118 $(V1) ( \
1119 cd $(OPENOCD_BUILD_DIR) ; \
1120 git checkout -q $(OPENOCD_REV) ; \
1123 # apply patches
1124 $(V0) @echo " PATCH $(OPENOCD_BUILD_DIR)"
1125 $(V1) ( \
1126 cd $(OPENOCD_BUILD_DIR) ; \
1127 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0001-armv7m-remove-dummy-FP-regs-for-new-gdb.patch ; \
1128 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0002-rtos-add-stm32_stlink-to-FreeRTOS-targets.patch ; \
1131 # build and install
1132 $(V0) @echo " BUILD $(OPENOCD_WIN_DIR)"
1133 $(V1) mkdir -p "$(OPENOCD_WIN_DIR)"
1134 $(V1) ( \
1135 cd $(OPENOCD_BUILD_DIR) ; \
1136 ./bootstrap ; \
1137 ./configure --enable-maintainer-mode --prefix="$(OPENOCD_WIN_DIR)" \
1138 --build=i686-pc-linux-gnu --host=i586-mingw32msvc \
1139 CPPFLAGS=-I$(LIBUSB_WIN_DIR)/include \
1140 LDFLAGS=-L$(LIBUSB_WIN_DIR)/lib/gcc \
1141 --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=$(FTD2XX_DIR) \
1142 --disable-werror \
1143 --enable-stlink ; \
1144 $(MAKE) ; \
1145 $(MAKE) install ; \
1148 # delete the extracted source when we're done
1149 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1151 .PHONY: openocd_win_clean
1152 openocd_win_clean:
1153 $(V0) @echo " CLEAN $(OPENOCD_WIN_DIR)"
1154 $(V1) [ ! -d "$(OPENOCD_WIN_DIR)" ] || $(RM) -r "$(OPENOCD_WIN_DIR)"
1156 .PHONY: openocd_git_install
1158 openocd_git_install: | $(DL_DIR) $(TOOLS_DIR)
1159 openocd_git_install: OPENOCD_URL := git://openocd.git.sourceforge.net/gitroot/openocd/openocd
1160 openocd_git_install: OPENOCD_REV := f1c0133321c8fcadadd10bba5537c0a634eb183b
1161 openocd_git_install: openocd_clean
1162 # download the source
1163 $(V0) @echo " DOWNLOAD $(OPENOCD_URL) @ $(OPENOCD_REV)"
1164 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1165 $(V1) mkdir -p "$(OPENOCD_BUILD_DIR)"
1166 $(V1) git clone --no-checkout $(OPENOCD_URL) "$(OPENOCD_BUILD_DIR)"
1167 $(V1) ( \
1168 cd $(OPENOCD_BUILD_DIR) ; \
1169 git checkout -q $(OPENOCD_REV) ; \
1172 # apply patches
1173 $(V0) @echo " PATCH $(OPENOCD_DIR)"
1174 $(V1) ( \
1175 cd $(OPENOCD_BUILD_DIR) ; \
1176 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0001-armv7m-remove-dummy-FP-regs-for-new-gdb.patch ; \
1177 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0002-rtos-add-stm32_stlink-to-FreeRTOS-targets.patch ; \
1180 # build and install
1181 $(V0) @echo " BUILD $(OPENOCD_DIR)"
1182 $(V1) mkdir -p "$(OPENOCD_DIR)"
1183 $(V1) ( \
1184 cd $(OPENOCD_BUILD_DIR) ; \
1185 ./bootstrap ; \
1186 ./configure --enable-maintainer-mode --prefix="$(OPENOCD_DIR)" --enable-ft2232_libftdi --enable-buspirate --enable-stlink ; \
1187 $(MAKE) ; \
1188 $(MAKE) install ; \
1191 # delete the extracted source when we're done
1192 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1194 .PHONY: openocd_clean
1195 openocd_clean:
1196 $(V0) @echo " CLEAN $(OPENOCD_DIR)"
1197 $(V1) [ ! -d "$(OPENOCD_DIR)" ] || $(RM) -r "$(OPENOCD_DIR)"
1199 STM32FLASH_DIR := $(TOOLS_DIR)/stm32flash
1200 ifeq ($(UNAME), Windows)
1201 STM32FLASH_BUILD_OPTIONS := "CC=GCC"
1202 endif
1203 .PHONY: stm32flash_install
1204 stm32flash_install: STM32FLASH_URL := https://code.google.com/p/stm32flash/
1205 stm32flash_install: STM32FLASH_REV := a358bd1f025d
1206 stm32flash_install: stm32flash_clean
1207 # download the source
1208 $(V0) @$(ECHO) " DOWNLOAD $(STM32FLASH_URL) @ r$(STM32FLASH_REV)"
1209 $(V1) [ ! -d "$(STM32FLASH_DIR)" ] || $(RM) -rf "$(STM32FLASH_DIR)"
1210 $(V1) $(MKDIR) -p "$(STM32FLASH_DIR)"
1211 $(V1) $(GIT) clone --no-checkout $(STM32FLASH_URL) "$(STM32FLASH_DIR)"
1212 $(V1) ( \
1213 $(CD) $(STM32FLASH_DIR) ; \
1214 $(GIT) checkout -q $(STM32FLASH_REV) ; \
1216 # build
1217 $(V0) @$(ECHO) " BUILD $(STM32FLASH_DIR)"
1218 $(V1) $(MAKE) --silent -C $(STM32FLASH_DIR) all $(STM32FLASH_BUILD_OPTIONS)
1220 .PHONY: stm32flash_clean
1221 stm32flash_clean:
1222 $(V0) @$(ECHO) " CLEAN $(STM32FLASH_DIR)"
1223 $(V1) [ ! -d "$(STM32FLASH_DIR)" ] || $(RM) -rf "$(STM32FLASH_DIR)"
1225 DFUUTIL_DIR := $(TOOLS_DIR)/dfu-util
1227 .PHONY: dfuutil_install
1228 dfuutil_install: DFUUTIL_URL := http://dfu-util.sourceforge.net/releases/dfu-util-0.8.tar.gz
1229 dfuutil_install: DFUUTIL_FILE := $(notdir $(DFUUTIL_URL))
1230 dfuutil_install: | $(DL_DIR) $(TOOLS_DIR)
1231 dfuutil_install: dfuutil_clean
1232 # download the source
1233 $(V0) @echo " DOWNLOAD $(DFUUTIL_URL)"
1234 $(V1) $(CURL) $(CURL_OPTIONS) -o "$(DL_DIR)/$(DFUUTIL_FILE)" "$(DFUUTIL_URL)"
1236 # extract the source
1237 $(V0) @echo " EXTRACT $(DFUUTIL_FILE)"
1238 $(V1) [ ! -d "$(DL_DIR)/dfuutil-build" ] || $(RM) -r "$(DL_DIR)/dfuutil-build"
1239 $(V1) mkdir -p "$(DL_DIR)/dfuutil-build"
1240 $(V1) tar -C $(DL_DIR)/dfuutil-build -xf "$(DL_DIR)/$(DFUUTIL_FILE)"
1242 # build
1243 $(V0) @echo " BUILD $(DFUUTIL_DIR)"
1244 $(V1) mkdir -p "$(DFUUTIL_DIR)"
1245 $(V1) ( \
1246 cd $(DL_DIR)/dfuutil-build/dfu-util-0.8 ; \
1247 ./configure --prefix="$(DFUUTIL_DIR)" ; \
1248 $(MAKE) ; \
1249 $(MAKE) install ; \
1252 .PHONY: dfuutil_clean
1253 dfuutil_clean:
1254 $(V0) @echo " CLEAN $(DFUUTIL_DIR)"
1255 $(V1) [ ! -d "$(DFUUTIL_DIR)" ] || $(RM) -r "$(DFUUTIL_DIR)"
1257 # see http://developer.android.com/sdk/ for latest versions
1258 ANDROID_SDK_DIR := $(TOOLS_DIR)/android-sdk-linux
1259 .PHONY: android_sdk_install
1260 android_sdk_install: ANDROID_SDK_URL := http://dl.google.com/android/android-sdk_r20.0.3-linux.tgz
1261 android_sdk_install: ANDROID_SDK_FILE := $(notdir $(ANDROID_SDK_URL))
1262 # order-only prereq on directory existance:
1263 android_sdk_install: | $(DL_DIR) $(TOOLS_DIR)
1264 android_sdk_install: android_sdk_clean
1265 # download the source only if it's newer than what we already have
1266 $(V0) @echo " DOWNLOAD $(ANDROID_SDK_URL)"
1267 $(V1) $(WGET) --no-check-certificate -N -P "$(DL_DIR)" "$(ANDROID_SDK_URL)"
1269 # binary only release so just extract it
1270 $(V0) @echo " EXTRACT $(ANDROID_SDK_FILE)"
1271 $(V1) tar -C $(TOOLS_DIR) -xf "$(DL_DIR)/$(ANDROID_SDK_FILE)"
1273 .PHONY: android_sdk_clean
1274 android_sdk_clean:
1275 $(V0) @echo " CLEAN $(ANDROID_SDK_DIR)"
1276 $(V1) [ ! -d "$(ANDROID_SDK_DIR)" ] || $(RM) -r $(ANDROID_SDK_DIR)
1278 .PHONY: android_sdk_update
1279 android_sdk_update:
1280 $(V0) @echo " UPDATE $(ANDROID_SDK_DIR)"
1281 $(ANDROID_SDK_DIR)/tools/android update sdk --no-ui -t platform-tools,android-16,addon-google_apis-google-16
1283 #Install git hooks under the right folder
1285 .PHONY: prepare
1286 prepare:
1287 $(V0) @echo " Configuring GIT commit template"
1288 $(V1) $(CD) "$(ROOT_DIR)"
1289 $(V1) $(GIT) config commit.template .commit-template
1291 .PHONY: prepare_clean
1292 prepare_clean:
1293 $(V0) @echo " Cleanup GIT commit template configuration"
1294 $(V1) $(CD) "$(ROOT_DIR)"
1295 $(V1) $(GIT) config --unset commit.template
1297 ##############################
1299 # TODO: these defines will go to tool install sections
1301 ##############################
1303 ifeq ($(shell [ -d "$(OPENOCD_DIR)" ] && $(ECHO) "exists"), exists)
1304 export OPENOCD := $(OPENOCD_DIR)/bin/openocd
1305 else
1306 # not installed, hope it's in the path...
1307 export OPENOCD ?= openocd
1308 endif
1310 ifeq ($(shell [ -d "$(ANDROID_SDK_DIR)" ] && $(ECHO) "exists"), exists)
1311 ANDROID := $(ANDROID_SDK_DIR)/tools/android
1312 ANDROID_DX := $(ANDROID_SDK_DIR)/platform-tools/dx
1313 else
1314 # not installed, hope it's in the path...
1315 ANDROID ?= android
1316 ANDROID_DX ?= dx
1317 endif