Index: gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/XPDFTOOLS.sh
===================================================================
--- gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/XPDFTOOLS.sh	(revision 32236)
+++ gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/XPDFTOOLS.sh	(revision 32237)
@@ -72,4 +72,5 @@
 	    -DCMAKE_CXX_FLAGS="$CXXFLAGS" \
 	    -DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS" \
+	    -DGSDLFLAG_STATIC_BUILD="true" \
 	    $GEXT_XPDFTOOLS/packages/$package$version
     fi ; \
@@ -94,6 +95,9 @@
 #	    -DPNG_LIBRARY=$prefix/lib/libpng15.a \
 #	    -DFREETYPE_LIBRARY=$prefix/lib/libfreetype.a \
-# else, in place of FREETYPE_LIBRARY:
+# And throw in -DGSDLFLAG_STATIC_BUILD="true"
+# In place of FREETYPE_LIBRARY, could also try the following (then check built bins
+# by running ldd and file over them):
 ##	    -DFREETYPE_DIR=$prefix \
+
 
 ## When -DFREETYPE_DIR is used in place of -DFREETYPE_LIBRARY above, it makes
@@ -113,5 +117,7 @@
 #	    -DPNG_LIBRARY=$prefix/lib/libpng15.so.15.30.0 \
 #	    -DFREETYPE_LIBRARY=$prefix/lib/libfreetype.so.6.3.20 \
-
+# The above is for building dynamic xpdf-tools executables. For which, also don't
+# pass in -DGSDLFLAG_STATIC_BUILD="true" (remove the line, don't comment it out, nor
+# set the value to false)
 
 # If compilation was successful, then we don't need cmake binaries anymore when
Index: gs2-extensions/xpdf-tools/trunk/src/packages/gs-CMakeLists.txt
===================================================================
--- gs2-extensions/xpdf-tools/trunk/src/packages/gs-CMakeLists.txt	(revision 32236)
+++ gs2-extensions/xpdf-tools/trunk/src/packages/gs-CMakeLists.txt	(revision 32237)
@@ -19,4 +19,10 @@
 include_directories("${PROJECT_SOURCE_DIR}/fofi")
 include_directories("${PROJECT_SOURCE_DIR}/splash")
+
+if(GSDLFLAG_STATIC_BUILD)
+  message(STATUS "@@@@ GSDLFLAG_STATIC_BUILD SET. Building xpdf-tools statically.")
+else ()
+  message(STATUS "@@@@ GSDLFLAG_STATIC_BUILD not SET. Building dynamically using xpdf-tools' (mostly) original, unmodified linker flags.")
+endif ()
 if (PNG_FOUND)
   include_directories("${PNG_INCLUDE_DIRS}")
@@ -35,8 +41,17 @@
   include_directories("${LCMS_INCLUDE_DIR}")
   set(COLOR_MANAGER_SOURCE "ColorManager.cc")
+  if(GSDLFLAG_STATIC_BUILD)
+    # Untested combination, warn https://cmake.org/cmake/help/v3.0/command/message.html
+    message(AUTHOR_WARNING "@@@@@@@@@@@@@@@ GSDL Warning: static building with HAVE_LCMS on. If running ldd/file on generated binaries shows any binary to be partially a dynamic executable, then Export VERBOSE=1 and re-run the CMake build. Then check the verbose build output's linker flags (for static building) for that binary: they should not be -Wl,-Bstatic LIBS -Wl,-Bdynamic -lpthread but -static LIBS. Fix it by removing all references to LCMS_LIBRARY in the static linking flags of target_link_libraries statements (i.e. when GSDLFLAG_STATIC_BUILD is set) in file gs-CMakeLists.txt and replacing them with the -l equivalent for the color manager library, (l)cms. @@@@@@@@@@@@@@@")
+  endif ()
 else ()
   set(COLOR_MANAGER_SOURCE "")
 endif ()
