ttfautohint-build.sh 5.3 KB

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