LP-312 Hide I2C port also for Discovery and Revoproto
[librepilot.git] / make / tools.mk
blob1322d20b2727524807b459fd95caaa258ab2c762
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.0
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.1-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.1-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.1-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.1-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.1-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 else
169 BUILD_SDK_TARGETS += qt_sdk osg
170 endif
171 ALL_SDK_TARGETS := $(BUILD_SDK_TARGETS) gtest uncrustify doxygen
173 define GROUP_SDK_TEMPLATE
174 .PHONY: $(1)_install $(1)_clean $(1)_distclean $(1)_version
175 $(1)_install: $(addsuffix _install,$(2))
176 $(1)_clean: $(addsuffix _clean,$(2))
177 $(1)_distclean: $(addsuffix _distclean,$(2))
178 $(1)_version: $(addsuffix _version,$(2))
179 endef
181 $(eval $(call GROUP_SDK_TEMPLATE,build_sdk,$(BUILD_SDK_TARGETS)))
182 $(eval $(call GROUP_SDK_TEMPLATE,all_sdk,$(ALL_SDK_TARGETS)))
184 ##############################
186 # Misc host tools
188 ##############################
190 # Used by other makefiles
191 export MKDIR := mkdir
192 export CP := cp
193 export RM := rm
194 export LN := ln
195 export CAT := cat
196 export CUT := cut
197 export SED := sed
199 # Used only by this Makefile
200 GIT := git
201 CURL := curl
202 TAR := tar
203 UNZIP := unzip
204 ZIP := gzip
205 OPENSSL := openssl
206 ANT := ant
207 JAVAC := javac
208 JAR := jar
209 CD := cd
210 GREP := grep
211 CMAKE := cmake
212 ifneq ($(UNAME), Windows)
213 SEVENZIP := 7za
214 else
215 SEVENZIP := 7za.exe
216 ifneq ($(shell $(SEVENZIP) --version >/dev/null 2>&1 && $(ECHO) "found"), found)
217 # no $(SEVENZIP) found in path. hope is in bin...
218 SEVENZIP = $(TOOLS_DIR)/bin/7za.exe
219 endif
220 endif
221 ifneq ($(UNAME), Windows)
222 MAKE := make
223 else
224 MAKE := mingw32-make
225 endif
227 # Echo in recipes is a bit tricky in a Windows Git Bash window in some cases.
228 # It does not work if make started under msysGit installed into a path with spaces.
229 ifneq ($(UNAME), Windows)
230 export ECHO := echo
231 else
232 # export ECHO := $(PYTHON) -c "import sys; print(' '.join(sys.argv[1:]))"
233 export ECHO := echo
234 endif
236 # Test if quotes are needed for the echo command
237 ifeq ($(shell $(ECHO) "test"), test)
238 export QUOTE := '
239 # This line is just to clear out the single quote above '
240 else
241 export QUOTE :=
242 endif
244 # Command to extract version info data from the repository and source tree
245 export VERSION_INFO = $(PYTHON) $(ROOT_DIR)/make/scripts/version-info.py --path=$(ROOT_DIR)
247 export CCACHE
249 ##############################
251 # Misc settings
253 ##############################
255 # Define messages
256 MSG_VERIFYING = $(QUOTE) VERIFY $(QUOTE)
257 MSG_DOWNLOADING = $(QUOTE) DOWNLOAD $(QUOTE)
258 MSG_CHECKSUMMING = $(QUOTE) MD5 $(QUOTE)
259 MSG_EXTRACTING = $(QUOTE) EXTRACT $(QUOTE)
260 MSG_CONFIGURING = $(QUOTE) CONFIGURE $(QUOTE)
261 MSG_BUILDING = $(QUOTE) BUILD $(QUOTE)
262 MSG_INSTALLING = $(QUOTE) INSTALL $(QUOTE)
263 MSG_CLEANING = $(QUOTE) CLEAN $(QUOTE)
264 MSG_DISTCLEANING = $(QUOTE) DISTCLEAN $(QUOTE)
265 MSG_NOTICE = $(QUOTE) NOTE $(QUOTE)
267 # Verbosity level
268 ifeq ($(V), 1)
269 MAKE_SILENT :=
270 UNZIP_SILENT :=
271 else
272 MAKE_SILENT := --silent
273 UNZIP_SILENT := -q
274 endif
276 # Batch mode
277 ifeq ($(BATCH), 1)
278 CURL_OPTIONS := --silent -L
279 else
280 CURL_OPTIONS := -L
281 endif
283 # MSYS tar workaround
284 ifeq ($(UNAME), Windows)
285 TAR_OPTIONS := --force-local
286 else
287 TAR_OPTIONS :=
288 endif
290 # Print some useful notes for *_install targets
291 ifneq ($(strip $(filter $(addsuffix _install,all_sdk $(ALL_SDK_TARGETS)),$(MAKECMDGOALS))),)
292 ifneq ($(shell $(CURL) --version >/dev/null 2>&1 && $(ECHO) "found"), found)
293 $(error Please install curl first ('apt-get install curl' or similar))
294 endif
295 $(info $(EMPTY) NOTE Use 'make all_sdk_distclean' to remove installation files)
296 $(info $(EMPTY) NOTE Use 'make all_sdk_version' to check toolchain versions)
297 $(info $(EMPTY) NOTE Add 'V=1' to make command line to diagnose make problems)
298 $(info $(EMPTY) NOTE Add 'BATCH=1' to make command line to disable progress reporting during downloads)
299 endif
301 ##############################
303 # Cross-platform MD5 check template
304 # $(1) = file name without quotes
305 # $(2) = string compare operator, e.g. = or !=
307 ##############################
309 define MD5_CHECK_TEMPLATE
310 "`test -f \"$(1)\" && $(OPENSSL) dgst -md5 \"$(1)\" | $(CUT) -f2 -d' '`" $(2) "`$(GREP) $(notdir $(1)) $(1).md5 | $(CUT) -f1 -d' '`"
311 endef
313 ##############################
315 # Cross-platform MD5 generation template
316 # $(1) = file name without quotes
318 ##############################
320 ifeq ($(UNAME), Darwin)
322 define MD5_GEN_TEMPLATE
323 md5 -r $(1) > $(1).md5
324 endef
326 else
328 define MD5_GEN_TEMPLATE
329 $(OPENSSL) dgst -r -md5 $(1) > $(1).md5
330 endef
332 endif
334 ##############################
336 # Cross platform download template
337 # $(1) = Package URL
338 # $(2) = Package file
339 # $(3) = URL for .md5 file to be tested against Package
341 ##############################
343 define DOWNLOAD_TEMPLATE
344 @$(ECHO) $(MSG_VERIFYING) $$(call toprel, $(DL_DIR)/$(2))
345 $(V1) ( \
346 cd "$(DL_DIR)" && \
347 $(CURL) $(CURL_OPTIONS) --silent -o "$(DL_DIR)/$(2).md5" "$(3)" && \
348 if [ $(call MD5_CHECK_TEMPLATE,$(DL_DIR)/$(2),!=) ]; then \
349 $(ECHO) $(MSG_DOWNLOADING) $(1) && \
350 $(CURL) $(CURL_OPTIONS) -o "$(DL_DIR)/$(2)" "$(1)" && \
351 $(ECHO) $(MSG_CHECKSUMMING) $$(call toprel, $(DL_DIR)/$(2)) && \
352 [ $(call MD5_CHECK_TEMPLATE,$(DL_DIR)/$(2),=) ]; \
353 fi; \
355 endef
357 ##############################
359 # Common tool install template
360 # $(1) = tool name
361 # $(2) = tool extract/build directory
362 # $(3) = tool distribution URL
363 # $(4) = tool distribution MD5 URL
364 # $(5) = tool distribution file
365 # $(6) = optional extra build recipes template
366 # $(7) = optional extra clean recipes template
368 ##############################
370 define TOOL_INSTALL_TEMPLATE
372 .PHONY: $(addprefix $(1)_, install clean distclean)
374 $(1)_install: $(1)_clean | $(DL_DIR) $(TOOLS_DIR)
376 $(if $(4), $(call DOWNLOAD_TEMPLATE,$(3),$(5),$(4)),$(call DOWNLOAD_TEMPLATE,$(3),$(5),"$(3).md5"))
378 @$(ECHO) $(MSG_EXTRACTING) $$(call toprel, $(2))
379 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(2)))
381 $(if $(filter $(suffix $(5)), .zip),
382 $(V1) $(UNZIP) $(UNZIP_SILENT) -d $$(call toprel, $(dir $(2))) $$(call toprel, $(DL_DIR)/$(5)),
383 $(V1) $(TAR) $(TAR_OPTIONS) -C $$(call toprel, $(dir $(2))) -xf $$(call toprel, $(DL_DIR)/$(5))
386 $(6)
388 $(1)_clean:
389 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(2))
390 $(V1) [ ! -d "$(2)" ] || $(RM) -rf "$(2)"
392 $(7)
394 $(1)_distclean:
395 @$(ECHO) $(MSG_DISTCLEANING) $$(call toprel, $(DL_DIR)/$(5))
396 $(V1) [ ! -f "$(DL_DIR)/$(5)" ] || $(RM) "$(DL_DIR)/$(5)"
397 $(V1) [ ! -f "$(DL_DIR)/$(5).md5" ] || $(RM) "$(DL_DIR)/$(5).md5"
399 endef
401 ##############################
403 # ARM SDK
405 ##############################
406 export ARM_SDK_PREFIX := arm-none-eabi-
407 ARM_SDK_TOOL := gcc-arm-none-eabi
409 .PHONY: arm_sdk_install
410 arm_sdk_install: $(ARM_SDK_TOOL)_install
412 .PHONY: arm_sdk_clean
413 arm_sdk_clean: $(ARM_SDK_TOOL)_remove
415 .PHONY: arm_sdk_version
416 arm_sdk_version:
417 -$(V1) $(ARM_SDK_PREFIX)gcc --version | head -n1
419 # Template to check ARM toolchain version before building targets
420 define ARM_GCC_VERSION_CHECK_TEMPLATE
421 if ! $(ARM_SDK_PREFIX)gcc --version --specs=nano.specs >/dev/null 2>&1; then \
422 $(ECHO) $(MSG_NOTICE) Please install ARM toolchain 4.8 2014q1 using \'make arm_sdk_install\' && \
423 $(ECHO) $(MSG_NOTICE) Older ARM SDKs do not support new \'--specs=nano.specs\' option && \
424 exit 1; \
426 endef
428 ##############################
430 # Qt install template
431 # $(1) = tool install directory
432 # $(2) = tool distribution URL
433 # $(3) = tool distribution .md5 URL
434 # $(4) = tool distribution file
435 # $(5) = Qt architecture
436 # $(6) = optional extra build recipes template
437 # $(7) = optional extra clean recipes template
439 ##############################
441 define QT_INSTALL_TEMPLATE
443 .PHONY: $(addprefix qt_sdk_, install clean distclean)
445 qt_sdk_install: qt_sdk_clean | $(DL_DIR) $(TOOLS_DIR)
446 $(call DOWNLOAD_TEMPLATE,$(2),$(4),"$(3)")
447 # Silently install Qt under tools directory
448 @$(ECHO) $(MSG_EXTRACTING) $(4) to $$(call toprel, $(1))
449 $(V1) ( export QT_INSTALL_TARGET_DIR=$(1) && \
450 chmod +x $(DL_DIR)/$(4) && \
451 $(DL_DIR)/$(4) --script $(ROOT_DIR)/make/tool_install/qt-install.qs ; \
453 # Execute post build templates
454 $(6)
456 qt_sdk_clean:
457 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
458 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
459 $(7)
461 qt_sdk_distclean:
462 @$(ECHO) $(MSG_DISTCLEANING) $$(call toprel, $(DL_DIR)/$(4))
463 $(V1) [ ! -f "$(DL_DIR)/$(4)" ] || $(RM) "$(DL_DIR)/$(4)"
464 $(V1) [ ! -f "$(DL_DIR)/$(4).md5" ] || $(RM) "$(DL_DIR)/$(4).md5"
466 endef
468 ##############################
470 # Mac QT install template
471 # $(1) = tool install directory
472 # $(2) = tool distribution URL
473 # $(3) = tool distribution .md5 URL
474 # $(4) = tool distribution file
475 # $(5) = QT architecture
476 # $(6) = optional extra build recipes template
477 # $(7) = optional extra clean recipes template
479 ##############################
481 define MAC_QT_INSTALL_TEMPLATE
483 .PHONY: $(addprefix qt_sdk_, install clean distclean)
485 qt_sdk_install: qt_sdk_clean | $(DL_DIR) $(TOOLS_DIR)
486 $(call DOWNLOAD_TEMPLATE,$(2),$(4),"$(3)")
487 # Mount .dmg file
488 $(V1) hdiutil attach -nobrowse $(DL_DIR)/$(4)
489 # Silently install Qt under tools directory
490 @$(ECHO) $(MSG_EXTRACTING) $(4) to $$(call toprel, $(1))
491 $(V1) ( export QT_INSTALL_TARGET_DIR=$(1) && \
492 $(QT_SDK_MAINTENANCE_TOOL) --script $(ROOT_DIR)/make/tool_install/qt-install.qs ; \
494 # Unmount the .dmg file
495 $(V1) hdiutil detach $(QT_SDK_MOUNT_DIR)
496 # Execute post build templates
497 $(6)
499 qt_sdk_clean:
500 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
501 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
502 $(7)
504 endef
506 ##############################
508 # Qt SDK
510 ##############################
512 ifeq ($(UNAME), Windows)
514 QT_SDK_PREFIX := $(QT_SDK_DIR)/$(QT_SHORT_VERSION)/$(QT_SDK_ARCH)
515 $(eval $(call QT_INSTALL_TEMPLATE,$(QT_SDK_DIR),$(QT_SDK_URL),$(QT_SDK_MD5_URL),$(notdir $(QT_SDK_URL)),$(QT_SDK_ARCH)))
517 else ifeq ($(UNAME), Linux)
519 QT_SDK_PREFIX := "$(QT_SDK_DIR)/$(QT_SHORT_VERSION)/$(QT_SDK_ARCH)"
520 $(eval $(call QT_INSTALL_TEMPLATE,$(QT_SDK_DIR),$(QT_SDK_URL),$(QT_SDK_MD5_URL),$(notdir $(QT_SDK_URL)),$(QT_SDK_ARCH)))
522 else ifeq ($(UNAME), Darwin)
524 QT_SDK_PREFIX := "$(QT_SDK_DIR)/$(QT_SHORT_VERSION)/$(QT_SDK_ARCH)"
525 $(eval $(call MAC_QT_INSTALL_TEMPLATE,$(QT_SDK_DIR),$(QT_SDK_URL),$(QT_SDK_MD5_URL),$(notdir $(QT_SDK_URL)),$(QT_SDK_ARCH)))
527 else
529 QT_SDK_PREFIX := $(QT_SDK_DIR)
531 .PHONY: qt_sdk_install
532 qt_sdk_install:
533 @$(ECHO) $(MSG_NOTICE) --------------------------------------------------------
534 @$(ECHO) $(MSG_NOTICE) Please install native Qt 5.6.x SDK using package manager
535 @$(ECHO) $(MSG_NOTICE) --------------------------------------------------------
537 .PHONY: qt_sdk_clean
538 qt_sdk_clean:
540 .PHONY: qt_sdk_distclean
541 qt_sdk_distclean:
543 endif
545 ifeq ($(shell [ -d "$(QT_SDK_DIR)" ] && $(ECHO) "exists"), exists)
546 export QMAKE := $(QT_SDK_PREFIX)/bin/qmake
548 # set Qt library search path
549 ifeq ($(UNAME), Windows)
550 export PATH := $(QT_SDK_PREFIX)/bin:$(PATH)
551 else
552 export LD_LIBRARY_PATH := $(QT_SDK_DIR)/lib:$(LD_LIBRARY_PATH)
553 endif
554 else
555 OPT_QT := qt56
556 OPT_QT_ENV_SH := /opt/$(OPT_QT)/bin/$(OPT_QT)-env.sh
557 ifneq ($(wildcard $(OPT_QT_ENV_SH)),)
558 SHELL := /bin/bash
559 QMAKE := . $(OPT_QT_ENV_SH) && qmake
560 else
561 # not installed, hope it's in the path...
562 QMAKE := qmake
563 endif
564 endif
566 .PHONY: qt_sdk_version
567 qt_sdk_version:
568 -$(V1) $(QMAKE) --version | tail -1
570 ##############################
572 # MinGW
574 ##############################
576 ifeq ($(UNAME), Windows)
578 ifeq ($(shell [ -d "$(MINGW_DIR)" ] && $(ECHO) "exists"), exists)
579 # set MinGW binary and library paths (QTMINGW is used by qmake, do not rename)
580 export QTMINGW := $(MINGW_DIR)/bin
581 export PATH := $(QTMINGW):$(PATH)
582 else
583 # not installed, use host gcc compiler
584 # $(info $(EMPTY) WARNING $(call toprel, $(MINGW_DIR)) not found, using system PATH)
585 endif
587 .PHONY: mingw_version
588 mingw_version: gcc_version
590 else # Linux or Mac
592 all_sdk_version: gcc_version
594 endif
596 .PHONY: gcc_version
597 gcc_version:
598 -$(V1) gcc --version | head -n1
600 ##############################
602 # Python
604 ##############################
606 ifeq ($(shell [ -d "$(PYTHON_DIR)" ] && $(ECHO) "exists"), exists)
607 export PYTHON := $(PYTHON_DIR)/python
608 export PATH := $(PYTHON_DIR):$(PATH)
609 else
610 # not installed, hope it's in the path...
611 # $(info $(EMPTY) WARNING $(call toprel, $(PYTHON_DIR)) not found, using system PATH)
612 ifeq ($(findstring Python 2,$(shell python --version 2>&1)), Python 2)
613 export PYTHON := python
614 else
615 export PYTHON := python2
616 endif
617 endif
619 .PHONY: python_version
620 python_version:
621 -$(V1) $(PYTHON) --version
623 ##############################
625 # NSIS Unicode (Windows only)
627 ##############################
629 ifeq ($(UNAME), Windows)
631 $(eval $(call TOOL_INSTALL_TEMPLATE,nsis,$(NSIS_DIR),$(NSIS_URL),,$(notdir $(NSIS_URL))))
633 ifeq ($(shell [ -d "$(NSIS_DIR)" ] && $(ECHO) "exists"), exists)
634 export NSIS := $(NSIS_DIR)/makensis
635 else
636 # not installed, hope it's in the path...
637 # $(info $(EMPTY) WARNING $(call toprel, $(NSIS_DIR)) not found (make nsis_install), using system PATH)
638 export NSIS ?= makensis
639 endif
641 .PHONY: nsis_version
642 nsis_version:
643 -$(V1) $(NSIS) | head -n1
645 endif
647 ##################################
649 # Mesa OpenGL DLL (Windows only)
651 ##################################
653 ifeq ($(UNAME), Windows)
655 $(eval $(call TOOL_INSTALL_TEMPLATE,mesawin,$(MESAWIN_DIR),$(MESAWIN_URL),,$(notdir $(MESAWIN_URL))))
657 ifeq ($(shell [ -d "$(MESAWIN_DIR)" ] && $(ECHO) "exists"), exists)
658 export MESAWIN_DIR := $(MESAWIN_DIR)
659 else
660 # not installed, hope it's in the path...
661 #$(info $(EMPTY) WARNING $(call toprel, $(MESA_WIN_DIR)) not found (make mesawin_install), using system PATH)
662 endif
664 .PHONY: mesawin_version
665 mesawin_version:
666 -$(V1) $(ECHO) "MesaOpenGL vXX"
668 endif
670 ##############################
672 # Uncrustify
674 ##############################
676 ifeq ($(UNAME), Windows)
678 $(eval $(call TOOL_INSTALL_TEMPLATE,uncrustify,$(UNCRUSTIFY_DIR),$(UNCRUSTIFY_URL),,$(notdir $(UNCRUSTIFY_URL))))
680 else # Linux or Mac
682 UNCRUSTIFY_BUILD_DIR := $(BUILD_DIR)/$(notdir $(UNCRUSTIFY_DIR))
684 define UNCRUSTIFY_BUILD_TEMPLATE
685 $(V1) ( \
686 $(ECHO) $(MSG_CONFIGURING) $(call toprel, $(UNCRUSTIFY_BUILD_DIR)) && \
687 cd $(UNCRUSTIFY_BUILD_DIR) && \
688 ./configure --prefix="$(UNCRUSTIFY_DIR)" && \
689 $(ECHO) $(MSG_BUILDING) $(call toprel, $(UNCRUSTIFY_BUILD_DIR)) && \
690 $(MAKE) $(MAKE_SILENT) && \
691 $(ECHO) $(MSG_INSTALLING) $(call toprel, $(UNCRUSTIFY_DIR)) && \
692 $(MAKE) $(MAKE_SILENT) install-strip \
694 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(UNCRUSTIFY_BUILD_DIR))
695 -$(V1) [ ! -d "$(UNCRUSTIFY_BUILD_DIR)" ] || $(RM) -rf "$(UNCRUSTIFY_BUILD_DIR)"
696 endef
698 define UNCRUSTIFY_CLEAN_TEMPLATE
699 -$(V1) [ ! -d "$(UNCRUSTIFY_DIR)" ] || $(RM) -rf "$(UNCRUSTIFY_DIR)"
700 endef
702 $(eval $(call TOOL_INSTALL_TEMPLATE,uncrustify,$(UNCRUSTIFY_BUILD_DIR),$(UNCRUSTIFY_URL),,$(notdir $(UNCRUSTIFY_URL)),$(UNCRUSTIFY_BUILD_TEMPLATE),$(UNCRUSTIFY_CLEAN_TEMPLATE)))
704 endif
706 ifeq ($(shell [ -d "$(UNCRUSTIFY_DIR)" ] && $(ECHO) "exists"), exists)
707 export UNCRUSTIFY := $(UNCRUSTIFY_DIR)/bin/uncrustify
708 else
709 # not installed, hope it's in the path...
710 # $(info $(EMPTY) WARNING $(call toprel, $(UNCRUSTIFY_DIR)) not found (make uncrustify_install), using system PATH)
711 export UNCRUSTIFY := uncrustify
712 endif
714 .PHONY: uncrustify_version
715 uncrustify_version:
716 -$(V1) $(UNCRUSTIFY) --version
718 ##############################
720 # Doxygen
722 ##############################
724 ifeq ($(UNAME), Windows)
726 $(eval $(call TOOL_INSTALL_TEMPLATE,doxygen,$(DOXYGEN_DIR),$(DOXYGEN_URL),,$(notdir $(DOXYGEN_URL))))
728 else # Linux or Mac
730 DOXYGEN_BUILD_DIR := $(BUILD_DIR)/$(notdir $(DOXYGEN_DIR))
732 define DOXYGEN_BUILD_TEMPLATE
733 $(V1) ( \
734 $(ECHO) $(MSG_CONFIGURING) $(call toprel, $(DOXYGEN_BUILD_DIR)) && \
735 cd $(DOXYGEN_BUILD_DIR) && \
736 ./configure --prefix "$(DOXYGEN_DIR)" --english-only && \
737 $(ECHO) $(MSG_BUILDING) $(call toprel, $(DOXYGEN_BUILD_DIR)) && \
738 $(MAKE) $(MAKE_SILENT) && \
739 $(ECHO) $(MSG_INSTALLING) $(call toprel, $(DOXYGEN_DIR)) && \
740 $(MAKE) $(MAKE_SILENT) install \
742 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(DOXYGEN_BUILD_DIR))
743 -$(V1) [ ! -d "$(DOXYGEN_BUILD_DIR)" ] || $(RM) -rf "$(DOXYGEN_BUILD_DIR)"
744 endef
746 define DOXYGEN_CLEAN_TEMPLATE
747 -$(V1) [ ! -d "$(DOXYGEN_DIR)" ] || $(RM) -rf "$(DOXYGEN_DIR)"
748 endef
750 $(eval $(call TOOL_INSTALL_TEMPLATE,doxygen,$(DOXYGEN_BUILD_DIR),$(DOXYGEN_URL),,$(notdir $(DOXYGEN_URL)),$(DOXYGEN_BUILD_TEMPLATE),$(DOXYGEN_CLEAN_TEMPLATE)))
752 endif
754 ifeq ($(shell [ -d "$(DOXYGEN_DIR)" ] && $(ECHO) "exists"), exists)
755 export DOXYGEN := $(DOXYGEN_DIR)/bin/doxygen
756 else
757 # not installed, hope it's in the path...
758 # $(info $(EMPTY) WARNING $(call toprel, $(DOXYGEN_DIR)) not found (make doxygen_install), using system PATH)
759 export DOXYGEN := doxygen
760 endif
762 .PHONY: doxygen_version
763 doxygen_version:
764 -$(V1) $(ECHO) "Doxygen `$(DOXYGEN) --version`"
766 ##############################
768 # GoogleTest
770 ##############################
772 $(eval $(call TOOL_INSTALL_TEMPLATE,gtest,$(GTEST_DIR),$(GTEST_URL),,$(notdir $(GTEST_URL))))
774 export GTEST_DIR
776 .PHONY: gtest_version
777 gtest_version:
778 -$(V1) $(SED) -n "s/^PACKAGE_STRING='\(.*\)'/\1/p" < $(GTEST_DIR)/configure
780 ##############################
782 # CCACHE
784 ##############################
786 CCACHE_BUILD_DIR := $(BUILD_DIR)/ccache-3.2.2
788 define CCACHE_BUILD_TEMPLATE
789 $(V1) ( \
790 $(ECHO) $(MSG_CONFIGURING) $(call toprel, $(CCACHE_BUILD_DIR)) && \
791 cd $(CCACHE_BUILD_DIR) && \
792 ./configure --prefix="$(CCACHE_DIR)" && \
793 $(ECHO) $(MSG_BUILDING) $(call toprel, $(CCACHE_BUILD_DIR)) && \
794 $(MAKE) $(MAKE_SILENT) && \
795 $(ECHO) $(MSG_INSTALLING) $(call toprel, $(CCACHE_DIR)) && \
796 $(MAKE) $(MAKE_SILENT) install \
798 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(CCACHE_BUILD_DIR))
799 -$(V1) [ ! -d "$(CCACHE_BUILD_DIR)" ] || $(RM) -rf "$(CCACHE_BUILD_DIR)"
801 @$(ECHO)
802 @$(ECHO) "Setting up CCACHE configuration:"
804 $(V1) [ -d "$(ROOT_DIR)/.ccache" ] || mkdir $(ROOT_DIR)/.ccache
805 $(V1) [ -d "$(CCACHE_DIR)/etc" ] || mkdir $(CCACHE_DIR)/etc
807 $(V1) $(ECHO) $(QUOTE)cache_dir = $(ROOT_DIR)/.ccache $(QUOTE) > $(CCACHE_DIR)/etc/ccache.conf
808 $(V1) $(ECHO) $(QUOTE)max_size = 250M$(QUOTE) >> $(CCACHE_DIR)/etc/ccache.conf
809 $(V1) $(CAT) $(CCACHE_DIR)/etc/ccache.conf
810 endef
812 define CCACHE_CLEAN_TEMPLATE
813 -$(V1) [ ! -d "$(CCACHE_DIR)" ] || $(RM) -rf "$(CCACHE_DIR)"
814 endef
816 $(eval $(call TOOL_INSTALL_TEMPLATE,ccache,$(CCACHE_BUILD_DIR),$(CCACHE_URL),$(CCACHE_MD5_URL),$(notdir $(CCACHE_URL)),$(CCACHE_BUILD_TEMPLATE),$(CCACHE_CLEAN_TEMPLATE)))
818 ##############################
820 # osg
822 ##############################
824 $(eval $(call TOOL_INSTALL_TEMPLATE,osg,$(OSG_SDK_DIR),$(OSG_URL),,$(notdir $(OSG_URL))))
826 ifeq ($(shell [ -d "$(OSG_SDK_DIR)" ] && $(ECHO) "exists"), exists)
827 export OSG_SDK_DIR := $(OSG_SDK_DIR)
828 else
829 # not installed, hope it's in the path...
830 $(info $(EMPTY) WARNING $(call toprel, $(OSG_SDK_DIR)) not found (make osg_install), using system PATH)
831 endif
833 .PHONY: osg_version
834 osg_version:
835 -$(V1) $(ECHO) "`$(OSG_SDK_DIR)/bin/osgversion`"
837 ##############################
839 # osgearth
841 ##############################
843 $(eval $(call TOOL_INSTALL_TEMPLATE,osgearth,$(OSGEARTH_SDK_DIR),$(OSGEARTH_URL),,$(notdir $(OSGEARTH_URL))))
845 ifeq ($(shell [ -d "$(OSGEARTH_SDK_DIR)" ] && $(ECHO) "exists"), exists)
846 export OSGEARTH_SDK_DIR := $(OSGEARTH_SDK_DIR)
847 else
848 # not installed, hope it's in the path...
849 $(info $(EMPTY) WARNING $(call toprel, $(OSGEARTH_SDK_DIR)) not found (make osgearth_install), using system PATH)
850 endif
852 .PHONY: osgearth_version
853 osgearth_version:
854 -$(V1) $(ECHO) "`$(OSGEARTH_SDK_DIR)/bin/osgearth_version`"
856 ##############################
858 # TODO: code below is not revised yet
860 ##############################
862 # Set up openocd tools
863 OPENOCD_DIR := $(TOOLS_DIR)/openocd
864 OPENOCD_WIN_DIR := $(TOOLS_DIR)/openocd_win
865 OPENOCD_BUILD_DIR := $(DL_DIR)/openocd-build
867 .PHONY: openocd_install
868 openocd_install: | $(DL_DIR) $(TOOLS_DIR)
869 openocd_install: OPENOCD_URL := http://sourceforge.net/projects/openocd/files/openocd/0.6.1/openocd-0.6.1.tar.bz2/download
870 openocd_install: OPENOCD_FILE := openocd-0.6.1.tar.bz2
871 openocd_install: openocd_clean
872 # download the source only if it's newer than what we already have
873 $(V1) $(WGET) -N -P "$(DL_DIR)" --trust-server-name "$(OPENOCD_URL)"
875 # extract the source
876 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -r "$(OPENOCD_BUILD_DIR)"
877 $(V1) mkdir -p "$(OPENOCD_BUILD_DIR)"
878 $(V1) tar -C $(OPENOCD_BUILD_DIR) -xjf "$(DL_DIR)/$(OPENOCD_FILE)"
880 # apply patches
881 $(V0) @echo " PATCH $(OPENOCD_DIR)"
882 $(V1) ( \
883 cd $(OPENOCD_BUILD_DIR)/openocd-0.6.1 ; \
884 patch -p1 < $(ROOT_DIR)/flight/Project/OpenOCD/0001-armv7m-remove-dummy-FP-regs-for-new-gdb.patch ; \
885 patch -p1 < $(ROOT_DIR)/flight/Project/OpenOCD/0002-rtos-add-stm32_stlink-to-FreeRTOS-targets.patch ; \
888 # build and install
889 $(V1) mkdir -p "$(OPENOCD_DIR)"
890 $(V1) ( \
891 cd $(OPENOCD_BUILD_DIR)/openocd-0.6.1 ; \
892 ./configure --prefix="$(OPENOCD_DIR)" --enable-ft2232_libftdi --enable-stlink ; \
893 $(MAKE) --silent ; \
894 $(MAKE) --silent install ; \
897 # delete the extracted source when we're done
898 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
900 .PHONY: ftd2xx_install
902 FTD2XX_DIR := $(DL_DIR)/ftd2xx
904 ftd2xx_install: | $(DL_DIR)
905 ftd2xx_install: FTD2XX_URL := http://www.ftdichip.com/Drivers/CDM/Beta/CDM20817.zip
906 ftd2xx_install: FTD2XX_FILE := CDM20817.zip
907 ftd2xx_install: ftd2xx_clean
908 # download the file only if it's newer than what we already have
909 $(V0) @echo " DOWNLOAD $(FTD2XX_URL)"
910 $(V1) $(WGET) -q -N -P "$(DL_DIR)" "$(FTD2XX_URL)"
912 # extract the source
913 $(V0) @echo " EXTRACT $(FTD2XX_FILE) -> $(FTD2XX_DIR)"
914 $(V1) mkdir -p "$(FTD2XX_DIR)"
915 $(V1) unzip -q -d "$(FTD2XX_DIR)" "$(DL_DIR)/$(FTD2XX_FILE)"
917 .PHONY: ftd2xx_clean
918 ftd2xx_clean:
919 $(V0) @echo " CLEAN $(FTD2XX_DIR)"
920 $(V1) [ ! -d "$(FTD2XX_DIR)" ] || $(RM) -r "$(FTD2XX_DIR)"
922 .PHONY: ftd2xx_install
924 LIBUSB_WIN_DIR := $(DL_DIR)/libusb-win32-bin-1.2.6.0
926 libusb_win_install: | $(DL_DIR)
927 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
928 libusb_win_install: LIBUSB_WIN_FILE := libusb-win32-bin-1.2.6.0.zip
929 libusb_win_install: libusb_win_clean
930 # download the file only if it's newer than what we already have
931 $(V0) @echo " DOWNLOAD $(LIBUSB_WIN_URL)"
932 $(V1) $(WGET) -q -N -P "$(DL_DIR)" --trust-server-name "$(LIBUSB_WIN_URL)"
934 # extract the source
935 $(V0) @echo " EXTRACT $(LIBUSB_WIN_FILE) -> $(LIBUSB_WIN_DIR)"
936 $(V1) mkdir -p "$(LIBUSB_WIN_DIR)"
937 $(V1) unzip -q -d "$(DL_DIR)" "$(DL_DIR)/$(LIBUSB_WIN_FILE)"
939 # fixup .h file needed by openocd build
940 $(V0) @echo " FIXUP $(LIBUSB_WIN_DIR)"
941 $(V1) ln -s "$(LIBUSB_WIN_DIR)/include/lusb0_usb.h" "$(LIBUSB_WIN_DIR)/include/usb.h"
943 .PHONY: libusb_win_clean
944 libusb_win_clean:
945 $(V0) @echo " CLEAN $(LIBUSB_WIN_DIR)"
946 $(V1) [ ! -d "$(LIBUSB_WIN_DIR)" ] || $(RM) -r "$(LIBUSB_WIN_DIR)"
948 .PHONY: openocd_git_win_install
950 openocd_git_win_install: | $(DL_DIR) $(TOOLS_DIR)
951 openocd_git_win_install: OPENOCD_URL := git://openocd.git.sourceforge.net/gitroot/openocd/openocd
952 openocd_git_win_install: OPENOCD_REV := f1c0133321c8fcadadd10bba5537c0a634eb183b
953 openocd_git_win_install: openocd_win_clean libusb_win_install ftd2xx_install
954 # download the source
955 $(V0) @echo " DOWNLOAD $(OPENOCD_URL) @ $(OPENOCD_REV)"
956 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
957 $(V1) mkdir -p "$(OPENOCD_BUILD_DIR)"
958 $(V1) git clone --no-checkout $(OPENOCD_URL) "$(DL_DIR)/openocd-build"
959 $(V1) ( \
960 cd $(OPENOCD_BUILD_DIR) ; \
961 git checkout -q $(OPENOCD_REV) ; \
964 # apply patches
965 $(V0) @echo " PATCH $(OPENOCD_BUILD_DIR)"
966 $(V1) ( \
967 cd $(OPENOCD_BUILD_DIR) ; \
968 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0001-armv7m-remove-dummy-FP-regs-for-new-gdb.patch ; \
969 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0002-rtos-add-stm32_stlink-to-FreeRTOS-targets.patch ; \
972 # build and install
973 $(V0) @echo " BUILD $(OPENOCD_WIN_DIR)"
974 $(V1) mkdir -p "$(OPENOCD_WIN_DIR)"
975 $(V1) ( \
976 cd $(OPENOCD_BUILD_DIR) ; \
977 ./bootstrap ; \
978 ./configure --enable-maintainer-mode --prefix="$(OPENOCD_WIN_DIR)" \
979 --build=i686-pc-linux-gnu --host=i586-mingw32msvc \
980 CPPFLAGS=-I$(LIBUSB_WIN_DIR)/include \
981 LDFLAGS=-L$(LIBUSB_WIN_DIR)/lib/gcc \
982 --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=$(FTD2XX_DIR) \
983 --disable-werror \
984 --enable-stlink ; \
985 $(MAKE) ; \
986 $(MAKE) install ; \
989 # delete the extracted source when we're done
990 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
992 .PHONY: openocd_win_clean
993 openocd_win_clean:
994 $(V0) @echo " CLEAN $(OPENOCD_WIN_DIR)"
995 $(V1) [ ! -d "$(OPENOCD_WIN_DIR)" ] || $(RM) -r "$(OPENOCD_WIN_DIR)"
997 .PHONY: openocd_git_install
999 openocd_git_install: | $(DL_DIR) $(TOOLS_DIR)
1000 openocd_git_install: OPENOCD_URL := git://openocd.git.sourceforge.net/gitroot/openocd/openocd
1001 openocd_git_install: OPENOCD_REV := f1c0133321c8fcadadd10bba5537c0a634eb183b
1002 openocd_git_install: openocd_clean
1003 # download the source
1004 $(V0) @echo " DOWNLOAD $(OPENOCD_URL) @ $(OPENOCD_REV)"
1005 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1006 $(V1) mkdir -p "$(OPENOCD_BUILD_DIR)"
1007 $(V1) git clone --no-checkout $(OPENOCD_URL) "$(OPENOCD_BUILD_DIR)"
1008 $(V1) ( \
1009 cd $(OPENOCD_BUILD_DIR) ; \
1010 git checkout -q $(OPENOCD_REV) ; \
1013 # apply patches
1014 $(V0) @echo " PATCH $(OPENOCD_DIR)"
1015 $(V1) ( \
1016 cd $(OPENOCD_BUILD_DIR) ; \
1017 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0001-armv7m-remove-dummy-FP-regs-for-new-gdb.patch ; \
1018 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0002-rtos-add-stm32_stlink-to-FreeRTOS-targets.patch ; \
1021 # build and install
1022 $(V0) @echo " BUILD $(OPENOCD_DIR)"
1023 $(V1) mkdir -p "$(OPENOCD_DIR)"
1024 $(V1) ( \
1025 cd $(OPENOCD_BUILD_DIR) ; \
1026 ./bootstrap ; \
1027 ./configure --enable-maintainer-mode --prefix="$(OPENOCD_DIR)" --enable-ft2232_libftdi --enable-buspirate --enable-stlink ; \
1028 $(MAKE) ; \
1029 $(MAKE) install ; \
1032 # delete the extracted source when we're done
1033 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1035 .PHONY: openocd_clean
1036 openocd_clean:
1037 $(V0) @echo " CLEAN $(OPENOCD_DIR)"
1038 $(V1) [ ! -d "$(OPENOCD_DIR)" ] || $(RM) -r "$(OPENOCD_DIR)"
1040 STM32FLASH_DIR := $(TOOLS_DIR)/stm32flash
1041 ifeq ($(UNAME), Windows)
1042 STM32FLASH_BUILD_OPTIONS := "CC=GCC"
1043 endif
1044 .PHONY: stm32flash_install
1045 stm32flash_install: STM32FLASH_URL := https://code.google.com/p/stm32flash/
1046 stm32flash_install: STM32FLASH_REV := a358bd1f025d
1047 stm32flash_install: stm32flash_clean
1048 # download the source
1049 $(V0) @$(ECHO) " DOWNLOAD $(STM32FLASH_URL) @ r$(STM32FLASH_REV)"
1050 $(V1) [ ! -d "$(STM32FLASH_DIR)" ] || $(RM) -rf "$(STM32FLASH_DIR)"
1051 $(V1) $(MKDIR) -p "$(STM32FLASH_DIR)"
1052 $(V1) $(GIT) clone --no-checkout $(STM32FLASH_URL) "$(STM32FLASH_DIR)"
1053 $(V1) ( \
1054 $(CD) $(STM32FLASH_DIR) ; \
1055 $(GIT) checkout -q $(STM32FLASH_REV) ; \
1057 # build
1058 $(V0) @$(ECHO) " BUILD $(STM32FLASH_DIR)"
1059 $(V1) $(MAKE) --silent -C $(STM32FLASH_DIR) all $(STM32FLASH_BUILD_OPTIONS)
1061 .PHONY: stm32flash_clean
1062 stm32flash_clean:
1063 $(V0) @$(ECHO) " CLEAN $(STM32FLASH_DIR)"
1064 $(V1) [ ! -d "$(STM32FLASH_DIR)" ] || $(RM) -rf "$(STM32FLASH_DIR)"
1066 DFUUTIL_DIR := $(TOOLS_DIR)/dfu-util
1068 .PHONY: dfuutil_install
1069 dfuutil_install: DFUUTIL_URL := http://dfu-util.sourceforge.net/releases/dfu-util-0.8.tar.gz
1070 dfuutil_install: DFUUTIL_FILE := $(notdir $(DFUUTIL_URL))
1071 dfuutil_install: | $(DL_DIR) $(TOOLS_DIR)
1072 dfuutil_install: dfuutil_clean
1073 # download the source
1074 $(V0) @echo " DOWNLOAD $(DFUUTIL_URL)"
1075 $(V1) $(CURL) $(CURL_OPTIONS) -o "$(DL_DIR)/$(DFUUTIL_FILE)" "$(DFUUTIL_URL)"
1077 # extract the source
1078 $(V0) @echo " EXTRACT $(DFUUTIL_FILE)"
1079 $(V1) [ ! -d "$(DL_DIR)/dfuutil-build" ] || $(RM) -r "$(DL_DIR)/dfuutil-build"
1080 $(V1) mkdir -p "$(DL_DIR)/dfuutil-build"
1081 $(V1) tar -C $(DL_DIR)/dfuutil-build -xf "$(DL_DIR)/$(DFUUTIL_FILE)"
1083 # build
1084 $(V0) @echo " BUILD $(DFUUTIL_DIR)"
1085 $(V1) mkdir -p "$(DFUUTIL_DIR)"
1086 $(V1) ( \
1087 cd $(DL_DIR)/dfuutil-build/dfu-util-0.8 ; \
1088 ./configure --prefix="$(DFUUTIL_DIR)" ; \
1089 $(MAKE) ; \
1090 $(MAKE) install ; \
1093 .PHONY: dfuutil_clean
1094 dfuutil_clean:
1095 $(V0) @echo " CLEAN $(DFUUTIL_DIR)"
1096 $(V1) [ ! -d "$(DFUUTIL_DIR)" ] || $(RM) -r "$(DFUUTIL_DIR)"
1098 # see http://developer.android.com/sdk/ for latest versions
1099 ANDROID_SDK_DIR := $(TOOLS_DIR)/android-sdk-linux
1100 .PHONY: android_sdk_install
1101 android_sdk_install: ANDROID_SDK_URL := http://dl.google.com/android/android-sdk_r20.0.3-linux.tgz
1102 android_sdk_install: ANDROID_SDK_FILE := $(notdir $(ANDROID_SDK_URL))
1103 # order-only prereq on directory existance:
1104 android_sdk_install: | $(DL_DIR) $(TOOLS_DIR)
1105 android_sdk_install: android_sdk_clean
1106 # download the source only if it's newer than what we already have
1107 $(V0) @echo " DOWNLOAD $(ANDROID_SDK_URL)"
1108 $(V1) $(WGET) --no-check-certificate -N -P "$(DL_DIR)" "$(ANDROID_SDK_URL)"
1110 # binary only release so just extract it
1111 $(V0) @echo " EXTRACT $(ANDROID_SDK_FILE)"
1112 $(V1) tar -C $(TOOLS_DIR) -xf "$(DL_DIR)/$(ANDROID_SDK_FILE)"
1114 .PHONY: android_sdk_clean
1115 android_sdk_clean:
1116 $(V0) @echo " CLEAN $(ANDROID_SDK_DIR)"
1117 $(V1) [ ! -d "$(ANDROID_SDK_DIR)" ] || $(RM) -r $(ANDROID_SDK_DIR)
1119 .PHONY: android_sdk_update
1120 android_sdk_update:
1121 $(V0) @echo " UPDATE $(ANDROID_SDK_DIR)"
1122 $(ANDROID_SDK_DIR)/tools/android update sdk --no-ui -t platform-tools,android-16,addon-google_apis-google-16
1124 #Install git hooks under the right folder
1126 .PHONY: prepare
1127 prepare:
1128 $(V0) @echo " Configuring GIT commit template"
1129 $(V1) $(CD) "$(ROOT_DIR)"
1130 $(V1) $(GIT) config commit.template .commit-template
1132 .PHONY: prepare_clean
1133 prepare_clean:
1134 $(V0) @echo " Cleanup GIT commit template configuration"
1135 $(V1) $(CD) "$(ROOT_DIR)"
1136 $(V1) $(GIT) config --unset commit.template
1138 ##############################
1140 # TODO: these defines will go to tool install sections
1142 ##############################
1144 ifeq ($(shell [ -d "$(OPENOCD_DIR)" ] && $(ECHO) "exists"), exists)
1145 export OPENOCD := $(OPENOCD_DIR)/bin/openocd
1146 else
1147 # not installed, hope it's in the path...
1148 export OPENOCD ?= openocd
1149 endif
1151 ifeq ($(shell [ -d "$(ANDROID_SDK_DIR)" ] && $(ECHO) "exists"), exists)
1152 ANDROID := $(ANDROID_SDK_DIR)/tools/android
1153 ANDROID_DX := $(ANDROID_SDK_DIR)/platform-tools/dx
1154 else
1155 # not installed, hope it's in the path...
1156 ANDROID ?= android
1157 ANDROID_DX ?= dx
1158 endif