git: e9a96e3df82a - main - math/plplot: switch to Qhull8

From: Thierry Thomas <thierry_at_FreeBSD.org>
Date: Fri, 18 Feb 2022 18:45:04 UTC
The branch main has been updated by thierry:

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

commit e9a96e3df82a6ecbac23785af719fb46cd37e771
Author:     Thierry Thomas <thierry@FreeBSD.org>
AuthorDate: 2022-02-18 18:31:24 +0000
Commit:     Thierry Thomas <thierry@FreeBSD.org>
CommitDate: 2022-02-18 18:44:54 +0000

    math/plplot: switch to Qhull8
    
    Patch borrowed from
    https://sourceforge.net/p/plplot/plplot/ci/52479b8830ee02900b41fe3ec947aed6b1841a48/
    
    PR:             261280
---
 math/plplot/Makefile                               |  14 +--
 .../files/patch-bindings_ocaml_CMakeLists.txt      |  48 +++++++++
 .../files/patch-cmake_modules_FindQHULL.cmake      |  48 +++++++++
 math/plplot/files/patch-cmake_modules_csiro.cmake  | 119 +++++++++++++++++++++
 math/plplot/files/patch-doc__docbook__src__tcl.xml |   6 +-
 .../files/patch-examples__python__CMakeLists.txt   |   4 +-
 ...plplot__configure.cmake__installed__examples.in |  19 ++++
 math/plplot/files/patch-lib_nn_CMakeLists.txt      |  30 ++++++
 math/plplot/files/patch-lib_nn_delaunay.c          |  53 +++++++++
 math/plplot/files/patch-plplotConfig.cmake         |  23 ++++
 math/plplot/files/patch-src_plgridd.c              |  11 ++
 math/plplot/pkg-plist                              |  16 +--
 12 files changed, 372 insertions(+), 19 deletions(-)

diff --git a/math/plplot/Makefile b/math/plplot/Makefile
index 2a6bd20bb17b..c34fd5938c2f 100644
--- a/math/plplot/Makefile
+++ b/math/plplot/Makefile
@@ -2,7 +2,7 @@
 
 PORTNAME=	plplot
 DISTVERSION=	5.15.0
-PORTREVISION=	4
+PORTREVISION=	5
 CATEGORIES=	math science
 MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}/${PORTVERSION}%20Source
 
@@ -16,6 +16,7 @@ BUILD_DEPENDS=	bash:shells/bash \
 LIB_DEPENDS=	libLASi.so:devel/lasi \
 		libfontconfig.so:x11-fonts/fontconfig \
 		libfreetype.so:print/freetype2 \
+		libharfbuzz.so:print/harfbuzz \
 		libltdl.so:devel/libltdl
 RUN_DEPENDS=	bash:shells/bash \
 		${FREEFONT_DIR}/FreeMono.ttf:x11-fonts/freefont-ttf
@@ -58,8 +59,8 @@ PLIST_SUB=	PLPLOT_VERSION=${PORTVERSION}
 
 FREEFONT_DIR=	${LOCALBASE}/share/fonts/freefont-ttf
 
-OPTIONS_DEFINE=		DOCS FORTRAN GD LUA QHULL2015 QT5 TCLTK THREADS WXGTK X11
-OPTIONS_DEFAULT=	QHULL2015 THREADS WXGTK X11
+OPTIONS_DEFINE=		DOCS FORTRAN GD LUA QHULL2020 QT5 TCLTK THREADS WXGTK X11
+OPTIONS_DEFAULT=	QHULL2020 THREADS WXGTK X11
 OPTIONS_SUB=		yes
 
 FORTRAN_USES=		fortran
@@ -76,9 +77,10 @@ LUA_BUILD_DEPENDS=	swig:devel/swig
 LUA_CMAKE_BOOL=		ENABLE_lua
 LUA_CMAKE_ON=		-DLUA_EXECUTABLE:FILEPATH="${LUA_CMD}"
 
