Changeset 32237 for gs2-extensions/xpdf-tools/trunk
- Timestamp:
- 2018-07-05T19:38:36+12:00 (6 years ago)
- Location:
- gs2-extensions/xpdf-tools/trunk/src/packages
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/XPDFTOOLS.sh
r32235 r32237 72 72 -DCMAKE_CXX_FLAGS="$CXXFLAGS" \ 73 73 -DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS" \ 74 -DGSDLFLAG_STATIC_BUILD="true" \ 74 75 $GEXT_XPDFTOOLS/packages/$package$version 75 76 fi ; \ … … 94 95 # -DPNG_LIBRARY=$prefix/lib/libpng15.a \ 95 96 # -DFREETYPE_LIBRARY=$prefix/lib/libfreetype.a \ 96 # else, in place of FREETYPE_LIBRARY: 97 # And throw in -DGSDLFLAG_STATIC_BUILD="true" 98 # In place of FREETYPE_LIBRARY, could also try the following (then check built bins 99 # by running ldd and file over them): 97 100 ## -DFREETYPE_DIR=$prefix \ 101 98 102 99 103 ## When -DFREETYPE_DIR is used in place of -DFREETYPE_LIBRARY above, it makes … … 113 117 # -DPNG_LIBRARY=$prefix/lib/libpng15.so.15.30.0 \ 114 118 # -DFREETYPE_LIBRARY=$prefix/lib/libfreetype.so.6.3.20 \ 115 119 # The above is for building dynamic xpdf-tools executables. For which, also don't 120 # pass in -DGSDLFLAG_STATIC_BUILD="true" (remove the line, don't comment it out, nor 121 # set the value to false) 116 122 117 123 # If compilation was successful, then we don't need cmake binaries anymore when -
gs2-extensions/xpdf-tools/trunk/src/packages/gs-CMakeLists.txt
r32234 r32237 19 19 include_directories("${PROJECT_SOURCE_DIR}/fofi") 20 20 include_directories("${PROJECT_SOURCE_DIR}/splash") 21 22 if(GSDLFLAG_STATIC_BUILD) 23 message(STATUS "@@@@ GSDLFLAG_STATIC_BUILD SET. Building xpdf-tools statically.") 24 else () 25 message(STATUS "@@@@ GSDLFLAG_STATIC_BUILD not SET. Building dynamically using xpdf-tools' (mostly) original, unmodified linker flags.") 26 endif () 21 27 if (PNG_FOUND) 22 28 include_directories("${PNG_INCLUDE_DIRS}") … … 35 41 include_directories("${LCMS_INCLUDE_DIR}") 36 42 set(COLOR_MANAGER_SOURCE "ColorManager.cc") 43 if(GSDLFLAG_STATIC_BUILD) 44 # Untested combination, warn https://cmake.org/cmake/help/v3.0/command/message.html 45 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. @@@@@@@@@@@@@@@") 46 endif () 37 47 else () 38 48 set(COLOR_MANAGER_SOURCE "") 39 49 endif () 40 50 if (TYPE_LIBRARY) 51 if(GSDLFLAG_STATIC_BUILD) 52 # Untested combination, warn 53 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. @@@@@@@@@@@@@@@") 54 endif () 55 endif () 41 56 add_library(xpdf_objs OBJECT 42 57 AcroForm.cc … … 114 129 # Want to make the min number of changes for building statically, so using the way 115 130 # below. Beware, must *append* "-static" to existing CMAKE_EXE_LINKER_FLAGS=LD_FLAGS 116 SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")117 SET(BUILD_SHARED_LIBS OFF)118 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")131 ##SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a") 132 ##SET(BUILD_SHARED_LIBS OFF) 133 ##SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") 119 134 120 135 # The original, unmodified CMakeLists.txt was not set up sufficiently … … 126 141 # found googling cmake and "-lpthread" (pthread) after ERRORS to do with this, like: 127 142 # undefined reference to `pthread_mutex_unlock' 128 set(THREADS_PREFER_PTHREAD_FLAG ON)129 find_package(Threads REQUIRED)143 ##set(THREADS_PREFER_PTHREAD_FLAG ON) 144 ##find_package(Threads REQUIRED) 130 145 131 146 #--- pdftops … … 138 153 SplashOutputDev.cc 139 154 pdftops.cc 140 ) 141 target_link_libraries(pdftops goo fofi splash 155 ) 156 if(GSDLFLAG_STATIC_BUILD) 157 target_link_libraries(pdftops goo fofi splash 158 -static -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -lz -lm -lc -lpthread) 159 # Threads::Threads instead of -lpthread results in a partially dynamic executable 160 else () 161 target_link_libraries(pdftops goo fofi splash 142 162 ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS} 143 ${ZLIB_LIBRARIES}144 163 ${DTYPE_LIBRARY} 145 164 ${LCMS_LIBRARY} 146 Threads::Threads) 165 ${ZLIB_LIBRARIES}) 166 endif () 147 167 else () 148 168 add_executable(pdftops … … 152 172 pdftops.cc 153 173 ) 154 target_link_libraries(pdftops goo fofi ${LCMS_LIBRARY} Threads::Threads) 174 if(GSDLFLAG_STATIC_BUILD) 175 target_link_libraries(pdftops goo fofi -static ${LCMS_LIBRARY} -lm -lc -lpthread) 176 else () 177 target_link_libraries(pdftops goo fofi ${LCMS_LIBRARY}) 178 endif () 155 179 endif () 156 180 install(TARGETS pdftops RUNTIME DESTINATION bin) … … 164 188 pdftotext.cc 165 189 ) 166 target_link_libraries(pdftotext goo fofi ${LCMS_LIBRARY} Threads::Threads) 190 if(GSDLFLAG_STATIC_BUILD) 191 target_link_libraries(pdftotext goo fofi -static ${LCMS_LIBRARY} -lpthread) 192 # Threads::Threads instead of -lpthread results in a partially dynamic executable 193 else () 194 target_link_libraries(pdftotext goo fofi ${LCMS_LIBRARY}) 195 endif () 167 196 install(TARGETS pdftotext RUNTIME DESTINATION bin) 168 197 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftotext.1 DESTINATION man/man1) … … 178 207 pdftohtml.cc 179 208 ) 180 target_link_libraries(pdftohtml goo fofi splash 209 if(GSDLFLAG_STATIC_BUILD) 210 target_link_libraries(pdftohtml goo fofi splash 211 -static -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -lpng -lz -lm -lc -lpthread) 212 else () 213 target_link_libraries(pdftohtml goo fofi splash 214 ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS} 215 ${DTYPE_LIBRARY} 216 ${LCMS_LIBRARY} ${PNG_LIBRARIES}) 217 endif () 218 # Doing the regular target_link_libraries() in static mode results in building with 219 # "-Wl,-Bstatic -lfreetype -lpng15 -lz -Wl,-Bdynamic -lpthread" at end of link line 220 # and produces broken binaries for pdftohtml/pdftoppm/pdftops/pdftopng. 221 # Note that PNG_LIBRARIES includes zlib/lz: "-lpng -lz", and along with freetype, 222 # these are linked statically. However, Threads/lpthread is included as a dynamically 223 # linked library instead of including a .a (regardless of whether it's appended 224 # as -lpthread or Threads::Threads in else above), contributing to the pdfhtml binary 225 # produced being a partially static, partially dynamic one, 226 # so a dynamic executable overall. 227 # The order of dynamic .so files listed by ldd in the broken binary differs from 228 # a manually linked working version of pdftohtml, and seems to be the only difference 229 # between the two in ldd output. Not using "-Wl,-Bstatic" and using -static in its 230 # place creates a partially static dynamic executable that isn't broken, whereas 231 # additionally removing "-Wl,-Bdynamic -lpthread" and replacing it with -lpthread 232 # moreover produces a working pdftohtml that is a fully static linked executable. 233 # The inclusion of the math lib and c lib (lm and lc) in the final link command 234 # are to completely bypass the remaining .so dependencies that were present in 235 # the executable and produce the fully static executable. 236 # Not sure what colormanager (lcms) and typelibrary, or how they're written in -l 237 # form as they were not present when the original unmodified static linking command 238 # was run, so they've not been included in the replacement static linking command. 239 install(TARGETS pdftohtml RUNTIME DESTINATION bin) 240 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftohtml.1 DESTINATION man/man1) 241 endif () 242 243 #--- pdfinfo 244 245 add_executable(pdfinfo 246 $<TARGET_OBJECTS:xpdf_objs> 247 pdfinfo.cc 248 ) 249 if(GSDLFLAG_STATIC_BUILD) 250 target_link_libraries(pdfinfo goo fofi -static ${LCMS_LIBRARY} -lpthread) 251 else () 252 target_link_libraries(pdfinfo goo fofi ${LCMS_LIBRARY}) 253 endif() 254 install(TARGETS pdfinfo RUNTIME DESTINATION bin) 255 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfinfo.1 DESTINATION man/man1) 256 257 #--- pdffonts 258 259 add_executable(pdffonts 260 $<TARGET_OBJECTS:xpdf_objs> 261 pdffonts.cc 262 ) 263 if(GSDLFLAG_STATIC_BUILD) 264 target_link_libraries(pdffonts goo fofi -static ${LCMS_LIBRARY} -lpthread) 265 else () 266 target_link_libraries(pdffonts goo fofi ${LCMS_LIBRARY}) 267 endif () 268 install(TARGETS pdffonts RUNTIME DESTINATION bin) 269 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdffonts.1 DESTINATION man/man1) 270 271 #--- pdfdetach 272 273 add_executable(pdfdetach 274 $<TARGET_OBJECTS:xpdf_objs> 275 pdfdetach.cc 276 ) 277 if(GSDLFLAG_STATIC_BUILD) 278 target_link_libraries(pdfdetach goo fofi -static ${LCMS_LIBRARY} -lpthread) 279 else () 280 target_link_libraries(pdfdetach goo fofi ${LCMS_LIBRARY}) 281 endif () 282 install(TARGETS pdfdetach RUNTIME DESTINATION bin) 283 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfdetach.1 DESTINATION man/man1) 284 285 #--- pdftoppm 286 287 if (HAVE_SPLASH) 288 add_executable(pdftoppm 289 $<TARGET_OBJECTS:xpdf_objs> 290 SplashOutputDev.cc 291 pdftoppm.cc 292 ) 293 if(GSDLFLAG_STATIC_BUILD) 294 target_link_libraries(pdftoppm goo fofi splash 295 -static -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -lz -lm -lc -lpthread) 296 else () 297 target_link_libraries(pdftoppm goo fofi splash 181 298 ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS} 182 299 ${DTYPE_LIBRARY} 183 ${LCMS_LIBRARY} ${PNG_LIBRARIES}184 Threads::Threads)185 install(TARGETS pdftohtml RUNTIME DESTINATION bin)186 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftohtml.1 DESTINATION man/man1)187 endif ()188 189 #--- pdfinfo190 191 add_executable(pdfinfo192 $<TARGET_OBJECTS:xpdf_objs>193 pdfinfo.cc194 )195 target_link_libraries(pdfinfo goo fofi ${LCMS_LIBRARY} Threads::Threads)196 install(TARGETS pdfinfo RUNTIME DESTINATION bin)197 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfinfo.1 DESTINATION man/man1)198 199 #--- pdffonts200 201 add_executable(pdffonts202 $<TARGET_OBJECTS:xpdf_objs>203 pdffonts.cc204 )205 target_link_libraries(pdffonts goo fofi ${LCMS_LIBRARY} Threads::Threads)206 install(TARGETS pdffonts RUNTIME DESTINATION bin)207 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdffonts.1 DESTINATION man/man1)208 209 #--- pdfdetach210 211 add_executable(pdfdetach212 $<TARGET_OBJECTS:xpdf_objs>213 pdfdetach.cc214 )215 target_link_libraries(pdfdetach goo fofi ${LCMS_LIBRARY} Threads::Threads)216 install(TARGETS pdfdetach RUNTIME DESTINATION bin)217 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfdetach.1 DESTINATION man/man1)218 219 #--- pdftoppm220 221 if (HAVE_SPLASH)222 add_executable(pdftoppm223 $<TARGET_OBJECTS:xpdf_objs>224 SplashOutputDev.cc225 pdftoppm.cc226 )227 target_link_libraries(pdftoppm goo fofi splash228 ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}229 ${ZLIB_LIBRARIES}230 ${DTYPE_LIBRARY}231 300 ${LCMS_LIBRARY} 232 Threads::Threads) 301 ${ZLIB_LIBRARIES}) 302 endif () 233 303 install(TARGETS pdftoppm RUNTIME DESTINATION bin) 234 304 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftoppm.1 DESTINATION man/man1) … … 243 313 pdftopng.cc 244 314 ) 245 target_link_libraries(pdftopng goo fofi splash 315 if(GSDLFLAG_STATIC_BUILD) 316 target_link_libraries(pdftopng goo fofi splash 317 -static -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -lpng -lz -lm -lc -lpthread) 318 else () 319 target_link_libraries(pdftopng goo fofi splash 246 320 ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS} 247 321 ${DTYPE_LIBRARY} 248 ${LCMS_LIBRARY} ${PNG_LIBRARIES} 249 Threads::Threads)322 ${LCMS_LIBRARY} ${PNG_LIBRARIES}) 323 endif () 250 324 install(TARGETS pdftopng RUNTIME DESTINATION bin) 251 325 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftopng.1 DESTINATION man/man1) … … 259 333 pdfimages.cc 260 334 ) 261 target_link_libraries(pdfimages goo fofi ${LCMS_LIBRARY} Threads::Threads) 335 if(GSDLFLAG_STATIC_BUILD) 336 target_link_libraries(pdfimages goo fofi -static ${LCMS_LIBRARY} -lpthread) 337 else () 338 target_link_libraries(pdfimages goo fofi ${LCMS_LIBRARY}) 339 endif () 262 340 install(TARGETS pdfimages RUNTIME DESTINATION bin) 263 341 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfimages.1 DESTINATION man/man1)
Note:
See TracChangeset
for help on using the changeset viewer.