File openocd.spec of Package openocd

%define external_jimtcl 0
%define external_libjaylink 1
%define _udevdir %(pkg-config --variable udevdir udev)
Name:           openocd
Version:        0.11.0+git20230120
Release:        0
Summary:        Open on-chip JTAG/SWD debug solution for RP2040 and other embedded target devices
License:        GPL-2.0-only
Group:          Development/Tools/Debuggers
URL:            https://github.com/raspberrypi/openocd
Source0:        %{name}-%{version}.tar.gz
#Patch0:         openocd-0.11.0-memhelperfix.patch
BuildRequires:  autoconf >= 2.64
BuildRequires:  automake
BuildRequires:  fdupes
BuildRequires:  libtool
%if %{external_jimtcl}
BuildRequires:  jimtcl-devel
%endif
%if %{external_libjaylink}
BuildRequires:  libjaylink-devel >= 0.2.0
%endif
BuildRequires:  libgpiod-devel
BuildRequires:  pkg-config >= 0.23
%if 0%{?suse_version}
BuildRequires:  makeinfo
BuildRequires:  libftdi1-devel
BuildRequires:  libhidapi-devel
BuildRequires:  libusb-compat-devel
BuildRequires:  pkgconfig(libusb-1.0)
BuildRequires:  pkgconfig(udev)
BuildRequires:  pkgconfig(libudev)
Requires(post): udev
Requires(postun):udev
%endif
%if 0%{?fedora_version}
BuildRequires:  texinfo
BuildRequires:  libftdi-devel
BuildRequires:  hidapi-devel
BuildRequires:  libusb-compat-0.1-devel
BuildRequires:  libusb1-devel
%endif

%description
The Open On-Chip Debugger (OpenOCD) provides debugging, in-system programming
and boundary-scan testing for embedded devices. Various different boards,
targets, and interfaces are supported to ease development time.

Install OpenOCD if you are looking for an open source solution for hardware
debugging.

This build is based on the rp2040 branch of the OpenOCD fork, maintained by the
Raspberry PI foundation. It includes support for the PicoProbe and RP2040
multicore debugging.

%prep
%autosetup -p1 -n %{name}

%build
%if !%{external_jimtcl}
# set this explicitly, else the configure from included jimtcl
# won't find a compiler :(
export CC=gcc
%endif

./bootstrap nosubmodule
%configure \
  --disable-silent-rules \
  --disable-shared \
  --enable-static \
  --disable-doxygen-html \
  --disable-werror \
  --enable-ftdi \
  --enable-stlink \
  --enable-ti-icdi \
  --enable-ulink \
  --enable-usb-blaster-2 \
  --enable-vsllink \
  --enable-osbdm \
  --enable-opendous \
  --enable-aice \
  --enable-usbprog \
  --enable-rlink \
  --enable-armjtagew \
  --enable-cmsis-dap \
  --enable-usb-blaster \
  --enable-presto \
  --enable-openjtag \
  --enable-jlink \
%ifarch %ix86 x86_64
  --enable-parport \
%endif
  --enable-amtjtagaccel \
%ifarch %arm
  --enable-bcm2835gpio \
%endif
  --enable-gw16012 \
  --enable-buspirate \
  --enable-sysfsgpio \
%if %{external_jimtcl}
  --disable-internal-jimtcl \
%endif
%if %{external_libjaylink}
  --disable-internal-libjaylink \
%endif
  --enable-remote-bitbang \

make %{?_smp_mflags} V=1

%install
%make_install
rm -f %{buildroot}%{_infodir}/dir
rm -f %{buildroot}%{_libdir}/libopenocd.*
rm -f %{buildroot}%{_datadir}/%{name}/contrib/openocd.udev
rm -rf %{buildroot}%{_datadir}/%{name}/contrib/libdcc
mkdir -p %{buildroot}%{_udevdir}/rules.d
%if 0%{?suse_version}
cat contrib/60-openocd.rules | sed -e 's/GROUP="plugdev"/GROUP="users"/' > %{buildroot}%{_udevdir}/rules.d/60-openocd.rules
%endif
%if 0%{?fedora_version}
cat contrib/60-openocd.rules | sed -e 's/MODE=.*/TAG+="uaccess"/' > %{buildroot}%{_udevdir}/rules.d/60-openocd.rules
%endif
%fdupes %{buildroot}

%post
%udev_rules_update

%postun
%udev_rules_update

%files
%defattr(-,root,root,-)
%doc contrib/libdcc README AUTHORS ChangeLog COPYING NEWS
%{_bindir}/%{name}
%{_mandir}/man1/*
%{_infodir}/%{name}.info*.gz
%{_udevdir}/rules.d/60-openocd.rules
%{_datadir}/%{name}

%changelog
openSUSE Build Service is sponsored by