ttfautohint-build.sh 4.4 KB

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