git: 70c2b8323241 - main - devel/openocd: Overhaul Makefile

From: Joel Bodenmann <jbo_at_FreeBSD.org>
Date: Tue, 27 Feb 2024 18:31:49 UTC
The branch main has been updated by jbo:

URL: https://cgit.FreeBSD.org/ports/commit/?id=70c2b83232415954356803e286ea2263f5e98c8d

commit 70c2b83232415954356803e286ea2263f5e98c8d
Author:     Joel Bodenmann <jbo@FreeBSD.org>
AuthorDate: 2024-02-21 18:04:23 +0000
Commit:     Joel Bodenmann <jbo@FreeBSD.org>
CommitDate: 2024-02-27 18:31:13 +0000

    devel/openocd: Overhaul Makefile
    
    Major overhaul after taking over maintainership.
    
    Background information to understand some of the changes: OpenOCD is a piece
    of software which talks to chip programming/debugging adapters (hardware).
    Different adapters use different interface to connect to the host OS (such as
    USB).
    
    * Previously, the port provided one option per upstream supported adapter.
      This was changed to a "per-interface" option as we mostly care about handling
      dependencies rather than sequezing out every single byte of the resulting
      binary size.
    
    * Upstream's doxygen documentation has been removed from this port as this
      particular piece of documentation is almost entirely only relevant when
      doing development work on upstream code.
      The man page is still being installed (unchanged).
    
    * Adding more options previously not exposed by the port.
    
    * The various VERBOSE_ options are not combined into a single option as the
      amount of information would be overwhelming and not necessarily helpful.
    
    * A local patch to resolve the broken Aarch64 build would be possible but up-
      stream has removed the offending piece of code since their last release. As
      such, this patch would be obsolete on the next release and existing users
      of this port are already "used" to this restriction.
    
    Approved by:            zirias (mentor)
    Differential Revision:  https://reviews.freebsd.org/D44067
---
 devel/openocd/Makefile | 358 +++++++++++--------------------------------------
 1 file changed, 78 insertions(+), 280 deletions(-)

diff --git a/devel/openocd/Makefile b/devel/openocd/Makefile
index 7e7a2d29de50..0f3eb65a2558 100644
--- a/devel/openocd/Makefile
+++ b/devel/openocd/Makefile
@@ -1,299 +1,97 @@
 PORTNAME=	openocd
-PORTVERSION=	0.12.0
+DISTVERSION=	0.12.0
+PORTREVISION=	1
 CATEGORIES=	devel
 MASTER_SITES=	SF
 
 MAINTAINER=	jbo@FreeBSD.org
 COMMENT=	Open On-Chip Debugger
-WWW=		http://openocd.sf.net/
+WWW=		https://openocd.sf.net
 
 LICENSE=	GPLv2
 LICENSE_FILE=	${WRKSRC}/COPYING
 
+# Note: A local patch would be feasible but upstream has removed support for the offending feature
+#       implementation since their last release (0.12.0). As such, this will no longer be relevant
+#       from 0.13.0 onwards. Hence we're not addressing this "limitation" right now.
 BROKEN_aarch64=	fails to build: src/target/nds32_tlb.h:25:2: error: expected identifier PAGE_SIZE_4K = 0
 
+USES=		gmake libtool makeinfo pkgconfig tar:bzip2
 GNU_CONFIGURE=	yes
-CONFIGURE_ENV+=	libusb_CFLAGS=" " libusb_LIBS="-lusb"
-CONFIGURE_ARGS+=	--disable-werror
-
-OPTIONS_DEFINE=	DOXYGEN JIMTCL VERBOSE JTAG_IO USB_IO PARPORT DUMMY FT2232 FTDI \
-	USBBLASTER EP93XX AT91RM9200 PRESTO USBPROG JLINK VSLLINK RLINK ULINK \
-	ARMJTAGEW BUSPIRATE TIICDI STLINK OSBDM OPENDOUS SYSFSGPIO RMTBITBANG \
-	MINIDRIVER CMSISDAP USB_COMMS
-OPTIONS_DEFAULT=JIMTCL PARPORT DUMMY FT2232 FTDI USBBLASTER EP93XX \
-	AT91RM9200 PRESTO USBPROG JLINK VSLLINK RLINK ULINK ARMJTAGEW \
-	BUSPIRATE STLINK OSBDM OPENDOUS RMTBITBANG
 
