update credits
[librepilot.git] / make / tools.mk
blobc626fcb3e4f7fd170bcc12b73ab8f20dcd8bcd52
2 # Installers for tools required by the 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 # mesawin_install (Windows only)
15 # uncrustify_install
16 # doxygen_install
17 # gtest_install
18 # ccache_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 TOP_LEVEL_MAKEFILE
49 $(error $(notdir $(lastword $(MAKEFILE_LIST))) should be included by the top level Makefile)
50 endif
52 ##############################
54 # Already installed tools modules
56 ##############################
57 -include $(wildcard $(TOOLS_DIR)/*.mk)
59 TOOL_INSTALL := $(ROOT_DIR)/tool_install.sh
60 TOOL_TARGETS := gcc-arm-none-eabi
62 TOOL_INSTALL_TARGETS := $(addsuffix _install,$(TOOL_TARGETS))
63 TOOL_FORCE_INSTALL_TARGETS := $(addsuffix _force_install,$(TOOL_TARGETS))
64 TOOL_REMOVE_TARGETS := $(addsuffix _remove,$(TOOL_TARGETS))
66 .PHONY: $(TOOL_INSTALL_TARGETS)
67 $(TOOL_INSTALL_TARGETS):
68 @$(ECHO) $(MSG_INSTALLING) $(@:_install=)
69 $(V1) $(TOOL_INSTALL) -n $(@:_install=)
71 .PHONY: $(TOOL_FORCE_INSTALL_TARGETS)
72 $(TOOL_FORCE_INSTALL_TARGETS):
73 @$(ECHO) $(MSG_INSTALLING) $(@:_install=)
74 $(V1) $(TOOL_INSTALL) -n -f $(@:_force_install=)
76 .PHONY: $(TOOL_REMOVE_TARGETS)
77 $(TOOL_REMOVE_TARGETS):
78 @$(ECHO) $(MSG_CLEANING) $(@:_install=)
79 $(V1) $(TOOL_INSTALL) -n -r $(@:_remove=)
81 ##############################
83 # Toolchain URLs and directories
85 ##############################
87 TOOLS_URL := http://librepilot.github.io/tools
89 # versions given below are defaults
90 # and are used only to install the tools on some OSes
91 # don't assume actual versions to match
93 QT_SHORT_VERSION := 5.9
94 QT_VERSION := 5.9.0
96 OSG_VERSION := 3.5.5
97 OSGEARTH_VERSION := 2.8
99 ifeq ($(UNAME), Linux)
100 ifeq ($(ARCH), x86_64)
101 QT_SDK_ARCH := gcc_64
102 QT_SDK_URL := http://download.qt.io/official_releases/qt/$(QT_SHORT_VERSION)/$(QT_VERSION)/qt-opensource-linux-x64-$(QT_VERSION).run
103 QT_SDK_MD5_URL := http://download.qt.io/official_releases/qt/$(QT_SHORT_VERSION)/$(QT_VERSION)/md5sums.txt
104 OSG_URL := $(TOOLS_URL)/osg-$(OSG_VERSION)-linux-x64.tar.gz
105 OSGEARTH_URL := $(TOOLS_URL)/osgearth-$(OSGEARTH_VERSION)-linux-x64.tar.gz
106 else
107 # x32 for linux no longer provided as pre-built binaries.
108 endif
109 UNCRUSTIFY_URL := $(TOOLS_URL)/uncrustify-0.60.tar.gz
110 DOXYGEN_URL := $(TOOLS_URL)/doxygen-1.8.3.1.src.tar.gz
111 else ifeq ($(UNAME), Darwin)
112 QT_SDK_ARCH := clang_64
113 QT_SDK_URL := http://download.qt.io/official_releases/qt/$(QT_SHORT_VERSION)/$(QT_VERSION)/qt-opensource-mac-x64-$(QT_VERSION).dmg
114 QT_SDK_MD5_URL := http://download.qt.io/official_releases/qt/$(QT_SHORT_VERSION)/$(QT_VERSION)/md5sums.txt
115 QT_SDK_MOUNT_DIR := /Volumes/qt-opensource-mac-x64-$(QT_VERSION)
116 QT_SDK_MAINTENANCE_TOOL := /Volumes/qt-opensource-mac-x64-$(QT_VERSION)/qt-opensource-mac-x64-$(QT_VERSION).app/Contents/MacOS/qt-opensource-mac-x64-$(QT_VERSION)
117 UNCRUSTIFY_URL := $(TOOLS_URL)/uncrustify-0.60.tar.gz
118 DOXYGEN_URL := $(TOOLS_URL)/doxygen-1.8.3.1.src.tar.gz
119 OSG_URL := $(TOOLS_URL)/osg-$(OSG_VERSION)-clang_64.tar.gz
120 OSGEARTH_URL := $(TOOLS_URL)/osgearth-$(OSGEARTH_VERSION)-clang_64.tar.gz
121 else ifeq ($(UNAME), Windows)
122 QT_SDK_ARCH := mingw53_32
123 QT_SDK_URL := http://download.qt.io/official_releases/qt/$(QT_SHORT_VERSION)/$(QT_VERSION)/qt-opensource-windows-x86-mingw530-$(QT_VERSION).exe
124 QT_SDK_MD5_URL := http://download.qt.io/official_releases/qt/$(QT_SHORT_VERSION)/$(QT_VERSION)/md5sums.txt
125 NSIS_URL := $(TOOLS_URL)/nsis-2.46-unicode.tar.bz2
126 MESAWIN_URL := $(TOOLS_URL)/mesawin.tar.gz
127 UNCRUSTIFY_URL := $(TOOLS_URL)/uncrustify-0.60-windows.tar.bz2
128 DOXYGEN_URL := $(TOOLS_URL)/doxygen-1.8.3.1-windows.tar.bz2
129 endif
131 GTEST_URL := $(TOOLS_URL)/gtest-1.7.0.zip
132 CCACHE_URL := http://samba.org/ftp/ccache/ccache-3.2.2.tar.bz2
133 CCACHE_MD5_URL := $(TOOLS_URL)/ccache-3.2.2.tar.bz2.md5
135 QT_SDK_DIR := $(TOOLS_DIR)/qt-$(QT_VERSION)
136 UNCRUSTIFY_DIR := $(TOOLS_DIR)/uncrustify-0.60
137 DOXYGEN_DIR := $(TOOLS_DIR)/doxygen-1.8.3.1
138 GTEST_DIR := $(TOOLS_DIR)/gtest-1.7.0
139 CCACHE_DIR := $(TOOLS_DIR)/ccache
141 ifeq ($(UNAME), Linux)
142 ifeq ($(ARCH), x86_64)
143 OSG_SDK_DIR := $(TOOLS_DIR)/osg-$(OSG_VERSION)-linux-x64
144 OSGEARTH_SDK_DIR := $(TOOLS_DIR)/osgearth-$(OSGEARTH_VERSION)-linux-x64
145 else
146 OSG_SDK_DIR := $(TOOLS_DIR)/osg-$(OSG_VERSION)-linux-x86
147 OSGEARTH_SDK_DIR := $(TOOLS_DIR)/osgearth-$(OSGEARTH_VERSION)-linux-x86
148 endif
149 else ifeq ($(UNAME), Darwin)
150 OSG_SDK_DIR := $(TOOLS_DIR)/osg-$(OSG_VERSION)-clang_64
151 OSGEARTH_SDK_DIR := $(TOOLS_DIR)/osgearth-$(OSGEARTH_VERSION)-clang_64
152 else ifeq ($(UNAME), Windows)
153 ifeq ($(ARCH), x86_64)
154 MINGW_DIR := /mingw64
155 else
156 MINGW_DIR := /mingw32
157 endif
158 # When changing PYTHON_DIR, you must also update it in ground/gcs/src/python.pri
159 PYTHON_DIR := $(MINGW_DIR)/bin
160 OSG_SDK_DIR := $(MINGW_DIR)
161 OSGEARTH_SDK_DIR := $(MINGW_DIR)
162 NSIS_DIR := $(TOOLS_DIR)/nsis-2.46-unicode
163 MESAWIN_DIR := $(TOOLS_DIR)/mesawin
164 endif
166 ##############################
168 # Build only and all toolchains available for the platform
170 ##############################
172 BUILD_SDK_TARGETS := arm_sdk
173 ifeq ($(UNAME), Windows)
174 BUILD_SDK_TARGETS += nsis mesawin
175 endif
176 ifeq ($(UNAME), Darwin)
177 BUILD_SDK_TARGETS += qt_sdk osg
178 endif
179 ALL_SDK_TARGETS := $(BUILD_SDK_TARGETS) gtest uncrustify doxygen
181 define GROUP_SDK_TEMPLATE
182 .PHONY: $(1)_install $(1)_clean $(1)_distclean $(1)_version
183 $(1)_install: $(addsuffix _install,$(2))
184 $(1)_clean: $(addsuffix _clean,$(2))
185 $(1)_distclean: $(addsuffix _distclean,$(2))
186 $(1)_version: $(addsuffix _version,$(2))
187 endef
189 $(eval $(call GROUP_SDK_TEMPLATE,build_sdk,$(BUILD_SDK_TARGETS)))
190 $(eval $(call GROUP_SDK_TEMPLATE,all_sdk,$(ALL_SDK_TARGETS)))
192 ##############################
194 # Misc host tools
196 ##############################
198 # Used by other makefiles
199 export MKDIR := mkdir
200 export CP := cp
201 export RM := rm
202 export LN := ln
203 export CAT := cat
204 export CUT := cut
205 export SED := sed
207 # Used only by this Makefile
208 GIT := git
209 CURL := curl
210 TAR := tar
211 UNZIP := unzip
212 ZIP := gzip
213 OPENSSL := openssl
214 ANT := ant
215 JAVAC := javac
216 JAR := jar
217 CD := cd
218 GREP := grep
219 CMAKE := cmake
220 ifneq ($(UNAME), Windows)
221 SEVENZIP := 7za
222 else
223 SEVENZIP := 7za.exe
224 ifneq ($(shell $(SEVENZIP) --version >/dev/null 2>&1 && $(ECHO) "found"), found)
225 # no $(SEVENZIP) found in path. hope is in bin...
226 SEVENZIP = $(TOOLS_DIR)/bin/7za.exe
227 endif
228 endif
229 ifneq ($(UNAME), Windows)
230 MAKE := make
231 else
232 MAKE := mingw32-make
233 endif
235 # Echo in recipes is a bit tricky in a Windows Git Bash window in some cases.
236 # It does not work if make started under msysGit installed into a path with spaces.
237 ifneq ($(UNAME), Windows)
238 export ECHO := echo
239 else
240 # export ECHO := $(PYTHON) -c "import sys; print(' '.join(sys.argv[1:]))"
241 export ECHO := echo
242 endif
244 # Test if quotes are needed for the echo command
245 ifeq ($(shell $(ECHO) "test"), test)
246 export QUOTE := '
247 # This line is just to clear out the single quote above '
248 else
249 export QUOTE :=
250 endif
252 # Command to extract version info data from the repository and source tree
253 export VERSION_INFO = $(PYTHON) $(ROOT_DIR)/make/scripts/version-info.py --path=$(ROOT_DIR)
255 export CCACHE
257 ##############################
259 # Misc settings
261 ##############################
263 # Define messages
264 MSG_VERIFYING = $(QUOTE) VERIFY $(QUOTE)
265 MSG_DOWNLOADING = $(QUOTE) DOWNLOAD $(QUOTE)
266 MSG_CHECKSUMMING = $(QUOTE) MD5 $(QUOTE)
267 MSG_EXTRACTING = $(QUOTE) EXTRACT $(QUOTE)
268 MSG_CONFIGURING = $(QUOTE) CONFIGURE $(QUOTE)
269 MSG_BUILDING = $(QUOTE) BUILD $(QUOTE)
270 MSG_INSTALLING = $(QUOTE) INSTALL $(QUOTE)
271 MSG_CLEANING = $(QUOTE) CLEAN $(QUOTE)
272 MSG_DISTCLEANING = $(QUOTE) DISTCLEAN $(QUOTE)
273 MSG_NOTICE = $(QUOTE) NOTE $(QUOTE)
275 # Verbosity level
276 ifeq ($(V), 1)
277 MAKE_SILENT :=
278 UNZIP_SILENT :=
279 else
280 MAKE_SILENT := --silent
281 UNZIP_SILENT := -q
282 endif
284 # Batch mode
285 ifeq ($(BATCH), 1)
286 CURL_OPTIONS := --silent -L
287 else
288 CURL_OPTIONS := -L
289 endif
291 # MSYS tar workaround
292 ifeq ($(UNAME), Windows)
293 TAR_OPTIONS := --force-local
294 else
295 TAR_OPTIONS :=
296 endif
298 # Print some useful notes for *_install targets
299 ifneq ($(strip $(filter $(addsuffix _install,all_sdk $(ALL_SDK_TARGETS)),$(MAKECMDGOALS))),)
300 ifneq ($(shell $(CURL) --version >/dev/null 2>&1 && $(ECHO) "found"), found)
301 $(error Please install curl first ('apt-get install curl' or similar))
302 endif
303 $(info $(EMPTY) NOTE Use 'make all_sdk_distclean' to remove installation files)
304 $(info $(EMPTY) NOTE Use 'make all_sdk_version' to check toolchain versions)
305 $(info $(EMPTY) NOTE Add 'V=1' to make command line to diagnose make problems)
306 $(info $(EMPTY) NOTE Add 'BATCH=1' to make command line to disable progress reporting during downloads)
307 endif
309 ##############################
311 # Cross-platform MD5 check template
312 # $(1) = file name without quotes
313 # $(2) = string compare operator, e.g. = or !=
315 ##############################
317 define MD5_CHECK_TEMPLATE
318 "`test -f \"$(1)\" && $(OPENSSL) dgst -md5 \"$(1)\" | $(CUT) -f2 -d' '`" $(2) "`$(GREP) $(notdir $(1)) $(1).md5 | $(CUT) -f1 -d' '`"
319 endef
321 ##############################
323 # Cross-platform MD5 generation template
324 # $(1) = file name without quotes
326 ##############################
328 ifeq ($(UNAME), Darwin)
330 define MD5_GEN_TEMPLATE
331 md5 -r $(1) > $(1).md5
332 endef
334 else
336 define MD5_GEN_TEMPLATE
337 $(OPENSSL) dgst -r -md5 $(1) > $(1).md5
338 endef
340 endif
342 ##############################
344 # Cross platform download template
345 # $(1) = Package URL
346 # $(2) = Package file
347 # $(3) = URL for .md5 file to be tested against Package
349 ##############################
351 define DOWNLOAD_TEMPLATE
352 @$(ECHO) $(MSG_VERIFYING) $$(call toprel, $(DL_DIR)/$(2))
353 $(V1) ( \
354 cd "$(DL_DIR)" && \
355 $(CURL) $(CURL_OPTIONS) --silent -o "$(DL_DIR)/$(2).md5" "$(3)" && \
356 if [ $(call MD5_CHECK_TEMPLATE,$(DL_DIR)/$(2),!=) ]; then \
357 $(ECHO) $(MSG_DOWNLOADING) $(1) && \
358 $(CURL) $(CURL_OPTIONS) -o "$(DL_DIR)/$(2)" "$(1)" && \
359 $(ECHO) $(MSG_CHECKSUMMING) $$(call toprel, $(DL_DIR)/$(2)) && \
360 [ $(call MD5_CHECK_TEMPLATE,$(DL_DIR)/$(2),=) ]; \
361 fi; \
363 endef
365 ##############################
367 # Common tool install template
368 # $(1) = tool name
369 # $(2) = tool extract/build directory
370 # $(3) = tool distribution URL
371 # $(4) = tool distribution MD5 URL
372 # $(5) = tool distribution file
373 # $(6) = optional extra build recipes template
374 # $(7) = optional extra clean recipes template
376 ##############################
378 define TOOL_INSTALL_TEMPLATE
380 .PHONY: $(addprefix $(1)_, install clean distclean)
382 $(1)_install: $(1)_clean | $(DL_DIR) $(TOOLS_DIR)
384 $(if $(4), $(call DOWNLOAD_TEMPLATE,$(3),$(5),$(4)),$(call DOWNLOAD_TEMPLATE,$(3),$(5),"$(3).md5"))
386 @$(ECHO) $(MSG_EXTRACTING) $$(call toprel, $(2))
387 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(2)))
389 $(if $(filter $(suffix $(5)), .zip),
390 $(V1) $(UNZIP) $(UNZIP_SILENT) -d $$(call toprel, $(dir $(2))) $$(call toprel, $(DL_DIR)/$(5)),
391 $(V1) $(TAR) $(TAR_OPTIONS) -C $$(call toprel, $(dir $(2))) -xf $$(call toprel, $(DL_DIR)/$(5))
394 $(6)
396 $(1)_clean:
397 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(2))
398 $(V1) [ ! -d "$(2)" ] || $(RM) -rf "$(2)"
400 $(7)
402 $(1)_distclean:
403 @$(ECHO) $(MSG_DISTCLEANING) $$(call toprel, $(DL_DIR)/$(5))
404 $(V1) [ ! -f "$(DL_DIR)/$(5)" ] || $(RM) "$(DL_DIR)/$(5)"
405 $(V1) [ ! -f "$(DL_DIR)/$(5).md5" ] || $(RM) "$(DL_DIR)/$(5).md5"
407 endef
409 ##############################
411 # ARM SDK
413 ##############################
414 export ARM_SDK_PREFIX := arm-none-eabi-
415 ARM_SDK_TOOL := gcc-arm-none-eabi
417 .PHONY: arm_sdk_install
418 arm_sdk_install: $(ARM_SDK_TOOL)_install
420 .PHONY: arm_sdk_clean
421 arm_sdk_clean: $(ARM_SDK_TOOL)_remove
423 .PHONY: arm_sdk_version
424 arm_sdk_version:
425 -$(V1) $(ARM_SDK_PREFIX)gcc --version | head -n1
427 # Template to check ARM toolchain version before building targets
428 define ARM_GCC_VERSION_CHECK_TEMPLATE
429 if ! $(ARM_SDK_PREFIX)gcc --version --specs=nano.specs >/dev/null 2>&1; then \
430 $(ECHO) $(MSG_NOTICE) Please install ARM toolchain 4.8 2014q1 using \'make arm_sdk_install\' && \
431 $(ECHO) $(MSG_NOTICE) Older ARM SDKs do not support new \'--specs=nano.specs\' option && \
432 exit 1; \
434 endef
436 ##############################
438 # Qt install template
439 # $(1) = tool install directory
440 # $(2) = tool distribution URL
441 # $(3) = tool distribution .md5 URL
442 # $(4) = tool distribution file
443 # $(5) = Qt architecture
444 # $(6) = optional extra build recipes template
445 # $(7) = optional extra clean recipes template
447 ##############################
449 define QT_INSTALL_TEMPLATE
451 .PHONY: $(addprefix qt_sdk_, install clean distclean)
453 qt_sdk_install: qt_sdk_clean | $(DL_DIR) $(TOOLS_DIR)
454 $(call DOWNLOAD_TEMPLATE,$(2),$(4),"$(3)")
455 # Silently install Qt under tools directory
456 @$(ECHO) $(MSG_EXTRACTING) $(4) to $$(call toprel, $(1))
457 $(V1) ( export QT_INSTALL_TARGET_DIR=$(1) && \
458 chmod +x $(DL_DIR)/$(4) && \
459 $(DL_DIR)/$(4) --script $(ROOT_DIR)/make/tool_install/qt-install.qs ; \
461 # Execute post build templates
462 $(6)
464 qt_sdk_clean:
465 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
466 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
467 $(7)
469 qt_sdk_distclean:
470 @$(ECHO) $(MSG_DISTCLEANING) $$(call toprel, $(DL_DIR)/$(4))
471 $(V1) [ ! -f "$(DL_DIR)/$(4)" ] || $(RM) "$(DL_DIR)/$(4)"
472 $(V1) [ ! -f "$(DL_DIR)/$(4).md5" ] || $(RM) "$(DL_DIR)/$(4).md5"
474 endef
476 ##############################
478 # Mac QT install template
479 # $(1) = tool install directory
480 # $(2) = tool distribution URL
481 # $(3) = tool distribution .md5 URL
482 # $(4) = tool distribution file
483 # $(5) = QT architecture
484 # $(6) = optional extra build recipes template
485 # $(7) = optional extra clean recipes template
487 ##############################
489 define MAC_QT_INSTALL_TEMPLATE
491 .PHONY: $(addprefix qt_sdk_, install clean distclean)
493 qt_sdk_install: qt_sdk_clean | $(DL_DIR) $(TOOLS_DIR)
494 $(call DOWNLOAD_TEMPLATE,$(2),$(4),"$(3)")
495 # Mount .dmg file
496 $(V1) hdiutil attach -nobrowse $(DL_DIR)/$(4)
497 # Silently install Qt under tools directory
498 @$(ECHO) $(MSG_EXTRACTING) $(4) to $$(call toprel, $(1))
499 $(V1) ( export QT_INSTALL_TARGET_DIR=$(1) && \
500 $(QT_SDK_MAINTENANCE_TOOL) --script $(ROOT_DIR)/make/tool_install/qt-install.qs ; \
502 # Unmount the .dmg file
503 $(V1) hdiutil detach $(QT_SDK_MOUNT_DIR)
504 # Execute post build templates
505 $(6)
507 qt_sdk_clean:
508 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
509 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
510 $(7)
512 endef
514 ##############################
516 # Qt SDK
518 ##############################
520 ifeq ($(UNAME), Windows)
522 QT_SDK_PREFIX := $(QT_SDK_DIR)/$(QT_SHORT_VERSION)/$(QT_SDK_ARCH)
523 $(eval $(call QT_INSTALL_TEMPLATE,$(QT_SDK_DIR),$(QT_SDK_URL),$(QT_SDK_MD5_URL),$(notdir $(QT_SDK_URL)),$(QT_SDK_ARCH)))
525 else ifeq ($(UNAME), Linux)
527 QT_SDK_PREFIX := "$(QT_SDK_DIR)/$(QT_SHORT_VERSION)/$(QT_SDK_ARCH)"
528 $(eval $(call QT_INSTALL_TEMPLATE,$(QT_SDK_DIR),$(QT_SDK_URL),$(QT_SDK_MD5_URL),$(notdir $(QT_SDK_URL)),$(QT_SDK_ARCH)))
530 else ifeq ($(UNAME), Darwin)
532 QT_SDK_PREFIX := "$(QT_SDK_DIR)/$(QT_SHORT_VERSION)/$(QT_SDK_ARCH)"
533 $(eval $(call MAC_QT_INSTALL_TEMPLATE,$(QT_SDK_DIR),$(QT_SDK_URL),$(QT_SDK_MD5_URL),$(notdir $(QT_SDK_URL)),$(QT_SDK_ARCH)))
535 else
537 QT_SDK_PREFIX := $(QT_SDK_DIR)
539 .PHONY: qt_sdk_install
540 qt_sdk_install:
541 @$(ECHO) $(MSG_NOTICE) --------------------------------------------------------
542 @$(ECHO) $(MSG_NOTICE) Please install native Qt 5.6.x SDK using package manager
543 @$(ECHO) $(MSG_NOTICE) --------------------------------------------------------
545 .PHONY: qt_sdk_clean
546 qt_sdk_clean:
548 .PHONY: qt_sdk_distclean
549 qt_sdk_distclean:
551 endif
553 ifeq ($(shell [ -d "$(QT_SDK_DIR)" ] && $(ECHO) "exists"), exists)
554 export QMAKE := $(QT_SDK_PREFIX)/bin/qmake
556 # set Qt library search path
557 ifeq ($(UNAME), Windows)
558 export PATH := $(QT_SDK_PREFIX)/bin:$(PATH)
559 else
560 export LD_LIBRARY_PATH := $(QT_SDK_DIR)/lib:$(LD_LIBRARY_PATH)
561 endif
562 else
563 OPT_QT := qt56
564 OPT_QT_ENV_SH := /opt/$(OPT_QT)/bin/$(OPT_QT)-env.sh
565 ifneq ($(wildcard $(OPT_QT_ENV_SH)),)
566 SHELL := /bin/bash
567 QMAKE := . $(OPT_QT_ENV_SH) && qmake
568 else
569 # not installed, hope it's in the path...
570 QMAKE := qmake
571 endif
572 endif
574 .PHONY: qt_sdk_version
575 qt_sdk_version:
576 -$(V1) $(QMAKE) --version | tail -1
578 ##############################
580 # MinGW
582 ##############################
584 ifeq ($(UNAME), Windows)
586 ifeq ($(shell [ -d "$(MINGW_DIR)" ] && $(ECHO) "exists"), exists)
587 # set MinGW binary and library paths (QTMINGW is used by qmake, do not rename)
588 export MINGW_DIR := $(MINGW_DIR)
589 export QTMINGW := $(MINGW_DIR)/bin
590 export PATH := $(QTMINGW):$(PATH)
591 else
592 # not installed, use host gcc compiler
593 # $(info $(EMPTY) WARNING $(call toprel, $(MINGW_DIR)) not found, using system PATH)
594 endif
596 .PHONY: mingw_version
597 mingw_version: gcc_version
599 endif
601 .PHONY: gcc_version
602 gcc_version:
603 -$(V1) gcc --version | head -n1
605 all_sdk_version: gcc_version
607 ##############################
609 # Python
611 ##############################
613 ifeq ($(shell [ -d "$(PYTHON_DIR)" ] && $(ECHO) "exists"), exists)
614 export PYTHON := $(PYTHON_DIR)/python
615 export PATH := $(PYTHON_DIR):$(PATH)
616 else
617 # not installed, hope it's in the path...
618 # $(info $(EMPTY) WARNING $(call toprel, $(PYTHON_DIR)) not found, using system PATH)
619 ifeq ($(findstring Python 2,$(shell python --version 2>&1)), Python 2)
620 export PYTHON := python
621 else
622 export PYTHON := python2
623 endif
624 endif
626 .PHONY: python_version
627 python_version:
628 -$(V1) $(PYTHON) --version
630 ##############################
632 # NSIS Unicode (Windows only)
634 ##############################
636 ifeq ($(UNAME), Windows)
638 $(eval $(call TOOL_INSTALL_TEMPLATE,nsis,$(NSIS_DIR),$(NSIS_URL),,$(notdir $(NSIS_URL))))
640 ifeq ($(shell [ -d "$(NSIS_DIR)" ] && $(ECHO) "exists"), exists)
641 export NSIS := $(NSIS_DIR)/makensis
642 else
643 # not installed, hope it's in the path...
644 # $(info $(EMPTY) WARNING $(call toprel, $(NSIS_DIR)) not found (make nsis_install), using system PATH)
645 export NSIS ?= makensis
646 endif
648 .PHONY: nsis_version
649 nsis_version:
650 -$(V1) $(NSIS) | head -n1
652 endif
654 ##################################
656 # Mesa OpenGL DLL (Windows only)
658 ##################################
660 ifeq ($(UNAME), Windows)
662 $(eval $(call TOOL_INSTALL_TEMPLATE,mesawin,$(MESAWIN_DIR),$(MESAWIN_URL),,$(notdir $(MESAWIN_URL))))
664 ifeq ($(shell [ -d "$(MESAWIN_DIR)" ] && $(ECHO) "exists"), exists)
665 export MESAWIN_DIR := $(MESAWIN_DIR)
666 else
667 # not installed, hope it's in the path...
668 #$(info $(EMPTY) WARNING $(call toprel, $(MESA_WIN_DIR)) not found (make mesawin_install), using system PATH)
669 endif
671 .PHONY: mesawin_version
672 mesawin_version:
673 -$(V1) $(ECHO) "MesaOpenGL vXX"
675 endif
677 ##############################
679 # Uncrustify
681 ##############################
683 ifeq ($(UNAME), Windows)
685 $(eval $(call TOOL_INSTALL_TEMPLATE,uncrustify,$(UNCRUSTIFY_DIR),$(UNCRUSTIFY_URL),,$(notdir $(UNCRUSTIFY_URL))))
687 else # Linux or Mac
689 UNCRUSTIFY_BUILD_DIR := $(BUILD_DIR)/$(notdir $(UNCRUSTIFY_DIR))
691 define UNCRUSTIFY_BUILD_TEMPLATE
692 $(V1) ( \
693 $(ECHO) $(MSG_CONFIGURING) $(call toprel, $(UNCRUSTIFY_BUILD_DIR)) && \
694 cd $(UNCRUSTIFY_BUILD_DIR) && \
695 ./configure --prefix="$(UNCRUSTIFY_DIR)" && \
696 $(ECHO) $(MSG_BUILDING) $(call toprel, $(UNCRUSTIFY_BUILD_DIR)) && \
697 $(MAKE) $(MAKE_SILENT) && \
698 $(ECHO) $(MSG_INSTALLING) $(call toprel, $(UNCRUSTIFY_DIR)) && \
699 $(MAKE) $(MAKE_SILENT) install-strip \
701 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(UNCRUSTIFY_BUILD_DIR))
702 -$(V1) [ ! -d "$(UNCRUSTIFY_BUILD_DIR)" ] || $(RM) -rf "$(UNCRUSTIFY_BUILD_DIR)"
703 endef
705 define UNCRUSTIFY_CLEAN_TEMPLATE
706 -$(V1) [ ! -d "$(UNCRUSTIFY_DIR)" ] || $(RM) -rf "$(UNCRUSTIFY_DIR)"
707 endef
709 $(eval $(call TOOL_INSTALL_TEMPLATE,uncrustify,$(UNCRUSTIFY_BUILD_DIR),$(UNCRUSTIFY_URL),,$(notdir $(UNCRUSTIFY_URL)),$(UNCRUSTIFY_BUILD_TEMPLATE),$(UNCRUSTIFY_CLEAN_TEMPLATE)))
711 endif
713 ifeq ($(shell [ -d "$(UNCRUSTIFY_DIR)" ] && $(ECHO) "exists"), exists)
714 export UNCRUSTIFY := $(UNCRUSTIFY_DIR)/bin/uncrustify
715 else
716 # not installed, hope it's in the path...
717 # $(info $(EMPTY) WARNING $(call toprel, $(UNCRUSTIFY_DIR)) not found (make uncrustify_install), using system PATH)
718 export UNCRUSTIFY := uncrustify
719 endif
721 .PHONY: uncrustify_version
722 uncrustify_version:
723 -$(V1) $(UNCRUSTIFY) --version
725 ##############################
727 # Doxygen
729 ##############################
731 ifeq ($(UNAME), Windows)
733 $(eval $(call TOOL_INSTALL_TEMPLATE,doxygen,$(DOXYGEN_DIR),$(DOXYGEN_URL),,$(notdir $(DOXYGEN_URL))))
735 else # Linux or Mac
737 DOXYGEN_BUILD_DIR := $(BUILD_DIR)/$(notdir $(DOXYGEN_DIR))
739 define DOXYGEN_BUILD_TEMPLATE
740 $(V1) ( \
741 $(ECHO) $(MSG_CONFIGURING) $(call toprel, $(DOXYGEN_BUILD_DIR)) && \
742 cd $(DOXYGEN_BUILD_DIR) && \
743 ./configure --prefix "$(DOXYGEN_DIR)" --english-only && \
744 $(ECHO) $(MSG_BUILDING) $(call toprel, $(DOXYGEN_BUILD_DIR)) && \
745 $(MAKE) $(MAKE_SILENT) && \
746 $(ECHO) $(MSG_INSTALLING) $(call toprel, $(DOXYGEN_DIR)) && \
747 $(MAKE) $(MAKE_SILENT) install \
749 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(DOXYGEN_BUILD_DIR))
750 -$(V1) [ ! -d "$(DOXYGEN_BUILD_DIR)" ] || $(RM) -rf "$(DOXYGEN_BUILD_DIR)"
751 endef
753 define DOXYGEN_CLEAN_TEMPLATE
754 -$(V1) [ ! -d "$(DOXYGEN_DIR)" ] || $(RM) -rf "$(DOXYGEN_DIR)"
755 endef
757 $(eval $(call TOOL_INSTALL_TEMPLATE,doxygen,$(DOXYGEN_BUILD_DIR),$(DOXYGEN_URL),,$(notdir $(DOXYGEN_URL)),$(DOXYGEN_BUILD_TEMPLATE),$(DOXYGEN_CLEAN_TEMPLATE)))
759 endif
761 ifeq ($(shell [ -d "$(DOXYGEN_DIR)" ] && $(ECHO) "exists"), exists)
762 export DOXYGEN := $(DOXYGEN_DIR)/bin/doxygen
763 else
764 # not installed, hope it's in the path...
765 # $(info $(EMPTY) WARNING $(call toprel, $(DOXYGEN_DIR)) not found (make doxygen_install), using system PATH)
766 export DOXYGEN := doxygen
767 endif
769 .PHONY: doxygen_version
770 doxygen_version:
771 -$(V1) $(ECHO) "Doxygen `$(DOXYGEN) --version`"
773 ##############################
775 # GoogleTest
777 ##############################
779 $(eval $(call TOOL_INSTALL_TEMPLATE,gtest,$(GTEST_DIR),$(GTEST_URL),,$(notdir $(GTEST_URL))))
781 export GTEST_DIR
783 .PHONY: gtest_version
784 gtest_version:
785 -$(V1) $(SED) -n "s/^PACKAGE_STRING='\(.*\)'/\1/p" < $(GTEST_DIR)/configure
787 ##############################
789 # CCACHE
791 ##############################
793 CCACHE_BUILD_DIR := $(BUILD_DIR)/ccache-3.2.2
795 define CCACHE_BUILD_TEMPLATE
796 $(V1) ( \
797 $(ECHO) $(MSG_CONFIGURING) $(call toprel, $(CCACHE_BUILD_DIR)) && \
798 cd $(CCACHE_BUILD_DIR) && \
799 ./configure --prefix="$(CCACHE_DIR)" && \
800 $(ECHO) $(MSG_BUILDING) $(call toprel, $(CCACHE_BUILD_DIR)) && \
801 $(MAKE) $(MAKE_SILENT) && \
802 $(ECHO) $(MSG_INSTALLING) $(call toprel, $(CCACHE_DIR)) && \
803 $(MAKE) $(MAKE_SILENT) install \
805 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(CCACHE_BUILD_DIR))
806 -$(V1) [ ! -d "$(CCACHE_BUILD_DIR)" ] || $(RM) -rf "$(CCACHE_BUILD_DIR)"
808 @$(ECHO)
809 @$(ECHO) "Setting up CCACHE configuration:"
811 $(V1) [ -d "$(ROOT_DIR)/.ccache" ] || mkdir $(ROOT_DIR)/.ccache
812 $(V1) [ -d "$(CCACHE_DIR)/etc" ] || mkdir $(CCACHE_DIR)/etc
814 $(V1) $(ECHO) $(QUOTE)cache_dir = $(ROOT_DIR)/.ccache $(QUOTE) > $(CCACHE_DIR)/etc/ccache.conf
815 $(V1) $(ECHO) $(QUOTE)max_size = 250M$(QUOTE) >> $(CCACHE_DIR)/etc/ccache.conf
816 $(V1) $(CAT) $(CCACHE_DIR)/etc/ccache.conf
817 endef
819 define CCACHE_CLEAN_TEMPLATE
820 -$(V1) [ ! -d "$(CCACHE_DIR)" ] || $(RM) -rf "$(CCACHE_DIR)"
821 endef
823 $(eval $(call TOOL_INSTALL_TEMPLATE,ccache,$(CCACHE_BUILD_DIR),$(CCACHE_URL),$(CCACHE_MD5_URL),$(notdir $(CCACHE_URL)),$(CCACHE_BUILD_TEMPLATE),$(CCACHE_CLEAN_TEMPLATE)))
825 ##############################
827 # osg
829 ##############################
831 ifneq ($(UNAME), Windows)
833 $(eval $(call TOOL_INSTALL_TEMPLATE,osg,$(OSG_SDK_DIR),$(OSG_URL),,$(notdir $(OSG_URL))))
835 endif
837 ifeq ($(shell [ -d "$(OSG_SDK_DIR)" ] && $(ECHO) "exists"), exists)
838 export OSG_SDK_DIR := $(OSG_SDK_DIR)
839 else
840 # not installed, hope it's in the path...
841 # $(info $(EMPTY) WARNING $(call toprel, $(OSG_SDK_DIR)) not found (make osg_install), using system PATH)
842 endif
844 .PHONY: osg_version
845 osg_version:
846 -$(V1) $(ECHO) "`$(OSG_SDK_DIR)/bin/osgversion`"
848 ##############################
850 # osgearth
852 ##############################
854 ifneq ($(UNAME), Windows)
856 $(eval $(call TOOL_INSTALL_TEMPLATE,osgearth,$(OSGEARTH_SDK_DIR),$(OSGEARTH_URL),,$(notdir $(OSGEARTH_URL))))
858 endif
860 ifeq ($(shell [ -d "$(OSGEARTH_SDK_DIR)" ] && $(ECHO) "exists"), exists)
861 export OSGEARTH_SDK_DIR := $(OSGEARTH_SDK_DIR)
862 else
863 # not installed, hope it's in the path...
864 # $(info $(EMPTY) WARNING $(call toprel, $(OSGEARTH_SDK_DIR)) not found (make osgearth_install), using system PATH)
865 endif
867 .PHONY: osgearth_version
868 osgearth_version:
869 -$(V1) $(ECHO) "`$(OSGEARTH_SDK_DIR)/bin/osgearth_version`"
871 ##############################
873 # TODO: code below is not revised yet
875 ##############################
877 # Set up openocd tools
878 OPENOCD_DIR := $(TOOLS_DIR)/openocd
879 OPENOCD_WIN_DIR := $(TOOLS_DIR)/openocd_win
880 OPENOCD_BUILD_DIR := $(DL_DIR)/openocd-build
882 .PHONY: openocd_install
883 openocd_install: | $(DL_DIR) $(TOOLS_DIR)
884 openocd_install: OPENOCD_URL := http://sourceforge.net/projects/openocd/files/openocd/0.6.1/openocd-0.6.1.tar.bz2/download
885 openocd_install: OPENOCD_FILE := openocd-0.6.1.tar.bz2
886 openocd_install: openocd_clean
887 # download the source only if it's newer than what we already have
888 $(V1) $(WGET) -N -P "$(DL_DIR)" --trust-server-name "$(OPENOCD_URL)"
890 # extract the source
891 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -r "$(OPENOCD_BUILD_DIR)"
892 $(V1) mkdir -p "$(OPENOCD_BUILD_DIR)"
893 $(V1) tar -C $(OPENOCD_BUILD_DIR) -xjf "$(DL_DIR)/$(OPENOCD_FILE)"
895 # apply patches
896 $(V0) @echo " PATCH $(OPENOCD_DIR)"
897 $(V1) ( \
898 cd $(OPENOCD_BUILD_DIR)/openocd-0.6.1 ; \
899 patch -p1 < $(ROOT_DIR)/flight/Project/OpenOCD/0001-armv7m-remove-dummy-FP-regs-for-new-gdb.patch ; \
900 patch -p1 < $(ROOT_DIR)/flight/Project/OpenOCD/0002-rtos-add-stm32_stlink-to-FreeRTOS-targets.patch ; \
903 # build and install
904 $(V1) mkdir -p "$(OPENOCD_DIR)"
905 $(V1) ( \
906 cd $(OPENOCD_BUILD_DIR)/openocd-0.6.1 ; \
907 ./configure --prefix="$(OPENOCD_DIR)" --enable-ft2232_libftdi --enable-stlink ; \
908 $(MAKE) --silent ; \
909 $(MAKE) --silent install ; \
912 # delete the extracted source when we're done
913 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
915 .PHONY: ftd2xx_install
917 FTD2XX_DIR := $(DL_DIR)/ftd2xx
919 ftd2xx_install: | $(DL_DIR)
920 ftd2xx_install: FTD2XX_URL := http://www.ftdichip.com/Drivers/CDM/Beta/CDM20817.zip
921 ftd2xx_install: FTD2XX_FILE := CDM20817.zip
922 ftd2xx_install: ftd2xx_clean
923 # download the file only if it's newer than what we already have
924 $(V0) @echo " DOWNLOAD $(FTD2XX_URL)"
925 $(V1) $(WGET) -q -N -P "$(DL_DIR)" "$(FTD2XX_URL)"
927 # extract the source
928 $(V0) @echo " EXTRACT $(FTD2XX_FILE) -> $(FTD2XX_DIR)"
929 $(V1) mkdir -p "$(FTD2XX_DIR)"
930 $(V1) unzip -q -d "$(FTD2XX_DIR)" "$(DL_DIR)/$(FTD2XX_FILE)"
932 .PHONY: ftd2xx_clean
933 ftd2xx_clean:
934 $(V0) @echo " CLEAN $(FTD2XX_DIR)"
935 $(V1) [ ! -d "$(FTD2XX_DIR)" ] || $(RM) -r "$(FTD2XX_DIR)"
937 .PHONY: ftd2xx_install
939 LIBUSB_WIN_DIR := $(DL_DIR)/libusb-win32-bin-1.2.6.0
941 libusb_win_install: | $(DL_DIR)
942 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
943 libusb_win_install: LIBUSB_WIN_FILE := libusb-win32-bin-1.2.6.0.zip
944 libusb_win_install: libusb_win_clean
945 # download the file only if it's newer than what we already have
946 $(V0) @echo " DOWNLOAD $(LIBUSB_WIN_URL)"
947 $(V1) $(WGET) -q -N -P "$(DL_DIR)" --trust-server-name "$(LIBUSB_WIN_URL)"
949 # extract the source
950 $(V0) @echo " EXTRACT $(LIBUSB_WIN_FILE) -> $(LIBUSB_WIN_DIR)"
951 $(V1) mkdir -p "$(LIBUSB_WIN_DIR)"
952 $(V1) unzip -q -d "$(DL_DIR)" "$(DL_DIR)/$(LIBUSB_WIN_FILE)"
954 # fixup .h file needed by openocd build
955 $(V0) @echo " FIXUP $(LIBUSB_WIN_DIR)"
956 $(V1) ln -s "$(LIBUSB_WIN_DIR)/include/lusb0_usb.h" "$(LIBUSB_WIN_DIR)/include/usb.h"
958 .PHONY: libusb_win_clean
959 libusb_win_clean:
960 $(V0) @echo " CLEAN $(LIBUSB_WIN_DIR)"
961 $(V1) [ ! -d "$(LIBUSB_WIN_DIR)" ] || $(RM) -r "$(LIBUSB_WIN_DIR)"
963 .PHONY: openocd_git_win_install
965 openocd_git_win_install: | $(DL_DIR) $(TOOLS_DIR)
966 openocd_git_win_install: OPENOCD_URL := git://openocd.git.sourceforge.net/gitroot/openocd/openocd
967 openocd_git_win_install: OPENOCD_REV := f1c0133321c8fcadadd10bba5537c0a634eb183b
968 openocd_git_win_install: openocd_win_clean libusb_win_install ftd2xx_install
969 # download the source
970 $(V0) @echo " DOWNLOAD $(OPENOCD_URL) @ $(OPENOCD_REV)"
971 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
972 $(V1) mkdir -p "$(OPENOCD_BUILD_DIR)"
973 $(V1) git clone --no-checkout $(OPENOCD_URL) "$(DL_DIR)/openocd-build"
974 $(V1) ( \
975 cd $(OPENOCD_BUILD_DIR) ; \
976 git checkout -q $(OPENOCD_REV) ; \
979 # apply patches
980 $(V0) @echo " PATCH $(OPENOCD_BUILD_DIR)"
981 $(V1) ( \
982 cd $(OPENOCD_BUILD_DIR) ; \
983 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0001-armv7m-remove-dummy-FP-regs-for-new-gdb.patch ; \
984 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0002-rtos-add-stm32_stlink-to-FreeRTOS-targets.patch ; \
987 # build and install
988 $(V0) @echo " BUILD $(OPENOCD_WIN_DIR)"
989 $(V1) mkdir -p "$(OPENOCD_WIN_DIR)"
990 $(V1) ( \
991 cd $(OPENOCD_BUILD_DIR) ; \
992 ./bootstrap ; \
993 ./configure --enable-maintainer-mode --prefix="$(OPENOCD_WIN_DIR)" \
994 --build=i686-pc-linux-gnu --host=i586-mingw32msvc \
995 CPPFLAGS=-I$(LIBUSB_WIN_DIR)/include \
996 LDFLAGS=-L$(LIBUSB_WIN_DIR)/lib/gcc \
997 --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=$(FTD2XX_DIR) \
998 --disable-werror \
999 --enable-stlink ; \
1000 $(MAKE) ; \
1001 $(MAKE) install ; \
1004 # delete the extracted source when we're done
1005 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1007 .PHONY: openocd_win_clean
1008 openocd_win_clean:
1009 $(V0) @echo " CLEAN $(OPENOCD_WIN_DIR)"
1010 $(V1) [ ! -d "$(OPENOCD_WIN_DIR)" ] || $(RM) -r "$(OPENOCD_WIN_DIR)"
1012 .PHONY: openocd_git_install
1014 openocd_git_install: | $(DL_DIR) $(TOOLS_DIR)
1015 openocd_git_install: OPENOCD_URL := git://openocd.git.sourceforge.net/gitroot/openocd/openocd
1016 openocd_git_install: OPENOCD_REV := f1c0133321c8fcadadd10bba5537c0a634eb183b
1017 openocd_git_install: openocd_clean
1018 # download the source
1019 $(V0) @echo " DOWNLOAD $(OPENOCD_URL) @ $(OPENOCD_REV)"
1020 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1021 $(V1) mkdir -p "$(OPENOCD_BUILD_DIR)"
1022 $(V1) git clone --no-checkout $(OPENOCD_URL) "$(OPENOCD_BUILD_DIR)"
1023 $(V1) ( \
1024 cd $(OPENOCD_BUILD_DIR) ; \
1025 git checkout -q $(OPENOCD_REV) ; \
1028 # apply patches
1029 $(V0) @echo " PATCH $(OPENOCD_DIR)"
1030 $(V1) ( \
1031 cd $(OPENOCD_BUILD_DIR) ; \
1032 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0001-armv7m-remove-dummy-FP-regs-for-new-gdb.patch ; \
1033 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0002-rtos-add-stm32_stlink-to-FreeRTOS-targets.patch ; \
1036 # build and install
1037 $(V0) @echo " BUILD $(OPENOCD_DIR)"
1038 $(V1) mkdir -p "$(OPENOCD_DIR)"
1039 $(V1) ( \
1040 cd $(OPENOCD_BUILD_DIR) ; \
1041 ./bootstrap ; \
1042 ./configure --enable-maintainer-mode --prefix="$(OPENOCD_DIR)" --enable-ft2232_libftdi --enable-buspirate --enable-stlink ; \
1043 $(MAKE) ; \
1044 $(MAKE) install ; \
1047 # delete the extracted source when we're done
1048 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1050 .PHONY: openocd_clean
1051 openocd_clean:
1052 $(V0) @echo " CLEAN $(OPENOCD_DIR)"
1053 $(V1) [ ! -d "$(OPENOCD_DIR)" ] || $(RM) -r "$(OPENOCD_DIR)"
1055 STM32FLASH_DIR := $(TOOLS_DIR)/stm32flash
1056 ifeq ($(UNAME), Windows)
1057 STM32FLASH_BUILD_OPTIONS := "CC=GCC"
1058 endif
1059 .PHONY: stm32flash_install
1060 stm32flash_install: STM32FLASH_URL := https://code.google.com/p/stm32flash/
1061 stm32flash_install: STM32FLASH_REV := a358bd1f025d
1062 stm32flash_install: stm32flash_clean
1063 # download the source
1064 $(V0) @$(ECHO) " DOWNLOAD $(STM32FLASH_URL) @ r$(STM32FLASH_REV)"
1065 $(V1) [ ! -d "$(STM32FLASH_DIR)" ] || $(RM) -rf "$(STM32FLASH_DIR)"
1066 $(V1) $(MKDIR) -p "$(STM32FLASH_DIR)"
1067 $(V1) $(GIT) clone --no-checkout $(STM32FLASH_URL) "$(STM32FLASH_DIR)"
1068 $(V1) ( \
1069 $(CD) $(STM32FLASH_DIR) ; \
1070 $(GIT) checkout -q $(STM32FLASH_REV) ; \
1072 # build
1073 $(V0) @$(ECHO) " BUILD $(STM32FLASH_DIR)"
1074 $(V1) $(MAKE) --silent -C $(STM32FLASH_DIR) all $(STM32FLASH_BUILD_OPTIONS)
1076 .PHONY: stm32flash_clean
1077 stm32flash_clean:
1078 $(V0) @$(ECHO) " CLEAN $(STM32FLASH_DIR)"
1079 $(V1) [ ! -d "$(STM32FLASH_DIR)" ] || $(RM) -rf "$(STM32FLASH_DIR)"
1081 DFUUTIL_DIR := $(TOOLS_DIR)/dfu-util
1083 .PHONY: dfuutil_install
1084 dfuutil_install: DFUUTIL_URL := http://dfu-util.sourceforge.net/releases/dfu-util-0.8.tar.gz
1085 dfuutil_install: DFUUTIL_FILE := $(notdir $(DFUUTIL_URL))
1086 dfuutil_install: | $(DL_DIR) $(TOOLS_DIR)
1087 dfuutil_install: dfuutil_clean
1088 # download the source
1089 $(V0) @echo " DOWNLOAD $(DFUUTIL_URL)"
1090 $(V1) $(CURL) $(CURL_OPTIONS) -o "$(DL_DIR)/$(DFUUTIL_FILE)" "$(DFUUTIL_URL)"
1092 # extract the source
1093 $(V0) @echo " EXTRACT $(DFUUTIL_FILE)"
1094 $(V1) [ ! -d "$(DL_DIR)/dfuutil-build" ] || $(RM) -r "$(DL_DIR)/dfuutil-build"
1095 $(V1) mkdir -p "$(DL_DIR)/dfuutil-build"
1096 $(V1) tar -C $(DL_DIR)/dfuutil-build -xf "$(DL_DIR)/$(DFUUTIL_FILE)"
1098 # build
1099 $(V0) @echo " BUILD $(DFUUTIL_DIR)"
1100 $(V1) mkdir -p "$(DFUUTIL_DIR)"
1101 $(V1) ( \
1102 cd $(DL_DIR)/dfuutil-build/dfu-util-0.8 ; \
1103 ./configure --prefix="$(DFUUTIL_DIR)" ; \
1104 $(MAKE) ; \
1105 $(MAKE) install ; \
1108 .PHONY: dfuutil_clean
1109 dfuutil_clean:
1110 $(V0) @echo " CLEAN $(DFUUTIL_DIR)"
1111 $(V1) [ ! -d "$(DFUUTIL_DIR)" ] || $(RM) -r "$(DFUUTIL_DIR)"
1113 # see http://developer.android.com/sdk/ for latest versions
1114 ANDROID_SDK_DIR := $(TOOLS_DIR)/android-sdk-linux
1115 .PHONY: android_sdk_install
1116 android_sdk_install: ANDROID_SDK_URL := http://dl.google.com/android/android-sdk_r20.0.3-linux.tgz
1117 android_sdk_install: ANDROID_SDK_FILE := $(notdir $(ANDROID_SDK_URL))
1118 # order-only prereq on directory existance:
1119 android_sdk_install: | $(DL_DIR) $(TOOLS_DIR)
1120 android_sdk_install: android_sdk_clean
1121 # download the source only if it's newer than what we already have
1122 $(V0) @echo " DOWNLOAD $(ANDROID_SDK_URL)"
1123 $(V1) $(WGET) --no-check-certificate -N -P "$(DL_DIR)" "$(ANDROID_SDK_URL)"
1125 # binary only release so just extract it
1126 $(V0) @echo " EXTRACT $(ANDROID_SDK_FILE)"
1127 $(V1) tar -C $(TOOLS_DIR) -xf "$(DL_DIR)/$(ANDROID_SDK_FILE)"
1129 .PHONY: android_sdk_clean
1130 android_sdk_clean:
1131 $(V0) @echo " CLEAN $(ANDROID_SDK_DIR)"
1132 $(V1) [ ! -d "$(ANDROID_SDK_DIR)" ] || $(RM) -r $(ANDROID_SDK_DIR)
1134 .PHONY: android_sdk_update
1135 android_sdk_update:
1136 $(V0) @echo " UPDATE $(ANDROID_SDK_DIR)"
1137 $(ANDROID_SDK_DIR)/tools/android update sdk --no-ui -t platform-tools,android-16,addon-google_apis-google-16
1139 #Install git hooks under the right folder
1141 .PHONY: prepare
1142 prepare:
1143 $(V0) @echo " Configuring GIT commit template"
1144 $(V1) $(CD) "$(ROOT_DIR)"
1145 $(V1) $(GIT) config commit.template .commit-template
1147 .PHONY: prepare_clean
1148 prepare_clean:
1149 $(V0) @echo " Cleanup GIT commit template configuration"
1150 $(V1) $(CD) "$(ROOT_DIR)"
1151 $(V1) $(GIT) config --unset commit.template
1153 ##############################
1155 # TODO: these defines will go to tool install sections
1157 ##############################
1159 ifeq ($(shell [ -d "$(OPENOCD_DIR)" ] && $(ECHO) "exists"), exists)
1160 export OPENOCD := $(OPENOCD_DIR)/bin/openocd
1161 else
1162 # not installed, hope it's in the path...
1163 export OPENOCD ?= openocd
1164 endif
1166 ifeq ($(shell [ -d "$(ANDROID_SDK_DIR)" ] && $(ECHO) "exists"), exists)
1167 ANDROID := $(ANDROID_SDK_DIR)/tools/android
1168 ANDROID_DX := $(ANDROID_SDK_DIR)/platform-tools/dx
1169 else
1170 # not installed, hope it's in the path...
1171 ANDROID ?= android
1172 ANDROID_DX ?= dx
1173 endif