Ignore:
Timestamp:
2018-07-06T21:31:53+12:00 (6 years ago)
Author:
ak19
Message:
  1. Overhaul to the GS-README for the xpdf-tools extension. 2. Moved a lot of verbose comments that explain reasonings behind doing things from gs-CMakeLists.txt and somewhat from XPDFTOOLS.sh
File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs2-extensions/xpdf-tools/trunk/src/packages/gs-CMakeLists.txt

    r32247 r32248  
    1010
    1111#========================================================================
    12 # This is a customised version of Xpdf Tools' CMake file.
    13 # Customised for Greenstone.
     12# This is a customised version of Xpdf Tools' CMake file for Greenstone
     13# where we want to build static xpdf-tools executables.
     14# Refer to the GS-README.txt file for the Greenstone "xpdf-tools"
     15# gs2-extension and read section D for the GS specific customisations
     16# in this file and the reasoning behind them, most of which have to do
     17# with attempting to successfully build xpdf-tools statically.
    1418#========================================================================
    1519
     
    2125
    2226
    23 # For Mac OSX, when -static is passed in for linking, we end up with the error "ld: library not found for -lcrt0.o"
    24 # See https://stackoverflow.com/questions/3801011/ld-library-not-found-for-lcrt0-o-on-osx-10-6-with-gcc-clang-static-flag
    25 # On Mac OSX, compile it with -Bstatic, as per https://stackoverflow.com/questions/844819/how-to-static-link-on-os-x
    26 # XPDFTOOLS.sh will have set the GSDLFLAG_STATIC to either "-static" (for linux) or "-Bstatic" for darwin
     27# When compiling statically, XPDFTOOLS.sh will have set the custom
     28# GSDLFLAG_STATIC flag to either "-static" for linux or "-Bstatic" for darwin
    2729
    2830if(GSDLFLAG_STATIC)
     
    131133endif ()
    132134
    133 # We want to build static xpdf-tools binaries. See
    134 # https://stackoverflow.com/questions/24648357/compiling-a-static-executable-with-cmake
    135 # Want to make the min number of changes for building statically, so using the way
    136 # below. Beware, must *append* "-static" to existing CMAKE_EXE_LINKER_FLAGS=LD_FLAGS
    137 ##SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
    138 ##SET(BUILD_SHARED_LIBS OFF)
    139 ##SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
    140 
    141 # The original, unmodified CMakeLists.txt was not set up sufficiently
    142 # for static compilation of xpdf-tools. As a result, compile would first fail
    143 # with errors about undefined refs to mutex / lpthread.
    144 # When building xpdf-tools statically, need to add the following 2 lines as well
    145 # as append "Threads::Threads" to the end of each "target_link_libraries(<list>)"
    146 # See https://stackoverflow.com/questions/1620918/cmake-and-libpthread
    147 # found googling cmake and "-lpthread" (pthread) after ERRORS to do with this, like:
    148 #   undefined reference to `pthread_mutex_unlock'
    149 ##set(THREADS_PREFER_PTHREAD_FLAG ON)
    150 ##find_package(Threads REQUIRED)
    151 
    152135#--- pdftops
    153136
     
    222205                          ${LCMS_LIBRARY} ${PNG_LIBRARIES})
    223206  endif ()
    224 # Doing the regular target_link_libraries() in static mode results in building with
    225 # "-Wl,-Bstatic -lfreetype -lpng15 -lz -Wl,-Bdynamic -lpthread" at end of link line
    226 # and produces broken binaries for pdftohtml/pdftoppm/pdftops/pdftopng.
    227 # Note that PNG_LIBRARIES includes zlib/lz: "-lpng -lz", and along with freetype,
    228 # these are linked statically. However, Threads/lpthread is included as a dynamically
    229 # linked library instead of including a .a (regardless of whether it's appended
    230 # as -lpthread or Threads::Threads in else above), contributing to the pdfhtml binary
    231 # produced being a partially static, partially dynamic one,
    232 # so a dynamic executable overall.
    233 # The order of dynamic .so files listed by ldd in the broken binary differs from
    234 # a manually linked working version of pdftohtml, and seems to be the only difference
    235 # between the two in ldd output. Not using "-Wl,-Bstatic" and using -static (-Bstatic on Mac)
    236 # in its place creates a partially static dynamic executable that isn't broken, whereas
    237 # additionally removing "-Wl,-Bdynamic -lpthread" and replacing it with -lpthread
    238 # moreover produces a working pdftohtml that is a fully static linked executable.
    239 # The inclusion of the math lib and c lib (lm and lc) in the final link command
    240 # are to completely bypass the remaining .so dependencies that were present in
    241 # the executable and produce the fully static executable.
    242 # Not sure what colormanager (lcms) and typelibrary, or how they're written in -l
    243 # form as they were not present when the original unmodified static linking command
    244 # was run, so they've not been included in the replacement static linking command.
    245207  install(TARGETS pdftohtml RUNTIME DESTINATION bin)
    246208  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftohtml.1 DESTINATION man/man1)
Note: See TracChangeset for help on using the changeset viewer.