-DOXYGEN_DESC=	Build HTML and PDF documentation with Doxygen
-JIMTCL_DESC=	Build with internal JimTCL interpreter
-VERBOSE_DESC=	Enable verbose JTAG I/O messages
-JTAG_IO_DESC=	Enable verbose JTAG I/O messages
-USB_IO_DESC=	Enable verbose USB I/O messages
-PARPORT_DESC=	Support Parallel Port based drivers
-DUMMY_DESC=	Support Dummy Driver
-FT2232_DESC=	Support FT2232 based USB devices (using libftdi)
-FTDI_DESC=	Support experimental FTDI+MPSSE+libusb-1.0 async.
-USBBLASTER_DESC=Support USB-Blaster Programmer (using libftdi)
-EP93XX_DESC=	Support EP93xx based SBCs
-AT91RM9200_DESC=Support AT91RM9200 based SBCs
-PRESTO_DESC=	Support ASIX Presto Programmer (using libftdi)
-USBPROG_DESC=	Support USB-Prog JTAG Programmer
-JLINK_DESC=	Support Segger J-Link JTAG Programmer
-VSLLINK_DESC=	Support Versaloon-Link JTAG Programmer
-RLINK_DESC=	Support Raisonance RLink JTAG Programmer
-ULINK_DESC=	Support Keil ULINK-JTAG Programmer
-ARMJTAGEW_DESC=	Support Olimex ARM-JTAG-EW Programmer
-BUSPIRATE_DESC=	Support BusPirate Programmer
-STLINK_DESC=	Support STLink Programmer
-OSBDM_DESC=	Support OSBDM Programmer (JTAG only)
-OPENDOUS_DESC=	Support EStick/OpenDous Programmer
-SYSFSGPIO_DESC=	Support Programming via sysfs GPIOs
-RMTBITBANG_DESC=	Support Remote-Bitbang Driver
-MINIDRIVER_DESC=	Dummy minidriver only (will exclude others!)
-CMSISDAP_DESC=	Support for CMSIS-DAP Compliant Debugger
-TIICDI_DESC=	Support for the TI ICDI JTAG Programmer
-USB_COMMS_DESC=	Enable verbose USB communication messages
+CFLAGS+=	-Wno-error=strict-prototypes \
+		-Wno-error=unused-but-set-parameter \
+		-Wno-error=unused-but-set-variable \
 
-USES=		gmake libtool makeinfo pkgconfig tar:bzip2
-CFLAGS+=	-I${LOCALBASE}/include -L${LOCALBASE}/lib -Wno-error
 INFO=		openocd
 
