This repository has been archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpoppler
57 lines (49 loc) · 2.16 KB
/
poppler
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
export HOMEBREW_NO_ANALYTICS=1
export HOMEBREW_NO_AUTO_UPDATE=1
# Offical Homebrew no longer supports El-Capitain
UPSTREAM_ORG="autobrew"
if [ "$DISABLE_AUTOBREW" ]; then return 0; fi
AUTOBREW=${TMPDIR-/tmp}
export HOMEBREW_TEMP="$AUTOBREW/hbtmp"
BREWDIR="$AUTOBREW/build-$PKG_BREW_NAME"
BREW="$BREWDIR/bin/brew"
rm -Rf $BREWDIR
mkdir -p $BREWDIR
echo "Auto-brewing $PKG_BREW_NAME in $BREWDIR..."
curl -fsSL https://github.com/$UPSTREAM_ORG/brew/tarball/master | tar xz --strip 1 -C $BREWDIR
# Do not build pkg-config from source, so need to override hardcoded paths
export HOMEBREW_CACHE="$AUTOBREW"
$BREW install --force-bottle pkg-config 2>&1 | perl -pe 's/Warning/Note/gi'
PKG_CONFIG="$BREWDIR/opt/pkg-config/bin/pkg-config"
PC_PATH=$($PKG_CONFIG --variable pc_path pkg-config)
PC_PATH=$(echo $PC_PATH | perl -pe "s#/usr/local/Homebrew#${BREWDIR}#gi") #HOMEBREW_LIBRARY
PC_PATH=$(echo $PC_PATH | perl -pe "s#/usr/local#${BREWDIR}#gi") #HOMEBREW_PREFIX
# Install binary builds
BREW_DEPS=$($BREW deps -n $PKG_BREW_NAME 2>/dev/null)
$BREW install --force-bottle $BREW_DEPS $PKG_BREW_NAME 2>&1 | perl -pe 's/Warning/Note/gi'
# Need to rebuild fontconfig on Mavericks
if [ $(sw_vers -productVersion | grep -F "10.9") ]; then
$BREW reinstall fontconfig --build-bottle 2>&1 | perl -pe 's/Warning/Note/gi'
$BREW install zlib
$BREW link --force zlib
fi
# Set flags manually (poppler.pc is broken for static)
export PKG_CONFIG_PATH=$PC_PATH
export PKG_CONFIG_LIBDIR=$PC_PATH
PKG_CFLAGS=$($PKG_CONFIG --cflags $PKG_CONFIG_NAME)
PKG_LIBS=$($PKG_CONFIG --libs --static ${PKG_CONFIG_NAME} cairo lcms2 libopenjp2 libtiff-4)
PKG_LIBS="-L${BREWDIR}/lib ${PKG_LIBS}"
# Prevent CRAN builder from linking against old libs in /usr/local/lib
for FILE in $BREWDIR/Cellar/*/*/lib/*.a; do
BASENAME=`basename $FILE`
LIBNAME=`echo "${BASENAME%.*}" | cut -c4-`
cp -f $FILE $BREWDIR/lib/libbrew$LIBNAME.a
echo "created $BREWDIR/lib/libbrew$LIBNAME.a"
PKG_LIBS=`echo $PKG_LIBS | sed "s/-l$LIBNAME /-lbrew$LIBNAME /g"`
done
rm -f $BREWDIR/lib/*.dylib
rm -f $BREWDIR/Cellar/*/*/lib/*.dylib
# Copy data files
mkdir -p inst/share
cp -r $BREWDIR/share/poppler inst/share/
PKG_CFLAGS="$PKG_CFLAGS -DBUNDLE_POPPLER_DATA"