-QHULL2015_DESC=		Latest Qhull support
-QHULL2015_LIB_DEPENDS=	libqhull.so.7:math/qhull
-QHULL2015_CMAKE_ON=	-DQHULL_INCLUDE_DIRS:PATH="${LOCALBASE}/include/libqhull"
+QHULL2020_DESC=		Latest Qhull support
+QHULL2020_LIB_DEPENDS=	libqhull_r.so:math/qhull8
+QHULL2020_CMAKE_BOOL=	PL_HAVE_QHULL HAS_LIBQHULL_INCLUDE
+QHULL2020_CMAKE_ON=	-DQHULL_RPATH=:FILEPATH="${LOCALBASE}/lib/libqhull_r.so"
 
 TCLTK_LIB_DEPENDS=	libitk.so:x11-toolkits/itk
 TCLTK_RUN_DEPENDS=	iwidgets>0:x11-toolkits/iwidgets
diff --git a/math/plplot/files/patch-bindings_ocaml_CMakeLists.txt b/math/plplot/files/patch-bindings_ocaml_CMakeLists.txt
new file mode 100644
index 000000000000..1e6cb8c502b4
--- /dev/null
+++ b/math/plplot/files/patch-bindings_ocaml_CMakeLists.txt
@@ -0,0 +1,48 @@
+--- bindings/ocaml/CMakeLists.txt.orig	2019-06-01 23:24:33 UTC
++++ bindings/ocaml/CMakeLists.txt
+@@ -1,11 +1,11 @@
+ # -*- mode: cmake -*-
+ # bindings/ocaml/CMakeLists.txt
+ #
++# Copyright (C) 2008-2011 Andrew Ross
++# Copyright (C) 2008-2021 Alan W. Irwin
++# Copyright (C) 2009-2013 Hezekiah M. Carty
++# Patch borrowed from https://sourceforge.net/p/plplot/plplot/ci/52479b8830ee02900b41fe3ec947aed6b1841a48/
+ #
+-# Copyright (C) 2008 Andrew Ross
+-# Copyright (C) 2009 Hezekiah M. Carty
+-# Copyright (C) 2009-2018 Alan W. Irwin
+-#
+ # This file is part of PLplot.
+ #
+ # PLplot is free software; you can redistribute it and/or modify
+@@ -142,9 +142,9 @@ if(ENABLE_ocaml)
+       list(APPEND ocaml_LIBRARIES_FLAGS ${LIBRARY_LIST})
+     endforeach(library in LISTS library_LIST)
+ 
+-    # Get rid of internal symbolic targets and symbolic Qt5 targets from the list
++    # Get rid of internal, Threads, Qt5, and Qhull symbolic targets from the list.
+     #message(STATUS "DEBUG: (original) ocaml_LIBRARIES_FLAGS = ${ocaml_LIBRARIES_FLAGS}")
+-    list(FILTER ocaml_LIBRARIES_FLAGS EXCLUDE REGEX "^PLPLOT::csirocsa$|^PLPLOT::csironn$|^PLPLOT::nistcd$|^PLPLOT::qsastime$|^Qt5::")
++    list(FILTER ocaml_LIBRARIES_FLAGS EXCLUDE REGEX "^PLPLOT::csirocsa$|^PLPLOT::csironn$|^PLPLOT::nistcd$|^PLPLOT::qsastime$|^Threads::Threads$|^Qt5::|Qhull::")
+     #message(STATUS "DEBUG: (filtered) ocaml_LIBRARIES_FLAGS = ${ocaml_LIBRARIES_FLAGS}")
+ 
+     # Add C++ libraries in case there is at least one C++ device
+@@ -159,6 +159,17 @@ if(ENABLE_ocaml)
+       list(APPEND ocaml_LIBRARIES_FLAGS ${pc_qt_LIBRARIES_LIST})
+       #message(STATUS "DEBUG: (Qt5 added) ocaml_LIBRARIES_FLAGS = ${ocaml_LIBRARIES_FLAGS}")
+     endif(PLPLOT_USE_QT5)
++
++    # Add back actual qhull_r library to replace the symbolic
++    # form of Qhull library that was removed above.
++    if(PL_HAVE_QHULL)
++      list(APPEND ocaml_LIBRARIES_FLAGS )
++      if(QHULL_RPATH)
++	list(APPEND ocaml_LIBRARIES_FLAGS -L${QHULL_RPATH} -lqhull_r)
++      else(QHULL_RPATH)
++	list(APPEND ocaml_LIBRARIES_FLAGS -lqhull_r)
++      endif(QHULL_RPATH)
++    endif(PL_HAVE_QHULL)
+ 
+     # There is a long-standing bug for cmake where the regexp "^[^-]"
+     # acts the same as "[^-]", i.e., the starting anchor is ignored.
diff --git a/math/plplot/files/patch-cmake_modules_FindQHULL.cmake b/math/plplot/files/patch-cmake_modules_FindQHULL.cmake
new file mode 100644
index 000000000000..8368a477263f
--- /dev/null
+++ b/math/plplot/files/patch-cmake_modules_FindQHULL.cmake
@@ -0,0 +1,48 @@
+--- cmake/modules/FindQHULL.cmake.orig	2019-06-01 23:24:33 UTC
++++ cmake/modules/FindQHULL.cmake
+@@ -1,44 +1 @@
+-# Find qhull header and library.
+-#
+-
+-# This module defines the following uncached variables:
+-#  QHULL_FOUND, if false, do not try to use qhull.
+-#  QHULL_INCLUDE_DIRS, where to find libqhull/qhull_a.h OR qhull/qhull_a.h.
+-#  HAS_LIBQHULL_INCLUDE
+-#    if true use the libqhull/qhull_a.h form of header,
+-#    if false use the qhull/qhull_a.h form of header.
+-#  QHULL_LIBRARIES, the libraries to link against to use the qhull library
+-#  QHULL_LIBRARY_DIRS, the directory where the qhull library is found.
+-
+-include(FindPackageHandleStandardArgs)
+-
+-# Look preferentially for the libqhull form of header directory since
+-# that is what is supplied by upstream qhull, and if the user is
+-# finding a local install of the upstream library below, he wants to
+-# access that same upstream version of the headers to be consistent.
+-find_file(QHULL_HEADER_FILE NAMES libqhull/qhull_a.h qhull/qhull_a.h)
+-if(QHULL_HEADER_FILE)
+-  # message(STATUS "QHULL_HEADER_FILE = ${QHULL_HEADER_FILE}")
+-  if(QHULL_HEADER_FILE MATCHES "libqhull")
+-    set(HAS_LIBQHULL_INCLUDE ON)
+-  else(QHULL_HEADER_FILE MATCHES "libqhull")
+-    set(HAS_LIBQHULL_INCLUDE OFF)
+-  endif(QHULL_HEADER_FILE MATCHES "libqhull")
+-  # Determine grandparent directory of header file
+-  get_filename_component(QHULL_INCLUDE_DIRS ${QHULL_HEADER_FILE} DIRECTORY)
+-  get_filename_component(QHULL_INCLUDE_DIRS ${QHULL_INCLUDE_DIRS} DIRECTORY)
+-elseif(NOT QHULL_HEADER_FILE AND NOT QHULL_FIND_QUIETLY)
+-  message(STATUS "Neither qhull/qhull_a.h header nor libqhull/qhull_a.h could be found")
+-endif(QHULL_HEADER_FILE)
+-
+-find_library(QHULL_LIBRARY qhull)
+-if( QHULL_LIBRARY )
+-  get_filename_component(QHULL_LIBRARY_DIRS ${QHULL_LIBRARY} DIRECTORY)
+-  set(QHULL_LIBRARIES ${QHULL_LIBRARY})
+-elseif(NOT QHULL_LIBRARY AND NOT QHULL_FIND_QUIETLY)
+-  message(STATUS "qhull library could not be found")
+-endif(QHULL_LIBRARY)
+-
+-find_package_handle_standard_args(QHULL
+-  REQUIRED_VARS QHULL_INCLUDE_DIRS QHULL_LIBRARIES QHULL_LIBRARY_DIRS
+-  )
++# Removed (See https://sourceforge.net/p/plplot/plplot/ci/52479b8830ee02900b41fe3ec947aed6b1841a48/)
diff --git a/math/plplot/files/patch-cmake_modules_csiro.cmake b/math/plplot/files/patch-cmake_modules_csiro.cmake
new file mode 100644
index 000000000000..d4d5fbd1bd6c
--- /dev/null
+++ b/math/plplot/files/patch-cmake_modules_csiro.cmake
@@ -0,0 +1,119 @@
+--- cmake/modules/csiro.cmake.orig	2019-06-01 23:24:33 UTC
++++ cmake/modules/csiro.cmake
+@@ -1,6 +1,7 @@
+ # cmake/modules/csiro.cmake
+ #
+-# Copyright (C) 2006-2019  Alan W. Irwin
++# Copyright (C) 2006-2021  Alan W. Irwin
++# Patch borrowed from https://sourceforge.net/p/plplot/plplot/ci/52479b8830ee02900b41fe3ec947aed6b1841a48/
+ #
+ # This file is part of PLplot.
+ #
+@@ -72,30 +73,29 @@ if(PL_HAVE_QHULL OR WITH_CSA)
+ endif(PL_HAVE_QHULL OR WITH_CSA)
+ 
+ if(PL_HAVE_QHULL)
+-  find_package(QHULL)
+-  if(QHULL_FOUND)
+-    message(STATUS "QHULL_INCLUDE_DIRS = ${QHULL_INCLUDE_DIRS}")
+-    message(STATUS "HAS_LIBQHULL_INCLUDE = ${HAS_LIBQHULL_INCLUDE}")
+-    message(STATUS "QHULL_LIBRARIES = ${QHULL_LIBRARIES}")
+-    set(QHULL_RPATH ${QHULL_LIBRARY_DIRS})
++  find_package(Qhull CONFIG)
++  if(Qhull_FOUND)
++
++    # Determine QHULL_RPATH, the location of the qhull_r library.
++    get_target_property(QHULL_RPATH Qhull::qhull_r LOCATION)
++    # Transform from full pathname to path where qhull_r is located.
++    get_filename_component(QHULL_RPATH ${QHULL_RPATH} DIRECTORY)
++    message(STATUS "DEBUG: QHULL_RPATH = ${QHULL_RPATH}")
++    # Filter it to exclude system location, i.e., only need
++    # QHULL_RPATH for the case when qhull installed in a non-standard
++    # location.
+     filter_rpath(QHULL_RPATH)
+-    message(STATUS "QHULL_RPATH = ${QHULL_RPATH}")
++    message(STATUS "DEBUG: QHULL_RPATH = ${QHULL_RPATH}")
++
+     include(CheckFunctionExists)
+     cmake_push_check_state()
+-    list(APPEND CMAKE_REQUIRED_LIBRARIES ${QHULL_LIBRARIES})
++    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${QHULL_RPATH} -lqhull_r")
+     check_function_exists(qh_new_qhull QH_NEW_EXIST)
+     cmake_pop_check_state()
+-    if(NOT QH_NEW_EXIST)
+-      message(STATUS "WARNING: function qh_new_qhull not found.  Setting PL_HAVE_QHULL to OFF.")
+-      set(PL_HAVE_QHULL OFF CACHE BOOL "Enable use of the Qhull library" FORCE)
+-    endif(NOT QH_NEW_EXIST)
+-    if(HAS_LIBQHULL_INCLUDE)
+-      file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Check_realT_size.c "#include <libqhull/qhull_a.h>")
+-    else(HAS_LIBQHULL_INCLUDE)
+-      file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Check_realT_size.c "#include <qhull/qhull_a.h>")
+-    endif(HAS_LIBQHULL_INCLUDE)
+-    file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/Check_realT_size.c
+-      "
++    if(QH_NEW_EXIST)
++      file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Check_realT_size.c "#include <libqhull_r/qhull_ra.h>")
++      file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/Check_realT_size.c
++	"
+ int main(void)
+ {
+   if ( sizeof ( realT ) != sizeof ( double ) )
+@@ -104,33 +104,34 @@ int main(void)
+     return 0;
+ }
+ "
+-      )
+-    try_run(RUN_RESULT COMPILE_RESULT
+-      ${CMAKE_CURRENT_BINARY_DIR}
+-      ${CMAKE_CURRENT_BINARY_DIR}/Check_realT_size.c
+-      CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=-I\"${QHULL_INCLUDE_DIRS}\""
+-      OUTPUT_VARIABLE OUTPUT
+-      )
+-    #message(STATUS "Check_realT_size COMPILE_RESULT = ${COMPILE_RESULT}")
+-    #message(STATUS "Check_realT_size RUN_RESULT = ${RUN_RESULT}")
+-    if(NOT COMPILE_RESULT OR RUN_RESULT MATCHES "FAILED_TO_RUN")
+-      message(STATUS "Either could not compile or could not run code to check wrong size for realT in qhull library.  Dropping qhull librarydependency of PLplot.")
+-      set(PL_HAVE_QHULL OFF CACHE BOOL "Enable use of the Qhull library" FORCE)
+-    endif(NOT COMPILE_RESULT OR RUN_RESULT MATCHES "FAILED_TO_RUN")
++	)
++      try_run(RUN_RESULT COMPILE_RESULT
++	${CMAKE_CURRENT_BINARY_DIR}
++	${CMAKE_CURRENT_BINARY_DIR}/Check_realT_size.c
++	OUTPUT_VARIABLE OUTPUT
++	)
++      #message(STATUS "Check_realT_size COMPILE_RESULT = ${COMPILE_RESULT}")
++      #message(STATUS "Check_realT_size RUN_RESULT = ${RUN_RESULT}")
++      if(NOT COMPILE_RESULT OR RUN_RESULT MATCHES "FAILED_TO_RUN")
++	message(STATUS "Either could not compile or could not run code to check wrong size for realT in qhull library.  Dropping qhull librarydependency of PLplot.")
++	set(PL_HAVE_QHULL OFF CACHE BOOL "Enable use of the Qhull library" FORCE)
++      endif(NOT COMPILE_RESULT OR RUN_RESULT MATCHES "FAILED_TO_RUN")
+ 
+-    if(RUN_RESULT)
+-      message(STATUS "qhull library compiled with incorrect (non-double) size for realT.  Dropping qhull dependency of PLplot.")
++      if(RUN_RESULT)
++	message(STATUS "qhull library compiled with incorrect (non-double) size for realT.  Dropping qhull dependency of PLplot.")
++	set(PL_HAVE_QHULL OFF CACHE BOOL "Enable use of the Qhull library" FORCE)
++      else(RUN_RESULT)
++	message(STATUS "qhull library compiled with correct (double) size for realT.")
++      endif(RUN_RESULT)
++    else(QH_NEW_EXIST)
++      message(STATUS "WARNING: function qh_new_qhull not found.  Setting PL_HAVE_QHULL to OFF.")
+       set(PL_HAVE_QHULL OFF CACHE BOOL "Enable use of the Qhull library" FORCE)
+-    else(RUN_RESULT)
+-      message(STATUS "qhull library compiled with correct (double) size for realT.")
+-    endif(RUN_RESULT)
++    endif(QH_NEW_EXIST)
+ 
+-  else(QHULL_FOUND)
+-    message(STATUS "QHULL_INCLUDE_DIRS = ${QHULL_INCLUDE_DIRS}")
+-    message(STATUS "QHULL_LIBRARIES = ${QHULL_LIBRARIES}")
++  else(Qhull_FOUND)
+     message(STATUS
+-      "WARNING: at least one of QHULL_INCLUDE_DIRS or QHULL_LIBRARIES is false so setting PL_HAVE_QHULL to OFF."
+-      )
++      "WARNING: Qhull package not found in CONFIG mode.  The required CONFIG mode files only available for later releases of qhull so perhaps you need to update your qhull version?")
++    message(STATUS "setting PL_HAVE_QHULL to OFF.")
+     set(PL_HAVE_QHULL OFF CACHE BOOL "Enable use of the Qhull library" FORCE)
+-  endif(QHULL_FOUND)
++  endif(Qhull_FOUND)
+ endif(PL_HAVE_QHULL)
diff --git a/math/plplot/files/patch-doc__docbook__src__tcl.xml b/math/plplot/files/patch-doc__docbook__src__tcl.xml
index de06f7a87e2d..19556084c013 100644
--- a/math/plplot/files/patch-doc__docbook__src__tcl.xml
+++ b/math/plplot/files/patch-doc__docbook__src__tcl.xml
@@ -1,6 +1,6 @@
---- doc/docbook/src/tcl.xml.orig	2015-04-12 10:08:04 UTC
+--- doc/docbook/src/tcl.xml.orig	2019-06-01 23:24:33 UTC
 +++ doc/docbook/src/tcl.xml
