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
RevLine 
[32227]1#!/bin/bash
2
3# only going to make xpdf-tools, not xpdf-reader. So not making all of xpdf
[32234]4package=xpdf
[32227]5version=-4.00
6
7progname=$0
8
9source ../cascade-make/lib/cascade-lib.bash GEXT_XPDFTOOLS ../.. $*
10
[32228]11# GEXT XDFTOOLS INSTALLED location is this GEXT's GSDLOS subdir
[32227]12prefix=$GEXTXPDFTOOLS_INSTALLED
13
[32256]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`
[32272]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
[32256]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
[32230]29# Use C/CPP/CXX FLAGS and LDFLAGS for further setting up
[32228]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"
[32256]33export CXXFLAGS="$CXXFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include -I$GEXTXPDFTOOLS_INSTALLED/include/libpng15 $arch"
[32228]34export LDFLAGS="$LDFLAGS -L$GEXTXPDFTOOLS_INSTALLED/lib"
[32227]35
[32248]36# See section D, 4c of the GS-README of this extension.
[32246]37if [ "x$GSDLOS" == "xdarwin" ] ; then
38 static_flag=-Bstatic
39else
40 static_flag=-static
41fi
[32227]42
43opt_run_untar $force_untar $auto_untar $package $version
44
[32249]45# patch the original tarball with our custom CMake configure/makefile
[32234]46if [[ -d "$package$version/xpdf" && -f "gs-CMakeLists.txt" ]]; then
47 echo "*******************************************************************"
[32249]48 echo "Using our custom gs-CMakeLists.txt instead of the one included in the xpdf subfolder of $package$version"
[32234]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
[32227]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
[32230]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.
[32228]71# TO AVOID building xpdf(reader), turn off finding Qt libs with the cmake flags below
[32227]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
[32230]81 # see xpdf-tools src code's INSTALL file for these options
[32227]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 \
[32249]87 -DTIFF_INCLUDE_DIR=$prefix/include \
88 -DJPEG_INCLUDE_DIR=$prefix/include \
[32233]89 -DZLIB_LIBRARY=$prefix/lib/libz.a \
[32249]90 -DTIFF_LIBRARY=$prefix/lib/libtiff.a \
[32233]91 -DPNG_LIBRARY=$prefix/lib/libpng15.a \
[32249]92 -DJPEG_LIBRARY=$prefix/lib/libjpeg.a \
[32235]93 -DFREETYPE_LIBRARY=$prefix/lib/libfreetype.a \
[32227]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" \
[32246]99 -DGSDLFLAG_STATIC="$static_flag" \
[32227]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
[32228]117
[32249]118
[32248]119## If compiling statically make sure the above CMake command contains the following
120## with these values:
[32230]121# -DZLIB_LIBRARY=$prefix/lib/libz.a \
[32249]122# -DTIFF_LIBRARY=$prefix/lib/libtiff.a \
[32230]123# -DPNG_LIBRARY=$prefix/lib/libpng15.a \
[32249]124# -DJPEG_LIBRARY=$prefix/lib/libjpeg.a \
[32230]125# -DFREETYPE_LIBRARY=$prefix/lib/libfreetype.a \
[32248]126# and
127# -DGSDLFLAG_STATIC="$static_flag" \
[32230]128
[32237]129
[32249]130## For building dynamic xpdf-tools executables, change the above to have the following instead
[32256]131## The .so for LIBJPEG gets generated for libjpeg version 9c (but not 6b). Correct the .so version number below.
[32228]132# -DZLIB_LIBRARY=$prefix/lib/libz.so.1.2.7 \
[32249]133# -DTIFF_LIBRARY=$prefix/lib/libtiff.so.5.2.2 \
[32228]134# -DPNG_LIBRARY=$prefix/lib/libpng15.so.15.30.0 \
[32256]135# -DJPEG_LIBRARY=$prefix/lib/libjpeg.so.PUT_THE_NUMBER_HERE \
[32228]136# -DFREETYPE_LIBRARY=$prefix/lib/libfreetype.so.6.3.20 \
[32248]137# (The 3rd line can alternatively be "-DFREETYPE_DIR=$prefix")
[32249]138# And REMOVE the following line. Don't comment it out, nor set it to "", but remove it:
[32248]139# -DGSDLFLAG_STATIC="$static_flag" \
[32228]140
[32248]141
[32228]142# If compilation was successful, then we don't need cmake binaries anymore when
[32249]143# packaging up xpdf-tools. Move them away from the distribution area:
[32239]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.