ttfautohint-build.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. #!/bin/sh
  2. # shellcheck disable=SC2103
  3. #
  4. # This script builds a stand-alone binary for the command line version of
  5. # ttfautohint, downloading any necessary libraries.
  6. #
  7. # Version 2017-Aug-17.
  8. # Written by Werner Lemberg <wl@gnu.org>.
  9. # To the extent possible under law, the person who associated CC0 with this work
  10. # has waived all copyright and related or neighboring rights to this work.
  11. #
  12. # User configuration.
  13. #
  14. # The build directory.
  15. BUILD="$HOME/ttfautohint-build"
  16. # The library versions.
  17. FREETYPE_VERSION="2.8"
  18. HARFBUZZ_VERSION="1.4.8"
  19. TTFAUTOHINT_VERSION="1.6"
  20. # Necessary patches (lists of at most 10 URLs each separated by whitespace,
  21. # to be applied in order).
  22. FREETYPE_PATCHES="\
  23. http://git.savannah.gnu.org/cgit/freetype/freetype2.git/patch/?id=c9a9cf59 \
  24. http://git.savannah.gnu.org/cgit/freetype/freetype2.git/patch/?id=c8829e4b \
  25. "
  26. HARFBUZZ_PATCHES=""
  27. TTFAUTOHINT_PATCHES=""
  28. #
  29. # Nothing to configure below this comment.
  30. #
  31. FREETYPE="freetype-$FREETYPE_VERSION"
  32. HARFBUZZ="harfbuzz-$HARFBUZZ_VERSION"
  33. TTFAUTOHINT="ttfautohint-$TTFAUTOHINT_VERSION"
  34. if test -d "$BUILD" -o -f "$BUILD"; then
  35. echo "Build directory \`$BUILD' must not exist."
  36. exit 1
  37. fi
  38. INST="$BUILD/local"
  39. mkdir "$BUILD"
  40. mkdir "$INST"
  41. cd "$BUILD" || exit 1
  42. echo "#####"
  43. echo "Download all necessary archives and patches."
  44. echo "#####"
  45. curl -L -O "http://download.savannah.gnu.org/releases/freetype/$FREETYPE.tar.gz"
  46. curl -O "https://www.freedesktop.org/software/harfbuzz/release/$HARFBUZZ.tar.bz2"
  47. curl -L -O "http://download.savannah.gnu.org/releases/freetype/$TTFAUTOHINT.tar.gz"
  48. count=0
  49. for i in $FREETYPE_PATCHES
  50. do
  51. curl -o ft-patch-$count.diff $i
  52. count=$($count + 1)
  53. done
  54. count=0
  55. for i in $HARFBUZZ_PATCHES
  56. do
  57. curl -o hb-patch-$count.diff $i
  58. count=$($count + 1)
  59. done
  60. count=0
  61. for i in $TTFAUTOHINT_PATCHES
  62. do
  63. curl -o ta-patch-$count.diff $i
  64. count=$($count + 1)
  65. done
  66. # Our environment variables.
  67. TA_CPPFLAGS="-I$INST/include"
  68. TA_CFLAGS="-g -O2"
  69. TA_CXXFLAGS="-g -O2"
  70. TA_LDFLAGS="-L$INST/lib"
  71. echo "#####"
  72. echo "Extract archives."
  73. echo "#####"
  74. tar -xzvf "$FREETYPE.tar.gz"
  75. tar -xjvf "$HARFBUZZ.tar.bz2"
  76. tar -xzvf "$TTFAUTOHINT.tar.gz"
  77. echo "#####"
  78. echo "Apply patches."
  79. echo "#####"
  80. cd "$FREETYPE" || exit 1
  81. for i in ../ft-patch-*.diff
  82. do
  83. test -f "$i" || continue
  84. patch --forward \
  85. --strip=1 \
  86. --reject-file=- \
  87. < "$i"
  88. done
  89. cd ..
  90. cd "$HARFBUZZ" || exit 1
  91. for i in ../hb-patch-*.diff
  92. do
  93. test -f "$i" || continue
  94. patch --forward \
  95. --strip=1 \
  96. --reject-file=- \
  97. < "$i"
  98. done
  99. cd ..
  100. cd "$TTFAUTOHINT" || exit 1
  101. for i in ../ta-patch-*.diff
  102. do
  103. test -f "$i" || continue
  104. patch --forward \
  105. --strip=1 \
  106. --reject-file=- \
  107. < "$i"
  108. done
  109. cd ..
  110. echo "#####"
  111. echo "$FREETYPE"
  112. echo "#####"
  113. cd "$FREETYPE" || exit 1
  114. ./configure \
  115. --without-bzip2 \
  116. --without-png \
  117. --without-zlib \
  118. --without-harfbuzz \
  119. --prefix="$INST" \
  120. --enable-static \
  121. --disable-shared \
  122. CFLAGS="$TA_CPPFLAGS $TA_CFLAGS" \
  123. CXXFLAGS="$TA_CPPFLAGS $TA_CXXFLAGS" \
  124. LDFLAGS="$TA_LDFLAGS"
  125. make
  126. make install
  127. cd ..
  128. echo "#####"
  129. echo "$HARFBUZZ"
  130. echo "#####"
  131. cd "$HARFBUZZ" || exit 1
  132. ./configure \
  133. --disable-dependency-tracking \
  134. --disable-gtk-doc-html \
  135. --with-glib=no \
  136. --with-cairo=no \
  137. --with-fontconfig=no \
  138. --with-icu=no \
  139. --prefix="$INST" \
  140. --enable-static \
  141. --disable-shared \
  142. CFLAGS="$TA_CPPFLAGS $TA_CFLAGS" \
  143. CXXFLAGS="$TA_CPPFLAGS $TA_CXXFLAGS" \
  144. LDFLAGS="$TA_LDFLAGS" \
  145. PKG_CONFIG=true \
  146. FREETYPE_CFLAGS="-I$INST/include/freetype2" \
  147. FREETYPE_LIBS="-L$INST/lib -lfreetype"
  148. make
  149. make install
  150. cd ..
  151. echo "#####"
  152. echo "$TTFAUTOHINT"
  153. echo "#####"
  154. cd "$TTFAUTOHINT" || exit 1
  155. ./configure \
  156. --disable-dependency-tracking \
  157. --without-qt \
  158. --without-doc \
  159. --prefix="$INST" \
  160. --enable-static \
  161. --disable-shared \
  162. --with-freetype-config="$INST/bin/freetype-config" \
  163. CFLAGS="$TA_CPPFLAGS $TA_CFLAGS" \
  164. CXXFLAGS="$TA_CPPFLAGS $TA_CXXFLAGS" \
  165. LDFLAGS="$TA_LDFLAGS" \
  166. PKG_CONFIG=true \
  167. HARFBUZZ_CFLAGS="-I$INST/include/harfbuzz" \
  168. HARFBUZZ_LIBS="-L$INST/lib -lharfbuzz"
  169. make LDFLAGS="$TA_LDFLAGS -all-static"
  170. make install-strip
  171. cd ..
  172. echo "#####"
  173. echo "binary: $INST/bin/ttfautohint"
  174. echo "#####"
  175. # eof