-@@ -576,7 +576,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SU
+@@ -755,7 +755,7 @@ Combination of previously defined matrices, deep lists
  	if (pm->fdata[i] > max)
  	max = pm->fdata[i];
  
@@ -9,7 +9,7 @@
  	return TCL_OK;
  	}
  
-@@ -589,7 +589,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SU
+@@ -768,7 +768,7 @@ Combination of previously defined matrices, deep lists
  	if (pm->fdata[i] &lt; min)
  	min = pm->fdata[i];
  
diff --git a/math/plplot/files/patch-examples__python__CMakeLists.txt b/math/plplot/files/patch-examples__python__CMakeLists.txt
index 188b64b29d05..0df6f736603a 100644
--- a/math/plplot/files/patch-examples__python__CMakeLists.txt
+++ b/math/plplot/files/patch-examples__python__CMakeLists.txt
@@ -1,6 +1,6 @@
---- examples/python/CMakeLists.txt.orig	2015-04-12 10:08:04 UTC
+--- examples/python/CMakeLists.txt.orig	2022-01-14 18:34:58 UTC
 +++ examples/python/CMakeLists.txt
-@@ -245,7 +245,7 @@ if(CORE_BUILD)
+@@ -222,7 +222,7 @@ if(CORE_BUILD)
      @ONLY
      )
  
