root/gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/XPDFTOOLS.sh @ 32256

Revision 32256, 5.8 KB (checked in by sjm84, 8 months ago)

Changes to get xpdftools compiled up on the 32 bit linux LSB, since 32 bit xpdftools binaries is what we hope to use on both 32 and 64 bit machines.

  • Property svn:executable set to *
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# When trying to compile xpdf-tools on a 32 bit linux LSB, we get the error
15# "undefined reference to `__sync_add_and_fetch_4'" unless we follow the instructions at
16# https://stackoverflow.com/questions/130740/link-error-when-compiling-gcc-atomic-operation-in-32-bit-mode
17# and append to CXXFLAGS "-march=i486", which is the earliest architecture for which compilation
18# succeeds and the xpdftool binaries produced work (even though our 32 bit LSB is i686).
19arch=`uname -m`
20if [[ $arch = *"64"* ]]; then
21    arch=
22else
23    echo "@@@ 32 bit unix, passing in -march=i486 to avoid certain linking errors"
24    arch="-march=i486"
25fi
26
27# Use C/CPP/CXX FLAGS and LDFLAGS for further setting up
28# libpng and libz for compiling xpdftools
29export CFLAGS="$CFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include -I$GEXTXPDFTOOLS_INSTALLED/include/libpng15"
30export CPPFLAGS="$CPPFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include -I$GEXTXPDFTOOLS_INSTALLED/include/libpng15"
31export CXXFLAGS="$CXXFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include -I$GEXTXPDFTOOLS_INSTALLED/include/libpng15 $arch"
32export LDFLAGS="$LDFLAGS -L$GEXTXPDFTOOLS_INSTALLED/lib"
33
34# See section D, 4c of the GS-README of this extension.
35if [ "x$GSDLOS" == "xdarwin" ] ; then
36    static_flag=-Bstatic
37else
38    static_flag=-static
39fi
40
41opt_run_untar $force_untar $auto_untar $package $version
42
43# patch the original tarball with our custom CMake configure/makefile
44if [[ -d "$package$version/xpdf" && -f "gs-CMakeLists.txt" ]]; then
45    echo "*******************************************************************"
46    echo "Using our custom gs-CMakeLists.txt instead of the one included in the xpdf subfolder of $package$version"
47    echo "Renaming gs-CMakeLists.txt to $package$version/xpdf/CMakeLists.txt"
48    echo "*******************************************************************"
49
50    cp "gs-CMakeLists.txt" "$package$version/xpdf/CMakeLists.txt"
51fi
52
53# Whether force_config is set for this package depends on CMake test
54# to see if 'release' directory has been created or not
55if [ $auto_config = "1" ] ; then
56  if [ ! -d $package$version/release ] ; then
57    force_config=1
58  fi
59fi
60
61echo "Using cmake: "
62echo `which cmake`
63
64# The xpdf-tools src code's INSTALL instructions say we need to create a 'build' dir,
65# cd into there and then run cmake from there, providing the xpdf-tools src dir
66# However, doing so breaks the way cascade-lib.bash runs a CMake compile sequence.
67# cascade-lib.bash wants a 'release' directory, so do it the cascade-make way as
68# that works.
69# TO AVOID building xpdf(reader), turn off finding Qt libs with the cmake flags below
70if [ $force_config = "1" ] ; then
71  echo "[pushd $package$version]"
72  ( cd $package$version ; \
73    if [ ! -d release ] ; then \
74      echo "Creating 'release' directory" ; \
75      mkdir release ; \
76    fi ; \
77    cd release ; \
78
79    # see xpdf-tools src code's INSTALL file for these options
80    if [ ! -f Makefile ] ; then \
81      #cmake -D CMAKE_BUILD_TYPE=RELEASE \
82      #      -D CMAKE_INSTALL_PREFIX=$prefix ..;
83    cmake -DCMAKE_BUILD_TYPE=Release \
84        -DCMAKE_INSTALL_PREFIX=$prefix \
85        -DTIFF_INCLUDE_DIR=$prefix/include \
86        -DJPEG_INCLUDE_DIR=$prefix/include \
87        -DZLIB_LIBRARY=$prefix/lib/libz.a \
88        -DTIFF_LIBRARY=$prefix/lib/libtiff.a \
89        -DPNG_LIBRARY=$prefix/lib/libpng15.a \
90        -DJPEG_LIBRARY=$prefix/lib/libjpeg.a \
91        -DFREETYPE_LIBRARY=$prefix/lib/libfreetype.a \
92        -DCMAKE_DISABLE_FIND_PACKAGE_Qt4=1 \
93        -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Widgets=1 \
94        -DCMAKE_C_FLAGS="$CFLAGS" \
95        -DCMAKE_CXX_FLAGS="$CXXFLAGS" \
96        -DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS" \
97        -DGSDLFLAG_STATIC="$static_flag" \
98        $GEXT_XPDFTOOLS/packages/$package$version
99    fi ; \
100    PKG_CONFIG_PATH=$prefix/lib/pkgconfig:${PKG_CONFIG_PATH}; \
101    export PKG_CONFIG_PATH; \
102   )
103  if [ $? != 0 ] ; then
104      echo "      Error encountered running *configure* stage of $progname"
105      exit 1
106  fi
107  echo "[popd]"
108  opt_run_cmake $compile $package $version "release"
109  opt_run_cmake $install $package $version "release" "install"
110else
111  if [ $auto_config = "1" ] ; then
112    echo "Found top-level for ${progname%.*} => no need to run configure/initialize CMake"
113  fi
114fi
115
116
117## If compiling statically make sure the above CMake command contains the following
118## with these values:
119#       -DZLIB_LIBRARY=$prefix/lib/libz.a \
120#       -DTIFF_LIBRARY=$prefix/lib/libtiff.a \
121#       -DPNG_LIBRARY=$prefix/lib/libpng15.a \
122#       -DJPEG_LIBRARY=$prefix/lib/libjpeg.a \
123#       -DFREETYPE_LIBRARY=$prefix/lib/libfreetype.a \
124# and
125#       -DGSDLFLAG_STATIC="$static_flag" \
126
127
128## For building dynamic xpdf-tools executables, change the above to have the following instead
129## The .so for LIBJPEG gets generated for libjpeg version 9c (but not 6b). Correct the .so version number below.
130#       -DZLIB_LIBRARY=$prefix/lib/libz.so.1.2.7 \
131#       -DTIFF_LIBRARY=$prefix/lib/libtiff.so.5.2.2 \
132#       -DPNG_LIBRARY=$prefix/lib/libpng15.so.15.30.0 \
133#       -DJPEG_LIBRARY=$prefix/lib/libjpeg.so.PUT_THE_NUMBER_HERE \
134#       -DFREETYPE_LIBRARY=$prefix/lib/libfreetype.so.6.3.20 \
135# (The 3rd line can alternatively be "-DFREETYPE_DIR=$prefix")
136# And REMOVE the following line. Don't comment it out, nor set it to "", but remove it:
137#       -DGSDLFLAG_STATIC="$static_flag" \
138
139
140# If compilation was successful, then we don't need cmake binaries anymore when
141# packaging up xpdf-tools. Move them away from the distribution area:
142
143if [ -f "$GEXTXPDFTOOLS_INSTALLED/bin/pdftohtml" ]; then
144    echo "**************************************"
145    echo "Moving intermediary CMake products out of the distribution area"
146    $GEXT_XPDFTOOLS/move-cmake.sh away
147    echo "**************************************"
148fi
Note: See TracBrowser for help on using the browser.