$NetBSD: patch-Imakefile,v 1.3 2023/08/16 17:02:20 tsutsui Exp $

- use jpeg, png, tiff, and zlib from pkgsrc
- make ghostscript support optional
- add webp support from forked upstream
  https://gitlab.com/DavidGriffith/xv/-/commit/5682a07e
  and use libwebp from pkgsrc

--- Imakefile.orig	2023-08-16 16:51:48.939703880 +0000
+++ Imakefile
@@ -6,13 +6,20 @@
 /* if, for whatever reason, you're unable to get the JPEG library to compile
  * on your machine, *COMMENT OUT* the following line
  */
-#define HaveJpeg
+/* #define HaveJpeg */
+#define UseInstalledJpeg
 
+/* if, for whatever reason, you're unable to get the WEBP library to compile
+ * on your machine, *COMMENT OUT* the following line
+ */
+/* #define HaveWEBP */
+#define UseInstalledWEBP
 
 /* if, for whatever reason, you're unable to get the TIFF library to compile
  * on your machine, *COMMENT OUT* the following line
  */
-#define HaveTiff
+/* #define HaveTiff */
+#define UseInstalledTiff
 
 
 /* if, for whatever reason, you're unable to get the PDS/VICAR support
@@ -21,6 +28,10 @@
 #define HavePDS
 
 
+/* #define UseInstalledGhostScript */
+#define UseInstalledPng
+#define UseInstalledZlib
+
 /*
  * if you are running on a SysV-based machine, such as HP, Silicon Graphics,
  * etc, uncomment one of the following lines to get you *most* of the way
@@ -116,28 +127,84 @@ MGCSFX = -DMGCSFXDIR=\"$(MGCSFXDIR)\"
 
 /* This marks the end of the configuration parameters */
 
+#ifdef HaveWEBP
+WEBP = -DDOWEBP
+WEBPDIR = /usr
+LIBWEBP = $(WEBPDIR)/lib/libwebp.so $(WEBPDIR)/lib/libwebpdemux.so
+DEPLIBWEBP = $(LIBWEBP)
+WEBPINCLUDE = -I$(WEBPDIR)/include
+#endif
 
-
-
+#ifdef UseInstalledWEBP
+WEBP = -DDOWEBP
+LIBWEBP = $(LDFLAGS) -L$(PREFIX)/lib -Wl,-R$(PREFIX)/lib -lwebp -lwebpdemux
+WEBPINCLUDE = -I$(PREFIX)/include
+#endif
 
 #ifdef HaveJpeg
 JPEG = -DDOJPEG
 JPEGDIR = jpeg
 LIBJPEG = $(JPEGDIR)/libjpeg.a
+DEPLIBJPEG = $(LIBJPEG)
 JPEGINCLUDE = -I$(JPEGDIR)
 #endif
 
+#ifdef UseInstalledJpeg
+JPEG = -DDOJPEG
+LIBJPEG = $(LDFLAGS) -L$(PREFIX)/lib -Wl,-R$(PREFIX)/lib -ljpeg
+JPEGINCLUDE = -I$(PREFIX)/include
+#endif
+
 #ifdef HaveTiff
 TIFF = -DDOTIFF
 TIFFDIR = tiff
 LIBTIFF = $(TIFFDIR)/libtiff.a
+DEPLIBTIFF = $(LIBTIFF)
 TIFFINCLUDE = -I$(TIFFDIR)
 #endif
 
+#ifdef UseInstalledTiff
+TIFF = -DDOTIFF
+LIBTIFF = -L$(PREFIX)/lib -Wl,-R$(PREFIX)/lib -ltiff -ljpeg -lz
+TIFFINCLUDE = -I$(PREFIX)/include
+#endif
+
 #ifdef HavePDS
 PDS = -DDOPDS
 #endif
 