-post-patch:
-	@${REINPLACE_CMD} -e '/PKG_CONFIG/{/1\.0/!s/libusb/&-0.1/;}' \
-		${WRKSRC}/configure
-
-# IMPORTANT INFORMATION FOR DEVELOPERS:
-# Some Interfaces and Options are not on the list because they break a build.
-# If you need them working on FreeeBSD, code, patches are welcome :-)
-
-.include <bsd.port.options.mk>
-
-.if ${PORT_OPTIONS:MDOXYGEN}
-CONFIGURE_ARGS+=	--enable-doxygen-pdf
-WITH_DOXYGEN=		yes
-.else
-CONFIGURE_ARGS+=	--disable-doxygen-pdf --disable-doxygen-html
-.endif
-
-.if ${PORT_OPTIONS:MJIMTCL}
-CONFIGURE_ARGS+=	--enable-internal-jimtcl
-.else
-CONFIGURE_ARGS+=	--disable-internal-jimtcl
-.endif
-
-.if ${PORT_OPTIONS:MVERBOSE}
-CONFIGURE_ARGS+=	--enable-verbose
-.else
-CONFIGURE_ARGS+=	--disable-verbose
-.endif
-
-.if ${PORT_OPTIONS:MJTAG_IO}
-CONFIGURE_ARGS+=	--enable-verbose-jtag-io
-.else
-CONFIGURE_ARGS+=	--disable-verbose-jtag-io
-.endif
-
-.if ${PORT_OPTIONS:MUSB_IO}
-CONFIGURE_ARGS+=	--enable-verbose-usb-io
-.else
-CONFIGURE_ARGS+=	--disable-verbose-usb-io
-.endif
-
-.if ${PORT_OPTIONS:MUSB_COMMS}
-CONFIGURE_ARGS+=	--enable-verbose-usb-comms
-.else
-CONFIGURE_ARGS+=	--disable-verbose-usb-comms
-.endif
-
-.if ${PORT_OPTIONS:MMALLOC}
-CONFIGURE_ARGS+=	--enable-malloc-logging
-.else
-CONFIGURE_ARGS+=	--disable-malloc-logging
-.endif
-
-.if ${PORT_OPTIONS:MPARPORT}
-CONFIGURE_ARGS+=	--enable-parport
-.else
-CONFIGURE_ARGS+=	--disable-parport
-.endif
-
-.if ${PORT_OPTIONS:MDUMMY}
-CONFIGURE_ARGS+=	--enable-dummy
-.else
-CONFIGURE_ARGS+=	--disable-dummy
-.endif
-
-.if ${PORT_OPTIONS:MFT2232}
-CONFIGURE_ARGS+=	--enable-legacy-ft2232_libftdi
-WITH_LIBFTDI=		yes
-.else
-CONFIGURE_ARGS+=	--disable-legacy-ft2232_libftdi
-.endif
-
-.if ${PORT_OPTIONS:MFTDI}
-CONFIGURE_ARGS+=	--enable-ftdi
-WITH_LIBFTDI=		yes
-.else
-CONFIGURE_ARGS+=	--disable-ftdi
-.endif
-
-.if ${PORT_OPTIONS:MUSBBLASTER}
-CONFIGURE_ARGS+=	--enable-usb_blaster_libftdi
-.else
-CONFIGURE_ARGS+=	--disable-usb_blaster_libftdi
-.endif
-
-.if ${PORT_OPTIONS:MAMTJTAGACCEL}
-CONFIGURE_ARGS+=	--enable-amtjtagaccel
-.else
-CONFIGURE_ARGS+=	--disable-amtjtagaccel
-.endif
-
-.if ${PORT_OPTIONS:MZY1000}
-CONFIGURE_ARGS+=	--enable-zy1000
-.else
-CONFIGURE_ARGS+=	--disable-zy1000
-.endif
-
-.if ${PORT_OPTIONS:MIOUTIL}
-CONFIGURE_ARGS+=	--enable-ioutil
-.else
-CONFIGURE_ARGS+=	--disable-ioutil
-.endif
-
-.if ${PORT_OPTIONS:MEP93XX}
-CONFIGURE_ARGS+=	--enable-ep93xx
-.else
-CONFIGURE_ARGS+=	--disable-ep93xx
-.endif
-
-.if ${PORT_OPTIONS:MAT91RM9200}
-CONFIGURE_ARGS+=	--enable-at91rm9200
-.else
-CONFIGURE_ARGS+=	--disable-at91rm9200
-.endif
-
-.if ${PORT_OPTIONS:MGW16012}
-CONFIGURE_ARGS+=	--enable-gw16012
-.else
-CONFIGURE_ARGS+=	--disable-gw16012
-.endif
-
-.if ${PORT_OPTIONS:MPRESTO}
-CONFIGURE_ARGS+=	--enable-presto_libftdi
-WITH_LIBFTDI=		yes
-.else
-CONFIGURE_ARGS+=	--disable-presto_libftdi
-.endif
-
-.if ${PORT_OPTIONS:MUSBPROG}
-CONFIGURE_ARGS+=	--enable-usbprog
-WITH_LIBUSB=		yes
-.else
-CONFIGURE_ARGS+=	--disable-usbprog
-.endif
-
-.if ${PORT_OPTIONS:MOOCDTRACE}
-CONFIGURE_ARGS+=	--enable-oocd_trace
-.else
-CONFIGURE_ARGS+=	--disable-oocd_trace
-.endif
-
-.if ${PORT_OPTIONS:MJLINK}
-CONFIGURE_ARGS+=	--enable-jlink
-WITH_LIBUSB=		yes
-.else
-CONFIGURE_ARGS+=	--disable-jlink
-.endif
-
-.if ${PORT_OPTIONS:MVSLLINK}
-CONFIGURE_ARGS+=	--enable-vsllink
-WITH_LIBUSB=		yes
-.else
-CONFIGURE_ARGS+=	--disable-vsllink
-.endif
-
-.if ${PORT_OPTIONS:MRLINK}
-CONFIGURE_ARGS+=	--enable-rlink
-WITH_LIBUSB=		yes
-.else
-CONFIGURE_ARGS+=	--disable-rlink
-.endif
-
-.if ${PORT_OPTIONS:MULINK}
-CONFIGURE_ARGS+=	--enable-ulink
-.else
-CONFIGURE_ARGS+=	--disable-ulink
-.endif
-
-.if ${PORT_OPTIONS:MARMJTAGEW}
-CONFIGURE_ARGS+=	--enable-arm-jtag-ew
-WITH_LIBUSB=		yes
-.else
-CONFIGURE_ARGS+=	--disable-arm-jtag-ew
-.endif
-
-.if ${PORT_OPTIONS:MBUSPIRATE}
-CONFIGURE_ARGS+=	--enable-buspirate
-.else
-CONFIGURE_ARGS+=	--disable-buspirate
-.endif
-
-.if ${PORT_OPTIONS:MSTLINK}
-CONFIGURE_ARGS+=	--enable-stlink
-.else
-CONFIGURE_ARGS+=	--disable-stlink
-.endif
-
-.if ${PORT_OPTIONS:MTIICDI}
-CONFIGURE_ARGS+=	--enable-ti-icdi
-.else
-CONFIGURE_ARGS+=	--disable-ti-icdi
-.endif
-
-.if ${PORT_OPTIONS:MOSBDM}
-CONFIGURE_ARGS+=	--enable-osbdm
-.else
-CONFIGURE_ARGS+=	--disable-osbdm
-.endif
-
-.if ${PORT_OPTIONS:MOPENDOUS}
-CONFIGURE_ARGS+=	--enable-opendous
-.else
-CONFIGURE_ARGS+=	--disable-opendous
-.endif
-
-.if ${PORT_OPTIONS:MSYSFSGPIO}
-CONFIGURE_ARGS+=	--enable-sysfsgpio
-.else
-CONFIGURE_ARGS+=	--disable-sysfsgpio
-.endif
-
-.if ${PORT_OPTIONS:MRMTBITBANG}
-CONFIGURE_ARGS+=	--enable-remote-bitbang
-.else
-CONFIGURE_ARGS+=	--disable-remote-bitbang
-.endif
-
-.if ${PORT_OPTIONS:MMINIDRIVER}
-CONFIGURE_ARGS+=	--enable-minidriver-dummy
-.else
-CONFIGURE_ARGS+=	--disable-minidriver-dummy
-.endif
-
-.if ${PORT_OPTIONS:MCMSISDAP}
-CONFIGURE_ARGS+=	--enable-cmsis-dap
-LIB_DEPENDS+=		libhidapi.so:comms/hidapi
-.else
-CONFIGURE_ARGS+=	--disable-cmsis-dap
-.endif
-
-.if defined(WITH_LIBFTDI)
-LIB_DEPENDS+=		libftdi.so:devel/libftdi
-.endif
-
-.if ${PORT_OPTIONS:MDOXYGEN}
-BUILD_DEPENDS+=		doxygen:devel/doxygen
-.endif
+# Note: Some adapters are not supported or do not currently work on FreeBSD.
+#       These have been consciously left out of this port entirely.
+
+OPTIONS_DEFAULT=	JIMTCL_INTERNAL LIBUSB LIBHIDAPI LIBFTDI SERIAL
+OPTIONS_GROUP=		DEBUG ADAPTERS
+OPTIONS_GROUP_ADAPTERS=	LIBUSB LIBHIDAPI LIBFTDI SERIAL PARPORT
+OPTIONS_GROUP_DEBUG=	VERBOSE_JTAGIO VERBOSE_USBIO VERBOSE_USBCOMM
+OPTIONS_SINGLE=		JIMTCL
+OPTIONS_SINGLE_JIMTCL=	JIMTCL_INTERNAL JIMTCL_EXTERNAL
+
+ADAPTERS_DESC=		Hardware adapters/programmers/debuggers support
+JIMTCL_DESC=		Jim Tcl interpreter
+JIMTCL_EXTERNAL_DESC=	External
+JIMTCL_INTERNAL_DESC=	Internal
+LIBFTDI_DESC=		Adapters using libftdi
+LIBHIDAPI_DESC=		Adapters using libhidapi
+LIBUSB_DESC=		Adapters using libusb
+PARPORT_DESC=		Adapters using parallel port
+SERIAL_DESC=		Adapters using serial port
+VERBOSE_JTAGIO_DESC=	Enable verbose JTAG I/O messages
+VERBOSE_USBCOMM_DESC=	Enable verbose USB communication messages
+VERBOSE_USBIO_DESC=	Enable verbose USB I/O messages
+
+# Internal (built-in) or external Jim Tcl interpreter
+JIMTCL_EXTERNAL_LIB_DEPENDS=		libjim.so:lang/jimtcl
+JIMTCL_EXTERNAL_USES=			localbase:ldflags
+JIMTCL_INTERNAL_CONFIGURE_ENABLE=	internal-jimtcl
+
+# Adapters depending on libftdi
+LIBFTDI_LIB_DEPENDS=		libftdi.so:devel/libftdi
+LIBFTDI_CONFIGURE_ENABLE=	usb_blaster \
+				presto \
+				openjtag
+
+# Adapters depending on libhidapi
+LIBHIDAPI_LIB_DEPENDS=		libhidapi.so:comms/hidapi
+LIBHIDAPI_CONFIGURE_ENABLE=	cmsis_dap \
+				nulink \
+				kitprog
+
+# Adapters depending on libusb
+LIBUSB_CONFIGURE_ENABLE=	ftdi \
+				stlink \
+				ti_icdi \
+				ulink \
+				angie \
+				usb_blaster_2 \
+				ft232r \
+				vsllink \
+				xds110 \
+				cmsis_dap_v2 \
+				osbdm \
+				opendous \
+				armjtagew \
+				rlink \
+				usbprog \
+				esp_usb_jtag
+
+# Parallel port based adapters
+PARPORT_CONFIGURE_ENABLE=	parport
+
+# Serial port based adapters
+SERIAL_CONFIGURE_ENABLE=	buspirate
+
+# Debug options
+VERBOSE_JTAGIO_CONFIGURE_ENABLE=	verbose
+VERBOSE_USBCOMM_CONFIGURE_ENABLE=	verbose-usb-comms
+VERBOSE_USBIO_CONFIGURE_ENABLE=		verbose-usb-io
 
 .include <bsd.port.mk>