--- plplot-5.13.0/CMakeLists.txt.orig	2017-08-26 10:43:25.000000000 +0800
+++ plplot-5.13.0/CMakeLists.txt	2018-07-27 15:36:03.549980000 +0800
@@ -126,6 +126,29 @@
 
 # Use configured variables to process configurable top-level files.
 
+# Installation paths
+#
+SET(BIN_INSTALL_DIR bin CACHE PATH "Where to install binaries to.")
+SET(LIB_INSTALL_DIR lib CACHE PATH "Where to install libraries to.")
+SET(INCLUDE_INSTALL_DIR include CACHE PATH "Where to install headers to.")
+
+# Set a couple variables to be substituted inside the .pc file.
+# We can't just use LIB_INSTALL_DIR in the .pc file, as passing them as absolue
+# or relative paths is both valid and supported by cmake.
+SET (PKGCONFIG_PREFIX ${CMAKE_INSTALL_PREFIX})
+
+IF(IS_ABSOLUTE ${LIB_INSTALL_DIR})
+  SET (PKGCONFIG_LIBDIR ${LIB_INSTALL_DIR})
+ELSE(IS_ABSOLUTE ${LIB_INSTALL_DIR})
+  SET (PKGCONFIG_LIBDIR "\${prefix}/${LIB_INSTALL_DIR}")
+ENDIF (IS_ABSOLUTE ${LIB_INSTALL_DIR})
+
+IF(IS_ABSOLUTE ${INCLUDE_INSTALL_DIR})
+  SET (PKGCONFIG_INCLUDEDIR ${INCLUDE_INSTALL_DIR})
+ELSE(IS_ABSOLUTE ${INCLUDE_INSTALL_DIR})
+  SET (PKGCONFIG_INCLUDEDIR "\${prefix}/${INCLUDE_INSTALL_DIR}")
+ENDIF(IS_ABSOLUTE ${INCLUDE_INSTALL_DIR})
+
 # This CMake-configured template file is processed further by sed for
 # abi-compliance-checker.
 configure_file(
--- plplot-5.13.0/pkgcfg/plplot-template.pc.in.orig	2017-08-26 10:43:25.000000000 +0800
+++ plplot-5.13.0/pkgcfg/plplot-template.pc.in	2018-07-27 15:43:39.324758100 +0800
@@ -1,6 +1,7 @@
-libdir=@LIB_DIR@
-includedir=@INCLUDE_DIR@
-drvdir=@LIB_DIR@/plplot@PLPLOT_VERSION@/drivers
+prefix="@PKGCONFIG_PREFIX@"
+libdir=@PKGCONFIG_LIBDIR@
+includedir=@PKGCONFIG_INCLUDEDIR@/plplot
+drvdir=@PKGCONFIG_LIBDIR@/plplot@PLPLOT_VERSION@/drivers
 
 Name: PLplot @PC_SHORT_NAME@
 Description: Scientific plotting library (@PC_PRECISION@@PC_LONG_NAME@)
