Index: gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE.sh
===================================================================
--- gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE.sh	(revision 32227)
+++ gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE.sh	(revision 32228)
@@ -3,6 +3,5 @@
 source ../cascade-make/lib/cascade-lib.bash GEXT_XPDFTOOLS .. $*
 
-#PACKAGES="CMAKE"
-PACKAGES="CMAKE XPDFTOOLS"
+PACKAGES="CMAKE LIBZ LIBPNG FREETYPE XPDFTOOLS"
 
 for d in $PACKAGES ; do
Index: gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/CMAKE.sh
===================================================================
--- gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/CMAKE.sh	(revision 32227)
+++ gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/CMAKE.sh	(revision 32228)
@@ -32,9 +32,11 @@
 
 # Only compile if necessary - we don't edit these source files.
-if type -p cmake; then
-  echo "found cmake in PATH"
-  _CMAKE=cmake
-elif [[ -x "$GEXTXPDFTOOLS_INSTALLED/linux/bin/cmake" ]]; then
-##if [[ -x "$GEXTXPDFTOOLS_INSTALLED/linux/bin/cmake" ]]; then
+#if type -p cmake; then
+#  echo "found cmake in PATH"
+#  _CMAKE=cmake
+#elif [[ -x "$GEXTXPDFTOOLS_INSTALLED/linux/bin/cmake" ]]; then
+# NO. Rather, only compile up OUR cmake if we haven't already got OUR cmake
+# But don't use any system cmake: xpdf-tools is dependent on cmake version (>= 2.8.8)
+if [[ -x "$GEXTXPDFTOOLS_INSTALLED/linux/bin/cmake" ]]; then
   echo "found cmake in $GEXTXPDFTOOLS_INSTALLED/linux/bin"
   _CMAKE="$GEXTXPDFTOOLS_INSTALLED/linux/bin/cmake"
Index: gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/FREETYPE.sh
===================================================================
--- gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/FREETYPE.sh	(revision 32228)
+++ gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/FREETYPE.sh	(revision 32228)
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+package=freetype
+version=-2.3.9
+
+progname=$0
+
+(cd .. ; \
+ source setup.bash silent; )
+ 
+source $GEXT_XPDFTOOLS/cascade-make/lib/cascade-lib.bash
+
+prefix=$GEXTXPDFTOOLS_INSTALLED
+
+opt_run_untar $force_untar $auto_untar $package $version
+opt_run_configure $force_config $auto_config $package $version "$prefix"
+
+opt_run_make $compile   $package $version
+opt_run_make $install   $package $version "install"
+opt_run_make $clean     $package $version "clean"
+opt_run_make $distclean $package $version "distclean"
+
+opt_run_tarclean $tarclean $package $version
+
+
+
Index: gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/LIBPNG.sh
===================================================================
--- gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/LIBPNG.sh	(revision 32228)
+++ gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/LIBPNG.sh	(revision 32228)
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+package=libpng
+#version=-1.5.0
+version=-1.5.30
+
+progname=$0
+
+source ../cascade-make/lib/cascade-lib.bash GEXT_XPDFTOOLS ../.. $*
+
+prefix=$GEXTXPDFTOOLS_INSTALLED
+
+export CFLAGS="$CFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include"
+export CPPFLAGS="$CPPFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include"
+export CXXFLAGS="$CXXFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include"
+export LDFLAGS="$LDFLAGS -L$GEXTXPDFTOOLS_INSTALLED/lib"
+
+echo GSDLOS = $GSDLOS
+
+if [ $GSDLOS != "darwin" ] ; then
+
+opt_run_untar $force_untar $auto_untar $package $version
+opt_run_configure $force_config $auto_config $package $version $prefix
+
+opt_run_make $compile $package $version
+opt_run_make $install $package $version "install"
+opt_run_make $clean $package $version "clean"
+opt_run_make $distclean $package $version "distclean"
+
+opt_run_tarclean $tarclean $package $version
+
+fi
Index: gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/LIBZ.sh
===================================================================
--- gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/LIBZ.sh	(revision 32228)
+++ gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/LIBZ.sh	(revision 32228)
@@ -0,0 +1,55 @@
+#!/bin/bash
+
+package=zlib
+version=-1.2.7
+
+progname=$0
+
+source ../cascade-make/lib/cascade-lib.bash GEXT_XPDFTOOLS ../.. $*
+
+prefix=$GEXTXPDFTOOLS_INSTALLED
+
+if [ "x$CROSSCONFIGURE_ARGS" != "x" ] ; then
+  if [ "x$crossOS" = "xwindows" ] ; then
+      export LDSHAREDLIBC=-lcrtdll
+  fi
+    # zlib configure does not support '--host'
+    export CROSSCONFIGURE_ARGS=
+fi
+
+
+opt_run_untar $force_untar $auto_untar $package $version
+
+#opt_run_configure $force_config $auto_config $package $version $prefix
+
+if [ $auto_config = "1" ] ; then
+  if [ ! -f $package$version/configure.log ] ; then
+    force_config=1
+  fi
+
+fi
+
+if [ $force_config = "1" ] ; then
+    echo "[pushd $package$version]"
+    ( cd $package$version ; \
+      echo $CROSSCONFIGURE_VARS ./configure --prefix="$prefix" $CROSSCONFIGURE_ARGS $@ ; \
+      eval $CROSSCONFIGURE_VARS ./configure --prefix="$prefix" $CROSSCONFIGURE_ARGS $@ )
+    if [ $? != 0 ] ; then
+        echo "      Error encountered running *configure* stage of $progname"
+        exit 1
+    fi
+    echo "[popd]"
+  else
+    if [ $auto_config = "1" ] ; then
+      echo "Found top-level for ${progname%.*} => no need to run ./configure"
+    fi
+fi
+
+
+
+opt_run_make $compile $package $version
+opt_run_make $install $package $version "install"
+opt_run_make $clean $package $version "clean"
+opt_run_make $distclean $package $version "distclean"
+
+opt_run_tarclean $tarclean $package $version
Index: gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/XPDFTOOLS.sh
===================================================================
--- gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/XPDFTOOLS.sh	(revision 32227)
+++ gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/XPDFTOOLS.sh	(revision 32228)
@@ -2,5 +2,5 @@
 
 # only going to make xpdf-tools, not xpdf-reader. So not making all of xpdf
-package=xpdf
+package=gs-xpdf
 version=-4.00
 
@@ -9,10 +9,13 @@
 source ../cascade-make/lib/cascade-lib.bash GEXT_XPDFTOOLS ../.. $*
 
+# GEXT XDFTOOLS INSTALLED location is this GEXT's GSDLOS subdir
 prefix=$GEXTXPDFTOOLS_INSTALLED
 
