Debian Codegraph @

tools/scripts/install/ttfautohint-build.sh

raw symbols SCIP
1 #!/bin/sh
2 # shellcheck disable=SC2103
3 # This script builds a stand-alone binary for the command line version of
4 # ttfautohint, downloading any necessary libraries.
5 #
6 # Version 2018-Feb-22.
7
8 # The MIT License (MIT)
9
10 # Copyright (c) 2018 Werner Lemberg
11
12 # Permission is hereby granted, free of charge, to any person obtaining a copy of
13 # this software and associated documentation files (the "Software"), to deal in
14 # the Software without restriction, including without limitation the rights to
15 # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
16 # the Software, and to permit persons to whom the Software is furnished to do so,
17 # subject to the following conditions:
18
19 # The above copyright notice and this permission notice shall be included in all
20 # copies or substantial portions of the Software.
21
22 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
24 # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
25 # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
26 # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
29
30 #
31 # User configuration.
32 #
33
34 # The build directory.
35 BUILD="$HOME/ttfautohint-build"
36
37 # The library versions.
38 FREETYPE_VERSION="2.8"
39 HARFBUZZ_VERSION="1.5.0"
40 TTFAUTOHINT_VERSION="1.7"
41
42 # Necessary patches (lists of at most 10 URLs each separated by whitespace,
43 # to be applied in order).
44 FREETYPE_PATCHES="\
45 http://git.savannah.gnu.org/cgit/freetype/freetype2.git/patch/?id=c9a9cf59 \
46 http://git.savannah.gnu.org/cgit/freetype/freetype2.git/patch/?id=c8829e4b \
47 "
48 HARFBUZZ_PATCHES=""
49 TTFAUTOHINT_PATCHES=""
50
51
52 #
53 # Nothing to configure below this comment.
54 #
55
56 FREETYPE="freetype-$FREETYPE_VERSION"
57 HARFBUZZ="harfbuzz-$HARFBUZZ_VERSION"
58 TTFAUTOHINT="ttfautohint-$TTFAUTOHINT_VERSION"
59
60 if test -d "$BUILD" -o -f "$BUILD"; then
61 echo "Build directory \`$BUILD' must not exist."
62 exit 1
63 fi
64
65 INST="$BUILD/local"
66
67 mkdir "$BUILD"
68 mkdir "$INST"
69
70 cd "$BUILD" || exit 1
71
72
73 echo "#####"
74 echo "Download all necessary archives and patches."
75 echo "#####"
76
77 curl -L -O "http://download.savannah.gnu.org/releases/freetype/$FREETYPE.tar.gz"
78 curl -O "https://www.freedesktop.org/software/harfbuzz/release/$HARFBUZZ.tar.bz2"
79 curl -L -O "http://download.savannah.gnu.org/releases/freetype/$TTFAUTOHINT.tar.gz"
80
81 count=0
82 for i in $FREETYPE_PATCHES
83 do
84 curl -o ft-patch-$count.diff "$i"
85 count=$((count + 1))
86 done
87
88 count=0
89 for i in $HARFBUZZ_PATCHES
90 do
91 curl -o hb-patch-$count.diff "$i"
92 count=$((count + 1))
93 done
94
95 count=0
96 for i in $TTFAUTOHINT_PATCHES
97 do
98 curl -o ta-patch-$count.diff "$i"
99 count=$((count + 1))
100 done
101
102
103 # Our environment variables.
104 TA_CPPFLAGS="-I$INST/include"
105 TA_CFLAGS="-g -O2"
106 TA_CXXFLAGS="-g -O2"
107 TA_LDFLAGS="-L$INST/lib -L$INST/lib64"
108
109
110 echo "#####"
111 echo "Extract archives."
112 echo "#####"
113
114 tar -xzvf "$FREETYPE.tar.gz"
115 tar -xjvf "$HARFBUZZ.tar.bz2"
116 tar -xzvf "$TTFAUTOHINT.tar.gz"
117
118
119 echo "#####"
120 echo "Apply patches."
121 echo "#####"
122
123 cd "$FREETYPE" || exit 1
124 for i in ../ft-patch-*.diff
125 do
126 test -f "$i" || continue
127 patch -p1 -N -r - < "$i"
128 done
129 cd ..
130
131 cd "$HARFBUZZ" || exit 1
132 for i in ../hb-patch-*.diff
133 do
134 test -f "$i" || continue
135 patch -p1 -N -r - < "$i"
136 done
137 cd ..
138
139 cd "$TTFAUTOHINT" || exit 1
140 for i in ../ta-patch-*.diff
141 do
142 test -f "$i" || continue
143 patch -p1 -N -r - < "$i"
144 done
145 cd ..
146
147
148 echo "#####"
149 echo "$FREETYPE"
150 echo "#####"
151
152 cd "$FREETYPE" || exit 1
153
154 # The space in `PKG_CONFIG' ensures that the created `freetype-config' file
155 # doesn't find a working pkg-config, falling back to the stored strings
156 # (which is what we want).
157 ./configure \
158 --without-bzip2 \
159 --without-png \
160 --without-zlib \
161 --without-harfbuzz \
162 --prefix="$INST" \
163 --enable-static \
164 --disable-shared \
165 PKG_CONFIG=" " \
166 CFLAGS="$TA_CPPFLAGS $TA_CFLAGS" \
167 CXXFLAGS="$TA_CPPFLAGS $TA_CXXFLAGS" \
168 LDFLAGS="$TA_LDFLAGS"
169 make
170 make install
171 cd ..
172
173
174 echo "#####"
175 echo "$HARFBUZZ"
176 echo "#####"
177
178 cd "$HARFBUZZ" || exit 1
179
180 # Value `true' for `PKG_CONFIG' ensures that XXX_CFLAGS and XXX_LIBS
181 # get actually used.
182 ./configure \
183 --disable-dependency-tracking \
184 --disable-gtk-doc-html \
185 --with-glib=no \
186 --with-cairo=no \
187 --with-fontconfig=no \
188 --with-icu=no \
189 --prefix="$INST" \
190 --enable-static \
191 --disable-shared \
192 CFLAGS="$TA_CPPFLAGS $TA_CFLAGS" \
193 CXXFLAGS="$TA_CPPFLAGS $TA_CXXFLAGS" \
194 LDFLAGS="$TA_LDFLAGS" \
195 PKG_CONFIG=true \
196 FREETYPE_CFLAGS="$TA_CPPFLAGS/freetype2" \
197 FREETYPE_LIBS="$TA_LDFLAGS -lfreetype"
198 make
199 make install
200 cd ..
201
202
203 echo "#####"
204 echo "$TTFAUTOHINT"
205 echo "#####"
206
207 cd "$TTFAUTOHINT" || exit 1
208
209 # Value `true' for `PKG_CONFIG' ensures that XXX_CFLAGS and XXX_LIBS
210 # get actually used.
211 ./configure \
212 --disable-dependency-tracking \
213 --without-qt \
214 --without-doc \
215 --prefix="$INST" \
216 --enable-static \
217 --disable-shared \
218 --with-freetype-config="$INST/bin/freetype-config" \
219 CFLAGS="$TA_CPPFLAGS $TA_CFLAGS" \
220 CXXFLAGS="$TA_CPPFLAGS $TA_CXXFLAGS" \
221 LDFLAGS="$TA_LDFLAGS" \
222 PKG_CONFIG=true \
223 HARFBUZZ_CFLAGS="$TA_CPPFLAGS/harfbuzz" \
224 HARFBUZZ_LIBS="$TA_LDFLAGS -lharfbuzz"
225 make LDFLAGS="$TA_LDFLAGS -all-static"
226 make install-strip
227 cd ..
228
229
230 echo "#####"
231 echo "binary: $INST/bin/ttfautohint"
232 echo "#####"
233
234 # eof