On Thu Dec 04, 2025 at 12:03:44PM +0100, Marc Espie wrote:
> I spent quite a bit of time fighting with cmake, until I realized
> that compiling with an external gmic was completely broken.
>
> So I've done the same thing that FreeBSD did, and forgot about it
> for now. It needs somewhat deep surgery to work again.
>
> Conveniently, this means this port does no longer depend on gmic per se,
> so it can be updated independently.
>
> The patches are slightly different, NetBSD has gotten support (I have zero
> idea why it goes thru (void *)(cimg_ulong) there I need to figure that out)
What happens if we do that under OpenBSD as well?
>
> I've tightened the deps on gimp/gimp3, obviously.
>
> All three variations of the port appear to work just fine.
>
> I hope to work with upstream and figure out a way to restore depending on
> the library eventually, but in the mean time, please test and commit.
>
> Note that I expect that adding a port that wants gimp3 install will cause
> a few other ports to fail.
>
> I will try to unmangle that mess today, trying anything that depends on gimp
> with just gimp3, see what fails. I hope the gegl filters will be just fine
> and not need any gimp/gimp3 variation.
>
> (I did leave the corresponding juicy parts commented in the existing
> Makefiles for the most part)
Two tweaks inline.
>
> Index: Makefile
> ===================================================================
> RCS file: /vide/cvs/ports/graphics/gmic-qt/Makefile,v
> diff -u -p -r1.4 Makefile
> --- Makefile 29 Mar 2022 18:31:13 -0000 1.4
> +++ Makefile 4 Dec 2025 10:53:40 -0000
> @@ -1,4 +1,5 @@
> SUBDIR += gimp
> + SUBDIR += gimp3
> SUBDIR += none
>
> .include <bsd.port.subdir.mk>
> Index: Makefile.inc
> ===================================================================
> RCS file: /vide/cvs/ports/graphics/gmic-qt/Makefile.inc,v
> diff -u -p -r1.7 Makefile.inc
> --- Makefile.inc 26 Sep 2023 11:39:04 -0000 1.7
> +++ Makefile.inc 3 Dec 2025 16:36:41 -0000
> @@ -1,5 +1,5 @@
> COMMENT = gmic-qt ${GMIC_WHAT}
> -V = 3.0.2
> +V = 3.6.4
>
> DISTNAME ?= gmic-qt-${QT_HOST}-$V
> CATEGORIES = graphics
> @@ -14,7 +14,7 @@ PERMIT_PACKAGE = Yes
> WANTLIB += ${COMPILER_LIBCXX} X11 c m z
> WANTLIB += curl fftw3 fftw3_threads
> WANTLIB += ICE Qt5Core Qt5Gui Qt5Network Qt5Widgets SM Xext
> -WANTLIB += png gmic
> +WANTLIB += png #gmic
That should be cleaned up!?
>
> SITES = https://gmic.eu/files/source/
> DISTFILES = gmic_$V${EXTRACT_SUFX}
> @@ -24,8 +24,7 @@ MODULES = devel/cmake x11/qt5
>
> LIB_DEPENDS += net/curl \
> graphics/png \
> - math/fftw3 \
> - graphics/gmic
> + math/fftw3
>
> CONFIGURE_STYLE = cmake
>
> @@ -33,12 +32,15 @@ CONFIGURE_STYLE = cmake
> MAKE_ENV = TERM=xterm
> MODCMAKE_LDFLAGS = -L${LOCALBASE}/lib
>
> -# XXX does not do what it says it does
> -CONFIGURE_ARGS += -DCUSTOM_CFLAGS=Yes
> -
> +# XXX ENABLE_SYSTEM_GMIC is broken, so is dynamic linking
> +CONFIGURE_ARGS += -DENABLE_SYSTEM_GMIC=OFF
> +CONFIGURE_ARGS += -DENABLE_DYNAMIC_LINKING=OFF
> CONFIGURE_ARGS += -DGMIC_QT_HOST=${QT_HOST}
> -CONFIGURE_ARGS += -DENABLE_DYNAMIC_LINKING=ON
> -CONFIGURE_ARGS += -DGMIC_PATH=${WRKDIST}/src
> +#CONFIGURE_ARGS += -DBUILD_LIB=OFF
> +#CONFIGURE_ARGS += -DBUILD_LIB_STATIC=OFF
> +#CONFIGURE_ARGS += -DBUILD_CLI=OFF
> +#CONFIGURE_ARGS += -DBUILD_MAN=OFF
> +#CONFIGURE_ARGS += -DGMIC_PATH=${WRKDIST}/src
>
> SUBST_VARS += QT_HOST GMIC_WHAT
> # XXX somehow there's no debug info generated ?
> Index: distinfo
> ===================================================================
> RCS file: /vide/cvs/ports/graphics/gmic-qt/distinfo,v
> diff -u -p -r1.5 distinfo
> --- distinfo 2 Mar 2022 11:03:04 -0000 1.5
> +++ distinfo 3 Dec 2025 15:01:35 -0000
> @@ -1,2 +1,2 @@
> -SHA256 (gmic_3.0.2.tar.gz) = aKzsMsRdVvsLBAis7E9jFmFxgW1wci1jEGeH8efRcDA=
> -SIZE (gmic_3.0.2.tar.gz) = 10458732
> +SHA256 (gmic_3.6.4.tar.gz) = xIL3qgdRrvJj7IPcUFfIhv08hi+o/3PhVobhKiXI5zE=
> +SIZE (gmic_3.6.4.tar.gz) = 20335806
> Index: gimp/Makefile
> ===================================================================
> RCS file: /vide/cvs/ports/graphics/gmic-qt/gimp/Makefile,v
> diff -u -p -r1.3 Makefile
> --- gimp/Makefile 29 Oct 2022 07:19:53 -0000 1.3
> +++ gimp/Makefile 3 Dec 2025 16:45:50 -0000
> @@ -4,7 +4,6 @@ WANTLIB += gimp-2.0 gimpbase-2.0 gimpcol
> WANTLIB += gegl-0.4 babl-0.1 cairo json-glib-1.0 intl
> WANTLIB += gdk_pixbuf-2.0 gio-2.0 glib-2.0 gmodule-2.0 gobject-2.0
>
> -LIB_DEPENDS += graphics/gimp/stable
> -REVISION = 0
> +LIB_DEPENDS += gimp-<3:graphics/gimp/stable
>
> .include <bsd.port.mk>
> Index: gimp3/Makefile
> ===================================================================
> RCS file: gimp3/Makefile
> diff -N gimp3/Makefile
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ gimp3/Makefile 3 Dec 2025 17:07:00 -0000
> @@ -0,0 +1,10 @@
> +QT_HOST = gimp3
> +
> +WANTLIB += babl-0.1 cairo gdk_pixbuf-2.0 gegl-0.4 gexiv2 gimp-3.0
> +WANTLIB += gimpbase-3.0 gimpcolor-3.0 gimpconfig-3.0 gimpmath-3.0
> +WANTLIB += gio-2.0 glib-2.0 gmodule-2.0 gobject-2.0 harfbuzz intl
> +WANTLIB += json-glib-1.0 pango-1.0
> +
> +LIB_DEPENDS += gimp->=3:graphics/gimp/snapshot
> +
> +.include <bsd.port.mk>
> Index: gimp3/pkg/PLIST
> ===================================================================
> RCS file: gimp3/pkg/PLIST
> diff -N gimp3/pkg/PLIST
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ gimp3/pkg/PLIST 4 Dec 2025 11:01:07 -0000
> @@ -0,0 +1,2 @@
> +lib/gimp/3.0/plug-ins/gmic_gimp_qt/
> +@bin lib/gimp/3.0/plug-ins/gmic_gimp_qt/gmic_gimp_qt
> Index: patches/patch-CMakeLists_txt
> ===================================================================
> RCS file: patches/patch-CMakeLists_txt
> diff -N patches/patch-CMakeLists_txt
> --- patches/patch-CMakeLists_txt 2 Mar 2022 11:03:04 -0000 1.3
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,15 +0,0 @@
> -- remove flags that make no sense for us
> -- fix CMake boo-boo (pr#364 on the gmic repo)
> -
> -Index: CMakeLists.txt
> ---- CMakeLists.txt.orig
> -+++ CMakeLists.txt
> -@@ -102,7 +102,7 @@ if(APPLE)
> - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
> - list(APPEND GMIC_CXX_COMPILE_FLAGS -Wno-error=c++11-narrowing
> -fpermissive)
> - else()
> -- list(APPEND GMIC_CXX_COMPILE_FLAGS -Wno-error=narrowing -fno-ipa-sra
> -fpermissive)
> -+ list(APPEND GMIC_CXX_COMPILE_FLAGS -Wno-error=narrowing -fpermissive)
> - endif()
> -
> - if(NOT "${PRERELEASE_TAG}" STREQUAL "")
> Index: patches/patch-src_CImg_h
> ===================================================================
> RCS file: patches/patch-src_CImg_h
> diff -N patches/patch-src_CImg_h
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_CImg_h 3 Dec 2025 15:01:35 -0000
> @@ -0,0 +1,24 @@
> +Index: src/CImg.h
> +--- src/CImg.h.orig
> ++++ src/CImg.h
> +@@ -3230,6 +3230,7 @@ namespace cimg_library {
> + pthread_t *events_thread;
> + pthread_cond_t wait_event;
> + pthread_mutex_t mutex_lock_display, mutex_wait_event;
> ++ pthread_mutexattr_t attr;
> + unsigned int nb_bits;
> + bool is_blue_first, is_shm_enabled, byte_order, events_thread_running;
> +
> +@@ -3243,8 +3244,10 @@ namespace cimg_library {
> + #ifdef __FreeBSD__
> + XInitThreads();
> + #endif
> +- pthread_mutex_init(&mutex_wait_event,0);
> +- pthread_mutex_init(&mutex_lock_display,0);
> ++ pthread_mutexattr_init(&attr);
> ++ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
indentation
> ++ pthread_mutex_init(&mutex_wait_event, &attr);
> ++ pthread_mutex_init(&mutex_lock_display, &attr);
> + pthread_cond_init(&wait_event,0);
> + #ifdef cimg_use_xrandr
> + resolutions = 0;
> Index: patches/patch-src_gmic_cpp
> ===================================================================
> RCS file: /vide/cvs/ports/graphics/gmic-qt/patches/patch-src_gmic_cpp,v
> diff -u -p -r1.4 patch-src_gmic_cpp
> --- patches/patch-src_gmic_cpp 11 Mar 2022 19:22:27 -0000 1.4
> +++ patches/patch-src_gmic_cpp 3 Dec 2025 15:01:35 -0000
> @@ -1,21 +1,12 @@
> Index: src/gmic.cpp
> --- src/gmic.cpp.orig
> +++ src/gmic.cpp
> -@@ -2473,6 +2473,8 @@ CImgList<void*> gmic::list_p_is_abort = CImgList<void*
> - bool *gmic::abort_ptr(bool *const p_is_abort) {
> +@@ -2051,6 +2051,8 @@ inline CImgList<void*>& gmic_runs() {
> + inline void* get_tid() {
> #if defined(__MACOSX__) || defined(__APPLE__)
> void* tid = (void*)(cimg_ulong)getpid();
> +#elif defined(__OpenBSD__)
> + void* tid = (void*)pthread_self();
> #elif cimg_OS==1
> - void* tid = (void*)(cimg_ulong)syscall(SYS_gettid);
> - #elif cimg_OS==2
> -@@ -2815,6 +2817,8 @@ gmic::~gmic() {
> - cimg::mutex(21);
> - #if defined(__MACOSX__) || defined(__APPLE__)
> - void* tid = (void*)(cimg_ulong)getpid();
> -+#elif defined(__OpenBSD__)
> -+ void* tid = (void*)pthread_self();
> - #elif cimg_OS==1
> - void* tid = (void*)(cimg_ulong)syscall(SYS_gettid);
> - #elif cimg_OS==2
> + #if defined(__NetBSD__) || defined(cimg_use_pthread) || cimg_display==1
> + void* tid = (void*)(cimg_ulong)pthread_self();
>