Revert "Revert "Merge remote-tracking branch 'origin/parched/OP-1324_fix_build_when_p...
[librepilot.git] / make / tools.mk
blob925751d0e73a03881e444e98795c34b3d0a08cce
2 # Installers for tools required by the OpenPilot build system.
3 # Copyright (c) 2010-2013, The OpenPilot Team, http://www.openpilot.org
5 # NOTE: install targets are not tied to the default goals and must
6 # be invoked manually. But tool paths set by this file are used
7 # across the build system.
9 # Ready to use:
10 # arm_sdk_install
11 # qt_sdk_install
12 # mingw_install (Windows only - NOT USED for Qt-5.3.x)
13 # python_install (Windows only - NOT USED for Qt-5.3.x)
14 # nsis_install (Windows only)
15 # sdl_install (Windows only)
16 # openssl_install (Windows only)
17 # mesawin_install (Windows only)
18 # uncrustify_install
19 # doxygen_install
20 # gtest_install
22 # TODO:
23 # openocd_install
24 # ftd2xx_install
25 # libusb_win_install
26 # openocd_git_win_install
27 # openocd_git_install
28 # stm32flash_install
29 # dfuutil_install
30 # android_sdk_install
32 # TODO:
33 # help in the top Makefile
35 # This program is free software; you can redistribute it and/or modify
36 # it under the terms of the GNU General Public License as published by
37 # the Free Software Foundation; either version 3 of the License, or
38 # (at your option) any later version.
40 # This program is distributed in the hope that it will be useful, but
41 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
42 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
43 # for more details.
45 # You should have received a copy of the GNU General Public License along
46 # with this program; if not, write to the Free Software Foundation, Inc.,
47 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
50 ifndef OPENPILOT_IS_COOL
51 $(error $(notdir $(lastword $(MAKEFILE_LIST))) should be included by the top level Makefile)
52 endif
54 ##############################
56 # Toolchain URLs and directories
58 ##############################
60 ifeq ($(UNAME), Linux)
61 ifeq ($(ARCH), x86_64)
62 ARM_SDK_URL := https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q1-update/+download/gcc-arm-none-eabi-4_8-2014q1-20140314-linux.tar.bz2
63 ARM_SDK_MD5_URL:= https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q1-update/+download/gcc-arm-none-eabi-4_8-2014q1-20140314-linux.tar.bz2/+md5
64 QT_SDK_URL := http://download.qt-project.org/official_releases/qt/5.3/5.3.1/qt-opensource-linux-x64-5.3.1.run
65 QT_SDK_MD5_URL := http://download.qt-project.org/official_releases/qt/5.3/5.3.1/qt-opensource-linux-x64-5.3.1.run.md5
66 QT_SDK_ARCH := gcc_64
67 else
68 ARM_SDK_URL := https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q1-update/+download/gcc-arm-none-eabi-4_8-2014q1-20140314-linux.tar.bz2
69 ARM_SDK_MD5_URL := https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q1-update/+download/gcc-arm-none-eabi-4_8-2014q1-20140314-linux.tar.bz2/+md5
70 QT_SDK_URL := http://download.qt-project.org/official_releases/qt/5.3/5.3.1/qt-opensource-linux-x86-5.3.1.run
71 QT_SDK_MD5_URL := http://download.qt-project.org/official_releases/qt/5.3/5.3.1/qt-opensource-linux-x86-5.3.1.run.md5
72 QT_SDK_ARCH := gcc
73 endif
74 UNCRUSTIFY_URL := http://wiki.openpilot.org/download/attachments/18612236/uncrustify-0.60.tar.gz
75 DOXYGEN_URL := http://wiki.openpilot.org/download/attachments/18612236/doxygen-1.8.3.1.src.tar.gz
76 else ifeq ($(UNAME), Darwin)
77 ARM_SDK_URL := https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q1-update/+download/gcc-arm-none-eabi-4_8-2014q1-20140314-mac.tar.bz2
78 ARM_SDK_MD5_URL:= https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q1-update/+download/gcc-arm-none-eabi-4_8-2014q1-20140314-mac.tar.bz2/+md5
79 QT_SDK_URL := http://download.qt-project.org/official_releases/qt/5.3/5.3.1/qt-opensource-mac-x64-clang-5.3.1.dmg
80 QT_SDK_MD5_URL := http://download.qt-project.org/official_releases/qt/5.3/5.3.1/qt-opensource-mac-x64-clang-5.3.1.dmg.md5
81 QT_SDK_ARCH := clang_64
82 QT_SDK_MAINTENANCE_TOOL := /Volumes/qt-opensource-mac-x64-clang-5.3.1/qt-opensource-mac-x64-clang-5.3.1.app/Contents/MacOS/qt-opensource-mac-x64-clang-5.3.1
83 QT_SDK_MOUNT_DIR := /Volumes/qt-opensource-mac-x64-clang-5.3.1
84 QT_SDK_INSTALLER_DAT := /Volumes/qt-opensource-mac-x64-clang-5.3.1/qt-opensource-mac-x64-clang-5.3.1.app/Contents/Resources/installer.dat
85 UNCRUSTIFY_URL := http://wiki.openpilot.org/download/attachments/18612236/uncrustify-0.60.tar.gz
86 DOXYGEN_URL := http://wiki.openpilot.org/download/attachments/18612236/doxygen-1.8.3.1.src.tar.gz
87 else ifeq ($(UNAME), Windows)
88 ARM_SDK_URL := https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q1-update/+download/gcc-arm-none-eabi-4_8-2014q1-20140314-win32.zip
89 ARM_SDK_MD5_URL:= https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q1-update/+download/gcc-arm-none-eabi-4_8-2014q1-20140314-win32.zip/+md5
90 QT_SDK_URL := http://download.qt-project.org/official_releases/qt/5.3/5.3.1/qt-opensource-windows-x86-mingw482_opengl-5.3.1.exe
91 QT_SDK_MD5_URL := http://download.qt-project.org/official_releases/qt/5.3/5.3.1/qt-opensource-windows-x86-mingw482_opengl-5.3.1.exe.md5
92 QT_SDK_ARCH := mingw482_32
93 NSIS_URL := http://wiki.openpilot.org/download/attachments/18612236/nsis-2.46-unicode.tar.bz2
94 SDL_URL := http://wiki.openpilot.org/download/attachments/18612236/SDL-devel-1.2.15-mingw32.tar.gz
95 OPENSSL_URL := http://wiki.openpilot.org/download/attachments/18612236/openssl-1.0.1e-win32.tar.bz2
96 UNCRUSTIFY_URL := http://wiki.openpilot.org/download/attachments/18612236/uncrustify-0.60-windows.tar.bz2
97 DOXYGEN_URL := http://wiki.openpilot.org/download/attachments/18612236/doxygen-1.8.3.1-windows.tar.bz2
98 MESAWIN_URL := http://wiki.openpilot.org/download/attachments/18612236/mesawin.tar.gz
99 endif
101 GTEST_URL := http://wiki.openpilot.org/download/attachments/18612236/gtest-1.6.0.zip
103 # Changing PYTHON_DIR, also update it in ground/openpilotgcs/src/python.pri
104 ARM_SDK_DIR := $(TOOLS_DIR)/gcc-arm-none-eabi-4_8-2014q1
105 QT_SDK_DIR := $(TOOLS_DIR)/qt-5.3.1
106 MINGW_DIR := $(QT_SDK_DIR)/Tools/mingw48_32
107 PYTHON_DIR := $(QT_SDK_DIR)/Tools/mingw48_32/opt/bin
108 NSIS_DIR := $(TOOLS_DIR)/nsis-2.46-unicode
109 SDL_DIR := $(TOOLS_DIR)/SDL-1.2.15
110 OPENSSL_DIR := $(TOOLS_DIR)/openssl-1.0.1e-win32
111 UNCRUSTIFY_DIR := $(TOOLS_DIR)/uncrustify-0.60
112 DOXYGEN_DIR := $(TOOLS_DIR)/doxygen-1.8.3.1
113 GTEST_DIR := $(TOOLS_DIR)/gtest-1.6.0
115 ifeq ($(UNAME), Windows)
116 MINGW_DIR := $(QT_SDK_DIR)/Tools/$(QT_SDK_ARCH)
117 PYTHON_DIR := $(QT_SDK_DIR)/Tools/$(QT_SDK_ARCH)/opt/bin
118 NSIS_DIR := $(TOOLS_DIR)/nsis-2.46-unicode
119 SDL_DIR := $(TOOLS_DIR)/SDL-1.2.15
120 OPENSSL_DIR := $(TOOLS_DIR)/openssl-1.0.1e-win32
121 MESAWIN_DIR := $(TOOLS_DIR)/mesawin
122 endif
124 QT_SDK_PREFIX := $(QT_SDK_DIR)
126 ##############################
128 # Build only and all toolchains available for the platform
130 ##############################
132 BUILD_SDK_TARGETS := arm_sdk qt_sdk
133 ifeq ($(UNAME), Windows)
134 BUILD_SDK_TARGETS += sdl nsis mesawin openssl
135 endif
136 ALL_SDK_TARGETS := $(BUILD_SDK_TARGETS) gtest uncrustify doxygen
138 define GROUP_SDK_TEMPLATE
139 .PHONY: $(1)_install $(1)_clean $(1)_distclean $(1)_version
140 $(1)_install: $(addsuffix _install,$(2))
141 $(1)_clean: $(addsuffix _clean,$(2))
142 $(1)_distclean: $(addsuffix _distclean,$(2))
143 $(1)_version: $(addsuffix _version,$(2))
144 endef
146 $(eval $(call GROUP_SDK_TEMPLATE,build_sdk,$(BUILD_SDK_TARGETS)))
147 $(eval $(call GROUP_SDK_TEMPLATE,all_sdk,$(ALL_SDK_TARGETS)))
149 ##############################
151 # Misc host tools
153 ##############################
155 # Used by other makefiles
156 export MKDIR := mkdir
157 export CP := cp
158 export RM := rm
159 export LN := ln
160 export CAT := cat
161 export CUT := cut
162 export SED := sed
164 # Used only by this Makefile
165 GIT := git
166 CURL := curl
167 TAR := tar
168 UNZIP := unzip
169 OPENSSL := openssl
170 ANT := ant
171 JAVAC := javac
172 JAR := jar
173 CD := cd
174 GREP := grep
175 ifneq ($(UNAME), Windows)
176 SEVENZIP := 7za
177 else
178 SEVENZIP := 7za.exe
179 ifneq ($(shell $(SEVENZIP) --version >/dev/null 2>&1 && $(ECHO) "found"), found)
180 # no $(SEVENZIP) found in path. hope is in bin...
181 SEVENZIP = $(TOOLS_DIR)/bin/7za.exe
182 endif
183 endif
185 # Echo in recipes is a bit tricky in a Windows Git Bash window in some cases.
186 # It does not work if make started under msysGit installed into a path with spaces.
187 ifneq ($(UNAME), Windows)
188 export ECHO := echo
189 else
190 # export ECHO := $(PYTHON) -c "import sys; print(' '.join(sys.argv[1:]))"
191 export ECHO := echo
192 endif
194 # Test if quotes are needed for the echo command
195 ifeq ($(shell $(ECHO) "test"), test)
196 export QUOTE := '
197 # This line is just to clear out the single quote above '
198 else
199 export QUOTE :=
200 endif
202 # Command to extract version info data from the repository and source tree
203 export VERSION_INFO = $(PYTHON) $(ROOT_DIR)/make/scripts/version-info.py --path=$(ROOT_DIR)
205 ##############################
207 # Misc settings
209 ##############################
211 # Define messages
212 MSG_VERIFYING = $(QUOTE) VERIFY $(QUOTE)
213 MSG_DOWNLOADING = $(QUOTE) DOWNLOAD $(QUOTE)
214 MSG_CHECKSUMMING = $(QUOTE) MD5 $(QUOTE)
215 MSG_EXTRACTING = $(QUOTE) EXTRACT $(QUOTE)
216 MSG_CONFIGURING = $(QUOTE) CONFIGURE $(QUOTE)
217 MSG_BUILDING = $(QUOTE) BUILD $(QUOTE)
218 MSG_INSTALLING = $(QUOTE) INSTALL $(QUOTE)
219 MSG_CLEANING = $(QUOTE) CLEAN $(QUOTE)
220 MSG_DISTCLEANING = $(QUOTE) DISTCLEAN $(QUOTE)
221 MSG_NOTICE = $(QUOTE) NOTE $(QUOTE)
223 # Verbosity level
224 ifeq ($(V), 1)
225 MAKE_SILENT :=
226 UNZIP_SILENT :=
227 else
228 MAKE_SILENT := --silent
229 UNZIP_SILENT := -q
230 endif
232 # Batch mode
233 ifeq ($(BATCH), 1)
234 CURL_OPTIONS := --silent -L
235 else
236 CURL_OPTIONS := -L
237 endif
239 # MSYS tar workaround
240 ifeq ($(UNAME), Windows)
241 TAR_OPTIONS := --force-local
242 else
243 TAR_OPTIONS :=
244 endif
246 # Print some useful notes for *_install targets
247 ifneq ($(strip $(filter $(addsuffix _install,all_sdk $(ALL_SDK_TARGETS)),$(MAKECMDGOALS))),)
248 ifneq ($(shell $(CURL) --version >/dev/null 2>&1 && $(ECHO) "found"), found)
249 $(error Please install curl first ('apt-get install curl' or similar))
250 endif
251 $(info $(EMPTY) NOTE Use 'make all_sdk_distclean' to remove installation files)
252 $(info $(EMPTY) NOTE Use 'make all_sdk_version' to check toolchain versions)
253 $(info $(EMPTY) NOTE Add 'V=1' to make command line to diagnose make problems)
254 $(info $(EMPTY) NOTE Add 'BATCH=1' to make command line to disable progress reporting during downloads)
255 endif
257 ##############################
259 # Cross-platform MD5 check template
260 # $(1) = file name without quotes
261 # $(2) = string compare operator, e.g. = or !=
263 ##############################
265 define MD5_CHECK_TEMPLATE
266 "`test -f \"$(1)\" && $(OPENSSL) dgst -md5 \"$(1)\" | $(CUT) -f2 -d' '`" $(2) "`$(CUT) -f1 -d' ' < \"$(1).md5\"`"
267 endef
269 ##############################
271 # Cross platform download template
272 # $(1) = Package URL
273 # $(2) = Package file
274 # $(3) = URL for .md5 file to be tested against Package
276 ##############################
278 define DOWNLOAD_TEMPLATE
279 @$(ECHO) $(MSG_VERIFYING) $$(call toprel, $(DL_DIR)/$(2))
280 $(V1) ( \
281 cd "$(DL_DIR)" && \
282 $(CURL) $(CURL_OPTIONS) --silent -o "$(DL_DIR)/$(2).md5" "$(3)" && \
283 if [ $(call MD5_CHECK_TEMPLATE,$(DL_DIR)/$(2),!=) ]; then \
284 $(ECHO) $(MSG_DOWNLOADING) $(1) && \
285 $(CURL) $(CURL_OPTIONS) -o "$(DL_DIR)/$(2)" "$(1)" && \
286 $(ECHO) $(MSG_CHECKSUMMING) $$(call toprel, $(DL_DIR)/$(2)) && \
287 [ $(call MD5_CHECK_TEMPLATE,$(DL_DIR)/$(2),=) ]; \
288 fi; \
290 endef
292 ##############################
294 # Common tool install template
295 # $(1) = tool name
296 # $(2) = tool extract/build directory
297 # $(3) = tool distribution URL
298 # $(4) = tool distribution MD5 URL
299 # $(5) = tool distribution file
300 # $(6) = optional extra build recipes template
301 # $(7) = optional extra clean recipes template
303 ##############################
307 define TOOL_INSTALL_TEMPLATE
309 .PHONY: $(addprefix $(1)_, install clean distclean)
311 $(1)_install: $(1)_clean | $(DL_DIR) $(TOOLS_DIR)
313 $(if $(4), $(call DOWNLOAD_TEMPLATE,$(3),$(5),$(4)),$(call DOWNLOAD_TEMPLATE,$(3),$(5),"$(3).md5"))
315 @$(ECHO) $(MSG_EXTRACTING) $$(call toprel, $(2))
316 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(2)))
318 $(if $(filter $(suffix $(5)), .zip),
319 $(V1) $(UNZIP) $(UNZIP_SILENT) -d $$(call toprel, $(dir $(2))) $$(call toprel, $(DL_DIR)/$(5)),
320 $(V1) $(TAR) $(TAR_OPTIONS) -C $$(call toprel, $(dir $(2))) -xf $$(call toprel, $(DL_DIR)/$(5))
323 $(6)
325 $(1)_clean:
326 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(2))
327 $(V1) [ ! -d "$(2)" ] || $(RM) -rf "$(2)"
329 $(7)
331 $(1)_distclean:
332 @$(ECHO) $(MSG_DISTCLEANING) $$(call toprel, $(DL_DIR)/$(5))
333 $(V1) [ ! -f "$(DL_DIR)/$(5)" ] || $(RM) "$(DL_DIR)/$(5)"
334 $(V1) [ ! -f "$(DL_DIR)/$(5).md5" ] || $(RM) "$(DL_DIR)/$(5).md5"
336 endef
338 ##############################
340 # Windows QT install template
341 # $(1) = tool temp extract/build directory
342 # $(2) = tool install directory
343 # $(3) = tool distribution URL
344 # $(4) = tool distribution .md5 URL
345 # $(5) = tool distribution file
346 # $(6) = QT architecture
347 # $(7) = optional extra build recipes template
348 # $(8) = optional extra clean recipes template
350 ##############################
352 define WIN_QT_INSTALL_TEMPLATE
354 .PHONY: $(addprefix qt_sdk_, install clean distclean)
356 qt_sdk_install: qt_sdk_clean | $(DL_DIR) $(TOOLS_DIR)
357 $(V1) if ! $(SEVENZIP) >/dev/null 2>&1; then \
358 $(ECHO) $(MSG_NOTICE) "Missing 7zip. Run ./make/scripts/win_sdk_install.sh [<OpenPilot tools dir>] to get it." && \
359 exit 1; \
361 $(call DOWNLOAD_TEMPLATE,$(3),$(5),"$(4)")
362 # Explode .run file into install packages
363 @$(ECHO) $(MSG_EXTRACTING) $$(call toprel, $(1))
364 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(1)))
365 $(V1) chmod +x $(DL_DIR)/$(5)
366 $(V1) $(DL_DIR)/$(5) --dump-binary-data -o $(1)
367 # Extract packages under tool directory
368 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(2)))
369 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.readme/1.0.0-0qt-project-url.7z" | grep -v Extracting
370 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt/5.3.1ThirdPartySoftware_Listing.7z" | grep -v Extracting
371 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.readme/1.0.0-0readme.7z" | grep -v Extracting
372 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.53.win32_mingw482/5.3.1-0qt5_essentials.7z" | grep -v Extracting
373 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.53.win32_mingw482/5.3.1-0i686-4.8.2-release-posix-dwarf-rt_v3-rev3-runtime.7z" | grep -v Extracting
374 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.53.win32_mingw482/5.3.1-0icu_52_1_mingw_builds_32_4_8_2_posix_dwarf.7z" | grep -v Extracting
375 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.53.win32_mingw482/5.3.1-0qt5_addons.7z" | grep -v Extracting
376 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.tools.win32_mingw482/4.8.2i686-4.8.2-release-posix-dwarf-rt_v3-rev3.7z" | grep -v Extracting
377 # Run patcher
378 @$(ECHO)
379 @$(ECHO) "Executing QtPatch in" $$(call toprel, $(QT_SDK_PREFIX))
380 $(V1) $(CD) $(QT_SDK_PREFIX)
381 $(V1) $(DL_DIR)/$(5) --runoperation QtPatch windows $(QT_SDK_PREFIX) qt5
383 # Execute post build templates
384 $(7)
386 # Clean up temporary files
387 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
388 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
390 qt_sdk_clean:
391 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
392 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
393 @$(ECHO) $(MSG_CLEANING) $$(call toprel, "$(2)")
394 $(V1) [ ! -d "$(2)" ] || $(RM) -rf "$(2)"
396 $(8)
398 qt_sdk_distclean:
399 @$(ECHO) $(MSG_DISTCLEANING) $$(call toprel, $(DL_DIR)/$(5))
400 $(V1) [ ! -f "$(DL_DIR)/$(5)" ] || $(RM) "$(DL_DIR)/$(5)"
401 $(V1) [ ! -f "$(DL_DIR)/$(5).md5" ] || $(RM) "$(DL_DIR)/$(5).md5"
403 endef
405 ##############################
407 # Linux QT install template
408 # $(1) = tool temp extract/build directory
409 # $(2) = tool install directory
410 # $(3) = tool distribution URL
411 # $(4) = tool distribution .md5 URL
412 # $(5) = tool distribution file
413 # $(6) = QT architecture
414 # $(7) = optional extra build recipes template
415 # $(8) = optional extra clean recipes template
417 ##############################
419 define LINUX_QT_INSTALL_TEMPLATE
421 .PHONY: $(addprefix qt_sdk_, install clean distclean)
423 qt_sdk_install: qt_sdk_clean | $(DL_DIR) $(TOOLS_DIR)
424 $(V1) if ! $(SEVENZIP) >/dev/null 2>&1; then \
425 $(ECHO) $(MSG_NOTICE) "Please install the p7zip for your distribution. i.e.: sudo apt-get install p7zip-full" && \
426 exit 1; \
428 $(call DOWNLOAD_TEMPLATE,$(3),$(5),"$(4)")
429 # Explode .run file into install packages
430 @$(ECHO) $(MSG_EXTRACTING) $$(call toprel, $(1))
431 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(1)))
432 $(V1) chmod +x $(DL_DIR)/$(5)
433 $(V1) $(DL_DIR)/$(5) --dump-binary-data -o $(1)
434 # Extract packages under tool directory
435 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(2)))
436 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.readme/1.0.0-0qt-project-url.7z" | grep -v Extracting
437 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt/5.3.1ThirdPartySoftware_Listing.7z" | grep -v Extracting
438 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.readme/1.0.0-0readme.7z" | grep -v Extracting
439 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.53.$(6)/5.3.1-0qt5_essentials.7z" | grep -v Extracting
440 $(V1) if [ -f "$(1)/qt.53.$(6)/5.3.1-0icu_51_1_ubuntu_11_10_64.7z" ]; then $(SEVENZIP) -y -o$(2) x "$(1)/qt.53.$(6)/5.3.1-0icu_51_1_ubuntu_11_10_64.7z" | grep -v Extracting; fi
441 $(V1) if [ -f "$(1)/qt.53.$(6)/5.3.1-0icu_51_1_ubuntu_11_10_32.7z" ]; then $(SEVENZIP) -y -o$(2) x "$(1)/qt.53.$(6)/5.3.1-0icu_51_1_ubuntu_11_10_32.7z" | grep -v Extracting; fi
442 # $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.53.$(6).essentials/5.3.1icu_path_patcher.sh.7z" | grep -v Extracting
443 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.53.$(6)/5.3.1-0qt5_addons.7z" | grep -v Extracting
444 # go to OpenPilot/tools/5.3.1/gcc_64 and call patcher.sh
445 @$(ECHO)
446 @$(ECHO) "Running patcher in" $$(call toprel, $(QT_SDK_PREFIX))
447 $(V1) $(CD) $(QT_SDK_PREFIX)
448 # $(V1) "$(QT_SDK_PREFIX)/patcher.sh" $(QT_SDK_PREFIX)
449 # call qmake patcher
450 @$(ECHO) "Executing QtPatch in" $$(call toprel, $(QT_SDK_PREFIX))
451 $(V1) $(DL_DIR)/$(5) --runoperation QtPatch linux $(QT_SDK_PREFIX) qt5
453 # Execute post build templates
454 $(7)
456 # Clean up temporary files
457 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
458 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
460 qt_sdk_clean:
461 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
462 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
463 @$(ECHO) $(MSG_CLEANING) $$(call toprel, "$(2)")
464 $(V1) [ ! -d "$(2)" ] || $(RM) -rf "$(2)"
466 $(8)
468 qt_sdk_distclean:
469 @$(ECHO) $(MSG_DISTCLEANING) $$(call toprel, $(DL_DIR)/$(5))
470 $(V1) [ ! -f "$(DL_DIR)/$(5)" ] || $(RM) "$(DL_DIR)/$(5)"
471 $(V1) [ ! -f "$(DL_DIR)/$(5).md5" ] || $(RM) "$(DL_DIR)/$(5).md5"
473 endef
476 ##############################
478 # Mac QT install template
479 # $(1) = tool temp extract/build directory
480 # $(2) = tool install directory
481 # $(3) = tool distribution URL
482 # $(4) = tool distribution .md5 URL
483 # $(5) = tool distribution file
484 # $(6) = QT architecture
485 # $(7) = optional extra build recipes template
486 # $(8) = optional extra clean recipes template
488 ##############################
490 define MAC_QT_INSTALL_TEMPLATE
492 .PHONY: $(addprefix qt_sdk_, install clean distclean)
494 qt_sdk_install: qt_sdk_clean | $(DL_DIR) $(TOOLS_DIR)
495 $(V1) if ! $(SEVENZIP) >/dev/null 2>&1; then \
496 $(ECHO) $(MSG_NOTICE) "Please install the p7zip for your distribution. i.e.: sudo brew install p7zip." && \
497 exit 1; \
499 $(call DOWNLOAD_TEMPLATE,$(3),$(5),"$(4)")
500 # Mount .dmg file
501 $(V1) hdiutil attach -nobrowse $(DL_DIR)/$(5)
502 # Explode .dmg file into install packages
503 @$(ECHO) $(MSG_EXTRACTING) $$(call toprel, $(1))
504 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(1)))
505 $(V1) $(QT_SDK_MAINTENANCE_TOOL) --dump-binary-data -i $(QT_SDK_INSTALLER_DAT) -o $(1)
506 # Extract packages under tool directory
507 $(V1) $(MKDIR) -p $$(call toprel, $(dir $(2)))
508 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.readme/1.0.0-0qt-project-url.7z" | grep -v Extracting
509 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt/5.3.1ThirdPartySoftware_Listing.7z" | grep -v Extracting
510 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.readme/1.0.0-0readme.7z" | grep -v Extracting
511 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.53.$(6)/5.3.1-0qt5_essentials.7z" | grep -v Extracting
512 # $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.53.$(6).essentials/5.3.1icu_path_patcher.sh.7z" | grep -v Extracting
513 $(V1) $(SEVENZIP) -y -o$(2) x "$(1)/qt.53.$(6)/5.3.1-0qt5_addons.7z" | grep -v Extracting
514 # go to OpenPilot/tools/5.3.1/gcc_64 and call patcher.sh
515 @$(ECHO)
516 @$(ECHO) "Running patcher in" $$(call toprel, $(QT_SDK_PREFIX))
517 $(V1) $(CD) $(QT_SDK_PREFIX)
518 # $(V1) "$(QT_SDK_PREFIX)/patcher.sh" $(QT_SDK_PREFIX)
519 # call qmake patcher
520 @$(ECHO) "Executing QtPatch in" $$(call toprel, $(QT_SDK_PREFIX))
521 $(V1) $(QT_SDK_MAINTENANCE_TOOL) --runoperation QtPatch mac $(QT_SDK_PREFIX) qt5
523 #Unmount the .dmg file
524 $(V1) hdiutil detach $(QT_SDK_MOUNT_DIR)
526 # Execute post build templates
527 $(7)
529 # Clean up temporary files
530 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
531 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
533 qt_sdk_clean:
534 @$(ECHO) $(MSG_CLEANING) $$(call toprel, $(1))
535 $(V1) [ ! -d "$(1)" ] || $(RM) -rf "$(1)"
536 @$(ECHO) $(MSG_CLEANING) $$(call toprel, "$(2)")
537 $(V1) [ ! -d "$(2)" ] || $(RM) -rf "$(2)"
539 $(8)
541 qt_sdk_distclean:
542 @$(ECHO) $(MSG_DISTCLEANING) $$(call toprel, $(DL_DIR)/$(5))
543 $(V1) [ ! -f "$(DL_DIR)/$(5)" ] || $(RM) "$(DL_DIR)/$(5)"
544 $(V1) [ ! -f "$(DL_DIR)/$(5).md5" ] || $(RM) "$(DL_DIR)/$(5).md5"
546 endef
548 ##############################
550 # ARM SDK
552 ##############################
553 ifeq ($(UNAME), Windows)
554 #unfortunately zip package for this release is missing root directory, so adding / at the end of the path
555 # so that template interpret last part as directory and use the full path
556 $(eval $(call TOOL_INSTALL_TEMPLATE,arm_sdk,$(ARM_SDK_DIR)/,$(ARM_SDK_URL),$(ARM_SDK_MD5_URL),$(notdir $(ARM_SDK_URL))))
557 else
558 $(eval $(call TOOL_INSTALL_TEMPLATE,arm_sdk,$(ARM_SDK_DIR),$(ARM_SDK_URL),$(ARM_SDK_MD5_URL),$(notdir $(ARM_SDK_URL))))
559 endif
560 ifeq ($(shell [ -d "$(ARM_SDK_DIR)" ] && $(ECHO) "exists"), exists)
561 export ARM_SDK_PREFIX := $(ARM_SDK_DIR)/bin/arm-none-eabi-
562 else
563 # not installed, hope it's in the path...
564 # $(info $(EMPTY) WARNING $(call toprel, $(ARM_SDK_DIR)) not found (make arm_sdk_install), using system PATH)
565 export ARM_SDK_PREFIX ?= arm-none-eabi-
566 endif
568 .PHONY: arm_sdk_version
569 arm_sdk_version:
570 -$(V1) $(ARM_SDK_PREFIX)gcc --version | head -n1
572 # Template to check ARM toolchain version before building targets
573 define ARM_GCC_VERSION_CHECK_TEMPLATE
574 if ! $(ARM_SDK_PREFIX)gcc --version --specs=nano.specs >/dev/null 2>&1; then \
575 $(ECHO) $(MSG_NOTICE) Please install ARM toolchain 4.8 2014q1 using \'make arm_sdk_install\' && \
576 $(ECHO) $(MSG_NOTICE) Older ARM SDKs do not support new \'--specs=nano.specs\' option && \
577 exit 1; \
579 endef
581 ##############################
583 # Qt SDK
585 ##############################
587 ifeq ($(UNAME), Windows)
589 QT_SDK_PREFIX := $(QT_SDK_DIR)/5.3/$(QT_SDK_ARCH)
591 # This additional configuration step should not be necessary
592 # but it is needed as a workaround to https://bugreports.qt-project.org/browse/QTBUG-33254
593 define QT_SDK_CONFIGURE_TEMPLATE
594 @$(ECHO) $(MSG_CONFIGURING) $(call toprel, $(QT_SDK_DIR))
595 $(V1) $(ECHO) $(QUOTE)[Paths]$(QUOTE) > $(QT_SDK_PREFIX)/bin/qt.conf
596 $(V1) $(ECHO) $(QUOTE)Prefix = $(QT_SDK_PREFIX)$(QUOTE) >> $(QT_SDK_PREFIX)/bin/qt.conf
597 endef
599 QT_BUILD_DIR := $(BUILD_DIR)/QT_BUILD
600 $(eval $(call WIN_QT_INSTALL_TEMPLATE,$(QT_BUILD_DIR),$(QT_SDK_DIR),$(QT_SDK_URL),$(QT_SDK_MD5_URL),$(notdir $(QT_SDK_URL)),$(QT_SDK_ARCH),$(QT_SDK_CONFIGURE_TEMPLATE)))
602 else ifeq ($(UNAME), Linux)
604 QT_SDK_PREFIX := "$(QT_SDK_DIR)/5.3/$(QT_SDK_ARCH)"
605 QT_BUILD_DIR := $(BUILD_DIR)/QT_BUILD
606 $(eval $(call LINUX_QT_INSTALL_TEMPLATE,$(QT_BUILD_DIR),$(QT_SDK_DIR),$(QT_SDK_URL),$(QT_SDK_MD5_URL),$(notdir $(QT_SDK_URL)),$(QT_SDK_ARCH)))
608 else ifeq ($(UNAME), Darwin)
610 QT_SDK_PREFIX := "$(QT_SDK_DIR)/5.3/$(QT_SDK_ARCH)"
611 QT_BUILD_DIR := $(BUILD_DIR)/QT_BUILD
612 $(eval $(call MAC_QT_INSTALL_TEMPLATE,$(QT_BUILD_DIR),$(QT_SDK_DIR),$(QT_SDK_URL),$(QT_SDK_MD5_URL),$(notdir $(QT_SDK_URL)),$(QT_SDK_ARCH)))
614 else
616 QT_SDK_PREFIX := $(QT_SDK_DIR)
618 .PHONY: qt_sdk_install
619 qt_sdk_install:
620 @$(ECHO) $(MSG_NOTICE) --------------------------------------------------------
621 @$(ECHO) $(MSG_NOTICE) Please install native Qt 5.3.x SDK using package manager
622 @$(ECHO) $(MSG_NOTICE) --------------------------------------------------------
624 .PHONY: qt_sdk_clean
625 qt_sdk_clean:
627 .PHONY: qt_sdk_distclean
628 qt_sdk_distclean:
630 endif
632 ifeq ($(shell [ -d "$(QT_SDK_DIR)" ] && $(ECHO) "exists"), exists)
633 export QMAKE := $(QT_SDK_PREFIX)/bin/qmake
635 # set Qt library search path
636 ifeq ($(UNAME), Windows)
637 export PATH := $(QT_SDK_PREFIX)/bin:$(PATH)
638 else
639 export LD_LIBRARY_PATH := $(QT_SDK_DIR)/lib:$(LD_LIBRARY_PATH)
640 endif
641 else
642 # not installed, hope it's in the path...
643 # $(info $(EMPTY) WARNING $(call toprel, $(QT_SDK_DIR)) not found (make qt_sdk_install), using system PATH)
644 QMAKE ?= qmake
645 endif
647 .PHONY: qt_sdk_version
648 qt_sdk_version:
649 -$(V1) $(QMAKE) --version | tail -1
651 ##############################
653 # MinGW
655 ##############################
657 ifeq ($(UNAME), Windows)
659 ifeq ($(shell [ -d "$(MINGW_DIR)" ] && $(ECHO) "exists"), exists)
660 # set MinGW binary and library paths (QTMINGW is used by qmake, do not rename)
661 export QTMINGW := $(MINGW_DIR)/bin
662 export PATH := $(QTMINGW):$(PATH)
663 else
664 # not installed, use host gcc compiler
665 # $(info $(EMPTY) WARNING $(call toprel, $(MINGW_DIR)) not found, using system PATH)
666 endif
668 .PHONY: mingw_version
669 mingw_version: gcc_version
671 else # Linux or Mac
673 all_sdk_version: gcc_version
675 endif
677 .PHONY: gcc_version
678 gcc_version:
679 -$(V1) gcc --version | head -n1
681 ##############################
683 # Python
685 ##############################
687 ifeq ($(shell [ -d "$(PYTHON_DIR)" ] && $(ECHO) "exists"), exists)
688 export PYTHON := $(PYTHON_DIR)/python
689 export PATH := $(PYTHON_DIR):$(PATH)
690 else
691 # not installed, hope it's in the path...
692 # $(info $(EMPTY) WARNING $(call toprel, $(PYTHON_DIR)) not found, using system PATH)
693 ifeq ($(findstring Python 2,$(shell python --version)), Python 2)
694 export PYTHON := python
695 else
696 export PYTHON := python2
697 endif
698 endif
700 .PHONY: python_version
701 python_version:
702 -$(V1) $(PYTHON) --version
704 ##############################
706 # NSIS Unicode (Windows only)
708 ##############################
710 ifeq ($(UNAME), Windows)
712 $(eval $(call TOOL_INSTALL_TEMPLATE,nsis,$(NSIS_DIR),$(NSIS_URL),,$(notdir $(NSIS_URL))))
714 ifeq ($(shell [ -d "$(NSIS_DIR)" ] && $(ECHO) "exists"), exists)
715 export NSIS := $(NSIS_DIR)/makensis
716 else
717 # not installed, hope it's in the path...
718 # $(info $(EMPTY) WARNING $(call toprel, $(NSIS_DIR)) not found (make nsis_install), using system PATH)
719 export NSIS ?= makensis
720 endif
722 .PHONY: nsis_version
723 nsis_version:
724 -$(V1) $(NSIS) | head -n1
726 endif
728 ##############################
730 # SDL (Windows only)
732 ##############################
734 ifeq ($(UNAME), Windows)
736 $(eval $(call TOOL_INSTALL_TEMPLATE,sdl,$(SDL_DIR),$(SDL_URL),,$(notdir $(SDL_URL))))
738 ifeq ($(shell [ -d "$(SDL_DIR)" ] && $(ECHO) "exists"), exists)
739 export SDL_DIR := $(SDL_DIR)
740 else
741 # not installed, hope it's in the path...
742 $(info $(EMPTY) WARNING $(call toprel, $(SDL_DIR)) not found (make sdl_install), using system PATH)
743 endif
745 .PHONY: sdl_version
746 sdl_version:
747 -$(V1) $(ECHO) "SDL 1.2.15"
749 endif
751 ##################################
753 # Mesa OpenGL DLL (Windows only)
755 ##################################
757 ifeq ($(UNAME), Windows)
759 $(eval $(call TOOL_INSTALL_TEMPLATE,mesawin,$(MESAWIN_DIR),$(MESAWIN_URL),,$(notdir $(MESAWIN_URL))))
761 ifeq ($(shell [ -d "$(MESAWIN_DIR)" ] && $(ECHO) "exists"), exists)
762 export MESAWIN_DIR := $(MESAWIN_DIR)
763 else
764 # not installed, hope it's in the path...
765 #$(info $(EMPTY) WARNING $(call toprel, $(MESA_WIN_DIR)) not found (make mesawin_install), using system PATH)
766 endif
768 .PHONY: mesawin_version
769 mesawin_version:
770 -$(V1) $(ECHO) "MesaOpenGL vXX"
772 endif
774 ##############################
776 # OpenSSL (Windows only)
778 ##############################
780 ifeq ($(UNAME), Windows)
782 $(eval $(call TOOL_INSTALL_TEMPLATE,openssl,$(OPENSSL_DIR),$(OPENSSL_URL),,$(notdir $(OPENSSL_URL))))
784 ifeq ($(shell [ -d "$(OPENSSL_DIR)" ] && $(ECHO) "exists"), exists)
785 export OPENSSL := "$(OPENSSL_DIR)/bin/openssl"
786 export OPENSSL_DIR := "$(OPENSSL_DIR)"
787 else
788 # not installed, hope it's in the path...
789 # $(info $(EMPTY) WARNING $(call toprel, $(OPENSSL_DIR)) not found (make openssl_install), using system PATH)
790 endif
792 .PHONY: openssl_version
793 openssl_version:
794 -$(V1) $(ECHO) "OpenSSL `$(OPENSSL) version`"
796 endif
798 ##############################
800 # Uncrustify
802 ##############################
804 ifeq ($(UNAME), Windows)
806 $(eval $(call TOOL_INSTALL_TEMPLATE,uncrustify,$(UNCRUSTIFY_DIR),$(UNCRUSTIFY_URL),,$(notdir $(UNCRUSTIFY_URL))))
808 else # Linux or Mac
810 UNCRUSTIFY_BUILD_DIR := $(BUILD_DIR)/$(notdir $(UNCRUSTIFY_DIR))
812 define UNCRUSTIFY_BUILD_TEMPLATE
813 $(V1) ( \
814 $(ECHO) $(MSG_CONFIGURING) $(call toprel, $(UNCRUSTIFY_BUILD_DIR)) && \
815 cd $(UNCRUSTIFY_BUILD_DIR) && \
816 ./configure --prefix="$(UNCRUSTIFY_DIR)" && \
817 $(ECHO) $(MSG_BUILDING) $(call toprel, $(UNCRUSTIFY_BUILD_DIR)) && \
818 $(MAKE) $(MAKE_SILENT) && \
819 $(ECHO) $(MSG_INSTALLING) $(call toprel, $(UNCRUSTIFY_DIR)) && \
820 $(MAKE) $(MAKE_SILENT) install-strip \
822 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(UNCRUSTIFY_BUILD_DIR))
823 -$(V1) [ ! -d "$(UNCRUSTIFY_BUILD_DIR)" ] || $(RM) -rf "$(UNCRUSTIFY_BUILD_DIR)"
824 endef
826 define UNCRUSTIFY_CLEAN_TEMPLATE
827 -$(V1) [ ! -d "$(UNCRUSTIFY_DIR)" ] || $(RM) -rf "$(UNCRUSTIFY_DIR)"
828 endef
830 $(eval $(call TOOL_INSTALL_TEMPLATE,uncrustify,$(UNCRUSTIFY_BUILD_DIR),$(UNCRUSTIFY_URL),,$(notdir $(UNCRUSTIFY_URL)),$(UNCRUSTIFY_BUILD_TEMPLATE),$(UNCRUSTIFY_CLEAN_TEMPLATE)))
832 endif
834 ifeq ($(shell [ -d "$(UNCRUSTIFY_DIR)" ] && $(ECHO) "exists"), exists)
835 export UNCRUSTIFY := $(UNCRUSTIFY_DIR)/bin/uncrustify
836 else
837 # not installed, hope it's in the path...
838 # $(info $(EMPTY) WARNING $(call toprel, $(UNCRUSTIFY_DIR)) not found (make uncrustify_install), using system PATH)
839 export UNCRUSTIFY := uncrustify
840 endif
842 .PHONY: uncrustify_version
843 uncrustify_version:
844 -$(V1) $(UNCRUSTIFY) --version
846 ##############################
848 # Doxygen
850 ##############################
852 ifeq ($(UNAME), Windows)
854 $(eval $(call TOOL_INSTALL_TEMPLATE,doxygen,$(DOXYGEN_DIR),$(DOXYGEN_URL),,$(notdir $(DOXYGEN_URL))))
856 else # Linux or Mac
858 DOXYGEN_BUILD_DIR := $(BUILD_DIR)/$(notdir $(DOXYGEN_DIR))
860 define DOXYGEN_BUILD_TEMPLATE
861 $(V1) ( \
862 $(ECHO) $(MSG_CONFIGURING) $(call toprel, $(DOXYGEN_BUILD_DIR)) && \
863 cd $(DOXYGEN_BUILD_DIR) && \
864 ./configure --prefix "$(DOXYGEN_DIR)" --english-only && \
865 $(ECHO) $(MSG_BUILDING) $(call toprel, $(DOXYGEN_BUILD_DIR)) && \
866 $(MAKE) $(MAKE_SILENT) && \
867 $(ECHO) $(MSG_INSTALLING) $(call toprel, $(DOXYGEN_DIR)) && \
868 $(MAKE) $(MAKE_SILENT) install \
870 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(DOXYGEN_BUILD_DIR))
871 -$(V1) [ ! -d "$(DOXYGEN_BUILD_DIR)" ] || $(RM) -rf "$(DOXYGEN_BUILD_DIR)"
872 endef
874 define DOXYGEN_CLEAN_TEMPLATE
875 -$(V1) [ ! -d "$(DOXYGEN_DIR)" ] || $(RM) -rf "$(DOXYGEN_DIR)"
876 endef
878 $(eval $(call TOOL_INSTALL_TEMPLATE,doxygen,$(DOXYGEN_BUILD_DIR),$(DOXYGEN_URL),,$(notdir $(DOXYGEN_URL)),$(DOXYGEN_BUILD_TEMPLATE),$(DOXYGEN_CLEAN_TEMPLATE)))
880 endif
882 ifeq ($(shell [ -d "$(DOXYGEN_DIR)" ] && $(ECHO) "exists"), exists)
883 export DOXYGEN := $(DOXYGEN_DIR)/bin/doxygen
884 else
885 # not installed, hope it's in the path...
886 # $(info $(EMPTY) WARNING $(call toprel, $(DOXYGEN_DIR)) not found (make doxygen_install), using system PATH)
887 export DOXYGEN := doxygen
888 endif
890 .PHONY: doxygen_version
891 doxygen_version:
892 -$(V1) $(ECHO) "Doxygen `$(DOXYGEN) --version`"
894 ##############################
896 # GoogleTest
898 ##############################
900 $(eval $(call TOOL_INSTALL_TEMPLATE,gtest,$(GTEST_DIR),$(GTEST_URL),,$(notdir $(GTEST_URL))))
902 export GTEST_DIR
904 .PHONY: gtest_version
905 gtest_version:
906 -$(V1) $(SED) -n "s/^PACKAGE_STRING='\(.*\)'/\1/p" < $(GTEST_DIR)/configure
912 ##############################
914 # TODO: code below is not revised yet
916 ##############################
918 # Set up openocd tools
919 OPENOCD_DIR := $(TOOLS_DIR)/openocd
920 OPENOCD_WIN_DIR := $(TOOLS_DIR)/openocd_win
921 OPENOCD_BUILD_DIR := $(DL_DIR)/openocd-build
923 .PHONY: openocd_install
924 openocd_install: | $(DL_DIR) $(TOOLS_DIR)
925 openocd_install: OPENOCD_URL := http://sourceforge.net/projects/openocd/files/openocd/0.6.1/openocd-0.6.1.tar.bz2/download
926 openocd_install: OPENOCD_FILE := openocd-0.6.1.tar.bz2
927 openocd_install: openocd_clean
928 # download the source only if it's newer than what we already have
929 $(V1) $(WGET) -N -P "$(DL_DIR)" --trust-server-name "$(OPENOCD_URL)"
931 # extract the source
932 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -r "$(OPENOCD_BUILD_DIR)"
933 $(V1) mkdir -p "$(OPENOCD_BUILD_DIR)"
934 $(V1) tar -C $(OPENOCD_BUILD_DIR) -xjf "$(DL_DIR)/$(OPENOCD_FILE)"
936 # apply patches
937 $(V0) @echo " PATCH $(OPENOCD_DIR)"
938 $(V1) ( \
939 cd $(OPENOCD_BUILD_DIR)/openocd-0.6.1 ; \
940 patch -p1 < $(ROOT_DIR)/flight/Project/OpenOCD/0001-armv7m-remove-dummy-FP-regs-for-new-gdb.patch ; \
941 patch -p1 < $(ROOT_DIR)/flight/Project/OpenOCD/0002-rtos-add-stm32_stlink-to-FreeRTOS-targets.patch ; \
944 # build and install
945 $(V1) mkdir -p "$(OPENOCD_DIR)"
946 $(V1) ( \
947 cd $(OPENOCD_BUILD_DIR)/openocd-0.6.1 ; \
948 ./configure --prefix="$(OPENOCD_DIR)" --enable-ft2232_libftdi --enable-stlink ; \
949 $(MAKE) --silent ; \
950 $(MAKE) --silent install ; \
953 # delete the extracted source when we're done
954 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
956 .PHONY: ftd2xx_install
958 FTD2XX_DIR := $(DL_DIR)/ftd2xx
960 ftd2xx_install: | $(DL_DIR)
961 ftd2xx_install: FTD2XX_URL := http://www.ftdichip.com/Drivers/CDM/Beta/CDM20817.zip
962 ftd2xx_install: FTD2XX_FILE := CDM20817.zip
963 ftd2xx_install: ftd2xx_clean
964 # download the file only if it's newer than what we already have
965 $(V0) @echo " DOWNLOAD $(FTD2XX_URL)"
966 $(V1) $(WGET) -q -N -P "$(DL_DIR)" "$(FTD2XX_URL)"
968 # extract the source
969 $(V0) @echo " EXTRACT $(FTD2XX_FILE) -> $(FTD2XX_DIR)"
970 $(V1) mkdir -p "$(FTD2XX_DIR)"
971 $(V1) unzip -q -d "$(FTD2XX_DIR)" "$(DL_DIR)/$(FTD2XX_FILE)"
973 .PHONY: ftd2xx_clean
974 ftd2xx_clean:
975 $(V0) @echo " CLEAN $(FTD2XX_DIR)"
976 $(V1) [ ! -d "$(FTD2XX_DIR)" ] || $(RM) -r "$(FTD2XX_DIR)"
978 .PHONY: ftd2xx_install
980 LIBUSB_WIN_DIR := $(DL_DIR)/libusb-win32-bin-1.2.6.0
982 libusb_win_install: | $(DL_DIR)
983 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
984 libusb_win_install: LIBUSB_WIN_FILE := libusb-win32-bin-1.2.6.0.zip
985 libusb_win_install: libusb_win_clean
986 # download the file only if it's newer than what we already have
987 $(V0) @echo " DOWNLOAD $(LIBUSB_WIN_URL)"
988 $(V1) $(WGET) -q -N -P "$(DL_DIR)" --trust-server-name "$(LIBUSB_WIN_URL)"
990 # extract the source
991 $(V0) @echo " EXTRACT $(LIBUSB_WIN_FILE) -> $(LIBUSB_WIN_DIR)"
992 $(V1) mkdir -p "$(LIBUSB_WIN_DIR)"
993 $(V1) unzip -q -d "$(DL_DIR)" "$(DL_DIR)/$(LIBUSB_WIN_FILE)"
995 # fixup .h file needed by openocd build
996 $(V0) @echo " FIXUP $(LIBUSB_WIN_DIR)"
997 $(V1) ln -s "$(LIBUSB_WIN_DIR)/include/lusb0_usb.h" "$(LIBUSB_WIN_DIR)/include/usb.h"
999 .PHONY: libusb_win_clean
1000 libusb_win_clean:
1001 $(V0) @echo " CLEAN $(LIBUSB_WIN_DIR)"
1002 $(V1) [ ! -d "$(LIBUSB_WIN_DIR)" ] || $(RM) -r "$(LIBUSB_WIN_DIR)"
1004 .PHONY: openocd_git_win_install
1006 openocd_git_win_install: | $(DL_DIR) $(TOOLS_DIR)
1007 openocd_git_win_install: OPENOCD_URL := git://openocd.git.sourceforge.net/gitroot/openocd/openocd
1008 openocd_git_win_install: OPENOCD_REV := f1c0133321c8fcadadd10bba5537c0a634eb183b
1009 openocd_git_win_install: openocd_win_clean libusb_win_install ftd2xx_install
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) "$(DL_DIR)/openocd-build"
1015 $(V1) ( \
1016 cd $(OPENOCD_BUILD_DIR) ; \
1017 git checkout -q $(OPENOCD_REV) ; \
1020 # apply patches
1021 $(V0) @echo " PATCH $(OPENOCD_BUILD_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_WIN_DIR)"
1030 $(V1) mkdir -p "$(OPENOCD_WIN_DIR)"
1031 $(V1) ( \
1032 cd $(OPENOCD_BUILD_DIR) ; \
1033 ./bootstrap ; \
1034 ./configure --enable-maintainer-mode --prefix="$(OPENOCD_WIN_DIR)" \
1035 --build=i686-pc-linux-gnu --host=i586-mingw32msvc \
1036 CPPFLAGS=-I$(LIBUSB_WIN_DIR)/include \
1037 LDFLAGS=-L$(LIBUSB_WIN_DIR)/lib/gcc \
1038 --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=$(FTD2XX_DIR) \
1039 --disable-werror \
1040 --enable-stlink ; \
1041 $(MAKE) ; \
1042 $(MAKE) install ; \
1045 # delete the extracted source when we're done
1046 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1048 .PHONY: openocd_win_clean
1049 openocd_win_clean:
1050 $(V0) @echo " CLEAN $(OPENOCD_WIN_DIR)"
1051 $(V1) [ ! -d "$(OPENOCD_WIN_DIR)" ] || $(RM) -r "$(OPENOCD_WIN_DIR)"
1053 .PHONY: openocd_git_install
1055 openocd_git_install: | $(DL_DIR) $(TOOLS_DIR)
1056 openocd_git_install: OPENOCD_URL := git://openocd.git.sourceforge.net/gitroot/openocd/openocd
1057 openocd_git_install: OPENOCD_REV := f1c0133321c8fcadadd10bba5537c0a634eb183b
1058 openocd_git_install: openocd_clean
1059 # download the source
1060 $(V0) @echo " DOWNLOAD $(OPENOCD_URL) @ $(OPENOCD_REV)"
1061 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1062 $(V1) mkdir -p "$(OPENOCD_BUILD_DIR)"
1063 $(V1) git clone --no-checkout $(OPENOCD_URL) "$(OPENOCD_BUILD_DIR)"
1064 $(V1) ( \
1065 cd $(OPENOCD_BUILD_DIR) ; \
1066 git checkout -q $(OPENOCD_REV) ; \
1069 # apply patches
1070 $(V0) @echo " PATCH $(OPENOCD_DIR)"
1071 $(V1) ( \
1072 cd $(OPENOCD_BUILD_DIR) ; \
1073 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0001-armv7m-remove-dummy-FP-regs-for-new-gdb.patch ; \
1074 git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0002-rtos-add-stm32_stlink-to-FreeRTOS-targets.patch ; \
1077 # build and install
1078 $(V0) @echo " BUILD $(OPENOCD_DIR)"
1079 $(V1) mkdir -p "$(OPENOCD_DIR)"
1080 $(V1) ( \
1081 cd $(OPENOCD_BUILD_DIR) ; \
1082 ./bootstrap ; \
1083 ./configure --enable-maintainer-mode --prefix="$(OPENOCD_DIR)" --enable-ft2232_libftdi --enable-buspirate --enable-stlink ; \
1084 $(MAKE) ; \
1085 $(MAKE) install ; \
1088 # delete the extracted source when we're done
1089 $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -rf "$(OPENOCD_BUILD_DIR)"
1091 .PHONY: openocd_clean
1092 openocd_clean:
1093 $(V0) @echo " CLEAN $(OPENOCD_DIR)"
1094 $(V1) [ ! -d "$(OPENOCD_DIR)" ] || $(RM) -r "$(OPENOCD_DIR)"
1096 STM32FLASH_DIR := $(TOOLS_DIR)/stm32flash
1098 .PHONY: stm32flash_install
1099 stm32flash_install: STM32FLASH_URL := http://stm32flash.googlecode.com/svn/trunk
1100 stm32flash_install: STM32FLASH_REV := 61
1101 stm32flash_install: stm32flash_clean
1102 # download the source
1103 $(V0) @echo " DOWNLOAD $(STM32FLASH_URL) @ r$(STM32FLASH_REV)"
1104 $(V1) svn export -q -r "$(STM32FLASH_REV)" "$(STM32FLASH_URL)" "$(STM32FLASH_DIR)"
1106 # build
1107 $(V0) @echo " BUILD $(STM32FLASH_DIR)"
1108 $(V1) $(MAKE) --silent -C $(STM32FLASH_DIR) all
1110 .PHONY: stm32flash_clean
1111 stm32flash_clean:
1112 $(V0) @echo " CLEAN $(STM32FLASH_DIR)"
1113 $(V1) [ ! -d "$(STM32FLASH_DIR)" ] || $(RM) -r "$(STM32FLASH_DIR)"
1115 DFUUTIL_DIR := $(TOOLS_DIR)/dfu-util
1117 .PHONY: dfuutil_install
1118 dfuutil_install: DFUUTIL_URL := http://dfu-util.gnumonks.org/releases/dfu-util-0.7.tar.gz
1119 dfuutil_install: DFUUTIL_FILE := $(notdir $(DFUUTIL_URL))
1120 dfuutil_install: | $(DL_DIR) $(TOOLS_DIR)
1121 dfuutil_install: dfuutil_clean
1122 # download the source
1123 $(V0) @echo " DOWNLOAD $(DFUUTIL_URL)"
1124 $(V1) $(WGET) -N -P "$(DL_DIR)" "$(DFUUTIL_URL)"
1126 # extract the source
1127 $(V0) @echo " EXTRACT $(DFUUTIL_FILE)"
1128 $(V1) [ ! -d "$(DL_DIR)/dfuutil-build" ] || $(RM) -r "$(DL_DIR)/dfuutil-build"
1129 $(V1) mkdir -p "$(DL_DIR)/dfuutil-build"
1130 $(V1) tar -C $(DL_DIR)/dfuutil-build -xf "$(DL_DIR)/$(DFUUTIL_FILE)"
1132 # build
1133 $(V0) @echo " BUILD $(DFUUTIL_DIR)"
1134 $(V1) mkdir -p "$(DFUUTIL_DIR)"
1135 $(V1) ( \
1136 cd $(DL_DIR)/dfuutil-build/dfu-util-0.7 ; \
1137 ./configure --prefix="$(DFUUTIL_DIR)" ; \
1138 $(MAKE) ; \
1139 $(MAKE) install ; \
1142 .PHONY: dfuutil_clean
1143 dfuutil_clean:
1144 $(V0) @echo " CLEAN $(DFUUTIL_DIR)"
1145 $(V1) [ ! -d "$(DFUUTIL_DIR)" ] || $(RM) -r "$(DFUUTIL_DIR)"
1147 # see http://developer.android.com/sdk/ for latest versions
1148 ANDROID_SDK_DIR := $(TOOLS_DIR)/android-sdk-linux
1149 .PHONY: android_sdk_install
1150 android_sdk_install: ANDROID_SDK_URL := http://dl.google.com/android/android-sdk_r20.0.3-linux.tgz
1151 android_sdk_install: ANDROID_SDK_FILE := $(notdir $(ANDROID_SDK_URL))
1152 # order-only prereq on directory existance:
1153 android_sdk_install: | $(DL_DIR) $(TOOLS_DIR)
1154 android_sdk_install: android_sdk_clean
1155 # download the source only if it's newer than what we already have
1156 $(V0) @echo " DOWNLOAD $(ANDROID_SDK_URL)"
1157 $(V1) $(WGET) --no-check-certificate -N -P "$(DL_DIR)" "$(ANDROID_SDK_URL)"
1159 # binary only release so just extract it
1160 $(V0) @echo " EXTRACT $(ANDROID_SDK_FILE)"
1161 $(V1) tar -C $(TOOLS_DIR) -xf "$(DL_DIR)/$(ANDROID_SDK_FILE)"
1163 .PHONY: android_sdk_clean
1164 android_sdk_clean:
1165 $(V0) @echo " CLEAN $(ANDROID_SDK_DIR)"
1166 $(V1) [ ! -d "$(ANDROID_SDK_DIR)" ] || $(RM) -r $(ANDROID_SDK_DIR)
1168 .PHONY: android_sdk_update
1169 android_sdk_update:
1170 $(V0) @echo " UPDATE $(ANDROID_SDK_DIR)"
1171 $(ANDROID_SDK_DIR)/tools/android update sdk --no-ui -t platform-tools,android-16,addon-google_apis-google-16
1173 #Install git hooks under the right folder
1175 .PHONY: prepare
1176 prepare:
1177 $(V0) @echo " Configuring GIT commit template"
1178 $(V1) $(CD) "$(ROOT_DIR)"
1179 $(V1) $(GIT) config commit.template .commit-template
1181 .PHONY: prepare_clean
1182 prepare_clean:
1183 $(V0) @echo " Cleanup GIT commit template configuration"
1184 $(V1) $(CD) "$(ROOT_DIR)"
1185 $(V1) $(GIT) config --unset commit.template
1187 ##############################
1189 # TODO: these defines will go to tool install sections
1191 ##############################
1193 ifeq ($(shell [ -d "$(OPENOCD_DIR)" ] && $(ECHO) "exists"), exists)
1194 export OPENOCD := $(OPENOCD_DIR)/bin/openocd
1195 else
1196 # not installed, hope it's in the path...
1197 export OPENOCD ?= openocd
1198 endif
1200 ifeq ($(shell [ -d "$(ANDROID_SDK_DIR)" ] && $(ECHO) "exists"), exists)
1201 ANDROID := $(ANDROID_SDK_DIR)/tools/android
1202 ANDROID_DX := $(ANDROID_SDK_DIR)/platform-tools/dx
1203 else
1204 # not installed, hope it's in the path...
1205 ANDROID ?= android
1206 ANDROID_DX ?= dx
1207 endif