Skip to content

Commit f897eed

Browse files
committed
Attempt to build OpenOCD with correct script dir
Override bindir and datadir, so that pkgdatadir ends up the same as bindir
1 parent 7fc0123 commit f897eed

6 files changed

Lines changed: 35 additions & 20 deletions

File tree

build.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ exec { tar -a -cf "bin\$filename" -C "build\picotool-install\$msysEnv" '*' }
265265
if ($env:SKIP_OPENOCD -ne '1') {
266266
# Package OpenOCD separately as well
267267

268-
$version = (cmd /c ".\build\openocd-install\$msysEnv\bin\openocd.exe" --version '2>&1')[0]
268+
$version = (cmd /c ".\build\openocd-install\openocd\openocd.exe" --version '2>&1')[0]
269269
if (-not ($version -match 'Open On-Chip Debugger (?<version>[a-zA-Z0-9\.\-+]+) \((?<timestamp>[0-9\-:]+)\)')) {
270270
Write-Error 'Could not determine openocd version'
271271
}
@@ -276,10 +276,10 @@ if ($env:SKIP_OPENOCD -ne '1') {
276276

277277
# Removing files with special char in their names
278278
# they cause issues with some decompression libraries
279-
Remove-Item "build\openocd-install\$msysEnv\share\openocd\scripts\target\1986*.cfg"
279+
Remove-Item "build\openocd-install\openocd\scripts\target\1986*.cfg"
280280

281281
Write-Host "Saving OpenOCD package to $filename"
282-
exec { tar -a -cf "bin\$filename" -C "build\openocd-install\$msysEnv\bin" '*' -C "..\share\openocd" "scripts" }
282+
exec { tar -a -cf "bin\$filename" -C "build\openocd-install\openocd" '*' }
283283
}
284284

285285
if ($env:SKIP_RISCV -ne '1') {

build_linux.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ popd
8484
if [[ "$SKIP_OPENOCD" != 1 ]]; then
8585
# Package OpenOCD separately as well
8686

87-
version=($("./$builddir/openocd-install/usr/local/bin/openocd" --version 2>&1))
87+
version=($("./$builddir/openocd-install/openocd/openocd" --version 2>&1))
8888
version=${version[0]}
8989
version=${version[3]}
9090
version=$(echo $version | cut -d "-" -f 1)
@@ -94,8 +94,8 @@ if [[ "$SKIP_OPENOCD" != 1 ]]; then
9494
filename="openocd-${version}-${suffix}.tar.gz"
9595

9696
echo "Saving OpenOCD package to $filename"
97-
pushd "$builddir/openocd-install/usr/local/bin"
98-
tar -a -cf "$topd/bin/$filename" * -C "../share/openocd" "scripts"
97+
pushd "$builddir/openocd-install/openocd"
98+
tar -a -cf "$topd/bin/$filename" *
9999
popd
100100
fi
101101

merge_macos.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ if [[ "$SKIP_OPENOCD" != 1 ]]; then
6464
echo "Packaging OpenOCD"
6565
# Package OpenOCD separately as well
6666

67-
version=($("./$builddir/openocd-install/usr/local/bin/openocd" --version 2>&1))
67+
version=($("./$builddir/openocd-install/openocd/openocd" --version 2>&1))
6868
version=${version[0]}
6969
version=${version[3]}
7070
version=$(echo $version | cut -d "-" -f 1)
@@ -74,8 +74,8 @@ if [[ "$SKIP_OPENOCD" != 1 ]]; then
7474
filename="openocd-${version}-${suffix}.zip"
7575

7676
echo "Saving OpenOCD package to $filename"
77-
pushd "$builddir/openocd-install/usr/local/bin"
78-
tar -a -cf "$topd/bin/$filename" * -C "../share/openocd" "scripts"
77+
pushd "$builddir/openocd-install/openocd"
78+
tar -a -cf "$topd/bin/$filename" *
7979
popd
8080
fi
8181

packages/linux/openocd/build-openocd.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,22 @@ set -euo pipefail
55
export CFLAGS=-static
66
export LDFLAGS=-static
77

8+
BUILDDIR=$(pwd)
9+
INSTALLDIR="openocd-install"
10+
BINDIR="/openocd"
11+
DATADIR="/"
12+
813
cd openocd
914
./bootstrap
10-
./configure --disable-werror --enable-internal-jimtcl
15+
./configure --disable-werror --enable-internal-jimtcl --bindir="$BINDIR" --datadir="$DATADIR"
1116
make clean
1217
make
13-
INSTALLDIR="$PWD/../openocd-install/usr/local/bin"
14-
rm -rf "$PWD/../openocd-install"
15-
DESTDIR="$PWD/../openocd-install" make install
18+
rm -rf "$BUILDDIR/$INSTALLDIR"
19+
DESTDIR="$BUILDDIR/$INSTALLDIR" make install
1620

1721
# Add libraries that may be different versions on the system
18-
cd $INSTALLDIR
22+
cd "$BUILDDIR/$INSTALLDIR/$BINDIR"
23+
find . -maxdepth 1 ! -name . ! -name .. ! -name openocd ! -name scripts -exec rm -r {} +
1924
if [[ $(uname -m) == 'aarch64' ]]; then
2025
cp $(ldd openocd | egrep -o "(/.*/libgpiod\.so\.\S*)") ./
2126
fi

packages/macos/openocd/build-openocd.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@
22

33
set -euo pipefail
44

5+
BUILDDIR=$(pwd)
6+
INSTALLDIR="openocd-install-$(uname -m)"
7+
BINDIR="/openocd"
8+
DATADIR="/"
9+
510
cd openocd
611

712
./bootstrap
813
# See https://github.com/raspberrypi/openocd/issues/30
914
# ./configure --disable-werror CAPSTONE_CFLAGS="$(pkg-config capstone --cflags | sed s/.capstone\$//)"
10-
./configure --disable-werror --enable-internal-jimtcl
15+
./configure --disable-werror --enable-internal-jimtcl --bindir="$BINDIR" --datadir="$DATADIR"
1116
make clean
1217
make
13-
INSTALLDIR="$PWD/../openocd-install-$(uname -m)/usr/local/bin"
14-
rm -rf "$PWD/../openocd-install-$(uname -m)"
15-
DESTDIR="$PWD/../openocd-install-$(uname -m)" make install
18+
rm -rf "$BUILDDIR/$INSTALLDIR"
19+
DESTDIR="$BUILDDIR/$INSTALLDIR" make install
20+
21+
cd "$BUILDDIR/$INSTALLDIR/$BINDIR"
22+
find . -maxdepth 1 ! -name . ! -name .. ! -name openocd ! -name scripts -exec rm -r {} +

packages/windows/openocd/build-openocd.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ set -euo pipefail
44

55
BUILDDIR=$(pwd)
66
INSTALLDIR="openocd-install"
7+
BINDIR="/openocd"
8+
DATADIR="/"
79

810
cd openocd
911

1012
./bootstrap
11-
./configure --disable-werror --enable-internal-jimtcl
13+
./configure --disable-werror --enable-internal-jimtcl --bindir="$BINDIR" --datadir="$DATADIR"
1214
make clean
1315
make
1416
DESTDIR="$BUILDDIR/$INSTALLDIR" make install
1517

16-
cd "$BUILDDIR/$INSTALLDIR/${MSYSTEM,,}/bin"
18+
cd "$BUILDDIR/$INSTALLDIR/$BINDIR"
19+
find . -maxdepth 1 ! -name . ! -name .. ! -name openocd.exe ! -name scripts -exec rm -r {} +
1720
"$BUILDDIR/../packages/windows/copy-deps.sh"

0 commit comments

Comments
 (0)