-
+if (TYPE_LIBRARY)
+  if(GSDLFLAG_STATIC_BUILD)
+    # Untested combination, warn
+    message(AUTHOR_WARNING "@@@@@@@@@@@@@@@ GSDL Warning: static building with TYPE_LIBRARY. If running ldd/file on generated binaries shows any binary to be partially a dynamic executable, then export VERBOSE=1 and re-run the CMake build. Then check the verbose build output's linker flags (for static building) for that binary: they should not be -Wl,-Bstatic LIBS -Wl,-Bdynamic -lpthread but -static LIBS. Fix it by removing all references to DTYPE_LIBRARY in the static linking flags of target_link_libraries statements (i.e. when GSDLFLAG_STATIC_BUILD is set) in file gs-CMakeLists.txt and replacing them with the -l equivalent for typelib. @@@@@@@@@@@@@@@")
+  endif ()
+endif ()
 add_library(xpdf_objs OBJECT
   AcroForm.cc
@@ -114,7 +129,7 @@
 # Want to make the min number of changes for building statically, so using the way
 # below. Beware, must *append* "-static" to existing CMAKE_EXE_LINKER_FLAGS=LD_FLAGS
-SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
-SET(BUILD_SHARED_LIBS OFF)
-SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
+##SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
+##SET(BUILD_SHARED_LIBS OFF)
+##SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
 
 # The original, unmodified CMakeLists.txt was not set up sufficiently
@@ -126,6 +141,6 @@
 # found 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)
+##set(THREADS_PREFER_PTHREAD_FLAG ON)
+##find_package(Threads REQUIRED)
 
 #--- pdftops
@@ -138,11 +153,16 @@
     SplashOutputDev.cc
     pdftops.cc
-  )
-  target_link_libraries(pdftops goo fofi splash
+  )  
+  if(GSDLFLAG_STATIC_BUILD)
+    target_link_libraries(pdftops goo fofi splash
+      -static -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -lz -lm -lc -lpthread)
+    # Threads::Threads instead of -lpthread results in a partially dynamic executable
+  else ()
+    target_link_libraries(pdftops goo fofi splash
                         ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
-			${ZLIB_LIBRARIES}
                         ${DTYPE_LIBRARY}
                         ${LCMS_LIBRARY}
-			Threads::Threads)
+			${ZLIB_LIBRARIES})
+  endif ()
 else ()
   add_executable(pdftops
@@ -152,5 +172,9 @@
     pdftops.cc
   )
-  target_link_libraries(pdftops goo fofi ${LCMS_LIBRARY} Threads::Threads)
+  if(GSDLFLAG_STATIC_BUILD)
+    target_link_libraries(pdftops goo fofi -static ${LCMS_LIBRARY} -lm -lc -lpthread)
+  else ()
+    target_link_libraries(pdftops goo fofi ${LCMS_LIBRARY})
+  endif ()
 endif ()
 install(TARGETS pdftops RUNTIME DESTINATION bin)
@@ -164,5 +188,10 @@
   pdftotext.cc
 )
-target_link_libraries(pdftotext goo fofi ${LCMS_LIBRARY} Threads::Threads)
+if(GSDLFLAG_STATIC_BUILD)
+  target_link_libraries(pdftotext goo fofi -static ${LCMS_LIBRARY} -lpthread)
+  # Threads::Threads instead of -lpthread results in a partially dynamic executable
+else ()
+  target_link_libraries(pdftotext goo fofi ${LCMS_LIBRARY})
+endif ()
 install(TARGETS pdftotext RUNTIME DESTINATION bin)
 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftotext.1 DESTINATION man/man1)
@@ -178,57 +207,98 @@
     pdftohtml.cc
   )
