target/xtensa: avoid IHI for writes to non-executable memory
[openocd.git] / contrib / cross-build.sh
index 821d48ec77c8b944b3fe8eed33debfbebe1e2eb9..bb8c8c47db88991bfe88936d21a38255eaaf78e2 100755 (executable)
@@ -1,4 +1,5 @@
 #!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
 
 # This is an example of how to do a cross-build of OpenOCD using pkg-config.
 # Cross-building with pkg-config is deceptively hard and most guides and
@@ -14,8 +15,8 @@
 #    paths refer to the build file system.
 #
 # This script is probably more useful as a reference than as a complete build
-# tool but for some configurations it may be usable as-is. It only cross-
-# builds libusb-1.0, hidapi and libftdi from source, but the script can be
+# tool but for some configurations it may be usable as-is. It only cross-builds
+# libusb-1.0, hidapi, libftdi and capstone from source, but the script can be
 # extended to build other prerequisites in a similar manner.
 #
 # Usage:
@@ -39,17 +40,23 @@ WORK_DIR=$PWD
 : ${LIBUSB1_SRC:=/path/to/libusb1}
 : ${HIDAPI_SRC:=/path/to/hidapi}
 : ${LIBFTDI_SRC:=/path/to/libftdi}
+: ${CAPSTONE_SRC:=/path/to/capstone}
+: ${LIBJAYLINK_SRC:=/path/to/libjaylink}
 
 OPENOCD_SRC=`readlink -m $OPENOCD_SRC`
 LIBUSB1_SRC=`readlink -m $LIBUSB1_SRC`
 HIDAPI_SRC=`readlink -m $HIDAPI_SRC`
 LIBFTDI_SRC=`readlink -m $LIBFTDI_SRC`
+CAPSTONE_SRC=`readlink -m $CAPSTONE_SRC`
+LIBJAYLINK_SRC=`readlink -m $LIBJAYLINK_SRC`
 
 HOST_TRIPLET=$1
 BUILD_DIR=$WORK_DIR/$HOST_TRIPLET-build
 LIBUSB1_BUILD_DIR=$BUILD_DIR/libusb1
 HIDAPI_BUILD_DIR=$BUILD_DIR/hidapi
 LIBFTDI_BUILD_DIR=$BUILD_DIR/libftdi
+CAPSTONE_BUILD_DIR=$BUILD_DIR/capstone
+LIBJAYLINK_BUILD_DIR=$BUILD_DIR/libjaylink
 OPENOCD_BUILD_DIR=$BUILD_DIR/openocd
 
 ## Root of host file tree
@@ -118,17 +125,53 @@ fi
 if [ -d $LIBFTDI_SRC ] ; then
   mkdir -p $LIBFTDI_BUILD_DIR
   cd $LIBFTDI_BUILD_DIR
-  # libftdi requires libusb1 static libraries, granted by:
-  # export LIBUSB1_CONFIG="--enable-static ..."
+  # note : libftdi versions < 1.5 requires libusb1 static
+  #   hint use : # export LIBUSB1_CONFIG="--enable-static ..."
+  #   not needed since libftdi-1.5 when LIBFTDI_CONFIG="-DSTATICLIBS=OFF ..."
+
+  # fix <toolchain>.cmake file
+  ESCAPED_SYSROOT=$(printf '%s\n' "$SYSROOT" | sed -e 's/[\/&]/\\&/g')
+  sed -i -E "s/(SET\(CMAKE_FIND_ROOT_PATH\s+).+\)/\1${ESCAPED_SYSROOT})/" \
+    ${LIBFTDI_SRC}/cmake/Toolchain-${HOST_TRIPLET}.cmake
+
   cmake $LIBFTDI_CONFIG \
-    -DLIBUSB_INCLUDE_DIR=${SYSROOT}${PREFIX}/include/libusb-1.0 \
-    -DLIBUSB_LIBRARIES=${SYSROOT}${PREFIX}/lib/libusb-1.0.a \
+    -DCMAKE_TOOLCHAIN_FILE=${LIBFTDI_SRC}/cmake/Toolchain-${HOST_TRIPLET}.cmake \
     -DCMAKE_INSTALL_PREFIX=${PREFIX} \
     -DPKG_CONFIG_EXECUTABLE=`which pkg-config` \
     $LIBFTDI_SRC
   make install DESTDIR=$SYSROOT
 fi
 
+# capstone build & install into sysroot
+if [ -d $CAPSTONE_SRC ] ; then
+  mkdir -p $CAPSTONE_BUILD_DIR
+  cd $CAPSTONE_BUILD_DIR
+  cp -r $CAPSTONE_SRC/* .
+  make install DESTDIR=$SYSROOT PREFIX=$PREFIX \
+    CROSS="${HOST_TRIPLET}-" \
+    $CAPSTONE_CONFIG
+  # fix the generated capstone.pc
+  CAPSTONE_PC_FILE=${SYSROOT}${PREFIX}/lib/pkgconfig/capstone.pc
+  sed -i '/^libdir=/d' $CAPSTONE_PC_FILE
+  sed -i '/^includedir=/d' $CAPSTONE_PC_FILE
+  sed -i '/^archive=/d' $CAPSTONE_PC_FILE
+  sed -i '1s;^;prefix=/usr \
+exec_prefix=${prefix} \
+libdir=${exec_prefix}/lib \
+includedir=${prefix}/include/capstone\n\n;' $CAPSTONE_PC_FILE
+fi
+
+# libjaylink build & install into sysroot
+if [ -d $LIBJAYLINK_SRC ] ; then
+  mkdir -p $LIBJAYLINK_BUILD_DIR
+  cd $LIBJAYLINK_BUILD_DIR
+  $LIBJAYLINK_SRC/configure --build=`$LIBJAYLINK_SRC/config.guess` --host=$HOST_TRIPLET \
+    --with-sysroot=$SYSROOT --prefix=$PREFIX \
+    $LIBJAYLINK_CONFIG
+  make -j $MAKE_JOBS
+  make install DESTDIR=$SYSROOT
+fi
+
 # OpenOCD build & install into sysroot
 mkdir -p $OPENOCD_BUILD_DIR
 cd $OPENOCD_BUILD_DIR

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)