diff -Nurd grads-2.2.1.orig/configure.ac grads-2.2.1/configure.ac
--- grads-2.2.1.orig/configure.ac	2018-04-24 17:22:23.000000000 -0400
+++ grads-2.2.1/configure.ac	2021-12-16 01:23:11.000000000 -0500
@@ -413,12 +413,12 @@
 if test "Z$ga_supplib_dir" != "Z" ; then 
   echo looking in $ga_supplib_dir for additional dependent libs
 
-  # png15
+  # png16
   echo 
   echo png
   echo ---
   GA_SET_FLAGS([])
-  AC_CHECK_LIB([png15], [main], [have_png=yes])
+  AC_CHECK_LIB([png16], [main], [have_png=yes])
   GA_UNSET_FLAGS
 
   # zlib
@@ -525,8 +525,8 @@
     AC_CHECK_HEADER(grib2.h,
     [ AC_CHECK_LIB([grib2c], [main], 
       [ use_grib2=yes 
-#        GA_SET_LIB_VAR([grib2_libs], [grib2c jasper png15 z])
-        GA_SET_DYNLIB_VAR([grib2_libs], [grib2c jasper png15 z])
+#        GA_SET_LIB_VAR([grib2_libs], [grib2c jasper png16 z])
+        GA_SET_DYNLIB_VAR([grib2_libs], [grib2c jasper png16 z])
       ])
     ])
     GA_UNSET_FLAGS
@@ -557,7 +557,7 @@
   if test "$have_xml2" = "yes" -a  "$have_zlib" = "yes" -a "$have_png" = "yes" ; then
     echo looking in $ga_supplib_dir 
     # check for required header files 
-    GA_SET_FLAGS([cairo freetype2])
+    GA_SET_FLAGS([cairo freetype2], [-I/opt/X11/include], [-L/opt/X11/lib])
     AC_CHECK_HEADER(cairo.h,
     [ AC_CHECK_HEADER(cairo-xlib.h,
     [ AC_CHECK_HEADER(ft2build.h,
@@ -569,8 +569,8 @@
         [ use_cairo="yes"
           have_cairo="yes"
           GA_SET_INCLUDE_VAR([cairo_inc], [cairo freetype2])
-#          GA_SET_LIB_VAR(cairo_libs, [cairo Xrender fontconfig freetype pixman-1 png15 xml2 z])
-          GA_SET_DYNLIB_VAR(cairo_libs, [cairo])
+#          GA_SET_LIB_VAR(cairo_libs, [cairo Xrender fontconfig freetype png16 xml2 z])
+          GA_SET_DYNLIB_VAR(cairo_libs, [cairo freetype])
         ])
       ])
       ])