-  target_link_libraries(pdftohtml goo fofi splash
+  if(GSDLFLAG_STATIC_BUILD)
+    target_link_libraries(pdftohtml goo fofi splash
+      -static -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -lpng -lz -lm -lc -lpthread)
+  else ()
+    target_link_libraries(pdftohtml goo fofi splash
+                          ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                          ${DTYPE_LIBRARY}
+                          ${LCMS_LIBRARY} ${PNG_LIBRARIES})
+  endif ()
+# Doing the regular target_link_libraries() in static mode results in building with 
+# "-Wl,-Bstatic -lfreetype -lpng15 -lz -Wl,-Bdynamic -lpthread" at end of link line
+# and produces broken binaries for pdftohtml/pdftoppm/pdftops/pdftopng.
+# Note that PNG_LIBRARIES includes zlib/lz: "-lpng -lz", and along with freetype,
+# these are linked statically. However, Threads/lpthread is included as a dynamically
+# linked library instead of including a .a (regardless of whether it's appended
+# as -lpthread or Threads::Threads in else above), contributing to the pdfhtml binary
+# produced being a partially static, partially dynamic one,
+# so a dynamic executable overall.
+# The order of dynamic .so files listed by ldd in the broken binary differs from
+# a manually linked working version of pdftohtml, and seems to be the only difference
+# between the two in ldd output. Not using "-Wl,-Bstatic" and using -static in its
+# place creates a partially static dynamic executable that isn't broken, whereas
+# additionally removing "-Wl,-Bdynamic -lpthread" and replacing it with -lpthread
+# moreover produces a working pdftohtml that is a fully static linked executable.
+# The inclusion of the math lib and c lib (lm and lc) in the final link command
+# are to completely bypass the remaining .so dependencies that were present in
+# the executable and produce the fully static executable.
+# Not sure what colormanager (lcms) and typelibrary, or how they're written in -l
+# form as they were not present when the original unmodified static linking command
+# was run, so they've not been included in the replacement static linking command. 
+  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
+)
+if(GSDLFLAG_STATIC_BUILD)
+  target_link_libraries(pdfinfo goo fofi -static ${LCMS_LIBRARY} -lpthread)
+else ()
+  target_link_libraries(pdfinfo goo fofi ${LCMS_LIBRARY})
+endif()
+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
+)
+if(GSDLFLAG_STATIC_BUILD)
+  target_link_libraries(pdffonts goo fofi -static ${LCMS_LIBRARY} -lpthread)
+else ()
+  target_link_libraries(pdffonts goo fofi ${LCMS_LIBRARY})
+endif ()
+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
+)
+if(GSDLFLAG_STATIC_BUILD)
+  target_link_libraries(pdfdetach goo fofi -static ${LCMS_LIBRARY} -lpthread)
+else ()
+  target_link_libraries(pdfdetach goo fofi ${LCMS_LIBRARY})
+endif ()
+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
+  )
+  if(GSDLFLAG_STATIC_BUILD)
+    target_link_libraries(pdftoppm goo fofi splash
+      -static -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -lz -lm -lc -lpthread)
+  else ()
+    target_link_libraries(pdftoppm 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}
-			${ZLIB_LIBRARIES}
-                        ${DTYPE_LIBRARY}
                         ${LCMS_LIBRARY}
-			Threads::Threads)
+			${ZLIB_LIBRARIES})
+  endif ()
   install(TARGETS pdftoppm RUNTIME DESTINATION bin)
   install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftoppm.1 DESTINATION man/man1)
@@ -243,9 +313,13 @@
     pdftopng.cc
   )
-  target_link_libraries(pdftopng goo fofi splash
+  if(GSDLFLAG_STATIC_BUILD)
+    target_link_libraries(pdftopng goo fofi splash
+      -static -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -lpng -lz -lm -lc -lpthread)
+  else ()
+    target_link_libraries(pdftopng goo fofi splash
                         ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
                         ${DTYPE_LIBRARY}
-                        ${LCMS_LIBRARY} ${PNG_LIBRARIES}
-			Threads::Threads)
+                        ${LCMS_LIBRARY} ${PNG_LIBRARIES})
+  endif ()
   install(TARGETS pdftopng RUNTIME DESTINATION bin)
   install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftopng.1 DESTINATION man/man1)
@@ -259,5 +333,9 @@
   pdfimages.cc
 )
-target_link_libraries(pdfimages goo fofi ${LCMS_LIBRARY} Threads::Threads)
+if(GSDLFLAG_STATIC_BUILD)
+  target_link_libraries(pdfimages goo fofi -static ${LCMS_LIBRARY} -lpthread)
+else ()
+  target_link_libraries(pdfimages goo fofi ${LCMS_LIBRARY})
+endif ()
 install(TARGETS pdfimages RUNTIME DESTINATION bin)
 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfimages.1 DESTINATION man/man1)
