LP-03 About - Splash screen fixes
[librepilot.git] / make / tools.mk
blob344c0061d46fcce178dc2fa0006f8c6a0ecc5a71
2 # Installers for tools required by the OpenPilot build system.
3 # Copyright (c) 2010-2013, The OpenPilot Team, http://www.openpilot.org
5 # NOTE: install targets are not tied to the default goals and must
6 # be invoked manually. But tool paths set by this file are used
7 # across the build system.
9 # Ready to use:
10 # arm_sdk_install
11 # qt_sdk_install
12 # nsis_install (Windows only)
13 # sdl_install (Windows only)
14 # openssl_install (Windows only)
15 # mesawin_install (Windows only)
16 # uncrustify_install
17 # doxygen_install
18 # gtest_install
20 # TODO:
21 # openocd_install
22 # ftd2xx_install
23 # libusb_win_install
24 # openocd_git_win_install
25 # openocd_git_install
26 # stm32flash_install
27 # dfuutil_install
28 # android_sdk_install
30 # TODO:
31 # help in the top Makefile
33 # This program is free software; you can redistribute it and/or modify
34 # it under the terms of the GNU General Public License as published by
35 # the Free Software Foundation; either version 3 of the License, or
36 # (at your option) any later version.
38 # This program is distributed in the hope that it will be useful, but
39 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
40 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
41 # for more details.
43 # You should have received a copy of the GNU General Public License along
44 # with this program; if not, write to the Free Software Foundation, Inc.,
45 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
48 ifndef OPENPILOT_IS_COOL
49 $(error $(notdir $(lastword $(MAKEFILE_LIST))) should be included by the top level Makefile)
50 endif
52 ##############################
54 # Toolchain URLs and directories
56 ##############################
58 ifeq ($(UNAME), Linux)
59 ifeq ($(ARCH), x86_64)
60 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
61 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
62 QT_SDK_URL := http://download.qt.io/official_releases/qt/5.4/5.4.1/qt-opensource-linux-x64-5.4.1.run
63 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
64 QT_SDK_ARCH := gcc_64
65 else
66 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
67 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
68 QT_SDK_URL := http://download.qt.io/official_releases/qt/5.4/5.4.1/qt-opensource-linux-x86-5.4.1.run
69 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
70 QT_SDK_ARCH := gcc
71 endif
72 UNCRUSTIFY_URL := http://librepilot.github.io/tools/uncrustify-0.60.tar.gz
73 DOXYGEN_URL := http://librepilot.github.io/tools/doxygen-1.8.3.1.src.tar.gz
74 else ifeq ($(UNAME), Darwin)
75 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
76 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
77 QT_SDK_URL := http://download.qt.io/official_releases/qt/5.4/5.4.1/qt-opensource-mac-x64-clang-5.4.1.dmg
78 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
79 QT_SDK_ARCH := clang_64
80 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
81 QT_SDK_MOUNT_DIR := /Volumes/qt-opensource-mac-x64-clang-5.4.1
82 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
83 UNCRUSTIFY_URL := http://librepilot.github.io/tools/uncrustify-0.60.tar.gz
84 DOXYGEN_URL := http://librepilot.github.io/tools/doxygen-1.8.3.1.src.tar.gz
85 else ifeq ($(UNAME), Windows)
86 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
87 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
88 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
89 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
90 QT_SDK_ARCH := mingw491_32
91 NSIS_URL := http://librepilot.github.io/tools/nsis-2.46-unicode.tar.bz2
92 SDL_URL := http://librepilot.github.io/tools/SDL-devel-1.2.15-mingw32.tar.gz
93 OPENSSL_URL := http://librepilot.github.io/tools/openssl-1.0.1e-win32.tar.bz2
94 UNCRUSTIFY_URL := http://librepilot.github.io/tools/uncrustify-0.60-windows.tar.bz2
95 DOXYGEN_URL := http://librepilot.github.io/tools/doxygen-1.8.3.1-windows.tar.bz2
96 MESAWIN_URL := http://librepilot.github.io/tools/mesawin.tar.gz
97 CMAKE_URL := http://www.cmake.org/files/v2.8/cmake-2.8.12.2-win32-x86.zip
98 CMAKE_MD5_URL := http://librepilot.github.io/tools/cmake-2.8.12.2-win32-x86.zip.md5
99 MSYS_URL := http://librepilot.github.io/tools/MSYS-1.0.11.zip
100 endif
102 GTEST_URL := http://librepilot.github.io/tools/gtest-1.6.0.zip
104 ARM_SDK_DIR := $(TOOLS_DIR)/gcc-arm-none-eabi-4_9-2014q4
105 QT_SDK_DIR := $(TOOLS_DIR)/qt-5.4.1
106 UNCRUSTIFY_DIR := $(TOOLS_DIR)/uncrustify-0.60
107 DOXYGEN_DIR := $(TOOLS_DIR)/doxygen-1.8.3.1
108 GTEST_DIR := $(TOOLS_DIR)/gtest-1.6.0
110 ifeq ($(UNAME), Linux)
111 else ifeq ($(UNAME), Darwin)
112 else ifeq ($(UNAME), Windows)
113 MINGW_DIR := $(QT_SDK_DIR)/Tools/$(QT_SDK_ARCH)
114 # When changing PYTHON_DIR, you must also update it in ground/openpilotgcs/src/python.pri
115 PYTHON_DIR := $(QT_SDK_DIR)/Tools/$(QT_SDK_ARCH)/opt/bin
116 NSIS_DIR := $(TOOLS_DIR)/nsis-2.46-unicode
117 # When changing SDL_DIR or OPENSSL_DIR, you must also update them in ground/openpilotgcs/openpilotgcs.pri
118 SDL_DIR := $(TOOLS_DIR)/SDL-1.2.15
119 OPENSSL_DIR := $(TOOLS_DIR)/openssl-1.0.1e-win32
120 MESAWIN_DIR := $(TOOLS_DIR)/mesawin
121 CMAKE_DIR := $(TOOLS_DIR)/cmake-2.8.12.2-win32-x86
122 MSYS_DIR := $(TOOLS_DIR)/msys
123 endif
125 QT_SDK_PREFIX := $(QT_SDK_DIR)
127 ##############################
129 # Build only and all toolchains available for the platform
131 ##############################
133 BUILD_SDK_TARGETS := arm_sdk qt_sdk
134 ifeq ($(UNAME), Windows)
135 BUILD_SDK_TARGETS += sdl nsis mesawin openssl
136 endif
137 ALL_SDK_TARGETS := $(BUILD_SDK_TARGETS) gtest uncrustify doxygen
139 define GROUP_SDK_TEMPLATE
140 .PHONY: $(1)_install $(1)_clean $(1)_distclean $(1)_version
141 $(1)_install: $(addsuffix _install,$(2))
142 $(1)_clean: $(addsuffix _clean,$(2))
143 $(1)_distclean: $(addsuffix _distclean,$(2))
144 $(1)_version: $(addsuffix _version,$(2))
145 endef
147 $(eval $(call GROUP_SDK_TEMPLATE,build_sdk,$(BUILD_SDK_TARGETS)))
148 $(eval $(call GROUP_SDK_TEMPLATE,all_sdk,$(ALL_SDK_TARGETS)))
150 ##############################
152 # Misc host tools
154 ##############################
156 # Used by other makefiles
157 export MKDIR := mkdir
158 export CP := cp
159 export RM := rm
160 export LN := ln
161 export CAT := cat
162 export CUT := cut
163 export SED := sed
165 # Used only by this Makefile
166 GIT := git
167 CURL := curl
168 TAR := tar
169 UNZIP := unzip
170 ZIP := gzip
171 OPENSSL := openssl
172 ANT := ant
173 JAVAC := javac
174 JAR := jar
175 CD := cd
176 GREP := grep
177 ifneq ($(UNAME), Windows)
178 SEVENZIP := 7za
179 else
180 SEVENZIP := 7za.exe
181 ifneq ($(shell $(SEVENZIP) --version >/dev/null 2>&1 && $(ECHO) "found"), found)
182 # no $(SEVENZIP) found in path. hope is in bin...
183 SEVENZIP = $(TOOLS_DIR)/bin/7za.exe
184 endif
185 endif
187 # Echo in recipes is a bit tricky in a Windows Git Bash window in some cases.
188 # It does not work if make started under msysGit installed into a path with spaces.
189 ifneq ($(UNAME), Windows)
190 export ECHO := echo
191 else
192 # export ECHO := $(PYTHON) -c "import sys; print(' '.join(sys.argv[1:]))"
193 export ECHO := echo
194 endif
196 # Test if quotes are needed for the echo command
197 ifeq ($(shell $(ECHO) "test"), test)
198 export QUOTE := '
199 # This line is just to clear out the single quote above '
200 else
201 export QUOTE :=
202 endif
204 # Command to extract version info data from the repository and source tree
205 export VERSION_INFO = $(PYTHON) $(ROOT_DIR)/make/scripts/version-info.py --path=$(ROOT_DIR)
207 ##############################
209 # Misc settings
211 ##############################
213 # Define messages
214 MSG_VERIFYING = $(QUOTE) VERIFY $(QUOTE)
215 MSG_DOWNLOADING = $(QUOTE) DOWNLOAD $(QUOTE)
216 MSG_CHECKSUMMING = $(QUOTE) MD5 $(QUOTE)
217 MSG_EXTRACTING = $(QUOTE) EXTRACT $(QUOTE)
218 MSG_CONFIGURING = $(QUOTE) CONFIGURE $(QUOTE)
219 MSG_BUILDING = $(QUOTE) BUILD $(QUOTE)
220 MSG_INSTALLING = $(QUOTE) INSTALL $(QUOTE)
221 MSG_CLEANING = $(QUOTE) CLEAN $(QUOTE)
222 MSG_DISTCLEANING = $(QUOTE) DISTCLEAN $(QUOTE)
223 MSG_NOTICE = $(QUOTE) NOTE $(QUOTE)
225 # Verbosity level
226 ifeq ($(V), 1)
227 MAKE_SILENT :=
228 UNZIP_SILENT :=
229 else
230 MAKE_SILENT := --silent
231 UNZIP_SILENT := -q
232 endif
234 # Batch mode
235 ifeq ($(BATCH), 1)
236 CURL_OPTIONS := --silent -L
237 else
238 CURL_OPTIONS := -L
239 endif
241 # MSYS tar workaround
242 ifeq ($(UNAME), Windows)
243 TAR_OPTIONS := --force-local
244 else
245 TAR_OPTIONS :=
246 endif
248 # Print some useful notes for *_install targets
249 ifneq ($(strip $(filter $(addsuffix _install,all_sdk $(ALL_SDK_TARGETS)),$(MAKECMDGOALS))),)
250 ifneq ($(shell $(CURL) --version >/dev/null 2>&1 && $(ECHO) "found"), found)
251 $(error Please install curl first ('apt-get install curl' or similar))
252 endif
253 $(info $(EMPTY) NOTE Use 'make all_sdk_distclean' to remove installation files)
254 $(info $(EMPTY) NOTE Use 'make all_sdk_version' to check toolchain versions)
255 $(info $(EMPTY) NOTE Add 'V=1' to make command line to diagnose make problems)
256 $(info $(EMPTY) NOTE Add 'BATCH=1' to make command line to disable progress reporting during downloads)
257 endif
259 ##############################
261 # Cross-platform MD5 check template
262 # $(1) = file name without quotes
263 # $(2) = string compare operator, e.g. = or !=
265 ##############################
267 define MD5_CHECK_TEMPLATE
268 "`test -f \"$(1)\" && $(OPENSSL) dgst -md5 \"$(1)\" | $(CUT) -f2 -d' '`" $(2) "`$(CUT) -f1 -d' ' < \"$(1).md5\"`"
269 endef
271 ##############################
273 # Cross-platform MD5 generation template
274 # $(1) = file name without quotes
276 ##############################
278 ifeq ($(UNAME), Darwin)
280 define MD5_GEN_TEMPLATE
281 md5 -r $(1) > $(1).md5
282 endef
284 else
286 define MD5_GEN_TEMPLATE
287 $(OPENSSL) dgst -r -md5 $(1) > $(1).md5
288 endef
290 endif
292 ##############################
294 # Cross platform download template
295 # $(1) = Package URL
296 # $(2) = Package file
297 # $(3) = URL for .md5 file to be tested against Package
299 ##############################
301 define DOWNLOAD_TEMPLATE
302 @$(ECHO) $(MSG_VERIFYING) $$(call toprel, $(DL_DIR)/$(2))
303 $(V1) ( \
304 cd "$(DL_DIR)" && \
305 $(CURL) $(CURL_OPTIONS) --silent -o "$(DL_DIR)/$(2).md5" "$(3)" && \
306 if [ $(call MD5_CHECK_TEMPLATE,$(DL_DIR)/$(2),!=) ]; then \
307 $(ECHO) $(MSG_DOWNLOADING) $(1) && \
308 $(CURL) $(CURL_OPTIONS) -o "$(DL_DIR)/$(2)" "$(1)" && \
309 $(ECHO) $(MSG_CHECKSUMMING) $$(call toprel, $(DL_DIR)/$(2)) && \
310 [ $(call MD5_CHECK_TEMPLATE,$(DL_DIR)/$(2),=) ]; \
311 fi; \
313 endef
315 ##############################
317 # Common tool install template
318 # $(1) = tool name
319 # $(2) = tool extract/build directory
320 # $(3) = tool distribution URL
321 # $(4) = tool distribution MD5 URL
322 # $(5) = tool distribution file
323 # $(6) = optional extra build recipes template
324 # $(7) = optional extra clean recipes template
326 ##############################
328 define TOOL_INSTALL_TEMPLATE
330 .PHONY: $(addprefix $(1)_, install clean distclean)
332 $(1)_install: $(1)_clean | $(DL_DIR) $(TOOLS_DIR)
334 $(if $(4), $(call DOWNLOAD_TEMPLATE,$(3),$(5),$(4)),$(call DOWNLOAD_TEMPLATE,$(3),$(5),"$(3).md5"))
336 @$(ECHO) $(MSG_EXTRACTING) $$(call toprel, $(2))
337 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(2)))
339 $(if $(filter $(suffix $(5)), .zip),
340 $(V1) $(UNZIP) $(UNZIP_SILENT) -d $$(call toprel, $(dir $(2))) $$(call toprel, $(DL_DIR)/$(5)),
341 $(V1) $(TAR) $(TAR_OPTIONS) -C $$(call toprel, $(dir $(2))) -xf $$(call toprel, $(DL_DIR)/$(5))
344 $(6)
346 $(1)_clean:
347 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(2))
348 $(V1) [ ! -d "$(2)" ] || $(RM) -rf "$(2)"
350 $(7)
352 $(1)_distclean:
353 @$(ECHO) $(MSG_DISTCLEANING) $$(call toprel, $(DL_DIR)/$(5))
354 $(V1) [ ! -f "$(DL_DIR)/$(5)" ] || $(RM) "$(DL_DIR)/$(5)"
355 $(V1) [ ! -f "$(DL_DIR)/$(5).md5" ] || $(RM) "$(DL_DIR)/$(5).md5"
357 endef
359 ##############################
361 # Windows QT install template
362 # $(1) = tool temp extract/build directory
363 # $(2) = tool install directory
364 # $(3) = tool distribution URL
365 # $(4) = tool distribution .md5 URL
366 # $(5) = tool distribution file
367 # $(6) = QT architecture
368 # $(7) = optional extra build recipes template
369 # $(8) = optional extra clean recipes template
371 ##############################
373 define WIN_QT_INSTALL_TEMPLATE
375 .PHONY: $(addprefix qt_sdk_, install clean distclean)
377 qt_sdk_install: qt_sdk_clean | $(DL_DIR) $(TOOLS_DIR)
378 $(V1) if ! $(SEVENZIP) >/dev/null 2>&1; then \
379 $(ECHO) $(MSG_NOTICE) "Missing 7zip. Run ./make/scripts/win_sdk_install.sh [<OpenPilot tools dir>] to get it." && \
380 exit 1; \
382 $(call DOWNLOAD_TEMPLATE,$(3),$(5),"$(4)")
383 # Explode .run file into install packages
384 @$(ECHO) $(MSG_EXTRACTING) $$(call toprel, $(1))
385 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(1)))
386 $(V1) chmod +x $(DL_DIR)/$(5)
387 $(V1) $(DL_DIR)/$(5) --dump-binary-data -o $(1)
388 # Extract packages under tool directory
389 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(2)))
390 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.54.win32_mingw491/5.4.1-0qt5_essentials.7z" | grep -v Extracting
391 $(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
392 $(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
393 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.54.win32_mingw491/5.4.1-0qt5_addons.7z" | grep -v Extracting
394 $(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
395 # Run patcher
396 @$(ECHO)
397 @$(ECHO) "Executing QtPatch in" $$(call toprel, $(QT_SDK_PREFIX))
398 $(V1) $(CD) $(QT_SDK_PREFIX)
399 $(V1) $(DL_DIR)/$(5) --runoperation QtPatch windows $(QT_SDK_PREFIX) qt5
401 # Execute post build templates
402 $(7)
404 # Clean up temporary files
405 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
406 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
408 qt_sdk_clean:
409 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
410 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
411 @$(ECHO) $(MSG_CLEANING) $$(call toprel, "$(2)")
412 $(V1) [ ! -d "$(2)" ] || $(RM) -rf "$(2)"
414 $(8)
416 qt_sdk_distclean:
417 @$(ECHO) $(MSG_DISTCLEANING) $$(call toprel, $(DL_DIR)/$(5))
418 $(V1) [ ! -f "$(DL_DIR)/$(5)" ] || $(RM) "$(DL_DIR)/$(5)"
419 $(V1) [ ! -f "$(DL_DIR)/$(5).md5" ] || $(RM) "$(DL_DIR)/$(5).md5"
421 endef
423 ##############################
425 # Linux QT install template
426 # $(1) = tool temp extract/build directory
427 # $(2) = tool install directory
428 # $(3) = tool distribution URL
429 # $(4) = tool distribution .md5 URL
430 # $(5) = tool distribution file
431 # $(6) = QT architecture
432 # $(7) = optional extra build recipes template
433 # $(8) = optional extra clean recipes template
435 ##############################
437 define LINUX_QT_INSTALL_TEMPLATE
439 .PHONY: $(addprefix qt_sdk_, install clean distclean)
441 qt_sdk_install: qt_sdk_clean | $(DL_DIR) $(TOOLS_DIR)
442 $(V1) if ! $(SEVENZIP) >/dev/null 2>&1; then \
443 $(ECHO) $(MSG_NOTICE) "Please install the p7zip for your distribution. i.e.: sudo apt-get install p7zip-full" && \
444 exit 1; \
446 $(call DOWNLOAD_TEMPLATE,$(3),$(5),"$(4)")
447 # Explode .run file into install packages
448 @$(ECHO) $(MSG_EXTRACTING) $$(call toprel, $(1))
449 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(1)))
450 $(V1) chmod +x $(DL_DIR)/$(5)
451 $(V1) $(DL_DIR)/$(5) --dump-binary-data -o $(1)
452 # Extract packages under tool directory
453 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(2)))
454 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.54.$(6)/5.4.1-0qt5_essentials.7z" | grep -v Extracting
455 $(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
456 $(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
457 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.54.$(6)/5.4.1-0qt5_addons.7z" | grep -v Extracting
458 # Run patcher
459 @$(ECHO)
460 @$(ECHO) "Executing QtPatch in" $$(call toprel, $(QT_SDK_PREFIX))
461 $(V1) $(CD) $(QT_SDK_PREFIX)
462 $(V1) $(DL_DIR)/$(5) --runoperation QtPatch linux $(QT_SDK_PREFIX) qt5
464 # Execute post build templates
465 $(7)
467 # Clean up temporary files
468 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
469 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
471 qt_sdk_clean:
472 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
473 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
474 @$(ECHO) $(MSG_CLEANING) $$(call toprel, "$(2)")
475 $(V1) [ ! -d "$(2)" ] || $(RM) -rf "$(2)"
477 $(8)
479 qt_sdk_distclean:
480 @$(ECHO) $(MSG_DISTCLEANING) $$(call toprel, $(DL_DIR)/$(5))
481 $(V1) [ ! -f "$(DL_DIR)/$(5)" ] || $(RM) "$(DL_DIR)/$(5)"
482 $(V1) [ ! -f "$(DL_DIR)/$(5).md5" ] || $(RM) "$(DL_DIR)/$(5).md5"
484 endef
486 ##############################
488 # Mac QT install template
489 # $(1) = tool temp extract/build directory
490 # $(2) = tool install directory
491 # $(3) = tool distribution URL
492 # $(4) = tool distribution .md5 URL
493 # $(5) = tool distribution file
494 # $(6) = QT architecture
495 # $(7) = optional extra build recipes template
496 # $(8) = optional extra clean recipes template
498 ##############################
500 define MAC_QT_INSTALL_TEMPLATE
502 .PHONY: $(addprefix qt_sdk_, install clean distclean)
504 qt_sdk_install: qt_sdk_clean | $(DL_DIR) $(TOOLS_DIR)
505 $(V1) if ! $(SEVENZIP) >/dev/null 2>&1; then \
506 $(ECHO) $(MSG_NOTICE) "Please install the p7zip for your distribution. i.e.: brew install p7zip." && \
507 exit 1; \
509 $(call DOWNLOAD_TEMPLATE,$(3),$(5),"$(4)")
510 # Mount .dmg file
511 $(V1) hdiutil attach -nobrowse $(DL_DIR)/$(5)
512 # Explode .dmg file into install packages
513 @$(ECHO) $(MSG_EXTRACTING) $$(call toprel, $(1))
514 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(1)))
515 $(V1) $(QT_SDK_MAINTENANCE_TOOL) --dump-binary-data -i $(QT_SDK_INSTALLER_DAT) -o $(1)
516 # Extract packages under tool directory
517 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(2)))
518 #$(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.readme/1.0.0-0qt-project-url.7z" | grep -v Extracting
519 #$(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt/5.4.1ThirdPartySoftware_Listing.7z" | grep -v Extracting
520 #$(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.readme/1.0.0-0readme.7z" | grep -v Extracting
521 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.54.$(6)/5.4.1-0qt5_essentials.7z" | grep -v Extracting
522 # $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.54.$(6).essentials/5.4.1icu_path_patcher.sh.7z" | grep -v Extracting
523 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.54.$(6)/5.4.1-0qt5_addons.7z" | grep -v Extracting
526 # go to OpenPilot/tools/5.4/gcc_64 and call patcher.sh
527 @$(ECHO)
528 @$(ECHO) "Running patcher in" $$(call toprel, $(QT_SDK_PREFIX))
529 $(V1) $(CD) $(QT_SDK_PREFIX)
530 # $(V1) "$(QT_SDK_PREFIX)/patcher.sh" $(QT_SDK_PREFIX)
531 # call qmake patcher
532 @$(ECHO) "Executing QtPatch in" $$(call toprel, $(QT_SDK_PREFIX))
533 $(V1) $(QT_SDK_MAINTENANCE_TOOL) --runoperation QtPatch mac $(QT_SDK_PREFIX) qt5
535 #Unmount the .dmg file
536 $(V1) hdiutil detach $(QT_SDK_MOUNT_DIR)
538 # Execute post build templates
539 $(7)
541 # Clean up temporary files
542 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
543 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
545 qt_sdk_clean:
546 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
547 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
548 @$(ECHO) $(MSG_CLEANING) $$(call toprel, "$(2)")
549 $(V1) [ ! -d "$(2)" ] || $(RM) -rf "$(2)"
551 $(8)
553 qt_sdk_distclean:
554 @$(ECHO) $(MSG_DISTCLEANING) $$(call toprel, $(DL_DIR)/$(5))
555 $(V1) [ ! -f "$(DL_DIR)/$(5)" ] || $(RM) "$(DL_DIR)/$(5)"
556 $(V1) [ ! -f "$(DL_DIR)/$(5).md5" ] || $(RM) "$(DL_DIR)/$(5).md5"
558 endef
560 ##############################
562 # ARM SDK
564 ##############################
566 ifeq ($(UNAME), Windows)
568 # unfortunately zip package for this release is missing root directory, so adding / at the end of the path
569 # so that template interpret last part as directory and use the full path
570 $(eval $(call TOOL_INSTALL_TEMPLATE,arm_sdk,$(ARM_SDK_DIR)/,$(ARM_SDK_URL),$(ARM_SDK_MD5_URL),$(notdir $(ARM_SDK_URL))))
572 else
574 $(eval $(call TOOL_INSTALL_TEMPLATE,arm_sdk,$(ARM_SDK_DIR),$(ARM_SDK_URL),$(ARM_SDK_MD5_URL),$(notdir $(ARM_SDK_URL))))
576 endif
578 ifeq ($(shell [ -d "$(ARM_SDK_DIR)" ] && $(ECHO) "exists"), exists)
579 export ARM_SDK_PREFIX := $(ARM_SDK_DIR)/bin/arm-none-eabi-
580 else
581 # not installed, hope it's in the path...
582 # $(info $(EMPTY) WARNING $(call toprel, $(ARM_SDK_DIR)) not found (make arm_sdk_install), using system PATH)
583 export ARM_SDK_PREFIX ?= arm-none-eabi-
584 endif
586 .PHONY: arm_sdk_version
587 arm_sdk_version:
588 -$(V1) $(ARM_SDK_PREFIX)gcc --version | head -n1
590 # Template to check ARM toolchain version before building targets
591 define ARM_GCC_VERSION_CHECK_TEMPLATE
592 if ! $(ARM_SDK_PREFIX)gcc --version --specs=nano.specs >/dev/null 2>&1; then \
593 $(ECHO) $(MSG_NOTICE) Please install ARM toolchain 4.8 2014q1 using \'make arm_sdk_install\' && \
594 $(ECHO) $(MSG_NOTICE) Older ARM SDKs do not support new \'--specs=nano.specs\' option && \
595 exit 1; \
597 endef
599 ##############################
601 # Qt SDK
603 ##############################
605 ifeq ($(UNAME), Windows)
607 QT_SDK_PREFIX := $(QT_SDK_DIR)/5.4/$(QT_SDK_ARCH)
609 # This additional configuration step should not be necessary
610 # but it is needed as a workaround to https://bugreports.qt-project.org/browse/QTBUG-33254
611 define QT_SDK_CONFIGURE_TEMPLATE
612 @$(ECHO) $(MSG_CONFIGURING) $(call toprel, $(QT_SDK_DIR))
613 $(V1) $(ECHO) $(QUOTE)[Paths]$(QUOTE) > $(QT_SDK_PREFIX)/bin/qt.conf
614 $(V1) $(ECHO) $(QUOTE)Prefix = $(QT_SDK_PREFIX)$(QUOTE) >> $(QT_SDK_PREFIX)/bin/qt.conf
615 endef
617 QT_BUILD_DIR := $(BUILD_DIR)/QT_BUILD
618 $(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)))
620 else ifeq ($(UNAME), Linux)
622 QT_SDK_PREFIX := "$(QT_SDK_DIR)/5.4/$(QT_SDK_ARCH)"
623 QT_BUILD_DIR := $(BUILD_DIR)/QT_BUILD
624 $(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)))
626 else ifeq ($(UNAME), Darwin)
628 QT_SDK_PREFIX := "$(QT_SDK_DIR)/5.4/$(QT_SDK_ARCH)"
629 QT_BUILD_DIR := $(BUILD_DIR)/QT_BUILD
630 $(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)))
632 else
634 QT_SDK_PREFIX := $(QT_SDK_DIR)
636 .PHONY: qt_sdk_install
637 qt_sdk_install:
638 @$(ECHO) $(MSG_NOTICE) --------------------------------------------------------
639 @$(ECHO) $(MSG_NOTICE) Please install native Qt 5.4.x SDK using package manager
640 @$(ECHO) $(MSG_NOTICE) --------------------------------------------------------
642 .PHONY: qt_sdk_clean
643 qt_sdk_clean:
645 .PHONY: qt_sdk_distclean
646 qt_sdk_distclean:
648 endif
650 ifeq ($(shell [ -d "$(QT_SDK_DIR)" ] && $(ECHO) "exists"), exists)
651 export QMAKE := $(QT_SDK_PREFIX)/bin/qmake
653 # set Qt library search path
654 ifeq ($(UNAME), Windows)
655 export PATH := $(QT_SDK_PREFIX)/bin:$(PATH)
656 else
657 export LD_LIBRARY_PATH := $(QT_SDK_DIR)/lib:$(LD_LIBRARY_PATH)
658 endif
659 else
660 # not installed, hope it's in the path...
661 # $(info $(EMPTY) WARNING $(call toprel, $(QT_SDK_DIR)) not found (make qt_sdk_install), using system PATH)
662 QMAKE ?= qmake
663 endif
665 .PHONY: qt_sdk_version
666 qt_sdk_version:
667 -$(V1) $(QMAKE) --version | tail -1
669 ##############################
671 # MinGW
673 ##############################
675 ifeq ($(UNAME), Windows)
677 ifeq ($(shell [ -d "$(MINGW_DIR)" ] && $(ECHO) "exists"), exists)
678 # set MinGW binary and library paths (QTMINGW is used by qmake, do not rename)
679 export QTMINGW := $(MINGW_DIR)/bin
680 export PATH := $(QTMINGW):$(PATH)
681 else
682 # not installed, use host gcc compiler
683 # $(info $(EMPTY) WARNING $(call toprel, $(MINGW_DIR)) not found, using system PATH)
684 endif
686 .PHONY: mingw_version
687 mingw_version: gcc_version
689 else # Linux or Mac
691 all_sdk_version: gcc_version
693 endif
695 .PHONY: gcc_version
696 gcc_version:
697 -$(V1) gcc --version | head -n1
699 ##############################
701 # Python
703 ##############################
705 ifeq ($(shell [ -d "$(PYTHON_DIR)" ] && $(ECHO) "exists"), exists)
706 export PYTHON := $(PYTHON_DIR)/python
707 export PATH := $(PYTHON_DIR):$(PATH)
708 else
709 # not installed, hope it's in the path...
710 # $(info $(EMPTY) WARNING $(call toprel, $(PYTHON_DIR)) not found, using system PATH)
711 ifeq ($(findstring Python 2,$(shell python --version 2>&1)), Python 2)
712 export PYTHON := python
713 else
714 export PYTHON := python2
715 endif
716 endif
718 .PHONY: python_version
719 python_version:
720 -$(V1) $(PYTHON) --version
722 ##############################
724 # NSIS Unicode (Windows only)
726 ##############################
728 ifeq ($(UNAME), Windows)
730 $(eval $(call TOOL_INSTALL_TEMPLATE,nsis,$(NSIS_DIR),$(NSIS_URL),,$(notdir $(NSIS_URL))))
732 ifeq ($(shell [ -d "$(NSIS_DIR)" ] && $(ECHO) "exists"), exists)
733 export NSIS := $(NSIS_DIR)/makensis
734 else
735 # not installed, hope it's in the path...
736 # $(info $(EMPTY) WARNING $(call toprel, $(NSIS_DIR)) not found (make nsis_install), using system PATH)
737 export NSIS ?= makensis
738 endif
740 .PHONY: nsis_version
741 nsis_version:
742 -$(V1) $(NSIS) | head -n1
744 endif
746 ##############################
748 # SDL (Windows only)
750 ##############################
752 ifeq ($(UNAME), Windows)
754 $(eval $(call TOOL_INSTALL_TEMPLATE,sdl,$(SDL_DIR),$(SDL_URL),,$(notdir $(SDL_URL))))
756 ifeq ($(shell [ -d "$(SDL_DIR)" ] && $(ECHO) "exists"), exists)
757 export SDL_DIR := $(SDL_DIR)
758 else
759 # not installed, hope it's in the path...
760 $(info $(EMPTY) WARNING $(call toprel, $(SDL_DIR)) not found (make sdl_install), using system PATH)
761 endif
763 .PHONY: sdl_version
764 sdl_version:
765 -$(V1) $(ECHO) "SDL 1.2.15"
767 endif
769 ##################################
771 # Mesa OpenGL DLL (Windows only)
773 ##################################
775 ifeq ($(UNAME), Windows)
777 $(eval $(call TOOL_INSTALL_TEMPLATE,mesawin,$(MESAWIN_DIR),$(MESAWIN_URL),,$(notdir $(MESAWIN_URL))))
779 ifeq ($(shell [ -d "$(MESAWIN_DIR)" ] && $(ECHO) "exists"), exists)
780 export MESAWIN_DIR := $(MESAWIN_DIR)
781 else
782 # not installed, hope it's in the path...
783 #$(info $(EMPTY) WARNING $(call toprel, $(MESA_WIN_DIR)) not found (make mesawin_install), using system PATH)
784 endif
786 .PHONY: mesawin_version
787 mesawin_version:
788 -$(V1) $(ECHO) "MesaOpenGL vXX"
790 endif
792 ##############################
794 # OpenSSL (Windows only)
796 ##############################
798 ifeq ($(UNAME), Windows)
800 $(eval $(call TOOL_INSTALL_TEMPLATE,openssl,$(OPENSSL_DIR),$(OPENSSL_URL),,$(notdir $(OPENSSL_URL))))
802 ifeq ($(shell [ -d "$(OPENSSL_DIR)" ] && $(ECHO) "exists"), exists)
803 export OPENSSL := $(OPENSSL_DIR)/bin/openssl
804 export OPENSSL_CONF := $(OPENSSL_DIR)/bin/openssl.cfg
805 export OPENSSL_DIR
806 else
807 # not installed, hope it's in the path...
808 # $(info $(EMPTY) WARNING $(call toprel, $(OPENSSL_DIR)) not found (make openssl_install), using system PATH)
809 endif
811 .PHONY: openssl_version
812 openssl_version:
813 -$(V1) $(ECHO) "OpenSSL `$(OPENSSL) version`"
815 endif
817 ##############################
819 # Uncrustify
821 ##############################
823 ifeq ($(UNAME), Windows)
825 $(eval $(call TOOL_INSTALL_TEMPLATE,uncrustify,$(UNCRUSTIFY_DIR),$(UNCRUSTIFY_URL),,$(notdir $(UNCRUSTIFY_URL))))
827 else # Linux or Mac
829 UNCRUSTIFY_BUILD_DIR := $(BUILD_DIR)/$(notdir $(UNCRUSTIFY_DIR))
831 define UNCRUSTIFY_BUILD_TEMPLATE
832 $(V1) ( \
833 $(ECHO) $(MSG_CONFIGURING) $(call toprel, $(UNCRUSTIFY_BUILD_DIR)) && \
834 cd $(UNCRUSTIFY_BUILD_DIR) && \
835 ./configure --prefix="$(UNCRUSTIFY_DIR)" && \
836 $(ECHO) $(MSG_BUILDING) $(call toprel, $(UNCRUSTIFY_BUILD_DIR)) && \
837 $(MAKE) $(MAKE_SILENT) && \
838 $(ECHO) $(MSG_INSTALLING) $(call toprel, $(UNCRUSTIFY_DIR)) && \
839 $(MAKE) $(MAKE_SILENT) install-strip \
841 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(UNCRUSTIFY_BUILD_DIR))
842 -$(V1) [ ! -d "$(UNCRUSTIFY_BUILD_DIR)" ] || $(RM) -rf "$(UNCRUSTIFY_BUILD_DIR)"
843 endef
845 define UNCRUSTIFY_CLEAN_TEMPLATE
846 -$(V1) [ ! -d "$(UNCRUSTIFY_DIR)" ] || $(RM) -rf "$(UNCRUSTIFY_DIR)"
847 endef
849 $(eval $(call TOOL_INSTALL_TEMPLATE,uncrustify,$(UNCRUSTIFY_BUILD_DIR),$(UNCRUSTIFY_URL),,$(notdir $(UNCRUSTIFY_URL)),$(UNCRUSTIFY_BUILD_TEMPLATE),$(UNCRUSTIFY_CLEAN_TEMPLATE)))
851 endif
853 ifeq ($(shell [ -d "$(UNCRUSTIFY_DIR)" ] && $(ECHO) "exists"), exists)
854 export UNCRUSTIFY := $(UNCRUSTIFY_DIR)/bin/uncrustify
855 else
856 # not installed, hope it's in the path...
857 # $(info $(EMPTY) WARNING $(call toprel, $(UNCRUSTIFY_DIR)) not found (make uncrustify_install), using system PATH)
858 export UNCRUSTIFY := uncrustify
859 endif
861 .PHONY: uncrustify_version
862 uncrustify_version:
863 -$(V1) $(UNCRUSTIFY) --version
865 ##############################
867 # Doxygen
869 ##############################
871 ifeq ($(UNAME), Windows)
873 $(eval $(call TOOL_INSTALL_TEMPLATE,doxygen,$(DOXYGEN_DIR),$(DOXYGEN_URL),,$(notdir $(DOXYGEN_URL))))
875 else # Linux or Mac
877 DOXYGEN_BUILD_DIR := $(BUILD_DIR)/$(notdir $(DOXYGEN_DIR))
879 define DOXYGEN_BUILD_TEMPLATE
880 $(V1) ( \
881 $(ECHO) $(MSG_CONFIGURING) $(call toprel, $(DOXYGEN_BUILD_DIR)) && \
882 cd $(DOXYGEN_BUILD_DIR) && \
883 ./configure --prefix "$(DOXYGEN_DIR)" --english-only && \
884 $(ECHO) $(MSG_BUILDING) $(call toprel, $(DOXYGEN_BUILD_DIR)) && \
885 $(MAKE) $(MAKE_SILENT) && \
886 $(ECHO) $(MSG_INSTALLING) $(call toprel, $(DOXYGEN_DIR)) && \
887 $(MAKE) $(MAKE_SILENT) install \
889 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(DOXYGEN_BUILD_DIR))
890 -$(V1) [ ! -d "$(DOXYGEN_BUILD_DIR)" ] || $(RM) -rf "$(DOXYGEN_BUILD_DIR)"
891 endef
893 define DOXYGEN_CLEAN_TEMPLATE
894 -$(V1) [ ! -d "$(DOXYGEN_DIR)" ] || $(RM) -rf "$(DOXYGEN_DIR)"
895 endef
897 $(eval $(call TOOL_INSTALL_TEMPLATE,doxygen,$(DOXYGEN_BUILD_DIR),$(DOXYGEN_URL),,$(notdir $(DOXYGEN_URL)),$(DOXYGEN_BUILD_TEMPLATE),$(DOXYGEN_CLEAN_TEMPLATE)))
899 endif
901 ifeq ($(shell [ -d "$(DOXYGEN_DIR)" ] && $(ECHO) "exists"), exists)
902 export DOXYGEN := $(DOXYGEN_DIR)/bin/doxygen
903 else
904 # not installed, hope it's in the path...
905 # $(info $(EMPTY) WARNING $(call toprel, $(DOXYGEN_DIR)) not found (make doxygen_install), using system PATH)
906 export DOXYGEN := doxygen
907 endif
909 .PHONY: doxygen_version
910 doxygen_version:
911 -$(V1) $(ECHO) "Doxygen `$(DOXYGEN) --version`"
913 ##############################
915 # GoogleTest
917 ##############################
919 $(eval $(call TOOL_INSTALL_TEMPLATE,gtest,$(GTEST_DIR),$(GTEST_URL),,$(notdir $(GTEST_URL))))
921 export GTEST_DIR
923 .PHONY: gtest_version
924 gtest_version:
925 -$(V1) $(SED) -n "s/^PACKAGE_STRING='\(.*\)'/\1/p" < $(GTEST_DIR)/configure
927 ##############################
929 # CMake
931 ##############################
933 $(eval $(call TOOL_INSTALL_TEMPLATE,cmake,$(CMAKE_DIR),$(CMAKE_URL),$(CMAKE_MD5_URL),$(notdir $(CMAKE_URL))))
935 ifeq ($(shell [ -d "$(CMAKE_DIR)" ] && $(ECHO) "exists"), exists)
936 export CMAKE := $(CMAKE_DIR)/bin/cmake
937 export PATH := $(CMAKE_DIR)/bin:$(PATH)
938 else
939 # not installed, hope it's in the path...
940 #$(info $(EMPTY) WARNING $(call toprel, $(CMAKE_DIR)) not found (make cmake_install), using system PATH)
941 export CMAKE := cmake
942 endif
944 .PHONY: cmake_version
945 cmake_version:
946 -$(V1) $(CMAKE) --version
948 ##############################
950 # MSYS
952 ##############################
954 ifeq ($(UNAME), Windows)
956 $(eval $(call TOOL_INSTALL_TEMPLATE,msys,$(MSYS_DIR),$(MSYS_URL),,$(notdir $(MSYS_URL))))
958 ifeq ($(shell [ -d "$(MSYS_DIR)" ] && $(ECHO) "exists"), exists)
959 export MSYS_DIR
960 else
961 # not installed, hope it's in the path...
962 #$(info $(EMPTY) WARNING $(call toprel, $(MSYS_DIR)) not found (make msys_install), using system PATH)
963 endif
965 .PHONY: msys_version
966 msys_version:
968 endif
974 ##############################
976 # TODO: code below is not revised yet
978 ##############################
980 # Set up openocd tools
981 OPENOCD_DIR := $(TOOLS_DIR)/openocd
982 OPENOCD_WIN_DIR := $(TOOLS_DIR)/openocd_win
983 OPENOCD_BUILD_DIR := $(DL_DIR)/openocd-build
985 .PHONY: openocd_install
986 openocd_install: | $(DL_DIR) $(TOOLS_DIR)
987 openocd_install: OPENOCD_URL := http://sourceforge.net/projects/openocd/files/openocd/0.6.1/openocd-0.6.1.tar.bz2/download
988 openocd_install: OPENOCD_FILE := openocd-0.6.1.tar.bz2
989 openocd_install: openocd_clean
990 # download the source only if it's newer than what we already have
991 $(V1) $(WGET) -N -P "$(DL_DIR)" --trust-server-name "$(OPENOCD_URL)"
993 # extract the source
994 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -r "$(OPENOCD_BUILD_DIR)"
995 $(V1) mkdir -p "$(OPENOCD_BUILD_DIR)"
996 $(V1) tar -C $(OPENOCD_BUILD_DIR) -xjf "$(DL_DIR)/$(OPENOCD_FILE)"
998 # apply patches
999 $(V0) @echo " PATCH $(OPENOCD_DIR)"
1000 $(V1) ( \
1001 cd $(OPENOCD_BUILD_DIR)/openocd-0.6.1 ; \
1002 patch -p1 < $(ROOT_DIR)/flight/Project/OpenOCD/0001-armv7m-remove-dummy-FP-regs-for-new-gdb.patch ; \
1003 patch -p1 < $(ROOT_DIR)/flight/Project/OpenOCD/0002-rtos-add-stm32_stlink-to-FreeRTOS-targets.patch ; \
1006 # build and install
1007 $(V1) mkdir -p "$(OPENOCD_DIR)"
1008 $(V1) ( \
1009 cd $(OPENOCD_BUILD_DIR)/openocd-0.6.1 ; \
1010 ./configure --prefix="$(OPENOCD_DIR)" --enable-ft2232_libftdi --enable-stlink ; \
1011 $(MAKE) --silent ; \
1012 $(MAKE) --silent install ; \
1015 # delete the extracted source when we're done
1016 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1018 .PHONY: ftd2xx_install
1020 FTD2XX_DIR := $(DL_DIR)/ftd2xx
1022 ftd2xx_install: | $(DL_DIR)
1023 ftd2xx_install: FTD2XX_URL := http://www.ftdichip.com/Drivers/CDM/Beta/CDM20817.zip
1024 ftd2xx_install: FTD2XX_FILE := CDM20817.zip
1025 ftd2xx_install: ftd2xx_clean
1026 # download the file only if it's newer than what we already have
1027 $(V0) @echo " DOWNLOAD $(FTD2XX_URL)"
1028 $(V1) $(WGET) -q -N -P "$(DL_DIR)" "$(FTD2XX_URL)"
1030 # extract the source
1031 $(V0) @echo " EXTRACT $(FTD2XX_FILE) -> $(FTD2XX_DIR)"
1032 $(V1) mkdir -p "$(FTD2XX_DIR)"
1033 $(V1) unzip -q -d "$(FTD2XX_DIR)" "$(DL_DIR)/$(FTD2XX_FILE)"
1035 .PHONY: ftd2xx_clean
1036 ftd2xx_clean:
1037 $(V0) @echo " CLEAN $(FTD2XX_DIR)"
1038 $(V1) [ ! -d "$(FTD2XX_DIR)" ] || $(RM) -r "$(FTD2XX_DIR)"
1040 .PHONY: ftd2xx_install
1042 LIBUSB_WIN_DIR := $(DL_DIR)/libusb-win32-bin-1.2.6.0
1044 libusb_win_install: | $(DL_DIR)
1045 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
1046 libusb_win_install: LIBUSB_WIN_FILE := libusb-win32-bin-1.2.6.0.zip
1047 libusb_win_install: libusb_win_clean
1048 # download the file only if it's newer than what we already have
1049 $(V0) @echo " DOWNLOAD $(LIBUSB_WIN_URL)"
1050 $(V1) $(WGET) -q -N -P "$(DL_DIR)" --trust-server-name "$(LIBUSB_WIN_URL)"
1052 # extract the source
1053 $(V0) @echo " EXTRACT $(LIBUSB_WIN_FILE) -> $(LIBUSB_WIN_DIR)"
1054 $(V1) mkdir -p "$(LIBUSB_WIN_DIR)"
1055 $(V1) unzip -q -d "$(DL_DIR)" "$(DL_DIR)/$(LIBUSB_WIN_FILE)"
1057 # fixup .h file needed by openocd build
1058 $(V0) @echo " FIXUP $(LIBUSB_WIN_DIR)"
1059 $(V1) ln -s "$(LIBUSB_WIN_DIR)/include/lusb0_usb.h" "$(LIBUSB_WIN_DIR)/include/usb.h"
1061 .PHONY: libusb_win_clean
1062 libusb_win_clean:
1063 $(V0) @echo " CLEAN $(LIBUSB_WIN_DIR)"
1064 $(V1) [ ! -d "$(LIBUSB_WIN_DIR)" ] || $(RM) -r "$(LIBUSB_WIN_DIR)"
1066 .PHONY: openocd_git_win_install
1068 openocd_git_win_install: | $(DL_DIR) $(TOOLS_DIR)
1069 openocd_git_win_install: OPENOCD_URL := git://openocd.git.sourceforge.net/gitroot/openocd/openocd
1070 openocd_git_win_install: OPENOCD_REV := f1c0133321c8fcadadd10bba5537c0a634eb183b
1071 openocd_git_win_install: openocd_win_clean libusb_win_install ftd2xx_install
1072 # download the source
1073 $(V0) @echo " DOWNLOAD $(OPENOCD_URL) @ $(OPENOCD_REV)"
1074 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1075 $(V1) mkdir -p "$(OPENOCD_BUILD_DIR)"
1076 $(V1) git clone --no-checkout $(OPENOCD_URL) "$(DL_DIR)/openocd-build"
1077 $(V1) ( \
1078 cd $(OPENOCD_BUILD_DIR) ; \
1079 git checkout -q $(OPENOCD_REV) ; \
1082 # apply patches
1083 $(V0) @echo " PATCH $(OPENOCD_BUILD_DIR)"
1084 $(V1) ( \
1085 cd $(OPENOCD_BUILD_DIR) ; \
1086 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0001-armv7m-remove-dummy-FP-regs-for-new-gdb.patch ; \
1087 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0002-rtos-add-stm32_stlink-to-FreeRTOS-targets.patch ; \
1090 # build and install
1091 $(V0) @echo " BUILD $(OPENOCD_WIN_DIR)"
1092 $(V1) mkdir -p "$(OPENOCD_WIN_DIR)"
1093 $(V1) ( \
1094 cd $(OPENOCD_BUILD_DIR) ; \
1095 ./bootstrap ; \
1096 ./configure --enable-maintainer-mode --prefix="$(OPENOCD_WIN_DIR)" \
1097 --build=i686-pc-linux-gnu --host=i586-mingw32msvc \
1098 CPPFLAGS=-I$(LIBUSB_WIN_DIR)/include \
1099 LDFLAGS=-L$(LIBUSB_WIN_DIR)/lib/gcc \
1100 --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=$(FTD2XX_DIR) \
1101 --disable-werror \
1102 --enable-stlink ; \
1103 $(MAKE) ; \
1104 $(MAKE) install ; \
1107 # delete the extracted source when we're done
1108 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1110 .PHONY: openocd_win_clean
1111 openocd_win_clean:
1112 $(V0) @echo " CLEAN $(OPENOCD_WIN_DIR)"
1113 $(V1) [ ! -d "$(OPENOCD_WIN_DIR)" ] || $(RM) -r "$(OPENOCD_WIN_DIR)"
1115 .PHONY: openocd_git_install
1117 openocd_git_install: | $(DL_DIR) $(TOOLS_DIR)
1118 openocd_git_install: OPENOCD_URL := git://openocd.git.sourceforge.net/gitroot/openocd/openocd
1119 openocd_git_install: OPENOCD_REV := f1c0133321c8fcadadd10bba5537c0a634eb183b
1120 openocd_git_install: openocd_clean
1121 # download the source
1122 $(V0) @echo " DOWNLOAD $(OPENOCD_URL) @ $(OPENOCD_REV)"
1123 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1124 $(V1) mkdir -p "$(OPENOCD_BUILD_DIR)"
1125 $(V1) git clone --no-checkout $(OPENOCD_URL) "$(OPENOCD_BUILD_DIR)"
1126 $(V1) ( \
1127 cd $(OPENOCD_BUILD_DIR) ; \
1128 git checkout -q $(OPENOCD_REV) ; \
1131 # apply patches
1132 $(V0) @echo " PATCH $(OPENOCD_DIR)"
1133 $(V1) ( \
1134 cd $(OPENOCD_BUILD_DIR) ; \
1135 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0001-armv7m-remove-dummy-FP-regs-for-new-gdb.patch ; \
1136 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0002-rtos-add-stm32_stlink-to-FreeRTOS-targets.patch ; \
1139 # build and install
1140 $(V0) @echo " BUILD $(OPENOCD_DIR)"
1141 $(V1) mkdir -p "$(OPENOCD_DIR)"
1142 $(V1) ( \
1143 cd $(OPENOCD_BUILD_DIR) ; \
1144 ./bootstrap ; \
1145 ./configure --enable-maintainer-mode --prefix="$(OPENOCD_DIR)" --enable-ft2232_libftdi --enable-buspirate --enable-stlink ; \
1146 $(MAKE) ; \
1147 $(MAKE) install ; \
1150 # delete the extracted source when we're done
1151 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1153 .PHONY: openocd_clean
1154 openocd_clean:
1155 $(V0) @echo " CLEAN $(OPENOCD_DIR)"
1156 $(V1) [ ! -d "$(OPENOCD_DIR)" ] || $(RM) -r "$(OPENOCD_DIR)"
1158 STM32FLASH_DIR := $(TOOLS_DIR)/stm32flash
1159 ifeq ($(UNAME), Windows)
1160 STM32FLASH_BUILD_OPTIONS := "CC=GCC"
1161 endif
1162 .PHONY: stm32flash_install
1163 stm32flash_install: STM32FLASH_URL := https://code.google.com/p/stm32flash/
1164 stm32flash_install: STM32FLASH_REV := a358bd1f025d
1165 stm32flash_install: stm32flash_clean
1166 # download the source
1167 $(V0) @$(ECHO) " DOWNLOAD $(STM32FLASH_URL) @ r$(STM32FLASH_REV)"
1168 $(V1) [ ! -d "$(STM32FLASH_DIR)" ] || $(RM) -rf "$(STM32FLASH_DIR)"
1169 $(V1) $(MKDIR) -p "$(STM32FLASH_DIR)"
1170 $(V1) $(GIT) clone --no-checkout $(STM32FLASH_URL) "$(STM32FLASH_DIR)"
1171 $(V1) ( \
1172 $(CD) $(STM32FLASH_DIR) ; \
1173 $(GIT) checkout -q $(STM32FLASH_REV) ; \
1175 # build
1176 $(V0) @$(ECHO) " BUILD $(STM32FLASH_DIR)"
1177 $(V1) $(MAKE) --silent -C $(STM32FLASH_DIR) all $(STM32FLASH_BUILD_OPTIONS)
1179 .PHONY: stm32flash_clean
1180 stm32flash_clean:
1181 $(V0) @$(ECHO) " CLEAN $(STM32FLASH_DIR)"
1182 $(V1) [ ! -d "$(STM32FLASH_DIR)" ] || $(RM) -rf "$(STM32FLASH_DIR)"
1184 DFUUTIL_DIR := $(TOOLS_DIR)/dfu-util
1186 .PHONY: dfuutil_install
1187 dfuutil_install: DFUUTIL_URL := http://dfu-util.sourceforge.net/releases/dfu-util-0.8.tar.gz
1188 dfuutil_install: DFUUTIL_FILE := $(notdir $(DFUUTIL_URL))
1189 dfuutil_install: | $(DL_DIR) $(TOOLS_DIR)
1190 dfuutil_install: dfuutil_clean
1191 # download the source
1192 $(V0) @echo " DOWNLOAD $(DFUUTIL_URL)"
1193 $(V1) $(CURL) $(CURL_OPTIONS) -o "$(DL_DIR)/$(DFUUTIL_FILE)" "$(DFUUTIL_URL)"
1195 # extract the source
1196 $(V0) @echo " EXTRACT $(DFUUTIL_FILE)"
1197 $(V1) [ ! -d "$(DL_DIR)/dfuutil-build" ] || $(RM) -r "$(DL_DIR)/dfuutil-build"
1198 $(V1) mkdir -p "$(DL_DIR)/dfuutil-build"
1199 $(V1) tar -C $(DL_DIR)/dfuutil-build -xf "$(DL_DIR)/$(DFUUTIL_FILE)"
1201 # build
1202 $(V0) @echo " BUILD $(DFUUTIL_DIR)"
1203 $(V1) mkdir -p "$(DFUUTIL_DIR)"
1204 $(V1) ( \
1205 cd $(DL_DIR)/dfuutil-build/dfu-util-0.8 ; \
1206 ./configure --prefix="$(DFUUTIL_DIR)" ; \
1207 $(MAKE) ; \
1208 $(MAKE) install ; \
1211 .PHONY: dfuutil_clean
1212 dfuutil_clean:
1213 $(V0) @echo " CLEAN $(DFUUTIL_DIR)"
1214 $(V1) [ ! -d "$(DFUUTIL_DIR)" ] || $(RM) -r "$(DFUUTIL_DIR)"
1216 # see http://developer.android.com/sdk/ for latest versions
1217 ANDROID_SDK_DIR := $(TOOLS_DIR)/android-sdk-linux
1218 .PHONY: android_sdk_install
1219 android_sdk_install: ANDROID_SDK_URL := http://dl.google.com/android/android-sdk_r20.0.3-linux.tgz
1220 android_sdk_install: ANDROID_SDK_FILE := $(notdir $(ANDROID_SDK_URL))
1221 # order-only prereq on directory existance:
1222 android_sdk_install: | $(DL_DIR) $(TOOLS_DIR)
1223 android_sdk_install: android_sdk_clean
1224 # download the source only if it's newer than what we already have
1225 $(V0) @echo " DOWNLOAD $(ANDROID_SDK_URL)"
1226 $(V1) $(WGET) --no-check-certificate -N -P "$(DL_DIR)" "$(ANDROID_SDK_URL)"
1228 # binary only release so just extract it
1229 $(V0) @echo " EXTRACT $(ANDROID_SDK_FILE)"
1230 $(V1) tar -C $(TOOLS_DIR) -xf "$(DL_DIR)/$(ANDROID_SDK_FILE)"
1232 .PHONY: android_sdk_clean
1233 android_sdk_clean:
1234 $(V0) @echo " CLEAN $(ANDROID_SDK_DIR)"
1235 $(V1) [ ! -d "$(ANDROID_SDK_DIR)" ] || $(RM) -r $(ANDROID_SDK_DIR)
1237 .PHONY: android_sdk_update
1238 android_sdk_update:
1239 $(V0) @echo " UPDATE $(ANDROID_SDK_DIR)"
1240 $(ANDROID_SDK_DIR)/tools/android update sdk --no-ui -t platform-tools,android-16,addon-google_apis-google-16
1242 #Install git hooks under the right folder
1244 .PHONY: prepare
1245 prepare:
1246 $(V0) @echo " Configuring GIT commit template"
1247 $(V1) $(CD) "$(ROOT_DIR)"
1248 $(V1) $(GIT) config commit.template .commit-template
1250 .PHONY: prepare_clean
1251 prepare_clean:
1252 $(V0) @echo " Cleanup GIT commit template configuration"
1253 $(V1) $(CD) "$(ROOT_DIR)"
1254 $(V1) $(GIT) config --unset commit.template
1256 ##############################
1258 # TODO: these defines will go to tool install sections
1260 ##############################
1262 ifeq ($(shell [ -d "$(OPENOCD_DIR)" ] && $(ECHO) "exists"), exists)
1263 export OPENOCD := $(OPENOCD_DIR)/bin/openocd
1264 else
1265 # not installed, hope it's in the path...
1266 export OPENOCD ?= openocd
1267 endif
1269 ifeq ($(shell [ -d "$(ANDROID_SDK_DIR)" ] && $(ECHO) "exists"), exists)
1270 ANDROID := $(ANDROID_SDK_DIR)/tools/android
1271 ANDROID_DX := $(ANDROID_SDK_DIR)/platform-tools/dx
1272 else
1273 # not installed, hope it's in the path...
1274 ANDROID ?= android
1275 ANDROID_DX ?= dx
1276 endif