#!/bin/bash
BUILD_DIR=/path/to/openocd-build/build
# set source envexportOPENOCD_SRC=/path/to/openocd
exportLIBUSB1_SRC=/path/to/libusb-1.0.26
exportHIDAPI_SRC=/path/to/hidapi-0.13.1
exportLIBFTDI_SRC=/path/to/libftdi1-1.5
exportCAPSTONE_SRC=/path/to/capstone-4.0.2
exportLIBJAYLINK_SRC=/path/to/libjaylink-0.3.1
# configure openocdcd /path/to/openocd
./bootstrap
config_opts=()config_opts+=("--disable-wextra")config_opts+=("--disable-werror")config_opts+=("--disable-gccwarnings")config_opts+=("--disable-doxygen-html")config_opts+=("--disable-doxygen-pdf")config_opts+=("--enable-am335xgpio")config_opts+=("--enable-amtjtagaccel")config_opts+=("--enable-angie")config_opts+=("--enable-armjtagew")config_opts+=("--enable-at91rm9200")config_opts+=("--enable-bcm2835gpio")config_opts+=("--enable-cmsis-dap")config_opts+=("--enable-cmsis-dap-v2")config_opts+=("--enable-dummy")config_opts+=("--enable-esp-usb-jtag")config_opts+=("--enable-ft232r")config_opts+=("--enable-ftdi")config_opts+=("--enable-gw16012")config_opts+=("--enable-imx_gpio")config_opts+=("--enable-jlink")config_opts+=("--enable-jtag_dpi")config_opts+=("--enable-jtag_vpi")config_opts+=("--enable-kitprog")config_opts+=("--enable-nulink")config_opts+=("--enable-opendous")config_opts+=("--enable-openjtag")config_opts+=("--enable-osbdm")config_opts+=("--enable-parport")config_opts+=("--enable-parport-giveio")config_opts+=("--enable-presto")config_opts+=("--enable-remote-bitbang")config_opts+=("--enable-rlink")config_opts+=("--enable-stlink")config_opts+=("--enable-ti-icdi")config_opts+=("--enable-ulink")config_opts+=("--enable-usb-blaster")config_opts+=("--enable-usb-blaster-2")config_opts+=("--enable-usbprog")config_opts+=("--enable-vdebug")config_opts+=("--enable-vsllink")config_opts+=("--enable-xds110")config_opts+=("--disable-buspirate")# not support by MinGWconfig_opts+=("--disable-dmem")# only available on linuxconfig_opts+=("--disable-parport-ppdev")# only available on linux or freebsdconfig_opts+=("--disable-rshim")# only available on linux or freebsdconfig_opts+=("--disable-sysfsgpio")# only available on linuxconfig_opts+=("--disable-xlnx-pcie-xvc")# only available on linux# configure hidapicd$HIDAPI_SRC./bootstrap
# configure libjaylinkcd$LIBJAYLINK_SRC./autogen
# setup envexportMAKE_JOBS=16exportHOST=i686-w64-mingw32
exportLIBUSB1_CONFIG="--enable-shared --disable-static"exportHIDAPI_CONFIG="--enable-shared --disable-static --disable-testgui"exportLIBFTDI_CONFIG="-DSTATICLIBS=OFF -DEXAMPLES=OFF -DFTDI_EEPROM=OFF"exportCAPSTONE_CONFIG="CAPSTONE_BUILD_CORE_ONLY=yes CAPSTONE_STATIC=yes CAPSTONE_SHARED=no"exportLIBJAYLINK_CONFIG="--enable-shared --disable-static"exportOPENOCD_CONFIG=${config_opts[@]}cd$OPENOCD_SRC# check if there is tag pointing at HEAD, otherwise take the HEAD SHA-1 as OPENOCD_TAGOPENOCD_TAG="`git tag --points-at HEAD`"[ -z $OPENOCD_TAG]&&OPENOCD_TAG="`git rev-parse --short HEAD`"# check if there is tag pointing at HEAD, if so the release will have the same name as the tag,# otherwise it will be named 'latest'RELEASE_NAME="`git tag --points-at HEAD`"[ -z $RELEASE_NAME]&&RELEASE_NAME="latest"[[$RELEASE_NAME="latest"]]&&IS_PRE_RELEASE="true"||IS_PRE_RELEASE="false"# set env and call cross-build.shexportOPENOCD_TAG=$OPENOCD_TAGmkdir -p $BUILD_DIR&&cd$BUILD_DIRbash $OPENOCD_SRC/contrib/cross-build.sh $HOST[$? -eq 0]||exit# add missing dllscd$HOST-root/usr
cp `$HOST-gcc --print-file-name=libwinpthread-1.dll` ./bin/
# required by libftdi1.dll. For the gcc-mingw-10.3.x or later "libgcc_s_dw2-1.dll" will need to be copied.cp `$HOST-gcc --print-file-name=libgcc_s_dw2-1.dll` ./bin/
# prepare the artifactARTIFACT="openocd-${OPENOCD_TAG}-${HOST}.tar.gz"tar -czf $ARTIFACT *
echo"RELEASE_NAME=$RELEASE_NAME"echo"IS_PRE_RELEASE=$IS_PRE_RELEASE"echo"ARTIFACT_PATH=$PWD/$ARTIFACT
3. 使用
将 /path/to/openocd-build/build/i686-w64-mingw32-root/usr/ 目录下的文件,拷贝至 Windows (x64) 中即可使用。