+#ifdef UseInstalledGhostScript
+GS = -DDOGS
+#endif
+
+/*
+###
+### if, for whatever reason, you're unable to get the PNG library to compile
+### on your machine, *COMMENT OUT* the following lines
+###
+*/
+#ifdef UseInstalledPng
+PNG    = -DDOPNG
+PNGDIR = ${PREFIX}
+PNGINC = -I$(PNGDIR)/include
+PNGLIB = -L$(PNGDIR)/lib -lpng -lz
+LIBPNG = ${PNGLIB}
+PNGINCLUDE = ${PNGINC}
+#endif
+
+/*
+###
+### if, for whatever reason, you're unable to get the PNG library to compile
+### on your machine, *COMMENT OUT* the following lines
+###
+*/
+#ifdef UseInstalledZlib
+ZLIBDIR = $(PREFIX)
+ZLIBINC = -I$(ZLIBDIR)/include
+ZLIBLIB = -L$(ZLIBDIR)/lib -lz
+LIBZLIB = ${ZLIB}
+ZLIBINCLUDE = ${ZLIBINC}
+#endif
 
 #if defined(SCOArchitecture)
 SCO= -Dsco -DPOSIX -DNO_RANDOM 
@@ -149,14 +216,15 @@ SYS_LIBRARIES=        -lm
 #endif
 
 
-DEPLIBS = $(LIBJPEG) $(LIBTIFF)
-LOCAL_LIBRARIES = $(XLIB) $(DEPLIBS)
+DEPLIBS = $(DEPLIBJPEG) $(DEPLIBTIFF) $(DEPLIBPNG) $(DEPLIBWEBP) $(DEPLIBZLIB)
+LOCAL_LIBRARIES = $(XLIB) $(LIBJPEG) $(LIBTIFF) $(LIBPNG) $(LIBWEBP) $(LIBZLIB)
 
 DEFINES= $(SCO) $(UNIX) $(NODIRENT) $(VPRINTF) $(TIMERS) \
-	$(HPUX7) $(JPEG) $(TIFF) $(PDS) $(DXWM) $(RAND) \
+	$(HPUX7) $(JPEG) $(TIFF) $(GS) $(PNG) $(WEBP) $(PDS) $(DXWM) $(RAND) \
 	$(BACKING_STORE) $(BSDTYPES) $(SGI) $(MGCSFX)
 
-INCLUDES = $(JPEGINCLUDE) $(TIFFINCLUDE)
+INCLUDES = $(JPEGINCLUDE) $(TIFFINCLUDE) $(PNGINCLUDE) $(WEBPINCLUDE) \
+	$(ZLIBINCLUDE)
 
 SRCS1 =	xv.c xvevent.c xvroot.c xvmisc.c xvimage.c xvcolor.c xvsmooth.c \
 	xv24to8.c xvgif.c xvpm.c xvinfo.c xvctrl.c xvscrl.c xvalg.c \
@@ -166,7 +234,7 @@ SRCS1 =	xv.c xvevent.c xvroot.c xvmisc.c
 	xvbrowse.c xvtext.c xvpcx.c xviff.c xvtarga.c xvxpm.c xvcut.c \
 	xvxwd.c xvfits.c xvpng.c xvzx.c xvwbmp.c xvpcd.c \
 	xvmag.c xvpic.c xvmaki.c xvpi.c xvpic2.c xvvd.c xvmgcsfx.c \
-	xvml.c
+	xvml.c xvwebp.c
 
 OBJS1 =	xv.o xvevent.o xvroot.o xvmisc.o xvimage.o xvcolor.o xvsmooth.o \
 	xv24to8.o xvgif.o xvpm.o xvinfo.o xvctrl.o xvscrl.o xvalg.o \
@@ -176,7 +244,7 @@ OBJS1 =	xv.o xvevent.o xvroot.o xvmisc.o
 	xvbrowse.o xvtext.o xvpcx.o xviff.o xvtarga.o xvxpm.o xvcut.o \
 	xvxwd.o xvfits.o xvpng.o xvzx.o xvwbmp.o xvpcd.o \
 	xvmag.o xvpic.o xvmaki.o xvpi.o xvpic2.o xvvd.o xvmgcsfx.o \
-	xvml.o
+	xvml.o xvwebp.o
 
 SRCS2=	bggen.c
 OBJS2=	bggen.o
