Update WHATSNEW.txt for rel-16.09 RC1
[librepilot.git] / make / tools.mk
blobecf0462e031d158c9190c6697e0f62cf0606d418
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 QT_SHORT_VERSION := 5.6
90 QT_VERSION := 5.6.1
92 ifeq ($(UNAME), Linux)
93 ifeq ($(ARCH), x86_64)
94 QT_SDK_ARCH := gcc_64
95 QT_SDK_URL := http://download.qt.io/official_releases/qt/$(QT_SHORT_VERSION)/$(QT_VERSION)/qt-opensource-linux-x64-$(QT_VERSION).run
96 QT_SDK_MD5_URL := http://download.qt.io/official_releases/qt/$(QT_SHORT_VERSION)/$(QT_VERSION)/md5sums.txt
97 OSG_URL := $(TOOLS_URL)/osg-3.5.3-linux-x64-qt-$(QT_VERSION).tar.gz
98 OSGEARTH_URL := $(TOOLS_URL)/osgearth-2.7-linux-x64-qt-$(QT_VERSION).tar.gz
99 else
100 # x32 for linux no longer provided as pre-built binaries.
101 endif
102 UNCRUSTIFY_URL := $(TOOLS_URL)/uncrustify-0.60.tar.gz
103 DOXYGEN_URL := $(TOOLS_URL)/doxygen-1.8.3.1.src.tar.gz
104 else ifeq ($(UNAME), Darwin)
105 QT_SDK_ARCH := clang_64
106 QT_SDK_URL := http://download.qt.io/official_releases/qt/$(QT_SHORT_VERSION)/$(QT_VERSION)/qt-opensource-mac-x64-clang-$(QT_VERSION).dmg
107 QT_SDK_MD5_URL := http://download.qt.io/official_releases/qt/$(QT_SHORT_VERSION)/$(QT_VERSION)/md5sums.txt
108 QT_SDK_MOUNT_DIR := /Volumes/qt-opensource-mac-x64-clang-$(QT_VERSION)
109 QT_SDK_MAINTENANCE_TOOL := /Volumes/qt-opensource-mac-x64-clang-$(QT_VERSION)/qt-opensource-mac-x64-clang-$(QT_VERSION).app/Contents/MacOS/qt-opensource-mac-x64-clang-$(QT_VERSION)
110 UNCRUSTIFY_URL := $(TOOLS_URL)/uncrustify-0.60.tar.gz
111 DOXYGEN_URL := $(TOOLS_URL)/doxygen-1.8.3.1.src.tar.gz
112 OSG_URL := $(TOOLS_URL)/osg-3.5.3-clang_64-qt-$(QT_VERSION).tar.gz
113 OSGEARTH_URL := $(TOOLS_URL)/osgearth-2.7-clang_64-qt-$(QT_VERSION).tar.gz
114 else ifeq ($(UNAME), Windows)
115 QT_SDK_ARCH := mingw492_32
116 QT_SDK_URL := http://download.qt.io/official_releases/qt/$(QT_SHORT_VERSION)/$(QT_VERSION)/qt-opensource-windows-x86-mingw492-$(QT_VERSION).exe
117 QT_SDK_MD5_URL := http://download.qt.io/official_releases/qt/$(QT_SHORT_VERSION)/$(QT_VERSION)/md5sums.txt
118 NSIS_URL := $(TOOLS_URL)/nsis-2.46-unicode.tar.bz2
119 MESAWIN_URL := $(TOOLS_URL)/mesawin.tar.gz
120 UNCRUSTIFY_URL := $(TOOLS_URL)/uncrustify-0.60-windows.tar.bz2
121 DOXYGEN_URL := $(TOOLS_URL)/doxygen-1.8.3.1-windows.tar.bz2
122 endif
124 GTEST_URL := $(TOOLS_URL)/gtest-1.7.0.zip
125 CCACHE_URL := http://samba.org/ftp/ccache/ccache-3.2.2.tar.bz2
126 CCACHE_MD5_URL := $(TOOLS_URL)/ccache-3.2.2.tar.bz2.md5
128 QT_SDK_DIR := $(TOOLS_DIR)/qt-$(QT_VERSION)
129 UNCRUSTIFY_DIR := $(TOOLS_DIR)/uncrustify-0.60
130 DOXYGEN_DIR := $(TOOLS_DIR)/doxygen-1.8.3.1
131 GTEST_DIR := $(TOOLS_DIR)/gtest-1.7.0
132 CCACHE_DIR := $(TOOLS_DIR)/ccache
134 ifeq ($(UNAME), Linux)
135 ifeq ($(ARCH), x86_64)
136 OSG_SDK_DIR := $(TOOLS_DIR)/osg-3.5.3-linux-x64-qt-$(QT_VERSION)
137 OSGEARTH_SDK_DIR := $(TOOLS_DIR)/osgearth-2.7-linux-x64-qt-$(QT_VERSION)
138 else
139 OSG_SDK_DIR := $(TOOLS_DIR)/osg-3.5.3-linux-x86-qt-$(QT_VERSION)
140 OSGEARTH_SDK_DIR := $(TOOLS_DIR)/osgearth-2.7-linux-x86-qt-$(QT_VERSION)
141 endif
142 else ifeq ($(UNAME), Darwin)
143 OSG_SDK_DIR := $(TOOLS_DIR)/osg-3.5.3-clang_64-qt-$(QT_VERSION)
144 OSGEARTH_SDK_DIR := $(TOOLS_DIR)/osgearth-2.7-clang_64-qt-$(QT_VERSION)
145 else ifeq ($(UNAME), Windows)
146 ifeq ($(ARCH), x86_64)
147 MINGW_DIR := /mingw64
148 else
149 MINGW_DIR := /mingw32
150 endif
151 # When changing PYTHON_DIR, you must also update it in ground/gcs/src/python.pri
152 PYTHON_DIR := $(MINGW_DIR)/bin
153 OSG_SDK_DIR := $(MINGW_DIR)
154 OSGEARTH_SDK_DIR := $(MINGW_DIR)
155 NSIS_DIR := $(TOOLS_DIR)/nsis-2.46-unicode
156 MESAWIN_DIR := $(TOOLS_DIR)/mesawin
157 endif
159 ##############################
161 # Build only and all toolchains available for the platform
163 ##############################
165 BUILD_SDK_TARGETS := arm_sdk
166 ifeq ($(UNAME), Windows)
167 BUILD_SDK_TARGETS += nsis mesawin
168 endif
169 ifeq ($(UNAME), Darwin)
170 BUILD_SDK_TARGETS += qt_sdk osg
171 endif
172 ALL_SDK_TARGETS := $(BUILD_SDK_TARGETS) gtest uncrustify doxygen
174 define GROUP_SDK_TEMPLATE
175 .PHONY: $(1)_install $(1)_clean $(1)_distclean $(1)_version
176 $(1)_install: $(addsuffix _install,$(2))
177 $(1)_clean: $(addsuffix _clean,$(2))
178 $(1)_distclean: $(addsuffix _distclean,$(2))
179 $(1)_version: $(addsuffix _version,$(2))
180 endef
182 $(eval $(call GROUP_SDK_TEMPLATE,build_sdk,$(BUILD_SDK_TARGETS)))
183 $(eval $(call GROUP_SDK_TEMPLATE,all_sdk,$(ALL_SDK_TARGETS)))
185 ##############################
187 # Misc host tools
189 ##############################
191 # Used by other makefiles
192 export MKDIR := mkdir
193 export CP := cp
194 export RM := rm
195 export LN := ln
196 export CAT := cat
197 export CUT := cut
198 export SED := sed
200 # Used only by this Makefile
201 GIT := git
202 CURL := curl
203 TAR := tar
204 UNZIP := unzip
205 ZIP := gzip
206 OPENSSL := openssl
207 ANT := ant
208 JAVAC := javac
209 JAR := jar
210 CD := cd
211 GREP := grep
212 CMAKE := cmake
213 ifneq ($(UNAME), Windows)
214 SEVENZIP := 7za
215 else
216 SEVENZIP := 7za.exe
217 ifneq ($(shell $(SEVENZIP) --version >/dev/null 2>&1 && $(ECHO) "found"), found)
218 # no $(SEVENZIP) found in path. hope is in bin...
219 SEVENZIP = $(TOOLS_DIR)/bin/7za.exe
220 endif
221 endif
222 ifneq ($(UNAME), Windows)
223 MAKE := make
224 else
225 MAKE := mingw32-make
226 endif
228 # Echo in recipes is a bit tricky in a Windows Git Bash window in some cases.
229 # It does not work if make started under msysGit installed into a path with spaces.
230 ifneq ($(UNAME), Windows)
231 export ECHO := echo
232 else
233 # export ECHO := $(PYTHON) -c "import sys; print(' '.join(sys.argv[1:]))"
234 export ECHO := echo
235 endif
237 # Test if quotes are needed for the echo command
238 ifeq ($(shell $(ECHO) "test"), test)
239 export QUOTE := '
240 # This line is just to clear out the single quote above '
241 else
242 export QUOTE :=
243 endif
245 # Command to extract version info data from the repository and source tree
246 export VERSION_INFO = $(PYTHON) $(ROOT_DIR)/make/scripts/version-info.py --path=$(ROOT_DIR)
248 export CCACHE
250 ##############################
252 # Misc settings
254 ##############################
256 # Define messages
257 MSG_VERIFYING = $(QUOTE) VERIFY $(QUOTE)
258 MSG_DOWNLOADING = $(QUOTE) DOWNLOAD $(QUOTE)
259 MSG_CHECKSUMMING = $(QUOTE) MD5 $(QUOTE)
260 MSG_EXTRACTING = $(QUOTE) EXTRACT $(QUOTE)
261 MSG_CONFIGURING = $(QUOTE) CONFIGURE $(QUOTE)
262 MSG_BUILDING = $(QUOTE) BUILD $(QUOTE)
263 MSG_INSTALLING = $(QUOTE) INSTALL $(QUOTE)
264 MSG_CLEANING = $(QUOTE) CLEAN $(QUOTE)
265 MSG_DISTCLEANING = $(QUOTE) DISTCLEAN $(QUOTE)
266 MSG_NOTICE = $(QUOTE) NOTE $(QUOTE)
268 # Verbosity level
269 ifeq ($(V), 1)
270 MAKE_SILENT :=
271 UNZIP_SILENT :=
272 else
273 MAKE_SILENT := --silent
274 UNZIP_SILENT := -q
275 endif
277 # Batch mode
278 ifeq ($(BATCH), 1)
279 CURL_OPTIONS := --silent -L
280 else
281 CURL_OPTIONS := -L
282 endif
284 # MSYS tar workaround
285 ifeq ($(UNAME), Windows)
286 TAR_OPTIONS := --force-local
287 else
288 TAR_OPTIONS :=
289 endif
291 # Print some useful notes for *_install targets
292 ifneq ($(strip $(filter $(addsuffix _install,all_sdk $(ALL_SDK_TARGETS)),$(MAKECMDGOALS))),)
293 ifneq ($(shell $(CURL) --version >/dev/null 2>&1 && $(ECHO) "found"), found)
294 $(error Please install curl first ('apt-get install curl' or similar))
295 endif
296 $(info $(EMPTY) NOTE Use 'make all_sdk_distclean' to remove installation files)
297 $(info $(EMPTY) NOTE Use 'make all_sdk_version' to check toolchain versions)
298 $(info $(EMPTY) NOTE Add 'V=1' to make command line to diagnose make problems)
299 $(info $(EMPTY) NOTE Add 'BATCH=1' to make command line to disable progress reporting during downloads)
300 endif
302 ##############################
304 # Cross-platform MD5 check template
305 # $(1) = file name without quotes
306 # $(2) = string compare operator, e.g. = or !=
308 ##############################
310 define MD5_CHECK_TEMPLATE
311 "`test -f \"$(1)\" && $(OPENSSL) dgst -md5 \"$(1)\" | $(CUT) -f2 -d' '`" $(2) "`$(GREP) $(notdir $(1)) $(1).md5 | $(CUT) -f1 -d' '`"
312 endef
314 ##############################
316 # Cross-platform MD5 generation template
317 # $(1) = file name without quotes
319 ##############################
321 ifeq ($(UNAME), Darwin)
323 define MD5_GEN_TEMPLATE
324 md5 -r $(1) > $(1).md5
325 endef
327 else
329 define MD5_GEN_TEMPLATE
330 $(OPENSSL) dgst -r -md5 $(1) > $(1).md5
331 endef
333 endif
335 ##############################
337 # Cross platform download template
338 # $(1) = Package URL
339 # $(2) = Package file
340 # $(3) = URL for .md5 file to be tested against Package
342 ##############################
344 define DOWNLOAD_TEMPLATE
345 @$(ECHO) $(MSG_VERIFYING) $$(call toprel, $(DL_DIR)/$(2))
346 $(V1) ( \
347 cd "$(DL_DIR)" && \
348 $(CURL) $(CURL_OPTIONS) --silent -o "$(DL_DIR)/$(2).md5" "$(3)" && \
349 if [ $(call MD5_CHECK_TEMPLATE,$(DL_DIR)/$(2),!=) ]; then \
350 $(ECHO) $(MSG_DOWNLOADING) $(1) && \
351 $(CURL) $(CURL_OPTIONS) -o "$(DL_DIR)/$(2)" "$(1)" && \
352 $(ECHO) $(MSG_CHECKSUMMING) $$(call toprel, $(DL_DIR)/$(2)) && \
353 [ $(call MD5_CHECK_TEMPLATE,$(DL_DIR)/$(2),=) ]; \
354 fi; \
356 endef
358 ##############################
360 # Common tool install template
361 # $(1) = tool name
362 # $(2) = tool extract/build directory
363 # $(3) = tool distribution URL
364 # $(4) = tool distribution MD5 URL
365 # $(5) = tool distribution file
366 # $(6) = optional extra build recipes template
367 # $(7) = optional extra clean recipes template
369 ##############################
371 define TOOL_INSTALL_TEMPLATE
373 .PHONY: $(addprefix $(1)_, install clean distclean)
375 $(1)_install: $(1)_clean | $(DL_DIR) $(TOOLS_DIR)
377 $(if $(4), $(call DOWNLOAD_TEMPLATE,$(3),$(5),$(4)),$(call DOWNLOAD_TEMPLATE,$(3),$(5),"$(3).md5"))
379 @$(ECHO) $(MSG_EXTRACTING) $$(call toprel, $(2))
380 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(2)))
382 $(if $(filter $(suffix $(5)), .zip),
383 $(V1) $(UNZIP) $(UNZIP_SILENT) -d $$(call toprel, $(dir $(2))) $$(call toprel, $(DL_DIR)/$(5)),
384 $(V1) $(TAR) $(TAR_OPTIONS) -C $$(call toprel, $(dir $(2))) -xf $$(call toprel, $(DL_DIR)/$(5))
387 $(6)
389 $(1)_clean:
390 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(2))
391 $(V1) [ ! -d "$(2)" ] || $(RM) -rf "$(2)"
393 $(7)
395 $(1)_distclean:
396 @$(ECHO) $(MSG_DISTCLEANING) $$(call toprel, $(DL_DIR)/$(5))
397 $(V1) [ ! -f "$(DL_DIR)/$(5)" ] || $(RM) "$(DL_DIR)/$(5)"
398 $(V1) [ ! -f "$(DL_DIR)/$(5).md5" ] || $(RM) "$(DL_DIR)/$(5).md5"
400 endef
402 ##############################
404 # ARM SDK
406 ##############################
407 export ARM_SDK_PREFIX := arm-none-eabi-
408 ARM_SDK_TOOL := gcc-arm-none-eabi
410 .PHONY: arm_sdk_install
411 arm_sdk_install: $(ARM_SDK_TOOL)_install
413 .PHONY: arm_sdk_clean
414 arm_sdk_clean: $(ARM_SDK_TOOL)_remove
416 .PHONY: arm_sdk_version
417 arm_sdk_version:
418 -$(V1) $(ARM_SDK_PREFIX)gcc --version | head -n1
420 # Template to check ARM toolchain version before building targets
421 define ARM_GCC_VERSION_CHECK_TEMPLATE
422 if ! $(ARM_SDK_PREFIX)gcc --version --specs=nano.specs >/dev/null 2>&1; then \
423 $(ECHO) $(MSG_NOTICE) Please install ARM toolchain 4.8 2014q1 using \'make arm_sdk_install\' && \
424 $(ECHO) $(MSG_NOTICE) Older ARM SDKs do not support new \'--specs=nano.specs\' option && \
425 exit 1; \
427 endef
429 ##############################
431 # Qt install template
432 # $(1) = tool install directory
433 # $(2) = tool distribution URL
434 # $(3) = tool distribution .md5 URL
435 # $(4) = tool distribution file
436 # $(5) = Qt architecture
437 # $(6) = optional extra build recipes template
438 # $(7) = optional extra clean recipes template
440 ##############################
442 define QT_INSTALL_TEMPLATE
444 .PHONY: $(addprefix qt_sdk_, install clean distclean)
446 qt_sdk_install: qt_sdk_clean | $(DL_DIR) $(TOOLS_DIR)
447 $(call DOWNLOAD_TEMPLATE,$(2),$(4),"$(3)")
448 # Silently install Qt under tools directory
449 @$(ECHO) $(MSG_EXTRACTING) $(4) to $$(call toprel, $(1))
450 $(V1) ( export QT_INSTALL_TARGET_DIR=$(1) && \
451 chmod +x $(DL_DIR)/$(4) && \
452 $(DL_DIR)/$(4) --script $(ROOT_DIR)/make/tool_install/qt-install.qs ; \
454 # Execute post build templates
455 $(6)
457 qt_sdk_clean:
458 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
459 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
460 $(7)
462 qt_sdk_distclean:
463 @$(ECHO) $(MSG_DISTCLEANING) $$(call toprel, $(DL_DIR)/$(4))
464 $(V1) [ ! -f "$(DL_DIR)/$(4)" ] || $(RM) "$(DL_DIR)/$(4)"
465 $(V1) [ ! -f "$(DL_DIR)/$(4).md5" ] || $(RM) "$(DL_DIR)/$(4).md5"
467 endef
469 ##############################
471 # Mac QT install template
472 # $(1) = tool install directory
473 # $(2) = tool distribution URL
474 # $(3) = tool distribution .md5 URL
475 # $(4) = tool distribution file
476 # $(5) = QT architecture
477 # $(6) = optional extra build recipes template
478 # $(7) = optional extra clean recipes template
480 ##############################
482 define MAC_QT_INSTALL_TEMPLATE
484 .PHONY: $(addprefix qt_sdk_, install clean distclean)
486 qt_sdk_install: qt_sdk_clean | $(DL_DIR) $(TOOLS_DIR)
487 $(call DOWNLOAD_TEMPLATE,$(2),$(4),"$(3)")
488 # Mount .dmg file
489 $(V1) hdiutil attach -nobrowse $(DL_DIR)/$(4)
490 # Silently install Qt under tools directory
491 @$(ECHO) $(MSG_EXTRACTING) $(4) to $$(call toprel, $(1))
492 $(V1) ( export QT_INSTALL_TARGET_DIR=$(1) && \
493 $(QT_SDK_MAINTENANCE_TOOL) --script $(ROOT_DIR)/make/tool_install/qt-install.qs ; \
495 # Unmount the .dmg file
496 $(V1) hdiutil detach $(QT_SDK_MOUNT_DIR)
497 # Execute post build templates
498 $(6)
500 qt_sdk_clean:
501 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
502 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
503 $(7)
505 endef
507 ##############################
509 # Qt SDK
511 ##############################
513 ifeq ($(UNAME), Windows)
515 QT_SDK_PREFIX := $(QT_SDK_DIR)/$(QT_SHORT_VERSION)/$(QT_SDK_ARCH)
516 $(eval $(call QT_INSTALL_TEMPLATE,$(QT_SDK_DIR),$(QT_SDK_URL),$(QT_SDK_MD5_URL),$(notdir $(QT_SDK_URL)),$(QT_SDK_ARCH)))
518 else ifeq ($(UNAME), Linux)
520 QT_SDK_PREFIX := "$(QT_SDK_DIR)/$(QT_SHORT_VERSION)/$(QT_SDK_ARCH)"
521 $(eval $(call QT_INSTALL_TEMPLATE,$(QT_SDK_DIR),$(QT_SDK_URL),$(QT_SDK_MD5_URL),$(notdir $(QT_SDK_URL)),$(QT_SDK_ARCH)))
523 else ifeq ($(UNAME), Darwin)
525 QT_SDK_PREFIX := "$(QT_SDK_DIR)/$(QT_SHORT_VERSION)/$(QT_SDK_ARCH)"
526 $(eval $(call MAC_QT_INSTALL_TEMPLATE,$(QT_SDK_DIR),$(QT_SDK_URL),$(QT_SDK_MD5_URL),$(notdir $(QT_SDK_URL)),$(QT_SDK_ARCH)))
528 else
530 QT_SDK_PREFIX := $(QT_SDK_DIR)
532 .PHONY: qt_sdk_install
533 qt_sdk_install:
534 @$(ECHO) $(MSG_NOTICE) --------------------------------------------------------
535 @$(ECHO) $(MSG_NOTICE) Please install native Qt 5.6.x SDK using package manager
536 @$(ECHO) $(MSG_NOTICE) --------------------------------------------------------
538 .PHONY: qt_sdk_clean
539 qt_sdk_clean:
541 .PHONY: qt_sdk_distclean
542 qt_sdk_distclean:
544 endif
546 ifeq ($(shell [ -d "$(QT_SDK_DIR)" ] && $(ECHO) "exists"), exists)
547 export QMAKE := $(QT_SDK_PREFIX)/bin/qmake
549 # set Qt library search path
550 ifeq ($(UNAME), Windows)
551 export PATH := $(QT_SDK_PREFIX)/bin:$(PATH)
552 else
553 export LD_LIBRARY_PATH := $(QT_SDK_DIR)/lib:$(LD_LIBRARY_PATH)
554 endif
555 else
556 OPT_QT := qt56
557 OPT_QT_ENV_SH := /opt/$(OPT_QT)/bin/$(OPT_QT)-env.sh
558 ifneq ($(wildcard $(OPT_QT_ENV_SH)),)
559 SHELL := /bin/bash
560 QMAKE := . $(OPT_QT_ENV_SH) && qmake
561 else
562 # not installed, hope it's in the path...
563 QMAKE := qmake
564 endif
565 endif
567 .PHONY: qt_sdk_version
568 qt_sdk_version:
569 -$(V1) $(QMAKE) --version | tail -1
571 ##############################
573 # MinGW
575 ##############################
577 ifeq ($(UNAME), Windows)
579 ifeq ($(shell [ -d "$(MINGW_DIR)" ] && $(ECHO) "exists"), exists)
580 # set MinGW binary and library paths (QTMINGW is used by qmake, do not rename)
581 export QTMINGW := $(MINGW_DIR)/bin
582 export PATH := $(QTMINGW):$(PATH)
583 else
584 # not installed, use host gcc compiler
585 # $(info $(EMPTY) WARNING $(call toprel, $(MINGW_DIR)) not found, using system PATH)
586 endif
588 .PHONY: mingw_version
589 mingw_version: gcc_version
591 endif
593 .PHONY: gcc_version
594 gcc_version:
595 -$(V1) gcc --version | head -n1
597 all_sdk_version: gcc_version
599 ##############################
601 # Python
603 ##############################
605 ifeq ($(shell [ -d "$(PYTHON_DIR)" ] && $(ECHO) "exists"), exists)
606 export PYTHON := $(PYTHON_DIR)/python
607 export PATH := $(PYTHON_DIR):$(PATH)
608 else
609 # not installed, hope it's in the path...
610 # $(info $(EMPTY) WARNING $(call toprel, $(PYTHON_DIR)) not found, using system PATH)
611 ifeq ($(findstring Python 2,$(shell python --version 2>&1)), Python 2)
612 export PYTHON := python
613 else
614 export PYTHON := python2
615 endif
616 endif
618 .PHONY: python_version
619 python_version:
620 -$(V1) $(PYTHON) --version
622 ##############################
624 # NSIS Unicode (Windows only)
626 ##############################
628 ifeq ($(UNAME), Windows)
630 $(eval $(call TOOL_INSTALL_TEMPLATE,nsis,$(NSIS_DIR),$(NSIS_URL),,$(notdir $(NSIS_URL))))
632 ifeq ($(shell [ -d "$(NSIS_DIR)" ] && $(ECHO) "exists"), exists)
633 export NSIS := $(NSIS_DIR)/makensis
634 else
635 # not installed, hope it's in the path...
636 # $(info $(EMPTY) WARNING $(call toprel, $(NSIS_DIR)) not found (make nsis_install), using system PATH)
637 export NSIS ?= makensis
638 endif
640 .PHONY: nsis_version
641 nsis_version:
642 -$(V1) $(NSIS) | head -n1
644 endif
646 ##################################
648 # Mesa OpenGL DLL (Windows only)
650 ##################################
652 ifeq ($(UNAME), Windows)
654 $(eval $(call TOOL_INSTALL_TEMPLATE,mesawin,$(MESAWIN_DIR),$(MESAWIN_URL),,$(notdir $(MESAWIN_URL))))
656 ifeq ($(shell [ -d "$(MESAWIN_DIR)" ] && $(ECHO) "exists"), exists)
657 export MESAWIN_DIR := $(MESAWIN_DIR)
658 else
659 # not installed, hope it's in the path...
660 #$(info $(EMPTY) WARNING $(call toprel, $(MESA_WIN_DIR)) not found (make mesawin_install), using system PATH)
661 endif
663 .PHONY: mesawin_version
664 mesawin_version:
665 -$(V1) $(ECHO) "MesaOpenGL vXX"
667 endif
669 ##############################
671 # Uncrustify
673 ##############################
675 ifeq ($(UNAME), Windows)
677 $(eval $(call TOOL_INSTALL_TEMPLATE,uncrustify,$(UNCRUSTIFY_DIR),$(UNCRUSTIFY_URL),,$(notdir $(UNCRUSTIFY_URL))))
679 else # Linux or Mac
681 UNCRUSTIFY_BUILD_DIR := $(BUILD_DIR)/$(notdir $(UNCRUSTIFY_DIR))
683 define UNCRUSTIFY_BUILD_TEMPLATE
684 $(V1) ( \
685 $(ECHO) $(MSG_CONFIGURING) $(call toprel, $(UNCRUSTIFY_BUILD_DIR)) && \
686 cd $(UNCRUSTIFY_BUILD_DIR) && \
687 ./configure --prefix="$(UNCRUSTIFY_DIR)" && \
688 $(ECHO) $(MSG_BUILDING) $(call toprel, $(UNCRUSTIFY_BUILD_DIR)) && \
689 $(MAKE) $(MAKE_SILENT) && \
690 $(ECHO) $(MSG_INSTALLING) $(call toprel, $(UNCRUSTIFY_DIR)) && \
691 $(MAKE) $(MAKE_SILENT) install-strip \
693 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(UNCRUSTIFY_BUILD_DIR))
694 -$(V1) [ ! -d "$(UNCRUSTIFY_BUILD_DIR)" ] || $(RM) -rf "$(UNCRUSTIFY_BUILD_DIR)"
695 endef
697 define UNCRUSTIFY_CLEAN_TEMPLATE
698 -$(V1) [ ! -d "$(UNCRUSTIFY_DIR)" ] || $(RM) -rf "$(UNCRUSTIFY_DIR)"
699 endef
701 $(eval $(call TOOL_INSTALL_TEMPLATE,uncrustify,$(UNCRUSTIFY_BUILD_DIR),$(UNCRUSTIFY_URL),,$(notdir $(UNCRUSTIFY_URL)),$(UNCRUSTIFY_BUILD_TEMPLATE),$(UNCRUSTIFY_CLEAN_TEMPLATE)))
703 endif
705 ifeq ($(shell [ -d "$(UNCRUSTIFY_DIR)" ] && $(ECHO) "exists"), exists)
706 export UNCRUSTIFY := $(UNCRUSTIFY_DIR)/bin/uncrustify
707 else
708 # not installed, hope it's in the path...
709 # $(info $(EMPTY) WARNING $(call toprel, $(UNCRUSTIFY_DIR)) not found (make uncrustify_install), using system PATH)
710 export UNCRUSTIFY := uncrustify
711 endif
713 .PHONY: uncrustify_version
714 uncrustify_version:
715 -$(V1) $(UNCRUSTIFY) --version
717 ##############################
719 # Doxygen
721 ##############################
723 ifeq ($(UNAME), Windows)
725 $(eval $(call TOOL_INSTALL_TEMPLATE,doxygen,$(DOXYGEN_DIR),$(DOXYGEN_URL),,$(notdir $(DOXYGEN_URL))))
727 else # Linux or Mac
729 DOXYGEN_BUILD_DIR := $(BUILD_DIR)/$(notdir $(DOXYGEN_DIR))
731 define DOXYGEN_BUILD_TEMPLATE
732 $(V1) ( \
733 $(ECHO) $(MSG_CONFIGURING) $(call toprel, $(DOXYGEN_BUILD_DIR)) && \
734 cd $(DOXYGEN_BUILD_DIR) && \
735 ./configure --prefix "$(DOXYGEN_DIR)" --english-only && \
736 $(ECHO) $(MSG_BUILDING) $(call toprel, $(DOXYGEN_BUILD_DIR)) && \
737 $(MAKE) $(MAKE_SILENT) && \
738 $(ECHO) $(MSG_INSTALLING) $(call toprel, $(DOXYGEN_DIR)) && \
739 $(MAKE) $(MAKE_SILENT) install \
741 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(DOXYGEN_BUILD_DIR))
742 -$(V1) [ ! -d "$(DOXYGEN_BUILD_DIR)" ] || $(RM) -rf "$(DOXYGEN_BUILD_DIR)"
743 endef
745 define DOXYGEN_CLEAN_TEMPLATE
746 -$(V1) [ ! -d "$(DOXYGEN_DIR)" ] || $(RM) -rf "$(DOXYGEN_DIR)"
747 endef
749 $(eval $(call TOOL_INSTALL_TEMPLATE,doxygen,$(DOXYGEN_BUILD_DIR),$(DOXYGEN_URL),,$(notdir $(DOXYGEN_URL)),$(DOXYGEN_BUILD_TEMPLATE),$(DOXYGEN_CLEAN_TEMPLATE)))
751 endif
753 ifeq ($(shell [ -d "$(DOXYGEN_DIR)" ] && $(ECHO) "exists"), exists)
754 export DOXYGEN := $(DOXYGEN_DIR)/bin/doxygen
755 else
756 # not installed, hope it's in the path...
757 # $(info $(EMPTY) WARNING $(call toprel, $(DOXYGEN_DIR)) not found (make doxygen_install), using system PATH)
758 export DOXYGEN := doxygen
759 endif
761 .PHONY: doxygen_version
762 doxygen_version:
763 -$(V1) $(ECHO) "Doxygen `$(DOXYGEN) --version`"
765 ##############################
767 # GoogleTest
769 ##############################
771 $(eval $(call TOOL_INSTALL_TEMPLATE,gtest,$(GTEST_DIR),$(GTEST_URL),,$(notdir $(GTEST_URL))))
773 export GTEST_DIR
775 .PHONY: gtest_version
776 gtest_version:
777 -$(V1) $(SED) -n "s/^PACKAGE_STRING='\(.*\)'/\1/p" < $(GTEST_DIR)/configure
779 ##############################
781 # CCACHE
783 ##############################
785 CCACHE_BUILD_DIR := $(BUILD_DIR)/ccache-3.2.2
787 define CCACHE_BUILD_TEMPLATE
788 $(V1) ( \
789 $(ECHO) $(MSG_CONFIGURING) $(call toprel, $(CCACHE_BUILD_DIR)) && \
790 cd $(CCACHE_BUILD_DIR) && \
791 ./configure --prefix="$(CCACHE_DIR)" && \
792 $(ECHO) $(MSG_BUILDING) $(call toprel, $(CCACHE_BUILD_DIR)) && \
793 $(MAKE) $(MAKE_SILENT) && \
794 $(ECHO) $(MSG_INSTALLING) $(call toprel, $(CCACHE_DIR)) && \
795 $(MAKE) $(MAKE_SILENT) install \
797 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(CCACHE_BUILD_DIR))
798 -$(V1) [ ! -d "$(CCACHE_BUILD_DIR)" ] || $(RM) -rf "$(CCACHE_BUILD_DIR)"
800 @$(ECHO)
801 @$(ECHO) "Setting up CCACHE configuration:"
803 $(V1) [ -d "$(ROOT_DIR)/.ccache" ] || mkdir $(ROOT_DIR)/.ccache
804 $(V1) [ -d "$(CCACHE_DIR)/etc" ] || mkdir $(CCACHE_DIR)/etc
806 $(V1) $(ECHO) $(QUOTE)cache_dir = $(ROOT_DIR)/.ccache $(QUOTE) > $(CCACHE_DIR)/etc/ccache.conf
807 $(V1) $(ECHO) $(QUOTE)max_size = 250M$(QUOTE) >> $(CCACHE_DIR)/etc/ccache.conf
808 $(V1) $(CAT) $(CCACHE_DIR)/etc/ccache.conf
809 endef
811 define CCACHE_CLEAN_TEMPLATE
812 -$(V1) [ ! -d "$(CCACHE_DIR)" ] || $(RM) -rf "$(CCACHE_DIR)"
813 endef
815 $(eval $(call TOOL_INSTALL_TEMPLATE,ccache,$(CCACHE_BUILD_DIR),$(CCACHE_URL),$(CCACHE_MD5_URL),$(notdir $(CCACHE_URL)),$(CCACHE_BUILD_TEMPLATE),$(CCACHE_CLEAN_TEMPLATE)))
817 ##############################
819 # osg
821 ##############################
823 ifneq ($(UNAME), Windows)
825 $(eval $(call TOOL_INSTALL_TEMPLATE,osg,$(OSG_SDK_DIR),$(OSG_URL),,$(notdir $(OSG_URL))))
827 endif
829 ifeq ($(shell [ -d "$(OSG_SDK_DIR)" ] && $(ECHO) "exists"), exists)
830 export OSG_SDK_DIR := $(OSG_SDK_DIR)
831 else
832 # not installed, hope it's in the path...
833 # $(info $(EMPTY) WARNING $(call toprel, $(OSG_SDK_DIR)) not found (make osg_install), using system PATH)
834 endif
836 .PHONY: osg_version
837 osg_version:
838 -$(V1) $(ECHO) "`$(OSG_SDK_DIR)/bin/osgversion`"
840 ##############################
842 # osgearth
844 ##############################
846 ifneq ($(UNAME), Windows)
848 $(eval $(call TOOL_INSTALL_TEMPLATE,osgearth,$(OSGEARTH_SDK_DIR),$(OSGEARTH_URL),,$(notdir $(OSGEARTH_URL))))
850 endif
852 ifeq ($(shell [ -d "$(OSGEARTH_SDK_DIR)" ] && $(ECHO) "exists"), exists)
853 export OSGEARTH_SDK_DIR := $(OSGEARTH_SDK_DIR)
854 else
855 # not installed, hope it's in the path...
856 # $(info $(EMPTY) WARNING $(call toprel, $(OSGEARTH_SDK_DIR)) not found (make osgearth_install), using system PATH)
857 endif
859 .PHONY: osgearth_version
860 osgearth_version:
861 -$(V1) $(ECHO) "`$(OSGEARTH_SDK_DIR)/bin/osgearth_version`"
863 ##############################
865 # TODO: code below is not revised yet
867 ##############################
869 # Set up openocd tools
870 OPENOCD_DIR := $(TOOLS_DIR)/openocd
871 OPENOCD_WIN_DIR := $(TOOLS_DIR)/openocd_win
872 OPENOCD_BUILD_DIR := $(DL_DIR)/openocd-build
874 .PHONY: openocd_install
875 openocd_install: | $(DL_DIR) $(TOOLS_DIR)
876 openocd_install: OPENOCD_URL := http://sourceforge.net/projects/openocd/files/openocd/0.6.1/openocd-0.6.1.tar.bz2/download
877 openocd_install: OPENOCD_FILE := openocd-0.6.1.tar.bz2
878 openocd_install: openocd_clean
879 # download the source only if it's newer than what we already have
880 $(V1) $(WGET) -N -P "$(DL_DIR)" --trust-server-name "$(OPENOCD_URL)"
882 # extract the source
883 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -r "$(OPENOCD_BUILD_DIR)"
884 $(V1) mkdir -p "$(OPENOCD_BUILD_DIR)"
885 $(V1) tar -C $(OPENOCD_BUILD_DIR) -xjf "$(DL_DIR)/$(OPENOCD_FILE)"
887 # apply patches
888 $(V0) @echo " PATCH $(OPENOCD_DIR)"
889 $(V1) ( \
890 cd $(OPENOCD_BUILD_DIR)/openocd-0.6.1 ; \
891 patch -p1 < $(ROOT_DIR)/flight/Project/OpenOCD/0001-armv7m-remove-dummy-FP-regs-for-new-gdb.patch ; \
892 patch -p1 < $(ROOT_DIR)/flight/Project/OpenOCD/0002-rtos-add-stm32_stlink-to-FreeRTOS-targets.patch ; \
895 # build and install
896 $(V1) mkdir -p "$(OPENOCD_DIR)"
897 $(V1) ( \
898 cd $(OPENOCD_BUILD_DIR)/openocd-0.6.1 ; \
899 ./configure --prefix="$(OPENOCD_DIR)" --enable-ft2232_libftdi --enable-stlink ; \
900 $(MAKE) --silent ; \
901 $(MAKE) --silent install ; \
904 # delete the extracted source when we're done
905 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
907 .PHONY: ftd2xx_install
909 FTD2XX_DIR := $(DL_DIR)/ftd2xx
911 ftd2xx_install: | $(DL_DIR)
912 ftd2xx_install: FTD2XX_URL := http://www.ftdichip.com/Drivers/CDM/Beta/CDM20817.zip
913 ftd2xx_install: FTD2XX_FILE := CDM20817.zip
914 ftd2xx_install: ftd2xx_clean
915 # download the file only if it's newer than what we already have
916 $(V0) @echo " DOWNLOAD $(FTD2XX_URL)"
917 $(V1) $(WGET) -q -N -P "$(DL_DIR)" "$(FTD2XX_URL)"
919 # extract the source
920 $(V0) @echo " EXTRACT $(FTD2XX_FILE) -> $(FTD2XX_DIR)"
921 $(V1) mkdir -p "$(FTD2XX_DIR)"
922 $(V1) unzip -q -d "$(FTD2XX_DIR)" "$(DL_DIR)/$(FTD2XX_FILE)"
924 .PHONY: ftd2xx_clean
925 ftd2xx_clean:
926 $(V0) @echo " CLEAN $(FTD2XX_DIR)"
927 $(V1) [ ! -d "$(FTD2XX_DIR)" ] || $(RM) -r "$(FTD2XX_DIR)"
929 .PHONY: ftd2xx_install
931 LIBUSB_WIN_DIR := $(DL_DIR)/libusb-win32-bin-1.2.6.0
933 libusb_win_install: | $(DL_DIR)
934 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
935 libusb_win_install: LIBUSB_WIN_FILE := libusb-win32-bin-1.2.6.0.zip
936 libusb_win_install: libusb_win_clean
937 # download the file only if it's newer than what we already have
938 $(V0) @echo " DOWNLOAD $(LIBUSB_WIN_URL)"
939 $(V1) $(WGET) -q -N -P "$(DL_DIR)" --trust-server-name "$(LIBUSB_WIN_URL)"
941 # extract the source
942 $(V0) @echo " EXTRACT $(LIBUSB_WIN_FILE) -> $(LIBUSB_WIN_DIR)"
943 $(V1) mkdir -p "$(LIBUSB_WIN_DIR)"
944 $(V1) unzip -q -d "$(DL_DIR)" "$(DL_DIR)/$(LIBUSB_WIN_FILE)"
946 # fixup .h file needed by openocd build
947 $(V0) @echo " FIXUP $(LIBUSB_WIN_DIR)"
948 $(V1) ln -s "$(LIBUSB_WIN_DIR)/include/lusb0_usb.h" "$(LIBUSB_WIN_DIR)/include/usb.h"
950 .PHONY: libusb_win_clean
951 libusb_win_clean:
952 $(V0) @echo " CLEAN $(LIBUSB_WIN_DIR)"
953 $(V1) [ ! -d "$(LIBUSB_WIN_DIR)" ] || $(RM) -r "$(LIBUSB_WIN_DIR)"
955 .PHONY: openocd_git_win_install
957 openocd_git_win_install: | $(DL_DIR) $(TOOLS_DIR)
958 openocd_git_win_install: OPENOCD_URL := git://openocd.git.sourceforge.net/gitroot/openocd/openocd
959 openocd_git_win_install: OPENOCD_REV := f1c0133321c8fcadadd10bba5537c0a634eb183b
960 openocd_git_win_install: openocd_win_clean libusb_win_install ftd2xx_install
961 # download the source
962 $(V0) @echo " DOWNLOAD $(OPENOCD_URL) @ $(OPENOCD_REV)"
963 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
964 $(V1) mkdir -p "$(OPENOCD_BUILD_DIR)"
965 $(V1) git clone --no-checkout $(OPENOCD_URL) "$(DL_DIR)/openocd-build"
966 $(V1) ( \
967 cd $(OPENOCD_BUILD_DIR) ; \
968 git checkout -q $(OPENOCD_REV) ; \
971 # apply patches
972 $(V0) @echo " PATCH $(OPENOCD_BUILD_DIR)"
973 $(V1) ( \
974 cd $(OPENOCD_BUILD_DIR) ; \
975 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0001-armv7m-remove-dummy-FP-regs-for-new-gdb.patch ; \
976 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0002-rtos-add-stm32_stlink-to-FreeRTOS-targets.patch ; \
979 # build and install
980 $(V0) @echo " BUILD $(OPENOCD_WIN_DIR)"
981 $(V1) mkdir -p "$(OPENOCD_WIN_DIR)"
982 $(V1) ( \
983 cd $(OPENOCD_BUILD_DIR) ; \
984 ./bootstrap ; \
985 ./configure --enable-maintainer-mode --prefix="$(OPENOCD_WIN_DIR)" \
986 --build=i686-pc-linux-gnu --host=i586-mingw32msvc \
987 CPPFLAGS=-I$(LIBUSB_WIN_DIR)/include \
988 LDFLAGS=-L$(LIBUSB_WIN_DIR)/lib/gcc \
989 --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=$(FTD2XX_DIR) \
990 --disable-werror \
991 --enable-stlink ; \
992 $(MAKE) ; \
993 $(MAKE) install ; \
996 # delete the extracted source when we're done
997 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
999 .PHONY: openocd_win_clean
1000 openocd_win_clean:
1001 $(V0) @echo " CLEAN $(OPENOCD_WIN_DIR)"
1002 $(V1) [ ! -d "$(OPENOCD_WIN_DIR)" ] || $(RM) -r "$(OPENOCD_WIN_DIR)"
1004 .PHONY: openocd_git_install
1006 openocd_git_install: | $(DL_DIR) $(TOOLS_DIR)
1007 openocd_git_install: OPENOCD_URL := git://openocd.git.sourceforge.net/gitroot/openocd/openocd
1008 openocd_git_install: OPENOCD_REV := f1c0133321c8fcadadd10bba5537c0a634eb183b
1009 openocd_git_install: openocd_clean
1010 # download the source
1011 $(V0) @echo " DOWNLOAD $(OPENOCD_URL) @ $(OPENOCD_REV)"
1012 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1013 $(V1) mkdir -p "$(OPENOCD_BUILD_DIR)"
1014 $(V1) git clone --no-checkout $(OPENOCD_URL) "$(OPENOCD_BUILD_DIR)"
1015 $(V1) ( \
1016 cd $(OPENOCD_BUILD_DIR) ; \
1017 git checkout -q $(OPENOCD_REV) ; \
1020 # apply patches
1021 $(V0) @echo " PATCH $(OPENOCD_DIR)"
1022 $(V1) ( \
1023 cd $(OPENOCD_BUILD_DIR) ; \
1024 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0001-armv7m-remove-dummy-FP-regs-for-new-gdb.patch ; \
1025 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0002-rtos-add-stm32_stlink-to-FreeRTOS-targets.patch ; \
1028 # build and install
1029 $(V0) @echo " BUILD $(OPENOCD_DIR)"
1030 $(V1) mkdir -p "$(OPENOCD_DIR)"
1031 $(V1) ( \
1032 cd $(OPENOCD_BUILD_DIR) ; \
1033 ./bootstrap ; \
1034 ./configure --enable-maintainer-mode --prefix="$(OPENOCD_DIR)" --enable-ft2232_libftdi --enable-buspirate --enable-stlink ; \
1035 $(MAKE) ; \
1036 $(MAKE) install ; \
1039 # delete the extracted source when we're done
1040 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1042 .PHONY: openocd_clean
1043 openocd_clean:
1044 $(V0) @echo " CLEAN $(OPENOCD_DIR)"
1045 $(V1) [ ! -d "$(OPENOCD_DIR)" ] || $(RM) -r "$(OPENOCD_DIR)"
1047 STM32FLASH_DIR := $(TOOLS_DIR)/stm32flash
1048 ifeq ($(UNAME), Windows)
1049 STM32FLASH_BUILD_OPTIONS := "CC=GCC"
1050 endif
1051 .PHONY: stm32flash_install
1052 stm32flash_install: STM32FLASH_URL := https://code.google.com/p/stm32flash/
1053 stm32flash_install: STM32FLASH_REV := a358bd1f025d
1054 stm32flash_install: stm32flash_clean
1055 # download the source
1056 $(V0) @$(ECHO) " DOWNLOAD $(STM32FLASH_URL) @ r$(STM32FLASH_REV)"
1057 $(V1) [ ! -d "$(STM32FLASH_DIR)" ] || $(RM) -rf "$(STM32FLASH_DIR)"
1058 $(V1) $(MKDIR) -p "$(STM32FLASH_DIR)"
1059 $(V1) $(GIT) clone --no-checkout $(STM32FLASH_URL) "$(STM32FLASH_DIR)"
1060 $(V1) ( \
1061 $(CD) $(STM32FLASH_DIR) ; \
1062 $(GIT) checkout -q $(STM32FLASH_REV) ; \
1064 # build
1065 $(V0) @$(ECHO) " BUILD $(STM32FLASH_DIR)"
1066 $(V1) $(MAKE) --silent -C $(STM32FLASH_DIR) all $(STM32FLASH_BUILD_OPTIONS)
1068 .PHONY: stm32flash_clean
1069 stm32flash_clean:
1070 $(V0) @$(ECHO) " CLEAN $(STM32FLASH_DIR)"
1071 $(V1) [ ! -d "$(STM32FLASH_DIR)" ] || $(RM) -rf "$(STM32FLASH_DIR)"
1073 DFUUTIL_DIR := $(TOOLS_DIR)/dfu-util
1075 .PHONY: dfuutil_install
1076 dfuutil_install: DFUUTIL_URL := http://dfu-util.sourceforge.net/releases/dfu-util-0.8.tar.gz
1077 dfuutil_install: DFUUTIL_FILE := $(notdir $(DFUUTIL_URL))
1078 dfuutil_install: | $(DL_DIR) $(TOOLS_DIR)
1079 dfuutil_install: dfuutil_clean
1080 # download the source
1081 $(V0) @echo " DOWNLOAD $(DFUUTIL_URL)"
1082 $(V1) $(CURL) $(CURL_OPTIONS) -o "$(DL_DIR)/$(DFUUTIL_FILE)" "$(DFUUTIL_URL)"
1084 # extract the source
1085 $(V0) @echo " EXTRACT $(DFUUTIL_FILE)"
1086 $(V1) [ ! -d "$(DL_DIR)/dfuutil-build" ] || $(RM) -r "$(DL_DIR)/dfuutil-build"
1087 $(V1) mkdir -p "$(DL_DIR)/dfuutil-build"
1088 $(V1) tar -C $(DL_DIR)/dfuutil-build -xf "$(DL_DIR)/$(DFUUTIL_FILE)"
1090 # build
1091 $(V0) @echo " BUILD $(DFUUTIL_DIR)"
1092 $(V1) mkdir -p "$(DFUUTIL_DIR)"
1093 $(V1) ( \
1094 cd $(DL_DIR)/dfuutil-build/dfu-util-0.8 ; \
1095 ./configure --prefix="$(DFUUTIL_DIR)" ; \
1096 $(MAKE) ; \
1097 $(MAKE) install ; \
1100 .PHONY: dfuutil_clean
1101 dfuutil_clean:
1102 $(V0) @echo " CLEAN $(DFUUTIL_DIR)"
1103 $(V1) [ ! -d "$(DFUUTIL_DIR)" ] || $(RM) -r "$(DFUUTIL_DIR)"
1105 # see http://developer.android.com/sdk/ for latest versions
1106 ANDROID_SDK_DIR := $(TOOLS_DIR)/android-sdk-linux
1107 .PHONY: android_sdk_install
1108 android_sdk_install: ANDROID_SDK_URL := http://dl.google.com/android/android-sdk_r20.0.3-linux.tgz
1109 android_sdk_install: ANDROID_SDK_FILE := $(notdir $(ANDROID_SDK_URL))
1110 # order-only prereq on directory existance:
1111 android_sdk_install: | $(DL_DIR) $(TOOLS_DIR)
1112 android_sdk_install: android_sdk_clean
1113 # download the source only if it's newer than what we already have
1114 $(V0) @echo " DOWNLOAD $(ANDROID_SDK_URL)"
1115 $(V1) $(WGET) --no-check-certificate -N -P "$(DL_DIR)" "$(ANDROID_SDK_URL)"
1117 # binary only release so just extract it
1118 $(V0) @echo " EXTRACT $(ANDROID_SDK_FILE)"
1119 $(V1) tar -C $(TOOLS_DIR) -xf "$(DL_DIR)/$(ANDROID_SDK_FILE)"
1121 .PHONY: android_sdk_clean
1122 android_sdk_clean:
1123 $(V0) @echo " CLEAN $(ANDROID_SDK_DIR)"
1124 $(V1) [ ! -d "$(ANDROID_SDK_DIR)" ] || $(RM) -r $(ANDROID_SDK_DIR)
1126 .PHONY: android_sdk_update
1127 android_sdk_update:
1128 $(V0) @echo " UPDATE $(ANDROID_SDK_DIR)"
1129 $(ANDROID_SDK_DIR)/tools/android update sdk --no-ui -t platform-tools,android-16,addon-google_apis-google-16
1131 #Install git hooks under the right folder
1133 .PHONY: prepare
1134 prepare:
1135 $(V0) @echo " Configuring GIT commit template"
1136 $(V1) $(CD) "$(ROOT_DIR)"
1137 $(V1) $(GIT) config commit.template .commit-template
1139 .PHONY: prepare_clean
1140 prepare_clean:
1141 $(V0) @echo " Cleanup GIT commit template configuration"
1142 $(V1) $(CD) "$(ROOT_DIR)"
1143 $(V1) $(GIT) config --unset commit.template
1145 ##############################
1147 # TODO: these defines will go to tool install sections
1149 ##############################
1151 ifeq ($(shell [ -d "$(OPENOCD_DIR)" ] && $(ECHO) "exists"), exists)
1152 export OPENOCD := $(OPENOCD_DIR)/bin/openocd
1153 else
1154 # not installed, hope it's in the path...
1155 export OPENOCD ?= openocd
1156 endif
1158 ifeq ($(shell [ -d "$(ANDROID_SDK_DIR)" ] && $(ECHO) "exists"), exists)
1159 ANDROID := $(ANDROID_SDK_DIR)/tools/android
1160 ANDROID_DX := $(ANDROID_SDK_DIR)/platform-tools/dx
1161 else
1162 # not installed, hope it's in the path...
1163 ANDROID ?= android
1164 ANDROID_DX ?= dx
1165 endif