-#export CFLAGS="$CFLAGS -I$GEXTAUDIODB_INSTALLED/include"
-#export CPPFLAGS="$CPPFLAGS -I$GEXTAUDIODB_INSTALLED/include"
-#export CXXFLAGS="$CXXFLAGS -I$GEXTAUDIODB_INSTALLED/include"
-#export LDFLAGS="$LDFLAGS -L$GEXTAUDIODB_INSTALLED/lib"
+# Use C/CPP/CXX FLAGS and LDFLAGS for setting up
+# libpng and libz for compiling xpdftools
+export CFLAGS="$CFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include -I$GEXTXPDFTOOLS_INSTALLED/include/libpng15"
+export CPPFLAGS="$CPPFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include -I$GEXTXPDFTOOLS_INSTALLED/include/libpng15"
+export CXXFLAGS="$CXXFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include -I$GEXTXPDFTOOLS_INSTALLED/include/libpng15"
+export LDFLAGS="$LDFLAGS -L$GEXTXPDFTOOLS_INSTALLED/lib"
 
 #echo GSDLOS = $GSDLOS
@@ -32,17 +35,9 @@
 ##exit 0
 
-##if type -p pdftohtml; then
-##  echo "found xpdf-tools in PATH"
-##  _XPDFTOOLS=pdftohtml
-##elif [[ -x "$GEXTXPDFTOOLS_INSTALLED/linux/bin/pdftohtml" ]]; then
-if [[ -x "$GEXTXPDFTOOLS_INSTALLED/bin/pdftohtml" ]]; then
-  echo "found pdftohtml in $GEXTXPDFTOOLS_INSTALLED/bin"
-  _XPDFTOOLS="$GEXTXPDFTOOLS_INSTALLED/bin"
-fi
-
-# IGNORE: See xpdf-tools src' INSTALL instructions: need to create a build dir
+# IGNORE: See xpdf-tools src' INSTALL instructions: need to create a 'build' dir
 # cd there and then run cmake from there, providing the xpdf-tools src dir
-# Actually, doing the above breaks the way cascade-lib.bash does it. It wants
-# a 'release' directory, so do it the cascade-make way.
+# ACTUALLY: doing the above breaks the way cascade-lib.bash does it. It wants
+# a 'release' directory, so do it the cascade-make way as that works.
+# TO AVOID building xpdf(reader), turn off finding Qt libs with the cmake flags below
 if [ $force_config = "1" ] ; then
   echo "[pushd $package$version]"
@@ -59,4 +54,7 @@
 	cmake -DCMAKE_BUILD_TYPE=Release \
 	    -DCMAKE_INSTALL_PREFIX=$prefix \
+	    -DZLIB_LIBRARY=$prefix/lib/libz.a \
+	    -DPNG_LIBRARY=$prefix/lib/libpng15.a \
+	    -DFREETYPE_LIBRARY=$prefix/lib/libfreetype.a \
 	    -DCMAKE_DISABLE_FIND_PACKAGE_Qt4=1 \
 	    -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Widgets=1 \
@@ -64,4 +62,5 @@
 	    -DCMAKE_CXX_FLAGS="$CXXFLAGS" \
 	    -DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS" \
+	    -DPNG_LINK_FLAGS="-lpng15" \
 	    $GEXT_XPDFTOOLS/packages/$package$version
     fi ; \
@@ -81,2 +80,21 @@
   fi
 fi
