2016-09-02 19:56:15 -07:00
###############################################################
#
# Installers for tools
#
# NOTE: These are not tied to the default goals
# and must be invoked manually
#
###############################################################
##############################
#
# Check that environmental variables are sane
#
##############################
# Set up ARM (STM32) SDK
2017-12-23 04:05:11 -08:00
ARM_SDK_DIR ?= $( TOOLS_DIR) /gcc-arm-none-eabi-7-2017-q4-major
2016-09-13 20:14:55 -07:00
# Checked below, Should match the output of $(shell arm-none-eabi-gcc -dumpversion)
2017-12-23 04:05:11 -08:00
GCC_REQUIRED_VERSION ?= 7.2.1
2016-09-02 19:56:15 -07:00
2018-05-20 18:04:56 -07:00
.PHONY : arm_sdk_version
arm_sdk_version :
$( V1) $( ARM_SDK_PREFIX) gcc --version
2016-10-22 05:47:26 -07:00
## arm_sdk_install : Install Arm SDK
2016-09-02 19:56:15 -07:00
.PHONY : arm_sdk_install
2017-12-23 04:05:11 -08:00
ARM_SDK_URL_BASE := https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2017q4/gcc-arm-none-eabi-7-2017-q4-major
2016-10-22 09:03:23 -07:00
2017-01-25 11:56:22 -08:00
# source: https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
2016-09-02 19:56:15 -07:00
i f d e f L I N U X
2016-11-08 10:41:20 -08:00
ARM_SDK_URL := $( ARM_SDK_URL_BASE) -linux.tar.bz2
2016-09-02 19:56:15 -07:00
e n d i f
i f d e f M A C O S X
2016-11-08 10:41:20 -08:00
ARM_SDK_URL := $( ARM_SDK_URL_BASE) -mac.tar.bz2
2016-09-02 19:56:15 -07:00
e n d i f
i f d e f W I N D O W S
2017-07-01 03:03:09 -07:00
ARM_SDK_URL := $( ARM_SDK_URL_BASE) -win32.zip
2016-09-02 19:56:15 -07:00
e n d i f
2016-11-08 10:41:20 -08:00
ARM_SDK_FILE := $( notdir $( ARM_SDK_URL) )
SDK_INSTALL_MARKER := $( ARM_SDK_DIR) /bin/arm-none-eabi-gcc-$( GCC_REQUIRED_VERSION)
2016-09-02 19:56:15 -07:00
# order-only prereq on directory existance:
2016-11-08 10:41:20 -08:00
arm_sdk_install : | $( TOOLS_DIR )
arm_sdk_install : arm_sdk_download $( SDK_INSTALL_MARKER )
2016-09-02 19:56:15 -07:00
2016-11-08 10:41:20 -08:00
$(SDK_INSTALL_MARKER) :
i f n e q ( $( OSFAMILY ) , w i n d o w s )
2016-09-02 19:56:15 -07:00
# binary only release so just extract it
$( V1) tar -C $( TOOLS_DIR) -xjf " $( DL_DIR) / $( ARM_SDK_FILE) "
e l s e
$( V1) unzip -q -d $( ARM_SDK_DIR) " $( DL_DIR) / $( ARM_SDK_FILE) "
e n d i f
2016-11-08 10:41:20 -08:00
.PHONY : arm_sdk_download
arm_sdk_download : | $( DL_DIR )
arm_sdk_download : $( DL_DIR ) /$( ARM_SDK_FILE )
$(DL_DIR)/$(ARM_SDK_FILE) :
# download the source only if it's newer than what we already have
$( V1) curl -L -k -o " $( DL_DIR) / $( ARM_SDK_FILE) " -z " $( DL_DIR) / $( ARM_SDK_FILE) " " $( ARM_SDK_URL) "
2016-10-22 05:47:26 -07:00
## arm_sdk_clean : Uninstall Arm SDK
2016-09-02 19:56:15 -07:00
.PHONY : arm_sdk_clean
arm_sdk_clean :
$( V1) [ ! -d " $( ARM_SDK_DIR) " ] || $( RM) -r $( ARM_SDK_DIR)
2016-11-08 10:41:20 -08:00
$( V1) [ ! -d " $( DL_DIR) " ] || $( RM) -r $( DL_DIR)
2016-09-02 19:56:15 -07:00
.PHONY : openocd_win_install
openocd_win_install : | $( DL_DIR ) $( TOOLS_DIR )
openocd_win_install : OPENOCD_URL := git ://git .code .sf .net /p /openocd /code
openocd_win_install : OPENOCD_REV := cf 1418e 9a 85013bbf 8dbcc 2d 2e 9985695993d 9f 4
openocd_win_install : OPENOCD_OPTIONS :=
i f e q ( $( OPENOCD_FTDI ) , y e s )
openocd_win_install : OPENOCD_OPTIONS := $( OPENOCD_OPTIONS ) --enable -ft 2232_ftd 2xx --with -ftd 2xx -win 32-zipdir =$( FTD 2XX_DIR )
e n d i f
openocd_win_install : openocd_win_clean libusb_win_install ftd 2xx_install
# download the source
2017-12-30 07:28:52 -08:00
@echo " DOWNLOAD $( OPENOCD_URL) @ $( OPENOCD_REV) "
2016-09-02 19:56:15 -07:00
$( V1) [ ! -d " $( OPENOCD_BUILD_DIR) " ] || $( RM) -rf " $( OPENOCD_BUILD_DIR) "
$( V1) mkdir -p " $( OPENOCD_BUILD_DIR) "
$( V1) git clone --no-checkout $( OPENOCD_URL) " $( DL_DIR) /openocd-build "
$( V1) ( \
cd $( OPENOCD_BUILD_DIR) ; \
git checkout -q $( OPENOCD_REV) ; \
)
# apply patches
2017-12-30 07:28:52 -08:00
@echo " PATCH $( OPENOCD_BUILD_DIR) "
2016-09-02 19:56:15 -07:00
$( V1) ( \
cd $( OPENOCD_BUILD_DIR) ; \
git apply < $( ROOT_DIR) /flight/Project/OpenOCD/0003-freertos-cm4f-fpu-support.patch ; \
git apply < $( ROOT_DIR) /flight/Project/OpenOCD/0004-st-icdi-disable.patch ; \
)
# build and install
2017-12-30 07:28:52 -08:00
@echo " BUILD $( OPENOCD_WIN_DIR) "
2016-09-02 19:56:15 -07:00
$( V1) mkdir -p " $( OPENOCD_WIN_DIR) "
$( V1) ( \
cd $( OPENOCD_BUILD_DIR) ; \
./bootstrap ; \
./configure --enable-maintainer-mode --prefix= " $( OPENOCD_WIN_DIR) " \
--build= i686-pc-linux-gnu --host= i586-mingw32msvc \
CPPFLAGS = -I$( LIBUSB_WIN_DIR) /include \
LDFLAGS = -L$( LIBUSB_WIN_DIR) /lib/gcc \
$( OPENOCD_OPTIONS) \
--disable-werror \
--enable-stlink ; \
$( MAKE) ; \
$( MAKE) install ; \
)
# delete the extracted source when we're done
$( V1) [ ! -d " $( OPENOCD_BUILD_DIR) " ] || $( RM) -rf " $( OPENOCD_BUILD_DIR) "
.PHONY : openocd_win_clean
openocd_win_clean :
2017-12-30 07:28:52 -08:00
@echo " CLEAN $( OPENOCD_WIN_DIR) "
2016-09-02 19:56:15 -07:00
$( V1) [ ! -d " $( OPENOCD_WIN_DIR) " ] || $( RM) -r " $( OPENOCD_WIN_DIR) "
# Set up openocd tools
OPENOCD_DIR := $( TOOLS_DIR) /openocd
OPENOCD_WIN_DIR := $( TOOLS_DIR) /openocd_win
OPENOCD_BUILD_DIR := $( DL_DIR) /openocd-build
.PHONY : openocd_install
openocd_install : | $( DL_DIR ) $( TOOLS_DIR )
openocd_install : OPENOCD_URL := git ://git .code .sf .net /p /openocd /code
openocd_install : OPENOCD_TAG := v 0.9.0
openocd_install : OPENOCD_OPTIONS := --enable -maintainer -mode --prefix ="$( OPENOCD_DIR ) " --enable -buspirate --enable -stlink
i f e q ( $( OPENOCD_FTDI ) , y e s )
openocd_install : OPENOCD_OPTIONS := $( OPENOCD_OPTIONS ) --enable -ftdi
e n d i f
i f e q ( $( UNAME ) , D a r w i n )
openocd_install : OPENOCD_OPTIONS := $( OPENOCD_OPTIONS ) --disable -option -checking
e n d i f
openocd_install : openocd_clean
# download the source
2017-12-30 07:28:52 -08:00
@echo " DOWNLOAD $( OPENOCD_URL) @ $( OPENOCD_TAG) "
2016-09-02 19:56:15 -07:00
$( V1) [ ! -d " $( OPENOCD_BUILD_DIR) " ] || $( RM) -rf " $( OPENOCD_BUILD_DIR) "
$( V1) mkdir -p " $( OPENOCD_BUILD_DIR) "
$( V1) git clone --no-checkout $( OPENOCD_URL) " $( OPENOCD_BUILD_DIR) "
$( V1) ( \
cd $( OPENOCD_BUILD_DIR) ; \
git checkout -q tags/$( OPENOCD_TAG) ; \
)
# build and install
2017-12-30 07:28:52 -08:00
@echo " BUILD $( OPENOCD_DIR) "
2016-09-02 19:56:15 -07:00
$( V1) mkdir -p " $( OPENOCD_DIR) "
$( V1) ( \
cd $( OPENOCD_BUILD_DIR) ; \
./bootstrap ; \
./configure $( OPENOCD_OPTIONS) ; \
$( MAKE) ; \
$( MAKE) install ; \
)
# delete the extracted source when we're done
$( V1) [ ! -d " $( OPENOCD_BUILD_DIR) " ] || $( RM) -rf " $( OPENOCD_BUILD_DIR) "
.PHONY : openocd_clean
openocd_clean :
2017-12-30 07:28:52 -08:00
@echo " CLEAN $( OPENOCD_DIR) "
2016-09-02 19:56:15 -07:00
$( V1) [ ! -d " $( OPENOCD_DIR) " ] || $( RM) -r " $( OPENOCD_DIR) "
STM32FLASH_DIR := $( TOOLS_DIR) /stm32flash
.PHONY : stm 32flash_install
stm32flash_install : STM 32FLASH_URL := http ://stm 32flash .googlecode .com /svn /trunk
stm32flash_install : STM 32FLASH_REV := 61
stm32flash_install : stm 32flash_clean
# download the source
2017-12-30 07:28:52 -08:00
@echo " DOWNLOAD $( STM32FLASH_URL) @ r $( STM32FLASH_REV) "
2016-09-02 19:56:15 -07:00
$( V1) svn export -q -r " $( STM32FLASH_REV) " " $( STM32FLASH_URL) " " $( STM32FLASH_DIR) "
# build
2017-12-30 07:28:52 -08:00
@echo " BUILD $( STM32FLASH_DIR) "
2016-09-02 19:56:15 -07:00
$( V1) $( MAKE) --silent -C $( STM32FLASH_DIR) all
.PHONY : stm 32flash_clean
stm32flash_clean :
2017-12-30 07:28:52 -08:00
@echo " CLEAN $( STM32FLASH_DIR) "
2016-09-02 19:56:15 -07:00
$( V1) [ ! -d " $( STM32FLASH_DIR) " ] || $( RM) -r " $( STM32FLASH_DIR) "
DFUUTIL_DIR := $( TOOLS_DIR) /dfu-util
.PHONY : dfuutil_install
dfuutil_install : DFUUTIL_URL := http ://dfu -util .sourceforge .net /releases /dfu -util -0.8.tar .gz
dfuutil_install : DFUUTIL_FILE := $( notdir $ ( DFUUTIL_URL ) )
dfuutil_install : | $( DL_DIR ) $( TOOLS_DIR )
dfuutil_install : dfuutil_clean
# download the source
2017-12-30 07:28:52 -08:00
@echo " DOWNLOAD $( DFUUTIL_URL) "
2016-09-13 20:15:08 -07:00
$( V1) curl -L -k -o " $( DL_DIR) / $( DFUUTIL_FILE) " " $( DFUUTIL_URL) "
2016-09-02 19:56:15 -07:00
# extract the source
2017-12-30 07:28:52 -08:00
@echo " EXTRACT $( DFUUTIL_FILE) "
2016-09-02 19:56:15 -07:00
$( V1) [ ! -d " $( DL_DIR) /dfuutil-build " ] || $( RM) -r " $( DL_DIR) /dfuutil-build "
$( V1) mkdir -p " $( DL_DIR) /dfuutil-build "
$( V1) tar -C $( DL_DIR) /dfuutil-build -xf " $( DL_DIR) / $( DFUUTIL_FILE) "
# build
2017-12-30 07:28:52 -08:00
@echo " BUILD $( DFUUTIL_DIR) "
2016-09-02 19:56:15 -07:00
$( V1) mkdir -p " $( DFUUTIL_DIR) "
$( V1) ( \
cd $( DL_DIR) /dfuutil-build/dfu-util-0.8 ; \
./configure --prefix= " $( DFUUTIL_DIR) " ; \
$( MAKE) ; \
$( MAKE) install ; \
)
.PHONY : dfuutil_clean
dfuutil_clean :
2017-12-30 07:28:52 -08:00
@echo " CLEAN $( DFUUTIL_DIR) "
2016-09-02 19:56:15 -07:00
$( V1) [ ! -d " $( DFUUTIL_DIR) " ] || $( RM) -r " $( DFUUTIL_DIR) "
# Set up uncrustify tools
UNCRUSTIFY_DIR := $( TOOLS_DIR) /uncrustify-0.61
UNCRUSTIFY_BUILD_DIR := $( DL_DIR) /uncrustify
.PHONY : uncrustify_install
uncrustify_install : | $( DL_DIR ) $( TOOLS_DIR )
uncrustify_install : UNCRUSTIFY_URL := http ://downloads .sourceforge .net /project /uncrustify /uncrustify /uncrustify -0.61/uncrustify -0.61.tar .gz
uncrustify_install : UNCRUSTIFY_FILE := uncrustify -0.61.tar .gz
uncrustify_install : UNCRUSTIFY_OPTIONS := prefix =$( UNCRUSTIFY_DIR )
uncrustify_install : uncrustify_clean
i f n e q ( $( OSFAMILY ) , w i n d o w s )
2017-12-30 07:28:52 -08:00
@echo " DOWNLOAD $( UNCRUSTIFY_URL) "
2016-09-02 19:56:15 -07:00
$( V1) curl -L -k -o " $( DL_DIR) / $( UNCRUSTIFY_FILE) " " $( UNCRUSTIFY_URL) "
e n d i f
# extract the src
2017-12-30 07:28:52 -08:00
@echo " EXTRACT $( UNCRUSTIFY_FILE) "
2016-09-02 19:56:15 -07:00
$( V1) tar -C $( TOOLS_DIR) -xf " $( DL_DIR) / $( UNCRUSTIFY_FILE) "
2017-12-30 07:28:52 -08:00
@echo " BUILD $( UNCRUSTIFY_DIR) "
2016-09-02 19:56:15 -07:00
$( V1) ( \
cd $( UNCRUSTIFY_DIR) ; \
./configure --prefix= " $( UNCRUSTIFY_DIR) " ; \
$( MAKE) ; \
$( MAKE) install ; \
)
# delete the extracted source when we're done
$( V1) [ ! -d " $( UNCRUSTIFY_BUILD_DIR) " ] || $( RM) -r " $( UNCRUSTIFY_BUILD_DIR) "
.PHONY : uncrustify_clean
uncrustify_clean :
2017-12-30 07:28:52 -08:00
@echo " CLEAN $( UNCRUSTIFY_DIR) "
2016-09-02 19:56:15 -07:00
$( V1) [ ! -d " $( UNCRUSTIFY_DIR) " ] || $( RM) -r " $( UNCRUSTIFY_DIR) "
2017-12-30 07:28:52 -08:00
@echo " CLEAN $( UNCRUSTIFY_BUILD_DIR) "
2016-09-02 19:56:15 -07:00
$( V1) [ ! -d " $( UNCRUSTIFY_BUILD_DIR) " ] || $( RM) -r " $( UNCRUSTIFY_BUILD_DIR) "
# ZIP download URL
zip_install : ZIP_URL := http ://pkgs .fedoraproject .org /repo /pkgs /zip /zip 30.tar .gz /7b 74551e 63f 8ee 6aab 6fbc 86676c 0d 37/zip 30.tar .gz
zip_install : ZIP_FILE := $( notdir $ ( ZIP_URL ) )
ZIP_DIR = $( TOOLS_DIR) /zip30
# order-only prereq on directory existance:
zip_install : | $( DL_DIR ) $( TOOLS_DIR )
zip_install : zip_clean
$( V1) curl -L -k -o " $( DL_DIR) / $( ZIP_FILE) " " $( ZIP_URL) "
$( V1) tar --force-local -C $( TOOLS_DIR) -xzf " $( DL_DIR) / $( ZIP_FILE) "
i f n e q ( $( OSFAMILY ) , w i n d o w s )
$( V1) cd " $( ZIP_DIR) " && $( MAKE) -f unix/Makefile generic_gcc
e l s e
$( V1) cd " $( ZIP_DIR) " && $( MAKE) -f win32/makefile.gcc
e n d i f
.PHONY : zip_clean
zip_clean :
$( V1) [ ! -d " $( ZIP_DIR) " ] || $( RM) -rf $( ZIP_DIR)
##############################
#
# Set up paths to tools
#
##############################
i f e q ( $( shell [ -d "$ ( ARM_SDK_DIR ) " ] && echo "exists ") , e x i s t s )
ARM_SDK_PREFIX := $( ARM_SDK_DIR) /bin/arm-none-eabi-
2016-09-13 20:14:55 -07:00
e l s e i f e q ( , $( findstring _install ,$ ( MAKECMDGOALS ) ) )
2017-03-20 03:13:13 -07:00
GCC_VERSION = $( shell arm-none-eabi-gcc -dumpversion)
2016-09-13 20:14:55 -07:00
ifeq ( $( GCC_VERSION) ,)
$( error **ERROR** arm-none-eabi-gcc not in the PATH. Run 'make arm_sdk_install' to install automatically in the tools folder of this repo)
else ifneq ( $( GCC_VERSION) , $( GCC_REQUIRED_VERSION) )
2016-09-13 20:30:05 -07:00
$( error **ERROR** your arm-none-eabi-gcc is '$(GCC_VERSION)' , but '$(GCC_REQUIRED_VERSION)' is expected. Override with 'GCC_REQUIRED_VERSION' in make/local.mk or run 'make arm_sdk_install' to install the right version automatically in the tools folder of this repo)
2016-09-02 19:56:15 -07:00
endif
2017-03-20 03:13:13 -07:00
# ARM tookchain is in the path, and the version is what's required.
2016-09-02 19:56:15 -07:00
ARM_SDK_PREFIX ?= arm-none-eabi-
e n d i f
i f e q ( $( shell [ -d "$ ( ZIP_DIR ) " ] && echo "exists ") , e x i s t s )
export ZIPBIN := $( ZIP_DIR) /zip
e l s e
export ZIPBIN := zip
e n d i f
i f e q ( $( shell [ -d "$ ( OPENOCD_DIR ) " ] && echo "exists ") , e x i s t s )
OPENOCD := $( OPENOCD_DIR) /bin/openocd
e l s e
# not installed, hope it's in the path...
OPENOCD ?= openocd
e n d i f
i f e q ( $( shell [ -d "$ ( UNCRUSTIFY_DIR ) " ] && echo "exists ") , e x i s t s )
UNCRUSTIFY := $( UNCRUSTIFY_DIR) /bin/uncrustify
e l s e
# not installed, hope it's in the path...
UNCRUSTIFY ?= uncrustify
e n d i f
# Google Breakpad
DUMP_SYMBOLS_TOOL := $( TOOLS_DIR) /breakpad/$( OSFAMILY) -$( ARCHFAMILY) /dump_syms
BREAKPAD_URL := http://dronin.tracer.nz/tools/breakpad.zip
BREAKPAD_DL_FILE := $( DL_DIR) /$( notdir $( BREAKPAD_URL) )
BREAKPAD_DIR := $( TOOLS_DIR) /breakpad
.PHONY : breakpad_install
breakpad_install : | $( DL_DIR ) $( TOOLS_DIR )
breakpad_install : breakpad_clean
2017-12-30 07:28:52 -08:00
@echo " DOWNLOAD $( BREAKPAD_URL) "
2016-09-02 19:56:15 -07:00
$( V1) $( V1) curl -L -k -z " $( BREAKPAD_DL_FILE) " -o " $( BREAKPAD_DL_FILE) " " $( BREAKPAD_URL) "
2017-12-30 07:28:52 -08:00
@echo " EXTRACT $( notdir $( BREAKPAD_DL_FILE) ) "
2016-09-02 19:56:15 -07:00
$( V1) mkdir -p " $( BREAKPAD_DIR) "
$( V1) unzip -q -d $( BREAKPAD_DIR) " $( BREAKPAD_DL_FILE) "
i f e q ( $( OSFAMILY ) , w i n d o w s )
$( V1) ln -s " $( TOOLS_DIR) /breakpad/ $( OSFAMILY) -i686 " " $( TOOLS_DIR) /breakpad/ $( OSFAMILY) -x86_64 "
e n d i f
.PHONY : breakpad_clean
breakpad_clean :
2017-12-30 07:28:52 -08:00
@echo " CLEAN $( BREAKPAD_DIR) "
2016-09-02 19:56:15 -07:00
$( V1) [ ! -d " $( BREAKPAD_DIR) " ] || $( RM) -rf $( BREAKPAD_DIR)
2017-12-30 07:28:52 -08:00
@echo " CLEAN $( BREAKPAD_DL_FILE) "
2016-09-02 19:56:15 -07:00
$( V1) $( RM) -f $( BREAKPAD_DL_FILE)