source: gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/XPDFTOOLS.sh@ 32246

Last change on this file since 32246 was 32246, checked in by ak19, 6 years ago

I'm unable so far to get xpdf-tools to build statically on the mac. These are the changes to get it to build on the Mac in an attempt to make static xpdf-tools binaries. Running otool minus L on the binaries however shows that they're linking to dylib dlls, albeit our ones for freetype, libpng and zlib.

  • Property svn:executable set to *
File size: 6.1 KB
Line 
1#!/bin/bash
2
3# only going to make xpdf-tools, not xpdf-reader. So not making all of xpdf
4package=xpdf
5version=-4.00
6
7progname=$0
8
9source ../cascade-make/lib/cascade-lib.bash GEXT_XPDFTOOLS ../.. $*
10
11# GEXT XDFTOOLS INSTALLED location is this GEXT's GSDLOS subdir
12prefix=$GEXTXPDFTOOLS_INSTALLED
13
14# Use C/CPP/CXX FLAGS and LDFLAGS for further setting up
15# libpng and libz for compiling xpdftools
16export CFLAGS="$CFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include -I$GEXTXPDFTOOLS_INSTALLED/include/libpng15"
17export CPPFLAGS="$CPPFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include -I$GEXTXPDFTOOLS_INSTALLED/include/libpng15"
18export CXXFLAGS="$CXXFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include -I$GEXTXPDFTOOLS_INSTALLED/include/libpng15"
19export LDFLAGS="$LDFLAGS -L$GEXTXPDFTOOLS_INSTALLED/lib"
20
21# For Mac OSX, when -static is passed in for linking, we end up with the error "ld: library not found for -lcrt0.o"
22# See https://stackoverflow.com/questions/3801011/ld-library-not-found-for-lcrt0-o-on-osx-10-6-with-gcc-clang-static-flag
23# On Mac OSX, compile it with -Bstatic instead, as per https://stackoverflow.com/questions/844819/how-to-static-link-on-os-x
24# We will pass in the correct static variant as the custom GSDLFLAG_STATIC, so it will be set to either "-static" (for linux)
25# or "-Bstatic" for darwin when CMake starts compiling up xpdf-tools. When the GSDLFLAG_STATIC is set, it will also trigger
26# the branch of the gs-CMakeLists.txt code that does static compiling. If not set, xpdf-tools are compiled against dynamically
27# linked libraries.
28if [ "x$GSDLOS" == "xdarwin" ] ; then
29 static_flag=-Bstatic
30else
31 static_flag=-static
32fi
33
34opt_run_untar $force_untar $auto_untar $package $version
35
36# patch the original tarball with our custom makefile?
37if [[ -d "$package$version/xpdf" && -f "gs-CMakeLists.txt" ]]; then
38 echo "*******************************************************************"
39 echo "Using our custom gs-CMakeLists.txt instead of the one included in $package$version"
40 echo "Renaming gs-CMakeLists.txt to $package$version/xpdf/CMakeLists.txt"
41 echo "*******************************************************************"
42
43 cp "gs-CMakeLists.txt" "$package$version/xpdf/CMakeLists.txt"
44fi
45
46# Whether force_config is set for this package depends on CMake test
47# to see if 'release' directory has been created or not
48if [ $auto_config = "1" ] ; then
49 if [ ! -d $package$version/release ] ; then
50 force_config=1
51 fi
52fi
53
54echo "Using cmake: "
55echo `which cmake`
56
57# The xpdf-tools src code's INSTALL instructions say we need to create a 'build' dir,
58# cd into there and then run cmake from there, providing the xpdf-tools src dir
59# However, doing so breaks the way cascade-lib.bash runs a CMake compile sequence.
60# cascade-lib.bash wants a 'release' directory, so do it the cascade-make way as
61# that works.
62# TO AVOID building xpdf(reader), turn off finding Qt libs with the cmake flags below
63if [ $force_config = "1" ] ; then
64 echo "[pushd $package$version]"
65 ( cd $package$version ; \
66 if [ ! -d release ] ; then \
67 echo "Creating 'release' directory" ; \
68 mkdir release ; \
69 fi ; \
70 cd release ; \
71
72 # see xpdf-tools src code's INSTALL file for these options
73 if [ ! -f Makefile ] ; then \
74 #cmake -D CMAKE_BUILD_TYPE=RELEASE \
75 # -D CMAKE_INSTALL_PREFIX=$prefix ..;
76 cmake -DCMAKE_BUILD_TYPE=Release \
77 -DCMAKE_INSTALL_PREFIX=$prefix \
78 -DZLIB_LIBRARY=$prefix/lib/libz.a \
79 -DPNG_LIBRARY=$prefix/lib/libpng15.a \
80 -DFREETYPE_LIBRARY=$prefix/lib/libfreetype.a \
81 -DCMAKE_DISABLE_FIND_PACKAGE_Qt4=1 \
82 -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Widgets=1 \
83 -DCMAKE_C_FLAGS="$CFLAGS" \
84 -DCMAKE_CXX_FLAGS="$CXXFLAGS" \
85 -DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS" \
86 -DGSDLFLAG_STATIC="$static_flag" \
87 $GEXT_XPDFTOOLS/packages/$package$version
88 fi ; \
89 PKG_CONFIG_PATH=$prefix/lib/pkgconfig:${PKG_CONFIG_PATH}; \
90 export PKG_CONFIG_PATH; \
91 )
92 if [ $? != 0 ] ; then
93 echo " Error encountered running *configure* stage of $progname"
94 exit 1
95 fi
96 echo "[popd]"
97 opt_run_cmake $compile $package $version "release"
98 opt_run_cmake $install $package $version "release" "install"
99else
100 if [ $auto_config = "1" ] ; then
101 echo "Found top-level for ${progname%.*} => no need to run configure/initialize CMake"
102 fi
103fi
104
105# If compiling statically, need these above in place of the references to .so files
106# -DZLIB_LIBRARY=$prefix/lib/libz.a \
107# -DPNG_LIBRARY=$prefix/lib/libpng15.a \
108# -DFREETYPE_LIBRARY=$prefix/lib/libfreetype.a \
109# And throw in -DGSDLFLAG_STATIC_BUILD="-static" for linux or with "-Bstatic" for Macs
110# In place of FREETYPE_LIBRARY, could also try the following (then check built bins
111# by running ldd and file over them):
112## -DFREETYPE_DIR=$prefix \
113
114
115## When -DFREETYPE_DIR is used in place of -DFREETYPE_LIBRARY above, it makes
116## xpdf-tools compilation find the "libfreetype.so" (no versioning at end) in
117## our gs ext.
118## But -DZLIB_DIR and -DPNG_DIR are ignored because they go unrecognised, whereas
119## -DZLIB_LIBRARY and -DPNG_LIBRARY are recognised by XpdfTools' CMake files.
120## -DZLIB_LIBRARY and -DPNG_LIBRARY require full paths. So the first 2 lines of the
121## following won't work:
122# -DZLIB_DIR=$prefix \
123# -DPNG_DIR=$prefix \
124# -DFREETYPE_DIR=$prefix \
125
126## When specified in the following way, all 3 lines are recognised (freetype, zlib,
127## png). The 3rd line can alternatively still use "-DFREETYPE_DIR=$prefix"
128# -DZLIB_LIBRARY=$prefix/lib/libz.so.1.2.7 \
129# -DPNG_LIBRARY=$prefix/lib/libpng15.so.15.30.0 \
130# -DFREETYPE_LIBRARY=$prefix/lib/libfreetype.so.6.3.20 \
131# The above is for building dynamic xpdf-tools executables. For which, also don't
132# pass in -DGSDLFLAG_STATIC_BUILD="..." (remove the line, don't comment it out, nor
133# set the value to "")
134
135# If compilation was successful, then we don't need cmake binaries anymore when
136# packaging up xpdf-tools
137
138if [ -f "$GEXTXPDFTOOLS_INSTALLED/bin/pdftohtml" ]; then
139 echo "**************************************"
140 echo "Moving intermediary CMake products out of the distribution area"
141 $GEXT_XPDFTOOLS/move-cmake.sh away
142 echo "**************************************"
143fi
Note: See TracBrowser for help on using the repository browser.