@@ -649,7 +649,7 @@
   echo looking in $ga_supplib_dir 
   GA_SET_FLAGS([])
   AC_CHECK_HEADER([udunits.h], 
-  [ AC_CHECK_LIB([udunits], [utInit], 
+  [ AC_CHECK_LIB([udunits2], [utInit], 
     [ have_udunits=yes 
     ])
   ])
@@ -678,8 +678,8 @@
     [ AC_CHECK_LIB([df], [main], 
       [ AC_CHECK_LIB([mfhdf], [main],
         [ use_hdf=yes 
-#          GA_SET_LIB_VAR([hdf_libs], [mfhdf df jpeg z udunits])
-          GA_SET_DYNLIB_VAR([hdf_libs], [mfhdf df jpeg z udunits])
+#          GA_SET_LIB_VAR([hdf_libs], [mfhdf df jpeg z udunits2])
+          GA_SET_DYNLIB_VAR([hdf_libs], [mfhdf df jpeg z udunits2])
         ])
       ])
     ])
@@ -711,7 +711,6 @@
 echo ------
 # JMA We could support netcdf (without sdf/xdfopen) if udunits is unavailable.
 # JMA For now, the "#ifdef USENETCDF" code block requires udunits, so we put that test at the top.
-if test "$have_udunits" = "yes" ; then
   if test "Z$ga_supplib_dir" != "Z" ; then
     echo looking in $ga_supplib_dir 
     GA_SET_FLAGS([])
@@ -722,16 +721,16 @@
         NC_CONFIG=${ga_supplib_dir}/bin/nc-config
 	if test ! -f "$NC_CONFIG" || test ! -x "$NC_CONFIG"; then
           use_nc4="no"
-#          GA_SET_LIB_VAR(nc_libs, [udunits netcdf])
-          GA_SET_DYNLIB_VAR(nc_libs, [udunits netcdf])
+#          GA_SET_LIB_VAR(nc_libs, [udunits2 netcdf])
+          GA_SET_DYNLIB_VAR(nc_libs, [udunits2 netcdf])
         else
           # check if netcdf lib has hdf5 and if dap-enabled
           nchdf5=`$NC_CONFIG --has-hdf5`
           use_dap=`$NC_CONFIG --has-dap`
           if test "$nchdf5" = "yes" -a "$have_curl" = "yes" ; then
             use_nc4="yes"
-#            GA_SET_LIB_VAR(nc_libs, [udunits netcdf hdf5_hl hdf5 curl z])
-            GA_SET_DYNLIB_VAR(nc_libs, [udunits netcdf hdf5_hl hdf5 curl z])
+#            GA_SET_LIB_VAR(nc_libs, [udunits2 netcdf hdf5_hl hdf5 curl z])
+            GA_SET_DYNLIB_VAR(nc_libs, [udunits2 netcdf hdf5_hl hdf5 curl z])
           fi
         fi
       ])
@@ -756,7 +755,6 @@
     fi
   fi
 
-fi
 # set output variables
 if test $use_nc != "yes" ; then
   AC_DEFINE(USENETCDF, 0, [Enable netcdf])
diff -Nurd grads-2.2.1.orig/m4/cairo.m4 grads-2.2.1/m4/cairo.m4
--- grads-2.2.1.orig/m4/cairo.m4	1969-12-31 19:00:00.000000000 -0500
+++ grads-2.2.1/m4/cairo.m4	2021-12-16 01:04:18.000000000 -0500
@@ -0,0 +1,18 @@
+# Autoconf check that uses pkg-config to look for Cairo Graphics Library.
+# Usage:
+#   GA_CHECK_LIB_CAIRO(action-if-found, action-if-not-found)
+
+AC_DEFUN([GA_CHECK_LIB_CAIRO],
+[
+
+  cairo_pkgconfig=no
+  PKG_CHECK_MODULES([CAIRO],[cairo],[cairo_pkgconfig=yes])
+
+  if test $cairo_pkgconfig = 'yes'; then
+     m4_if([$1], [], [:], [$1])
+  else
+     m4_if([$2], [], [:], [$2])
+  fi
+
+])
+
diff -Nurd grads-2.2.1.orig/m4/gadap.m4 grads-2.2.1/m4/gadap.m4
--- grads-2.2.1.orig/m4/gadap.m4	1969-12-31 19:00:00.000000000 -0500
+++ grads-2.2.1/m4/gadap.m4	2021-12-16 01:04:18.000000000 -0500
@@ -0,0 +1,20 @@
+dnl GA_CHECK_LIB_SHP : Checks whether GrADS can be built with shapefile interface
+dnl  args : 		action-if-yes, action-if-no
+AC_DEFUN([GA_CHECK_LIB_GADAP],
+[
+  ga_check_gadap="no"
+  AC_CHECK_HEADER(gadap.h,
+  [ AC_CHECK_LIB(gadap, main, [
+      ga_check_gadap="yes"
+      GADAP_LIBS="-lgadap"
+    ])
+  ])
+  if test $ga_check_gadap = "yes" ; then
+     m4_if([$1], [], [:], [$1])
+  else
+     m4_if([$2], [], [:], [$2])
+  fi
+
+  AC_SUBST([GADAP_LIBS])
+])
+
diff -Nurd grads-2.2.1.orig/m4/shapelib.m4 grads-2.2.1/m4/shapelib.m4
--- grads-2.2.1.orig/m4/shapelib.m4	1969-12-31 19:00:00.000000000 -0500
+++ grads-2.2.1/m4/shapelib.m4	2021-12-16 01:04:18.000000000 -0500
@@ -0,0 +1,19 @@
+dnl GA_CHECK_LIB_SHP : Checks whether GrADS can be built with shapefile interface
+dnl  args : 		action-if-yes, action-if-no
+AC_DEFUN([GA_CHECK_LIB_SHP],
+[
+  ga_check_shp="no"
+  AC_CHECK_HEADER(shapefil.h,
+  [ AC_CHECK_LIB(shp, main, [
+      ga_check_shp="yes"
+      SHP_LIBS="-lshp"
+    ])
+  ])
+  if test $ga_check_shp = "yes" ; then
+     m4_if([$1], [], [:], [$1])
+  else
+     m4_if([$2], [], [:], [$2])
+  fi
+
+  AC_SUBST([SHP_LIBS])
+])
diff -Nurd grads-2.2.1.orig/src/Makefile.am grads-2.2.1/src/Makefile.am
--- grads-2.2.1.orig/src/Makefile.am	2018-04-24 12:42:58.000000000 -0400
+++ grads-2.2.1/src/Makefile.am	2021-12-16 01:17:16.000000000 -0500
@@ -84,7 +84,7 @@
 
 supp_include_dir	= $(SUPPLIBS)/include
 supp_lib_dir		= $(SUPPLIBS)/lib