+
+## The -DFREETYPE_DIR to be used in place of -DFREETYPE_LIBRARY above
+## this will help it find the "libfreetype.so" (no versioning at end) in our gs ext
+## But -DZLIB_DIR and -DPNG_DIR are ignored and unrecognised, whereas
+## -DZLIB_LIBRARY and -DPNG_LIBRARY are recognised & supposedly used when compiling
+## but weren't really used as seen when running ldd on the xpdf-tools binaries:
+#	    -DZLIB_DIR=$prefix \
+#	    -DPNG_DIR=$prefix \
+#	    -DFREETYPE_DIR=$prefix \
+
+## When specified this way, all 3 lines are recognised (freetype, zlib, png)
+## but weren't really used as seen when running ldd on the xpdf-tools binaries:
+#	    -DZLIB_LIBRARY=$prefix/lib/libz.so.1.2.7 \
+#	    -DPNG_LIBRARY=$prefix/lib/libpng15.so.15.30.0 \
+#	    -DFREETYPE_LIBRARY=$prefix/lib/libfreetype.so.6.3.20 \
+
+
+# If compilation was successful, then we don't need cmake binaries anymore when
+# packaging up xpdf-tools
Index: gs2-extensions/xpdf-tools/trunk/src/packages/CMakeLists.txt
===================================================================
--- gs2-extensions/xpdf-tools/trunk/src/packages/CMakeLists.txt	(revision 32228)
+++ gs2-extensions/xpdf-tools/trunk/src/packages/CMakeLists.txt	(revision 32228)
@@ -0,0 +1,235 @@
+#========================================================================
+#
+# xpdf/cmake-xpdf.txt
+#
+# CMake script for the Xpdf tools.
+#
+# Copyright 2015 Glyph & Cog, LLC
+#
+#========================================================================
+
+include_directories("${PROJECT_SOURCE_DIR}")
+include_directories("${PROJECT_BINARY_DIR}")
+include_directories("${PROJECT_SOURCE_DIR}/goo")
+include_directories("${PROJECT_SOURCE_DIR}/fofi")
+include_directories("${PROJECT_SOURCE_DIR}/splash")
+if (PNG_FOUND)
+  include_directories("${PNG_INCLUDE_DIRS}")
+  add_definitions("${PNG_DEFINITIONS}")
+endif ()
+# https://stackoverflow.com/questions/36126333/mingw-cmake-undefined-reference-to-zlib
+if (ZLIB_FOUND)
+  include_directories("${ZLIB_INCLUDE_DIRS}")
+  add_definitions("${ZLIB_DEFINITIONS}")
+endif ()
+if (HAVE_LCMS)
+  include_directories("${LCMS_INCLUDE_DIR}")
+  set(COLOR_MANAGER_SOURCE "ColorManager.cc")
+else ()
+  set(COLOR_MANAGER_SOURCE "")
+endif ()
+
+add_library(xpdf_objs OBJECT
+  AcroForm.cc
+  Annot.cc
+  Array.cc
+  BuiltinFont.cc
+  BuiltinFontTables.cc
+  Catalog.cc
+  CharCodeToUnicode.cc
+  CMap.cc
+  ${COLOR_MANAGER_SOURCE}
+  Decrypt.cc
+  Dict.cc
+  Error.cc
+  FontEncodingTables.cc
+  Form.cc
+  Function.cc
+  Gfx.cc
+  GfxFont.cc
+  GfxState.cc
+  GlobalParams.cc
+  JArithmeticDecoder.cc
+  JBIG2Stream.cc
+  JPXStream.cc
+  Lexer.cc
+  Link.cc
+  NameToCharCode.cc
+  Object.cc
+  OptionalContent.cc
+  Outline.cc
+  OutputDev.cc
+  Page.cc
+  Parser.cc
+  PDFDoc.cc
+  PDFDocEncoding.cc
+  PSTokenizer.cc
+  SecurityHandler.cc
+  Stream.cc
+  TextString.cc
+  UnicodeMap.cc
+  UnicodeTypeTable.cc
+  UTF8.cc
+  XFAForm.cc
+  XRef.cc
+  Zoox.cc
+)
+
+#--- object files needed by XpdfWidget
+
+if ((QT4_FOUND OR Qt5Widgets_FOUND)
+    AND HAVE_SPLASH AND MULTITHREADED AND USE_EXCEPTIONS)
+
+  if (HIGHLIGHTED_REGIONS)
+    set(HIGHLIGHT_SRC "HighlightFile.cc")
+  else ()
+    set(HIGHLIGHT_SRC "")
+  endif ()
+
+  add_library(xpdf_widget_objs OBJECT
+    DisplayState.cc
+    PDFCore.cc
+    PreScanOutputDev.cc
+    PSOutputDev.cc
+    SplashOutputDev.cc
+    TextOutputDev.cc
+    TileCache.cc
+    TileCompositor.cc
+    TileMap.cc
+    ${HIGHLIGHT_SRC}
+  )
+endif ()
+
+#--- pdftops
+
+if (HAVE_SPLASH)
+  add_executable(pdftops
+    $<TARGET_OBJECTS:xpdf_objs>
+    PreScanOutputDev.cc
+    PSOutputDev.cc
+    SplashOutputDev.cc
+    pdftops.cc
+  )
+  target_link_libraries(pdftops goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+			${ZLIB_LIBRARIES}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY})
+else ()
+  add_executable(pdftops
+    $<TARGET_OBJECTS:xpdf_objs>
+    PreScanOutputDev.cc
+    PSOutputDev.cc
+    pdftops.cc
+  )
+  target_link_libraries(pdftops goo fofi ${LCMS_LIBRARY})
+endif ()
+install(TARGETS pdftops RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftops.1 DESTINATION man/man1)
+
+#--- pdftotext
+
+add_executable(pdftotext
+  $<TARGET_OBJECTS:xpdf_objs>
+  TextOutputDev.cc
+  pdftotext.cc
+)
+target_link_libraries(pdftotext goo fofi ${LCMS_LIBRARY})
+install(TARGETS pdftotext RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftotext.1 DESTINATION man/man1)
+
+#--- pdftohtml
+
+if (HAVE_SPLASH AND PNG_FOUND)
+  add_executable(pdftohtml
+    $<TARGET_OBJECTS:xpdf_objs>
+    HTMLGen.cc
+    SplashOutputDev.cc
+    TextOutputDev.cc
+    pdftohtml.cc
+  )
+  target_link_libraries(pdftohtml goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY} ${PNG_LIBRARIES})
+  install(TARGETS pdftohtml RUNTIME DESTINATION bin)
+  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftohtml.1 DESTINATION man/man1)
+endif ()
+
+#--- pdfinfo
+
+add_executable(pdfinfo
+  $<TARGET_OBJECTS:xpdf_objs>
+  pdfinfo.cc
+)
+target_link_libraries(pdfinfo goo fofi ${LCMS_LIBRARY})
+install(TARGETS pdfinfo RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfinfo.1 DESTINATION man/man1)
+
+#--- pdffonts
+
+add_executable(pdffonts
+  $<TARGET_OBJECTS:xpdf_objs>
+  pdffonts.cc
+)
+target_link_libraries(pdffonts goo fofi ${LCMS_LIBRARY})
+install(TARGETS pdffonts RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdffonts.1 DESTINATION man/man1)
+
+#--- pdfdetach
+
+add_executable(pdfdetach
+  $<TARGET_OBJECTS:xpdf_objs>
+  pdfdetach.cc
+)
+target_link_libraries(pdfdetach goo fofi ${LCMS_LIBRARY})
+install(TARGETS pdfdetach RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfdetach.1 DESTINATION man/man1)
+
+#--- pdftoppm
+
+if (HAVE_SPLASH)
+  add_executable(pdftoppm
+    $<TARGET_OBJECTS:xpdf_objs>
+    SplashOutputDev.cc
+    pdftoppm.cc
+  )
+  target_link_libraries(pdftoppm goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+			${ZLIB_LIBRARIES}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY})
+  install(TARGETS pdftoppm RUNTIME DESTINATION bin)
+  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftoppm.1 DESTINATION man/man1)
+endif ()
+
+#--- pdftopng
+
+if (HAVE_SPLASH AND PNG_FOUND)
+  add_executable(pdftopng
+    $<TARGET_OBJECTS:xpdf_objs>
+    SplashOutputDev.cc
+    pdftopng.cc
+  )
+  target_link_libraries(pdftopng goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY} ${PNG_LIBRARIES})
+  install(TARGETS pdftopng RUNTIME DESTINATION bin)
+  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftopng.1 DESTINATION man/man1)
+endif ()
+
+#--- pdfimages
+
+add_executable(pdfimages
+  $<TARGET_OBJECTS:xpdf_objs>
+  ImageOutputDev.cc
+  pdfimages.cc
+)
+target_link_libraries(pdfimages goo fofi ${LCMS_LIBRARY})
+install(TARGETS pdfimages RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfimages.1 DESTINATION man/man1)
+
+#--- xpdfrc man page
+
+install(FILES ${PROJECT_SOURCE_DIR}/doc/xpdfrc.5 DESTINATION man/man5)
Index: gs2-extensions/xpdf-tools/trunk/src/packages/CMakeLists.txt.orig
===================================================================
--- gs2-extensions/xpdf-tools/trunk/src/packages/CMakeLists.txt.orig	(revision 32228)
+++ gs2-extensions/xpdf-tools/trunk/src/packages/CMakeLists.txt.orig	(revision 32228)
@@ -0,0 +1,228 @@
+#========================================================================
+#
+# xpdf/cmake-xpdf.txt
+#
+# CMake script for the Xpdf tools.
+#
+# Copyright 2015 Glyph & Cog, LLC
+#
+#========================================================================
+
+include_directories("${PROJECT_SOURCE_DIR}")
+include_directories("${PROJECT_BINARY_DIR}")
+include_directories("${PROJECT_SOURCE_DIR}/goo")
+include_directories("${PROJECT_SOURCE_DIR}/fofi")
+include_directories("${PROJECT_SOURCE_DIR}/splash")
+if (PNG_FOUND)
+  include_directories("${PNG_INCLUDE_DIRS}")
+  add_definitions("${PNG_DEFINITIONS}")
+endif ()
+if (HAVE_LCMS)
+  include_directories("${LCMS_INCLUDE_DIR}")
+  set(COLOR_MANAGER_SOURCE "ColorManager.cc")
+else ()
+  set(COLOR_MANAGER_SOURCE "")
+endif ()
+
+add_library(xpdf_objs OBJECT
+  AcroForm.cc
+  Annot.cc
+  Array.cc
+  BuiltinFont.cc
+  BuiltinFontTables.cc
+  Catalog.cc
+  CharCodeToUnicode.cc
+  CMap.cc
+  ${COLOR_MANAGER_SOURCE}
+  Decrypt.cc
+  Dict.cc
+  Error.cc
+  FontEncodingTables.cc
+  Form.cc
+  Function.cc
+  Gfx.cc
+  GfxFont.cc
+  GfxState.cc
+  GlobalParams.cc
+  JArithmeticDecoder.cc
+  JBIG2Stream.cc
+  JPXStream.cc
+  Lexer.cc
+  Link.cc
+  NameToCharCode.cc
+  Object.cc
+  OptionalContent.cc
+  Outline.cc
+  OutputDev.cc
+  Page.cc
+  Parser.cc
+  PDFDoc.cc
+  PDFDocEncoding.cc
+  PSTokenizer.cc
+  SecurityHandler.cc
+  Stream.cc
+  TextString.cc
+  UnicodeMap.cc
+  UnicodeTypeTable.cc
+  UTF8.cc
+  XFAForm.cc
+  XRef.cc
+  Zoox.cc
+)
+
+#--- object files needed by XpdfWidget
+
+if ((QT4_FOUND OR Qt5Widgets_FOUND)
+    AND HAVE_SPLASH AND MULTITHREADED AND USE_EXCEPTIONS)
+
+  if (HIGHLIGHTED_REGIONS)
+    set(HIGHLIGHT_SRC "HighlightFile.cc")
+  else ()
+    set(HIGHLIGHT_SRC "")
+  endif ()
+
+  add_library(xpdf_widget_objs OBJECT
+    DisplayState.cc
+    PDFCore.cc
+    PreScanOutputDev.cc
+    PSOutputDev.cc
+    SplashOutputDev.cc
+    TextOutputDev.cc
+    TileCache.cc
+    TileCompositor.cc
+    TileMap.cc
+    ${HIGHLIGHT_SRC}
+  )
+endif ()
+
+#--- pdftops
+
+if (HAVE_SPLASH)
+  add_executable(pdftops
+    $<TARGET_OBJECTS:xpdf_objs>
+    PreScanOutputDev.cc
+    PSOutputDev.cc
+    SplashOutputDev.cc
+    pdftops.cc
+  )
+  target_link_libraries(pdftops goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY})
+else ()
+  add_executable(pdftops
+    $<TARGET_OBJECTS:xpdf_objs>
+    PreScanOutputDev.cc
+    PSOutputDev.cc
+    pdftops.cc
+  )
+  target_link_libraries(pdftops goo fofi ${LCMS_LIBRARY})
+endif ()
+install(TARGETS pdftops RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftops.1 DESTINATION man/man1)
+
+#--- pdftotext
+
+add_executable(pdftotext
+  $<TARGET_OBJECTS:xpdf_objs>
+  TextOutputDev.cc
+  pdftotext.cc
+)
+target_link_libraries(pdftotext goo fofi ${LCMS_LIBRARY})
+install(TARGETS pdftotext RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftotext.1 DESTINATION man/man1)
+
+#--- pdftohtml
+
+if (HAVE_SPLASH AND PNG_FOUND)
+  add_executable(pdftohtml
+    $<TARGET_OBJECTS:xpdf_objs>
+    HTMLGen.cc
+    SplashOutputDev.cc
+    TextOutputDev.cc
+    pdftohtml.cc
+  )
+  target_link_libraries(pdftohtml goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY} ${PNG_LIBRARIES})
+  install(TARGETS pdftohtml RUNTIME DESTINATION bin)
+  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftohtml.1 DESTINATION man/man1)
+endif ()
+
+#--- pdfinfo
+
+add_executable(pdfinfo
+  $<TARGET_OBJECTS:xpdf_objs>
+  pdfinfo.cc
+)
+target_link_libraries(pdfinfo goo fofi ${LCMS_LIBRARY})
+install(TARGETS pdfinfo RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfinfo.1 DESTINATION man/man1)
+
+#--- pdffonts
+
+add_executable(pdffonts
+  $<TARGET_OBJECTS:xpdf_objs>
+  pdffonts.cc
+)
+target_link_libraries(pdffonts goo fofi ${LCMS_LIBRARY})
+install(TARGETS pdffonts RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdffonts.1 DESTINATION man/man1)
+
+#--- pdfdetach
+
+add_executable(pdfdetach
+  $<TARGET_OBJECTS:xpdf_objs>
+  pdfdetach.cc
+)
+target_link_libraries(pdfdetach goo fofi ${LCMS_LIBRARY})
+install(TARGETS pdfdetach RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfdetach.1 DESTINATION man/man1)
+
+#--- pdftoppm
+
+if (HAVE_SPLASH)
+  add_executable(pdftoppm
+    $<TARGET_OBJECTS:xpdf_objs>
+    SplashOutputDev.cc
+    pdftoppm.cc
+  )
+  target_link_libraries(pdftoppm goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY})
+  install(TARGETS pdftoppm RUNTIME DESTINATION bin)
+  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftoppm.1 DESTINATION man/man1)
+endif ()
+
+#--- pdftopng
+
+if (HAVE_SPLASH AND PNG_FOUND)
+  add_executable(pdftopng
+    $<TARGET_OBJECTS:xpdf_objs>
+    SplashOutputDev.cc
+    pdftopng.cc
+  )
+  target_link_libraries(pdftopng goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY} ${PNG_LIBRARIES})
+  install(TARGETS pdftopng RUNTIME DESTINATION bin)
+  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftopng.1 DESTINATION man/man1)
+endif ()
+
+#--- pdfimages
+
+add_executable(pdfimages
+  $<TARGET_OBJECTS:xpdf_objs>
+  ImageOutputDev.cc
+  pdfimages.cc
+)
+target_link_libraries(pdfimages goo fofi ${LCMS_LIBRARY})
+install(TARGETS pdfimages RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfimages.1 DESTINATION man/man1)
+
+#--- xpdfrc man page
+
+install(FILES ${PROJECT_SOURCE_DIR}/doc/xpdfrc.5 DESTINATION man/man5)
Index: gs2-extensions/xpdf-tools/trunk/src/packages/CMakeLists.txt.static1_notworking
===================================================================
--- gs2-extensions/xpdf-tools/trunk/src/packages/CMakeLists.txt.static1_notworking	(revision 32228)
+++ gs2-extensions/xpdf-tools/trunk/src/packages/CMakeLists.txt.static1_notworking	(revision 32228)
@@ -0,0 +1,248 @@
+#========================================================================
+#
+# xpdf/cmake-xpdf.txt
+#
+# CMake script for the Xpdf tools.
+#
+# Copyright 2015 Glyph & Cog, LLC
+#
+#========================================================================
+
+include_directories("${PROJECT_SOURCE_DIR}")
+include_directories("${PROJECT_BINARY_DIR}")
+include_directories("${PROJECT_SOURCE_DIR}/goo")
+include_directories("${PROJECT_SOURCE_DIR}/fofi")
+include_directories("${PROJECT_SOURCE_DIR}/splash")
+if (PNG_FOUND)
+  include_directories("${PNG_INCLUDE_DIRS}")
+  add_definitions("${PNG_DEFINITIONS}")
+endif ()
+if (HAVE_LCMS)
+  include_directories("${LCMS_INCLUDE_DIR}")
+  set(COLOR_MANAGER_SOURCE "ColorManager.cc")
+else ()
+  set(COLOR_MANAGER_SOURCE "")
+endif ()
+
+add_library(xpdf_objs OBJECT
+  AcroForm.cc
+  Annot.cc
+  Array.cc
+  BuiltinFont.cc
+  BuiltinFontTables.cc
+  Catalog.cc
+  CharCodeToUnicode.cc
+  CMap.cc
+  ${COLOR_MANAGER_SOURCE}
+  Decrypt.cc
+  Dict.cc
+  Error.cc
+  FontEncodingTables.cc
+  Form.cc
+  Function.cc
+  Gfx.cc
+  GfxFont.cc
+  GfxState.cc
+  GlobalParams.cc
+  JArithmeticDecoder.cc
+  JBIG2Stream.cc
+  JPXStream.cc
+  Lexer.cc
+  Link.cc
+  NameToCharCode.cc
+  Object.cc
+  OptionalContent.cc
+  Outline.cc
+  OutputDev.cc
+  Page.cc
+  Parser.cc
+  PDFDoc.cc
+  PDFDocEncoding.cc
+  PSTokenizer.cc
+  SecurityHandler.cc
+  Stream.cc
+  TextString.cc
+  UnicodeMap.cc
+  UnicodeTypeTable.cc
+  UTF8.cc
+  XFAForm.cc
+  XRef.cc
+  Zoox.cc
+)
+
+#--- object files needed by XpdfWidget
+
+if ((QT4_FOUND OR Qt5Widgets_FOUND)
+    AND HAVE_SPLASH AND MULTITHREADED AND USE_EXCEPTIONS)
+
+  if (HIGHLIGHTED_REGIONS)
+    set(HIGHLIGHT_SRC "HighlightFile.cc")
+  else ()
+    set(HIGHLIGHT_SRC "")
+  endif ()
+
+  add_library(xpdf_widget_objs OBJECT
+    DisplayState.cc
+    PDFCore.cc
+    PreScanOutputDev.cc
+    PSOutputDev.cc
+    SplashOutputDev.cc
+    TextOutputDev.cc
+    TileCache.cc
+    TileCompositor.cc
+    TileMap.cc
+    ${HIGHLIGHT_SRC}
+  )
+endif ()
+
+# We want to build static xpdf-tools binaries. See
+# https://stackoverflow.com/questions/24648357/compiling-a-static-executable-with-cmake
+# Want to make the min number of changes for building statically, so using this way:
+SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
+SET(BUILD_SHARED_LIBS OFF)
+SET(CMAKE_EXE_LINKER_FLAGS "-static")
+# See https://github.com/droe/sslsplit/issues/82
+# for warnings of this nature:
+#  ../goo/libgoo.a(gfile.cc.o): In function `getHomeDir()':
+#  gfile.cc:(.text+0x55): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
+#  gfile.cc:(.text+0x90): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
+# See https://stackoverflow.com/questions/1620918/cmake-and-libpthread
+# after googling cmake and "-lpthread" (pthread) after ERRORS to do with this, like:
+#   undefined reference to `pthread_mutex_unlock'
+set(THREADS_PREFER_PTHREAD_FLAG ON)
+find_package(Threads REQUIRED)
+
+#--- pdftops
+
+if (HAVE_SPLASH)
+  add_executable(pdftops
+    $<TARGET_OBJECTS:xpdf_objs>
+    PreScanOutputDev.cc
+    PSOutputDev.cc
+    SplashOutputDev.cc
+    pdftops.cc
+  )
+  target_link_libraries(pdftops goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY}
+			Threads::Threads)
+else ()
+  add_executable(pdftops
+    $<TARGET_OBJECTS:xpdf_objs>
+    PreScanOutputDev.cc
+    PSOutputDev.cc
+    pdftops.cc
+  )
+  target_link_libraries(pdftops goo fofi ${LCMS_LIBRARY} Threads::Threads)
+endif ()
+install(TARGETS pdftops RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftops.1 DESTINATION man/man1)
+
+#--- pdftotext
+
+add_executable(pdftotext
+  $<TARGET_OBJECTS:xpdf_objs>
+  TextOutputDev.cc
+  pdftotext.cc
+)
+target_link_libraries(pdftotext goo fofi ${LCMS_LIBRARY} Threads::Threads)
+install(TARGETS pdftotext RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftotext.1 DESTINATION man/man1)
+
+#--- pdftohtml
+
+if (HAVE_SPLASH AND PNG_FOUND)
+  add_executable(pdftohtml
+    $<TARGET_OBJECTS:xpdf_objs>
+    HTMLGen.cc
+    SplashOutputDev.cc
+    TextOutputDev.cc
+    pdftohtml.cc
+  )
+  target_link_libraries(pdftohtml goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY} ${PNG_LIBRARIES}
+			Threads::Threads)
+  install(TARGETS pdftohtml RUNTIME DESTINATION bin)
+  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftohtml.1 DESTINATION man/man1)
+endif ()
+
+#--- pdfinfo
+
+add_executable(pdfinfo
+  $<TARGET_OBJECTS:xpdf_objs>
+  pdfinfo.cc
+)
+target_link_libraries(pdfinfo goo fofi ${LCMS_LIBRARY} Threads::Threads)
+install(TARGETS pdfinfo RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfinfo.1 DESTINATION man/man1)
+
+#--- pdffonts
+
+add_executable(pdffonts
+  $<TARGET_OBJECTS:xpdf_objs>
+  pdffonts.cc
+)
+target_link_libraries(pdffonts goo fofi ${LCMS_LIBRARY} Threads::Threads)
+install(TARGETS pdffonts RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdffonts.1 DESTINATION man/man1)
+
+#--- pdfdetach
+
+add_executable(pdfdetach
+  $<TARGET_OBJECTS:xpdf_objs>
+  pdfdetach.cc
+)
+target_link_libraries(pdfdetach goo fofi ${LCMS_LIBRARY} Threads::Threads)
+install(TARGETS pdfdetach RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfdetach.1 DESTINATION man/man1)
+
+#--- pdftoppm
+
+if (HAVE_SPLASH)
+  add_executable(pdftoppm
+    $<TARGET_OBJECTS:xpdf_objs>
+    SplashOutputDev.cc
+    pdftoppm.cc
+  )
+  target_link_libraries(pdftoppm goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY}
+			Threads::Threads)
+  install(TARGETS pdftoppm RUNTIME DESTINATION bin)
+  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftoppm.1 DESTINATION man/man1)
+endif ()
+
+#--- pdftopng
+
+if (HAVE_SPLASH AND PNG_FOUND)
+  add_executable(pdftopng
+    $<TARGET_OBJECTS:xpdf_objs>
+    SplashOutputDev.cc
+    pdftopng.cc
+  )
+  target_link_libraries(pdftopng goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY} ${PNG_LIBRARIES} Threads::Threads)
+  install(TARGETS pdftopng RUNTIME DESTINATION bin)
+  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftopng.1 DESTINATION man/man1)
+endif ()
+
+#--- pdfimages
+
+add_executable(pdfimages
+  $<TARGET_OBJECTS:xpdf_objs>
+  ImageOutputDev.cc
+  pdfimages.cc
+)
+target_link_libraries(pdfimages goo fofi ${LCMS_LIBRARY} Threads::Threads)
+install(TARGETS pdfimages RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfimages.1 DESTINATION man/man1)
+
+#--- xpdfrc man page
+
+install(FILES ${PROJECT_SOURCE_DIR}/doc/xpdfrc.5 DESTINATION man/man5)
Index: gs2-extensions/xpdf-tools/trunk/src/packages/CMakeLists.txt.static2_notworking
===================================================================
--- gs2-extensions/xpdf-tools/trunk/src/packages/CMakeLists.txt.static2_notworking	(revision 32228)
+++ gs2-extensions/xpdf-tools/trunk/src/packages/CMakeLists.txt.static2_notworking	(revision 32228)
@@ -0,0 +1,287 @@
+#========================================================================
+#
+# xpdf/cmake-xpdf.txt
+#
+# CMake script for the Xpdf tools.
+#
+# Copyright 2015 Glyph & Cog, LLC
+#
+#========================================================================
+
+include_directories("${PROJECT_SOURCE_DIR}")
+include_directories("${PROJECT_BINARY_DIR}")
+include_directories("${PROJECT_SOURCE_DIR}/goo")
+include_directories("${PROJECT_SOURCE_DIR}/fofi")
+include_directories("${PROJECT_SOURCE_DIR}/splash")
+
+#------------------
+## https://stackoverflow.com/questions/36220123/undefined-reference-to-png-set-longjmp-fn-when-compiling-pcl-source-file
+## https://stackoverflow.com/questions/30980383/cmake-compile-options-for-libpng
+
+# search for pkg-config
+include (FindPkgConfig)
+if (NOT PKG_CONFIG_FOUND)
+    message (FATAL_ERROR "pkg-config not found")
+endif ()
+
+# check for libpng
+pkg_check_modules (PNG libpng15 REQUIRED)
+if (NOT PNG_FOUND)
+    message(FATAL_ERROR "You don't seem to have libpng15 development libraries installed")
+else ()
+    include_directories (${PNG_INCLUDE_DIRS})
+    link_directories (${PNG_LIBRARY_DIRS})
+    link_libraries (${PNG_LIBRARIES})
+endif ()
+#------------------
+
+if (ZLIB_FOUND)
+  message(STATUS "@@@@@@@@@@@@@@@ ZLIB_FOUND ${ZLIB_LIBRARIES}")
+  include_directories("${ZLIB_INCLUDE_DIRS}")
+else ()
+  message(STATUS "@@@@@@@@@@@@@@@ NOT ZLIB_FOUND")
+endif ()
+if (PNG_FOUND)
+  message(STATUS "@@@@@@@@@@@@@@@ PNG_FOUND ${PNG_LINK_FLAGS}")
+  include_directories("${PNG_INCLUDE_DIRS}")
+  link_directories (${PNG_LIBRARY_DIRS})
+  link_libraries (${PNG_LIBRARIES})
+  add_definitions("${PNG_DEFINITIONS}")
+else ()
+  message(STATUS "@@@@@@@@@@@@@@@ NOT PNG_FOUND")
+endif ()
+if (HAVE_LCMS)
+  include_directories("${LCMS_INCLUDE_DIR}")
+  set(COLOR_MANAGER_SOURCE "ColorManager.cc")
+else ()
+  set(COLOR_MANAGER_SOURCE "")
+endif ()
+
+add_library(xpdf_objs OBJECT
+  AcroForm.cc
+  Annot.cc
+  Array.cc
+  BuiltinFont.cc
+  BuiltinFontTables.cc
+  Catalog.cc
+  CharCodeToUnicode.cc
+  CMap.cc
+  ${COLOR_MANAGER_SOURCE}
+  Decrypt.cc
+  Dict.cc
+  Error.cc
+  FontEncodingTables.cc
+  Form.cc
+  Function.cc
+  Gfx.cc
+  GfxFont.cc
+  GfxState.cc
+  GlobalParams.cc
+  JArithmeticDecoder.cc
+  JBIG2Stream.cc
+  JPXStream.cc
+  Lexer.cc
+  Link.cc
+  NameToCharCode.cc
+  Object.cc
+  OptionalContent.cc
+  Outline.cc
+  OutputDev.cc
+  Page.cc
+  Parser.cc
+  PDFDoc.cc
+  PDFDocEncoding.cc
+  PSTokenizer.cc
+  SecurityHandler.cc
+  Stream.cc
+  TextString.cc
+  UnicodeMap.cc
+  UnicodeTypeTable.cc
+  UTF8.cc
+  XFAForm.cc
+  XRef.cc
+  Zoox.cc
+)
+
+#--- object files needed by XpdfWidget
+
+if ((QT4_FOUND OR Qt5Widgets_FOUND)
+    AND HAVE_SPLASH AND MULTITHREADED AND USE_EXCEPTIONS)
+
+  if (HIGHLIGHTED_REGIONS)
+    set(HIGHLIGHT_SRC "HighlightFile.cc")
+  else ()
+    set(HIGHLIGHT_SRC "")
+  endif ()
+
+  add_library(xpdf_widget_objs OBJECT
+    DisplayState.cc
+    PDFCore.cc
+    PreScanOutputDev.cc
+    PSOutputDev.cc
+    SplashOutputDev.cc
+    TextOutputDev.cc
+    TileCache.cc
+    TileCompositor.cc
+    TileMap.cc
+    ${HIGHLIGHT_SRC}
+  )
+endif ()
+
+# We want to build static xpdf-tools binaries. See
+# https://stackoverflow.com/questions/24648357/compiling-a-static-executable-with-cmake
+# Want to make the min number of changes for building statically, so using this way:
+SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
+SET(BUILD_SHARED_LIBS OFF)
+SET(CMAKE_EXE_LINKER_FLAGS "-static")
+# See https://github.com/droe/sslsplit/issues/82
+# for warnings of this nature:
+#  ../goo/libgoo.a(gfile.cc.o): In function `getHomeDir()':
+#  gfile.cc:(.text+0x55): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
+#  gfile.cc:(.text+0x90): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
+# See https://stackoverflow.com/questions/1620918/cmake-and-libpthread
+# after googling cmake and "-lpthread" (pthread) after ERRORS to do with this, like:
+#   undefined reference to `pthread_mutex_unlock'
+set(THREADS_PREFER_PTHREAD_FLAG ON)
+find_package(Threads REQUIRED)
+
+#-- libpng
+# https://stackoverflow.com/questions/36220123/undefined-reference-to-png-set-longjmp-fn-when-compiling-pcl-source-file
+# https://stackoverflow.com/questions/30980383/cmake-compile-options-for-libpng
+
+
+
+#--- pdftops
+
+if (HAVE_SPLASH)
+  add_executable(pdftops
+    $<TARGET_OBJECTS:xpdf_objs>
+    PreScanOutputDev.cc
+    PSOutputDev.cc
+    SplashOutputDev.cc
+    pdftops.cc
+  )
+  target_link_libraries(pdftops goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY}
+			Threads::Threads)
+else ()
+  add_executable(pdftops
+    $<TARGET_OBJECTS:xpdf_objs>
+    PreScanOutputDev.cc
+    PSOutputDev.cc
+    pdftops.cc
+  )
+  target_link_libraries(pdftops goo fofi ${LCMS_LIBRARY} Threads::Threads)
+endif ()
+install(TARGETS pdftops RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftops.1 DESTINATION man/man1)
+
+#--- pdftotext
+
+add_executable(pdftotext
+  $<TARGET_OBJECTS:xpdf_objs>
+  TextOutputDev.cc
+  pdftotext.cc
+)
+target_link_libraries(pdftotext goo fofi ${LCMS_LIBRARY} ${PNG_LIBRARIES} ${PNG_LINK_FLAGS} Threads::Threads)
+install(TARGETS pdftotext RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftotext.1 DESTINATION man/man1)
+
+#--- pdftohtml
+
+if (HAVE_SPLASH AND PNG_FOUND)
+  add_executable(pdftohtml
+    $<TARGET_OBJECTS:xpdf_objs>
+    HTMLGen.cc
+    SplashOutputDev.cc
+    TextOutputDev.cc
+    pdftohtml.cc
+  )
+  target_link_libraries(pdftohtml goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY} ${PNG_LIBRARIES}
+			Threads::Threads)
+  install(TARGETS pdftohtml RUNTIME DESTINATION bin)
+  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftohtml.1 DESTINATION man/man1)
+endif ()
+
+#--- pdfinfo
+
+add_executable(pdfinfo
+  $<TARGET_OBJECTS:xpdf_objs>
+  pdfinfo.cc
+)
+target_link_libraries(pdfinfo goo fofi ${LCMS_LIBRARY} Threads::Threads)
+install(TARGETS pdfinfo RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfinfo.1 DESTINATION man/man1)
+
+#--- pdffonts
+
+add_executable(pdffonts
+  $<TARGET_OBJECTS:xpdf_objs>
+  pdffonts.cc
+)
+target_link_libraries(pdffonts goo fofi ${LCMS_LIBRARY} Threads::Threads)
+install(TARGETS pdffonts RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdffonts.1 DESTINATION man/man1)
+
+#--- pdfdetach
+
+add_executable(pdfdetach
+  $<TARGET_OBJECTS:xpdf_objs>
+  pdfdetach.cc
+)
+target_link_libraries(pdfdetach goo fofi ${LCMS_LIBRARY} Threads::Threads)
+install(TARGETS pdfdetach RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfdetach.1 DESTINATION man/man1)
+
+#--- pdftoppm
+
+if (HAVE_SPLASH)
+  add_executable(pdftoppm
+    $<TARGET_OBJECTS:xpdf_objs>
+    SplashOutputDev.cc
+    pdftoppm.cc
+  )
+  target_link_libraries(pdftoppm goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY}
+			Threads::Threads)
+  install(TARGETS pdftoppm RUNTIME DESTINATION bin)
+  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftoppm.1 DESTINATION man/man1)
+endif ()
+
+#--- pdftopng
+
+if (HAVE_SPLASH AND PNG_FOUND)
+  add_executable(pdftopng
+    $<TARGET_OBJECTS:xpdf_objs>
+    SplashOutputDev.cc
+    pdftopng.cc
+  )
+  target_link_libraries(pdftopng goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY} ${PNG_LIBRARIES} Threads::Threads)
+  install(TARGETS pdftopng RUNTIME DESTINATION bin)
+  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftopng.1 DESTINATION man/man1)
+endif ()
+
+#--- pdfimages
+
+add_executable(pdfimages
+  $<TARGET_OBJECTS:xpdf_objs>
+  ImageOutputDev.cc
+  pdfimages.cc
+)
+target_link_libraries(pdfimages goo fofi ${LCMS_LIBRARY} Threads::Threads)
+install(TARGETS pdfimages RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfimages.1 DESTINATION man/man1)
+
+#--- xpdfrc man page
+
+install(FILES ${PROJECT_SOURCE_DIR}/doc/xpdfrc.5 DESTINATION man/man5)
Index: gs2-extensions/xpdf-tools/trunk/src/packages/CMakeLists.txt_complicated
===================================================================
--- gs2-extensions/xpdf-tools/trunk/src/packages/CMakeLists.txt_complicated	(revision 32228)
+++ gs2-extensions/xpdf-tools/trunk/src/packages/CMakeLists.txt_complicated	(revision 32228)
@@ -0,0 +1,269 @@
+#========================================================================
+#
+# xpdf/cmake-xpdf.txt
+#
+# CMake script for the Xpdf tools.
+#
+# Copyright 2015 Glyph & Cog, LLC
+#
+#========================================================================
+
+include_directories("${PROJECT_SOURCE_DIR}")
+include_directories("${PROJECT_BINARY_DIR}")
+include_directories("${PROJECT_SOURCE_DIR}/goo")
+include_directories("${PROJECT_SOURCE_DIR}/fofi")
+include_directories("${PROJECT_SOURCE_DIR}/splash")
+if (PNG_FOUND)
+  message(STATUS "@@@@@@@@@@@@@@@ PNG_FOUND")
+  include_directories("${PNG_INCLUDE_DIRS}")
+  link_directories (${PNG_LIBRARY_DIRS})
+  link_libraries (${PNG_LIBRARIES})
+  add_definitions("${PNG_DEFINITIONS}")
+else ()
+  message(STATUS "@@@@@@@@@@@@@@@ NOT PNG_FOUND")
+endif ()
+if (ZLIB_FOUND)
+  message(STATUS "@@@@@@@@@@@@@@@ ZLIB_FOUND")
+  include_directories("${ZLIB_INCLUDE_DIRS}")
+else ()
+  message(STATUS "@@@@@@@@@@@@@@@ NOT ZLIB_FOUND")
+endif ()
+if (HAVE_LCMS)
+  include_directories("${LCMS_INCLUDE_DIR}")
+  set(COLOR_MANAGER_SOURCE "ColorManager.cc")
+else ()
+  set(COLOR_MANAGER_SOURCE "")
+endif ()
+
+add_library(xpdf_objs OBJECT
+  AcroForm.cc
+  Annot.cc
+  Array.cc
+  BuiltinFont.cc
+  BuiltinFontTables.cc
+  Catalog.cc
+  CharCodeToUnicode.cc
+  CMap.cc
+  ${COLOR_MANAGER_SOURCE}
+  Decrypt.cc
+  Dict.cc
+  Error.cc
+  FontEncodingTables.cc
+  Form.cc
+  Function.cc
+  Gfx.cc
+  GfxFont.cc
+  GfxState.cc
+  GlobalParams.cc
+  JArithmeticDecoder.cc
+  JBIG2Stream.cc
+  JPXStream.cc
+  Lexer.cc
+  Link.cc
+  NameToCharCode.cc
+  Object.cc
+  OptionalContent.cc
+  Outline.cc
+  OutputDev.cc
+  Page.cc
+  Parser.cc
+  PDFDoc.cc
+  PDFDocEncoding.cc
+  PSTokenizer.cc
+  SecurityHandler.cc
+  Stream.cc
+  TextString.cc
+  UnicodeMap.cc
+  UnicodeTypeTable.cc
+  UTF8.cc
+  XFAForm.cc
+  XRef.cc
+  Zoox.cc
+)
+
+#--- object files needed by XpdfWidget
+
+if ((QT4_FOUND OR Qt5Widgets_FOUND)
+    AND HAVE_SPLASH AND MULTITHREADED AND USE_EXCEPTIONS)
+
+  if (HIGHLIGHTED_REGIONS)
+    set(HIGHLIGHT_SRC "HighlightFile.cc")
+  else ()
+    set(HIGHLIGHT_SRC "")
+  endif ()
+
+  add_library(xpdf_widget_objs OBJECT
+    DisplayState.cc
+    PDFCore.cc
+    PreScanOutputDev.cc
+    PSOutputDev.cc
+    SplashOutputDev.cc
+    TextOutputDev.cc
+    TileCache.cc
+    TileCompositor.cc
+    TileMap.cc
+    ${HIGHLIGHT_SRC}
+  )
+endif ()
+
+# We want to build static xpdf-tools binaries. See
+# https://stackoverflow.com/questions/24648357/compiling-a-static-executable-with-cmake
+# Want to make the min number of changes for building statically, so using this way:
+SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
+SET(BUILD_SHARED_LIBS OFF)
+SET(CMAKE_EXE_LINKER_FLAGS "-static")
+# See https://github.com/droe/sslsplit/issues/82
+# for warnings of this nature:
+#  ../goo/libgoo.a(gfile.cc.o): In function `getHomeDir()':
+#  gfile.cc:(.text+0x55): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
+#  gfile.cc:(.text+0x90): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
+# See https://stackoverflow.com/questions/1620918/cmake-and-libpthread
+# after googling cmake and "-lpthread" (pthread) after ERRORS to do with this, like:
+#   undefined reference to `pthread_mutex_unlock'
+set(THREADS_PREFER_PTHREAD_FLAG ON)
+find_package(Threads REQUIRED)
+
+#-- libpng
+# https://stackoverflow.com/questions/36220123/undefined-reference-to-png-set-longjmp-fn-when-compiling-pcl-source-file
+# https://stackoverflow.com/questions/30980383/cmake-compile-options-for-libpng
+
+
+
+#--- pdftops
+
+if (HAVE_SPLASH)
+  add_executable(pdftops
+    $<TARGET_OBJECTS:xpdf_objs>
+    PreScanOutputDev.cc
+    PSOutputDev.cc
+    SplashOutputDev.cc
+    pdftops.cc
+  )
+  target_link_libraries(pdftops goo fofi splash
+                        ${PNG_LIBRARY}
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY}
+			Threads::Threads)
+else ()
+  add_executable(pdftops
+    $<TARGET_OBJECTS:xpdf_objs>
+    PreScanOutputDev.cc
+    PSOutputDev.cc
+    pdftops.cc
+  )
+  target_link_libraries(pdftops goo fofi ${LCMS_LIBRARY} ${PNG_LIBRARY} Threads::Threads)
+endif ()
+install(TARGETS pdftops RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftops.1 DESTINATION man/man1)
+
+#--- pdftotext
+
+add_executable(pdftotext
+  $<TARGET_OBJECTS:xpdf_objs>
+  TextOutputDev.cc
+  pdftotext.cc
+)
+target_link_libraries(pdftotext goo fofi ${LCMS_LIBRARY} ${PNG_LIBRARY} Threads::Threads)
+install(TARGETS pdftotext RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftotext.1 DESTINATION man/man1)
+
+#--- pdftohtml
+
+if (HAVE_SPLASH AND PNG_FOUND)
+  add_executable(pdftohtml
+    $<TARGET_OBJECTS:xpdf_objs>
+    HTMLGen.cc
+    SplashOutputDev.cc
+    TextOutputDev.cc
+    pdftohtml.cc
+  )
+  target_link_libraries(pdftohtml goo fofi splash
+                        ${PNG_LIBRARY}
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY} ${PNG_LIBRARIES}
+			Threads::Threads)
+  install(TARGETS pdftohtml RUNTIME DESTINATION bin)
+  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftohtml.1 DESTINATION man/man1)
+endif ()
+
+#--- pdfinfo
+
+add_executable(pdfinfo
+  $<TARGET_OBJECTS:xpdf_objs>
+  pdfinfo.cc
+)
+target_link_libraries(pdfinfo goo fofi ${LCMS_LIBRARY} ${PNG_LIBRARY} Threads::Threads)
+install(TARGETS pdfinfo RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfinfo.1 DESTINATION man/man1)
+
+#--- pdffonts
+
+add_executable(pdffonts
+  $<TARGET_OBJECTS:xpdf_objs>
+  pdffonts.cc
+)
+target_link_libraries(pdffonts goo fofi ${LCMS_LIBRARY} ${PNG_LIBRARY} Threads::Threads)
+install(TARGETS pdffonts RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdffonts.1 DESTINATION man/man1)
+
+#--- pdfdetach
+
+add_executable(pdfdetach
+  $<TARGET_OBJECTS:xpdf_objs>
+  pdfdetach.cc
+)
+target_link_libraries(pdfdetach goo fofi ${LCMS_LIBRARY} ${PNG_LIBRARY} Threads::Threads)
+install(TARGETS pdfdetach RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfdetach.1 DESTINATION man/man1)
+
+#--- pdftoppm
+
+if (HAVE_SPLASH)
+  add_executable(pdftoppm
+    $<TARGET_OBJECTS:xpdf_objs>
+    SplashOutputDev.cc
+    pdftoppm.cc
+  )
+  target_link_libraries(pdftoppm goo fofi splash
+                        ${PNG_LIBRARY}
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY}
+			Threads::Threads)
+  install(TARGETS pdftoppm RUNTIME DESTINATION bin)
+  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftoppm.1 DESTINATION man/man1)
+endif ()
+
+#--- pdftopng
+
+if (HAVE_SPLASH AND PNG_FOUND)
+  add_executable(pdftopng
+    $<TARGET_OBJECTS:xpdf_objs>
+    SplashOutputDev.cc
+    pdftopng.cc
+  )
+  target_link_libraries(pdftopng goo fofi splash
+                        ${PNG_LIBRARY}
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY} ${PNG_LIBRARIES} Threads::Threads)
+  install(TARGETS pdftopng RUNTIME DESTINATION bin)
+  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftopng.1 DESTINATION man/man1)
+endif ()
+
+#--- pdfimages
+
+add_executable(pdfimages
+  $<TARGET_OBJECTS:xpdf_objs>
+  ImageOutputDev.cc
+  pdfimages.cc
+)
+target_link_libraries(pdfimages goo fofi ${LCMS_LIBRARY} ${PNG_LIBRARY} Threads::Threads)
+install(TARGETS pdfimages RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfimages.1 DESTINATION man/man1)
+
+#--- xpdfrc man page
+
+install(FILES ${PROJECT_SOURCE_DIR}/doc/xpdfrc.5 DESTINATION man/man5)
Index: gs2-extensions/xpdf-tools/trunk/src/setup.bash
===================================================================
--- gs2-extensions/xpdf-tools/trunk/src/setup.bash	(revision 32227)
+++ gs2-extensions/xpdf-tools/trunk/src/setup.bash	(revision 32228)
@@ -1,3 +1,3 @@
-# GEXTPARALLELBUILDING
+# GEXT: XPDFTOOLS
 
 extdesc="the Xpdf-Tools Extension"
@@ -58,9 +58,15 @@
     export GSDLEXTS=$GSDLEXTS:$extdir
   fi
-
-  echo "+Your environment is now setup for $extdesc in Greenstone"
+  if [ "x$1" != "xsilent" ] ; then
+      echo "+Your environment is now setup for $extdesc in Greenstone"
+  fi
 else
-  echo "+Your environment is already setup for $extdesc in Greenstone"
+    if [ "x$1" != "xsilent" ] ; then
+	echo "+Your environment is already setup for $extdesc in Greenstone"
+    fi
 fi
 
-
+# From http://trac.greenstone.org/browser/other-projects/trunk/realistic-books/setup.bash
+if [ -e devel.sh ] ; then
+    source devel.sh $*
+fi