Index: gs2-extensions/xpdf-tools/trunk/src/packages/gs-CMakeLists.txt.staticworks
===================================================================
--- gs2-extensions/xpdf-tools/trunk/src/packages/gs-CMakeLists.txt.staticworks	(revision 32236)
+++ 	(revision )
@@ -1,297 +1,0 @@
-#========================================================================
-#
-# xpdf/cmake-xpdf.txt
-#
-# CMake script for the Xpdf tools.
-#
-# Copyright 2015 Glyph & Cog, LLC
-#
-#========================================================================
-
-#========================================================================
-# This is a customised version of Xpdf Tools' CMake file.
-# Customised for Greenstone.
-#========================================================================
-
-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 "@@@@@@@@@@@@@@@ lib: ${PNG_LIBRARY}")
-  message(STATUS "@@@@@@@@@@@@@@@ libs: ${PNG_LIBRARIES}")
-  message(STATUS "@@@@@@@@@@@@@@@ freetype: ${FREETYPE_LIBRARY} - ${FREETYPE_OTHER_LIBS}")
-  include_directories("${PNG_INCLUDE_DIRS}")
-  add_definitions("${PNG_DEFINITIONS}")
-else ()
-  message(STATUS "@@@@@@@@@@@@@@@ NO PNG_FOUND")
-endif ()
-# https://stackoverflow.com/questions/36126333/mingw-cmake-undefined-reference-to-zlib
-if (ZLIB_FOUND)
-  message(STATUS "@@@@@@@@@@@@@@@ lib: ${ZLIB_LIBRARY} - ${ZLIB_LIBRARIES}")
-  include_directories("${ZLIB_INCLUDE_DIRS}")
-  add_definitions("${ZLIB_DEFINITIONS}")
-else ()
-  message(STATUS "@@@@@@@@@@@@@@@ NO ZLIB_FOUND")
-endif ()
-if (HAVE_LCMS)
-  include_directories("${LCMS_INCLUDE_DIR}")
-  set(COLOR_MANAGER_SOURCE "ColorManager.cc")
-  set(PDFTO_PS_PPM_LINK_FLAGS -static -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -lz -lm -lc -lpthread)
-  set(PDFTO_HTML_PNG_LINK_FLAGS -static -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -lpng -lz -lm -lc -lpthread)
-else ()
-  set(COLOR_MANAGER_SOURCE "")
-  set(PDFTO_PS_PPM_LINK_FLAGS -static -lfreetype ${DTYPE_LIBRARY} -lz -lm -lc -lpthread)
-  set(PDFTO_HTML_PNG_LINK_FLAGS -static -lfreetype ${DTYPE_LIBRARY} -lpng -lz -lm -lc -lpthread)
-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 the way
-# below. Beware, must *append* "-static" to existing CMAKE_EXE_LINKER_FLAGS=LD_FLAGS
-SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
-SET(BUILD_SHARED_LIBS OFF)
-SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
-
-# The original, unmodified CMakeLists.txt was not set up sufficiently
-# for static compilation of xpdf-tools. As a result, compile would first fail
-# with errors about undefined refs to mutex / lpthread.
-# When building xpdf-tools statically, need to add the following 2 lines as well
-# as append "Threads::Threads" to the end of each "target_link_libraries(<list>)"
-# See https://stackoverflow.com/questions/1620918/cmake-and-libpthread
-# found 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 ${PDFTO_PS_PPM_LINK_FLAGS})
-#    -static -lfreetype -lpng -lz -lm -lc -lpthread)
-#                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
-#			${ZLIB_LIBRARIES}
-#                        ${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 ${PDFTO_HTML_PNG_LINK_FLAGS})
-#    -static -lfreetype -lpng -lz -lm -lc -lpthread)
-#                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
-#                        ${DTYPE_LIBRARY}
-#                        ${LCMS_LIBRARY} ${PNG_LIBRARIES}
-#			Threads::Threads)
-# Doing the above builds with 
-# "-Wl,-Bstatic -lfreetype -lpng15 -lz -Wl,-Bdynamic -lpthread" at end 
-# and produces broken binaries for pdftohtml/pdftoppm/pdftops/pdftopng.
-# Note that PNG_LIBRARIES includes zlib/lz: "-lpng -lz", and with freetype, is
-# linked statically. However, Threads/lpthread is included as a dynamically
-# linked library instead of including a .a (regardless of whether it's written
-# as -lpthread or Threads::Threads above), making the pdfhtml binary produced
-# a partially static, partially dynamic one, so dynamic executable overall.
-# The order of dynamic .so files listed by ldd in the broken binary differs from
-# a manually linked working version of pdftohtml, and seems to be the only difference
-# between the two in ldd output. Not using "-Wl,-Bstatic" and using -static in its
-# place creates a partially static dynamic executable that isn't broken, whereas
-# additionally removing "-Wl,-Bdynamic -lpthread" and replacing it with -lpthread
-# moreover produces a working pdftohtml that is a fully static linked executable.
-# The inclusion of the math lib and c lib (lm and lc) in the final link command
-# are to completely bypass the remaining .so dependencies that were present in
-# the executable and produce the fully static executable.
-# Not sure what colormanager (lcms) and typelibrary, or how they're written in -l
-# form as they were not present when the original unmodified static linking command
-# was run, so they've not been included in the replacement static linking command. 
-  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 ${PDFTO_PS_PPM_LINK_FLAGS})
-#                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
-#			${ZLIB_LIBRARIES}
-#                        ${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 ${PDFTO_HTML_PNG_LINK_FLAGS})
-#                        ${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)