-LDADD			= -L$(supp_lib_dir) $(geotiff_ldflags) $(gd_ldflags)
+LDADD			= -L$(supp_lib_dir) -L@FINK_HDF5_DIR@/lib $(geotiff_ldflags) $(gd_ldflags)
 
 common_ldadd            = $(LDADD) $(host_ldadd) 
 X11_ldadd               = $(X_LIBS) $(X_PRE_LIBS) -lX11 -lXext $(X_EXTRA_LIBS)
@@ -97,7 +97,7 @@
 ## libraries needed
 grads_LDADD	      = $(common_ldadd) $(readline_libs) $(grib2_libs) \
 			$(hdf_libs) $(hdf5_libs) $(nc_libs) $(geotiff_libs) \
-			$(shp_libs) $(gadap_libs) $(gui_libs) -ldl 
+			$(shp_libs) $(gadap_libs) $(gui_libs) -ldl -lsz
 
 # print with GD
 if USEGD
@@ -107,18 +107,18 @@
 endif
 
 # display X11 
-libgxdX11_la_CPPFLAGS = -I. -I$(SUPPLIBS)/include
+libgxdX11_la_CPPFLAGS = -I. -I$(SUPPLIBS)/include $(X_CFLAGS)
 libgxdX11_la_LIBADD = $(X11_ldadd)
 libgxdX11_la_LDFLAGS = -version-info $(LIBGX_VERSION)
  
 # print with Cairo
-libgxpCairo_la_CPPFLAGS = -I. $(cairo_inc)
+libgxpCairo_la_CPPFLAGS = -I. $(cairo_inc) -I$(SUPPLIBS)/include $(X_CFLAGS)
 #-I$(SUPPLIBS)/include -I$(SUPPLIBS)/include/cairo -I$(SUPPLIBS)/include/freetype2
 libgxpCairo_la_LIBADD = $(LDADD) $(cairo_libs)
 libgxpCairo_la_LDFLAGS = -version-info $(LIBGX_VERSION)
 
 ## display X11 with Cairo 
-libgxdCairo_la_CPPFLAGS = -I. $(cairo_inc)
+libgxdCairo_la_CPPFLAGS = -I. $(cairo_inc) -I$(SUPPLIBS)/include $(X_CFLAGS)
 #-I$(SUPPLIBS)/include -I$(SUPPLIBS)/include/cairo -I$(SUPPLIBS)/include/freetype2
 libgxdCairo_la_LIBADD = $(X11_ldadd) $(LDADD) $(cairo_libs)
 libgxdCairo_la_LDFLAGS = -version-info $(LIBGX_VERSION)