diff --git a/math/plplot/files/patch-examples_plplot__configure.cmake__installed__examples.in b/math/plplot/files/patch-examples_plplot__configure.cmake__installed__examples.in
new file mode 100644
index 000000000000..72ced00bfc2d
--- /dev/null
+++ b/math/plplot/files/patch-examples_plplot__configure.cmake__installed__examples.in
@@ -0,0 +1,19 @@
+--- examples/plplot_configure.cmake_installed_examples.in.orig	2019-06-01 23:24:33 UTC
++++ examples/plplot_configure.cmake_installed_examples.in
+@@ -1,6 +1,7 @@
+ # -*- mode: cmake -*-
+ # This file used to configure CMake variables that are used to build the
+ # installed examples.
++# Patch borrowed from https://sourceforge.net/p/plplot/plplot/ci/52479b8830ee02900b41fe3ec947aed6b1841a48/
+ # Identify that this is the build system for the installed examples.
+ set(BUILD_TEST ON)
+ set(CORE_BUILD OFF)
+@@ -172,6 +173,8 @@ if(ENABLE_qt)
+   endif(PLPLOT_USE_QT5)
+   set(PLPLOT_AUTOMOC_MOC_OPTIONS @PLPLOT_AUTOMOC_MOC_OPTIONS@)
+ endif(ENABLE_qt)
++
++set(PL_HAVE_QHULL @PL_HAVE_QHULL@)
+ 
+ set(ENABLE_DYNDRIVERS @ENABLE_DYNDRIVERS@)
+ 
diff --git a/math/plplot/files/patch-lib_nn_CMakeLists.txt b/math/plplot/files/patch-lib_nn_CMakeLists.txt
new file mode 100644
index 000000000000..9d66ec28501e
--- /dev/null
+++ b/math/plplot/files/patch-lib_nn_CMakeLists.txt
@@ -0,0 +1,30 @@
+--- lib/nn/CMakeLists.txt.orig	2019-06-01 23:24:33 UTC
++++ lib/nn/CMakeLists.txt
+@@ -1,5 +1,6 @@
+ # lib/nn/CMakeLists.txt for PLplot
+ # Copyright (C) 2006-2019 Alan W. Irwin
++# Patch borrowed from https://sourceforge.net/p/plplot/plplot/ci/52479b8830ee02900b41fe3ec947aed6b1841a48/
+ #
+ # This file is part of PLplot.
+ #
+@@ -48,19 +49,8 @@ if(PL_HAVE_QHULL)
+       )
+   endif(HAS_LIBQHULL_INCLUDE)
+ 
+-  set_source_files_properties(
+-    ${csironn_LIB_SRCS}
+-    PROPERTIES
+-    COMPILE_FLAGS "-I${QHULL_INCLUDE_DIRS}"
+-    )
+-
+-  set(csironn_LINK_LIBRARIES ${QHULL_LIBRARIES})
+-  if(MATH_LIB)
+-    list(APPEND csironn_LINK_LIBRARIES ${MATH_LIB})
+-  endif(MATH_LIB)
+-
+   set(LIB_INSTALL_RPATH ${QHULL_RPATH})
+-  configure_library_build(csironn "" "${csironn_LIB_SRCS}" "${csironn_LINK_LIBRARIES}" "${QHULL_RPATH}")
++  configure_library_build(csironn "" "${csironn_LIB_SRCS}" Qhull::qhull_r "${QHULL_RPATH}")
+ 
+   set(nn_DOCFILES
+     README
diff --git a/math/plplot/files/patch-lib_nn_delaunay.c b/math/plplot/files/patch-lib_nn_delaunay.c
new file mode 100644
index 000000000000..85d1a502aedb
--- /dev/null
+++ b/math/plplot/files/patch-lib_nn_delaunay.c
@@ -0,0 +1,53 @@
+--- lib/nn/delaunay.c.orig	2019-06-01 23:24:33 UTC
++++ lib/nn/delaunay.c
+@@ -35,7 +35,7 @@
+ #include <float.h>
+ #ifdef USE_QHULL
+ #ifdef HAS_LIBQHULL_INCLUDE
+-#include <libqhull/qhull_a.h>
++#include <libqhull_r/qhull_ra.h>
+ #else
+ #include <qhull/qhull_a.h>
+ #endif
+@@ -388,7 +388,9 @@ delaunay* delaunay_build( int np, point points[], int 
+     // climax
+     //
+ 
+-    exitcode = qh_new_qhull( dim, np, qpoints, ismalloc,
++    qhT context = { 0 };
++    qhT *qh = &context;
++    exitcode = qh_new_qhull(qh, dim, np, qpoints, ismalloc,
+         flags, outfile, errfile );
+ 
+     if ( !exitcode )
+@@ -433,8 +435,8 @@ delaunay* delaunay_build( int np, point points[], int 
+             }
+         }
+ 
+-        qh_findgood_all( qh facet_list );
+-        qh_countfacets( qh facet_list, NULL, !qh_ALL, &numfacets,
++        qh_findgood_all (qh, qh->facet_list);
++        qh_countfacets(qh, qh->facet_list, NULL, !qh_ALL, &numfacets,
+             &numsimplicial, &totneighbors, &numridges,
+             &numcoplanars, &numtricoplanars );
+ 
+@@ -462,7 +464,7 @@ delaunay* delaunay_build( int np, point points[], int 
+ 
+                 j = 0;
+                 FOREACHvertex_( facet->vertices )
+-                t->vids[j++] = qh_pointid( vertex->point );
++                t->vids[j++] = qh_pointid(qh, vertex->point );
+ 
+                 j = 0;
+                 FOREACHneighbor_( facet )
+@@ -548,8 +550,8 @@ delaunay* delaunay_build( int np, point points[], int 
+     }
+ 
+     free( qpoints );
+-    qh_freeqhull( !qh_ALL );               // free long memory
+-    qh_memfreeshort( &curlong, &totlong ); // free short memory and memory allocator
++    qh_freeqhull(qh, !qh_ALL );               // free long memory
++    qh_memfreeshort(qh, &curlong, &totlong ); // free short memory and memory allocator
+     if ( curlong || totlong )
+         fprintf( errfile,
+             "qhull: did not free %d bytes of long memory (%d pieces)\n",
diff --git a/math/plplot/files/patch-plplotConfig.cmake b/math/plplot/files/patch-plplotConfig.cmake
new file mode 100644
index 000000000000..eabf48b2570d
--- /dev/null
+++ b/math/plplot/files/patch-plplotConfig.cmake
@@ -0,0 +1,23 @@
+--- plplotConfig.cmake.orig	2019-06-01 23:24:33 UTC
++++ plplotConfig.cmake
+@@ -1,3 +1,4 @@
++# Patch borrowed from https://sourceforge.net/p/plplot/plplot/ci/52479b8830ee02900b41fe3ec947aed6b1841a48/
+ if(ANY_QT_DEVICE AND PLPLOT_USE_QT5)
+   # Find Qt5 components that we need to link applications against
+   # the plplot library (if ENABLE_DYNDRIVERS is false) and which we
+@@ -15,6 +16,15 @@ if(ANY_QT_DEVICE AND PLPLOT_USE_QT5)
+     message(STATUS "WARNING: Qt5 core build-tree and install-tree inconsistency")
+   endif(NOT(Qt5_FOUND AND Qt5_VERSION_MAJOR STREQUAL "${CORE_Qt5_VERSION_MAJOR}" AND Qt5_VERSION_MINOR STREQUAL "${CORE_Qt5_VERSION_MINOR}" AND Qt5_VERSION_PATCH STREQUAL "${CORE_Qt5_VERSION_PATCH}"))
+ endif(ANY_QT_DEVICE AND PLPLOT_USE_QT5)
++
++if(PL_HAVE_QHULL)
++  # Maintenance(2021)
++  # Find qhull the same way as done in cmake/modules/csiro.cmake
++  find_package(Qhull CONFIG)
++  if(NOT Qhull_FOUND)
++    message(STATUS "WARNING: Qhull core build-tree and install-tree inconsistency")
++  endif(NOT Qhull_FOUND)
++endif(PL_HAVE_QHULL)
+ 
+ # Find export files in same directory location as present file.
+ include(${CMAKE_CURRENT_LIST_DIR}/plplot_exports.cmake)
diff --git a/math/plplot/files/patch-src_plgridd.c b/math/plplot/files/patch-src_plgridd.c
new file mode 100644
index 000000000000..2d449bffe10f
--- /dev/null
+++ b/math/plplot/files/patch-src_plgridd.c
@@ -0,0 +1,11 @@
+--- src/plgridd.c.orig	2019-06-01 23:24:33 UTC
++++ src/plgridd.c
+@@ -33,7 +33,7 @@
+ // PLPLOT_NONN not #defined or tested for more than a decade.
+ #ifdef PLPLOT_NONN // another DTLI, based only on QHULL, not nn
+ #ifdef HAS_LIBQHULL_INCLUDE
+-#include <libqhull/qhull_a.h>
++#include <libqhull_r/qhull_ra.h>
+ #else //#ifdef HAS_LIBQHULL_INCLUDE
+ #include <qhull/qhull_a.h>
+ #endif //#ifdef HAS_LIBQHULL_INCLUDE
diff --git a/math/plplot/pkg-plist b/math/plplot/pkg-plist
index 71062f79fbe5..51b18e2f74bf 100644
--- a/math/plplot/pkg-plist
+++ b/math/plplot/pkg-plist
@@ -6,8 +6,8 @@ include/plplot/csa.h
 include/plplot/csadll.h
 include/plplot/disptab.h
 include/plplot/drivers.h
-%%QHULL2015%%include/plplot/nn.h
-%%QHULL2015%%include/plplot/nndll.h
+%%QHULL2020%%include/plplot/nn.h
+%%QHULL2020%%include/plplot/nndll.h
 include/plplot/pdf.h
 include/plplot/plConfig.h
 include/plplot/plDevs.h
@@ -34,8 +34,8 @@ lib/cmake/plplot/export_cairo-release.cmake
 lib/cmake/plplot/export_cairo.cmake
 lib/cmake/plplot/export_csirocsa-release.cmake
 lib/cmake/plplot/export_csirocsa.cmake
-%%QHULL2015%%lib/cmake/plplot/export_csironn-release.cmake
-%%QHULL2015%%lib/cmake/plplot/export_csironn.cmake
+%%QHULL2020%%lib/cmake/plplot/export_csironn-release.cmake
+%%QHULL2020%%lib/cmake/plplot/export_csironn.cmake
 %%GD%%lib/cmake/plplot/export_gd-release.cmake
 %%GD%%lib/cmake/plplot/export_gd.cmake
 lib/cmake/plplot/export_mem-release.cmake
@@ -107,9 +107,9 @@ lib/cmake/plplot/plplot_exports.cmake
 lib/libcsirocsa.so
 lib/libcsirocsa.so.0
 lib/libcsirocsa.so.0.0.1
-%%QHULL2015%%lib/libcsironn.so
-%%QHULL2015%%lib/libcsironn.so.0
-%%QHULL2015%%lib/libcsironn.so.0.0.2
+%%QHULL2020%%lib/libcsironn.so
+%%QHULL2020%%lib/libcsironn.so.0
+%%QHULL2020%%lib/libcsironn.so.0.0.2
 %%FORTRAN%%lib/libplfortrandemolib.a
 lib/libplplot.so
 lib/libplplot.so.17
@@ -186,7 +186,7 @@ libdata/pkgconfig/plplot.pc
 %%PORTDOCS%%%%DOCSDIR%%/README.csa
 %%PORTDOCS%%%%DOCSDIR%%/README.cumulated_release
 %%PORTDOCS%%%%DOCSDIR%%/README.drivers
-%%QHULL2015%%%%PORTDOCS%%%%DOCSDIR%%/README.nn
+%%QHULL2020%%%%PORTDOCS%%%%DOCSDIR%%/README.nn
 %%PORTDOCS%%%%DOCSDIR%%/README.pkg-config
 %%PORTDOCS%%%%DOCSDIR%%/README.release
 %%PORTDOCS%%%%DOCSDIR%%/README.wxwidgets