-
-
Save tobywf/aeeeee63053aaaa841b4032963406684 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
set -xeuo pipefail | |
IFS=$'\n\t' | |
PREFIX="${1:-/usr/local/dvisvgm}" | |
TEX="$(kpsewhich -var SELFAUTOLOC)" | |
echo "$PREFIX, $TEX" | |
brew install automake freetype ghostscript potrace | |
# download the sources | |
mkdir -p "$PREFIX/source/texk" | |
cd "$PREFIX/source/" | |
# see https://www.tug.org/texlive/svn/ | |
rsync -av --exclude=.svn tug.org::tldevsrc/Build/source/build-aux . | |
rsync -av --exclude=.svn tug.org::tldevsrc/Build/source/texk/kpathsea texk/ | |
git clone git@github.com:mgieseki/dvisvgm.git | |
# compile kpathsea | |
cd texk/kpathsea | |
# patch SELFAUTOLOC | |
perl -0777 -i.bak \ | |
-pe 's|(kpathsea_selfdir \(kpathsea kpse, const_string argv0\)\n{)|$1\n return xstrdup("'"$TEX"'");\n|g' \ | |
progname.c | |
./configure --prefix="$PREFIX/" | |
make | |
make install | |
# compile dvisvgm | |
cd ../../dvisvgm | |
./autogen.sh | |
CPPFLAGS="-I$PREFIX/include/" LDFLAGS="-L$PREFIX/lib/" ./configure --prefix="$PREFIX/" | |
make | |
make check | |
make install |
Your script actually helped my to build and install it on Linux (LFS) too! I could not get kpathsea installed from the tex live sources (texk-7.2). I had segmentation fault build errors. By analyzing this script, it helped me get the directory structure ready to install both dvisvgm and kpathsea. Thank you!
^to nowaday's comment above you don't need to manually install Brotli or woff2, they are already bundled in dvisvgm. To build them and statically link them you have to do:
./configure --enable-bundled-libs
instead of ./configure
Also, with this script I was getting error:
kpsewhich: option `-var' is ambiguous
but it was helpful in getting the directory structure right for installing dvisvgm and Kpathsea so thank you!
Awesome, glad it helps! That's great tip. I think the WOFF stuff was added shortly after I originally published this in April 2017. Hopefully I'll get some time to re-run this with the latest sources.
For kpsewhich: option '-var' is ambiguous
, just replace -var
with -var-value
, and it works.
The perl regex fails due to unmatched left brace. Falling back to an older version of perl before 5.24 should work.
The perl regex fails due to unmatched left brace. Falling back to an older version of perl before 5.24 should work.
Escaping the left open brace '{' with a backslash \ works with perl 5.34 on macos 11.2.3
-pe 's|(kpathsea_selfdir \(kpathsea kpse, const_string argv0\)\n\{)|$1\n return xstrdup("'"$TEX"'");\n|g' \
I found that this wouldn't work unless I put the binary at $(kpsewhich -var-value SELFAUTOLOC)
and then made a symbolic link to it.
I got this :(¨
+ IFS='
'
+ PREFIX=/usr/local/dvisvgm
++ kpsewhich -var SELFAUTOLOC
kpsewhich: option `-var' is ambiguous
+ TEX=
-var-value
It worked!
macOS Mojave 10.14.2
It took me make a few additional things to make script works:
git clone git@github.com:mgieseki/dvisvgm.git
togit clone https://github.com/mgieseki/dvisvgm.git
And script has worked well. Thank you!