@@ -147,7 +147,7 @@
                          $(shp_inc) $(gadap_inc) $(X_CFLAGS) $(XAW_CFLAGS) 
 libgradspy_la_LIBADD   = $(common_ldadd) $(readline_libs) $(grib2_libs) \
 			 $(hdf_libs) $(hdf5_libs) $(nc_libs) $(geotiff_libs) \
-			 $(shp_libs) $(gadap_libs) $(gui_libs) 
+			 $(shp_libs) $(gadap_libs) $(gui_libs) -lsz
 libgradspy_la_LDFLAGS  = -version-info $(LIBGX_VERSION)
 
 
diff -Nurd grads-2.2.1.orig/src/grads.c grads-2.2.1/src/grads.c
--- grads-2.2.1.orig/src/grads.c	2018-03-27 15:40:44.000000000 -0400
+++ grads-2.2.1/src/grads.c	2021-12-16 01:05:13.000000000 -0500
@@ -48,7 +48,7 @@
 
 static struct gaupb *upba=NULL;     /* Anchor for user defined plug-in */
 char *gxgnam(char *);               /* This is also in gx.h */
-static struct gacmn gcmn;  
+struct gacmn gcmn;  /* follow debian's lead to make this non-static */
 static struct gawgds wgds; 
 extern struct gamfcmn mfcmn;
 
diff -Nurd grads-2.2.1.orig/src/gx.h grads-2.2.1/src/gx.h
--- grads-2.2.1.orig/src/gx.h	2018-01-30 10:23:09.000000000 -0500
+++ grads-2.2.1/src/gx.h	2021-12-16 01:04:18.000000000 -0500
@@ -20,7 +20,7 @@
 /* Default directory containing the stroke and map data sets.
    User can override this default via setenv GADDIR */
 
-/* static char *datad = "/usr/local/lib/grads"; */
+/* static char *datad = "@FINK_PREFIX@/lib/grads"; */
 
 
 /* Option flag.  If 0, map data set is only read once into a
diff -Nurd grads-2.2.1.orig/src/gxsubs.c grads-2.2.1/src/gxsubs.c
--- grads-2.2.1.orig/src/gxsubs.c	2018-03-26 11:00:58.000000000 -0400
+++ grads-2.2.1/src/gxsubs.c	2021-12-16 01:04:18.000000000 -0500
@@ -32,7 +32,7 @@
 /* The following variables are local to this file, and are used by
    all the routines in the file.    */
 
-static char *datad = "/usr/local/lib/grads";
+static char *datad = "@FINK_PREFIX@/lib/grads";
 static gadouble xsize, ysize;                /* Virtual page size  */
 static gadouble rxsize, rysize;              /* Real page size     */
 static gaint lwflg;                          /* Reduce lw due vpage*/
diff -Nurd grads-2.2.1.orig/udpt grads-2.2.1/udpt
--- grads-2.2.1.orig/udpt	1969-12-31 19:00:00.000000000 -0500
+++ grads-2.2.1/udpt	2021-12-16 01:04:18.000000000 -0500
@@ -0,0 +1,7 @@
+gxdisplay  Cairo    @FINK_PREFIX@/lib/grads/libgxdCairo.dylib
+gxdisplay  X11      @FINK_PREFIX@/lib/grads/libgxdX11.dylib
+gxdisplay  gxdummy  @FINK_PREFIX@/lib/grads/libgxdummy.dylib
+*
+gxprint    Cairo    @FINK_PREFIX@/lib/grads/libgxpCairo.dylib
+gxprint    GD       @FINK_PREFIX@/lib/grads/libgxpGD.dylib
+gxprint    gxdummy  @FINK_PREFIX@/lib/grads/libgxdummy.dylib
