ttfautohint-build.sh 5.3 KB

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