This patch by RegisteredOnlyToSay[1] adds the no_cups flavor to print/ghostscript.
[...] If you look at ports/print/ghostscript/gnu/Makefile you'll see that all cups dependencies are already pretty much separated. Just edit it slightly and make package. I added no_cups flavor to my ghostscript Makefile. Here is very straightforward patch. Feel free to send this patch to openbsd-ports if you want.
[1]: https://old.reddit.com/r/openbsd/comments/g7d2eu/why_does_ghostscript_have_avahi_as_dependence/foypuy5/
--- Makefile.~1.114.~ Fri Jul 12 23:48:55 2019 +++ Makefile Sun Apr 26 04:22:42 2020 @@ -16,7 +16,7 @@ MAINTAINER= Matthias Kilian <k...@openbsd.org> -FLAVORS= a4 gtk no_x11 +FLAVORS= a4 gtk no_x11 no_cups FLAVOR?= FLAVOR_STRING= ${FLAVOR_EXT:S/-/,/g} @@ -85,7 +85,10 @@ USE_GMAKE= Yes -ALL_TARGET = so all ${ALL_TARGET_CUPS} +ALL_TARGET = so all +.if !${FLAVOR:Mno_cups} +ALL_TARGET += ${ALL_TARGET_CUPS} +.endif INSTALL_TARGET = install install-so SOC_LIBS = -liconv -pthread @@ -289,6 +292,7 @@ # Aditional devices not mentioned in configure.ac: DEVICES+= ijs +.if !${FLAVOR:Mno_cups} # Cups LIB_DEPENDS+= print/cups,-libs WANTLIB += cups cupsimage @@ -304,5 +308,6 @@ CUPSPDFTORASTER=1 \ CUPS_FONTPATH="${LOCALBASE}/share/cups/fonts" \ CUPS_DATA="${LOCALBASE}/share/cups" +.endif .include <bsd.port.mk>