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

Last change on this file was 32272, checked in by sjm84, 6 years ago

Minor change: clarifying comments before I start committing PDFPlugin restructuring related things.

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