ttfautohint-build.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. HARFBUZZ_PATCHES=""
  24. TTFAUTOHINT_PATCHES=""
  25. #
  26. # Nothing to configure below this comment.
  27. #
  28. FREETYPE="freetype-$FREETYPE_VERSION"
  29. HARFBUZZ="harfbuzz-$HARFBUZZ_VERSION"
  30. TTFAUTOHINT="ttfautohint-$TTFAUTOHINT_VERSION"
  31. if test -d "$BUILD" -o -f "$BUILD"; then
  32. echo "Build directory \`$BUILD' must not exist."
  33. exit 1
  34. fi
  35. INST="$BUILD/local"
  36. mkdir "$BUILD"
  37. mkdir "$INST"
  38. cd "$BUILD" || exit 1
  39. echo "#####"
  40. echo "Download all necessary archives and patches."
  41. echo "#####"
  42. curl -L -O "http://download.savannah.gnu.org/releases/freetype/$FREETYPE.tar.gz"
  43. curl -O "https://www.freedesktop.org/software/harfbuzz/release/$HARFBUZZ.tar.bz2"
  44. curl -L -O "http://download.savannah.gnu.org/releases/freetype/$TTFAUTOHINT.tar.gz"
  45. count=0
  46. for i in $FREETYPE_PATCHES
  47. do
  48. curl -o ft-patch-$count.diff $i
  49. count=$($count + 1)
  50. done
  51. count=0
  52. for i in $HARFBUZZ_PATCHES
  53. do
  54. curl -o hb-patch-$count.diff $i
  55. count=$($count + 1)
  56. done
  57. count=0
  58. for i in $TTFAUTOHINT_PATCHES
  59. do
  60. curl -o ta-patch-$count.diff $i
  61. count=$($count + 1)
  62. done
  63. # Our environment variables.
  64. TA_CPPFLAGS="-I$INST/include"
  65. TA_CFLAGS="-g -O2"
  66. TA_CXXFLAGS="-g -O2"
  67. TA_LDFLAGS="-L$INST/lib"
  68. echo "#####"
  69. echo "Extract archives."
  70. echo "#####"
  71. tar -xzvf "$FREETYPE.tar.gz"
  72. tar -xjvf "$HARFBUZZ.tar.bz2"
  73. tar -xzvf "$TTFAUTOHINT.tar.gz"
  74. echo "#####"
  75. echo "Apply patches."
  76. echo "#####"
  77. cd "$FREETYPE" || exit 1
  78. for i in ../ft-patch-*.diff
  79. do
  80. test -f "$i" || continue
  81. patch --forward \
  82. --strip=1 \
  83. --reject-file=- \
  84. < "$i"
  85. done
  86. cd ..
  87. cd "$HARFBUZZ" || exit 1
  88. for i in ../hb-patch-*.diff
  89. do
  90. test -f "$i" || continue
  91. patch --forward \
  92. --strip=1 \
  93. --reject-file=- \
  94. < "$i"
  95. done
  96. cd ..
  97. cd "$TTFAUTOHINT" || exit 1
  98. for i in ../ta-patch-*.diff
  99. do
  100. test -f "$i" || continue
  101. patch --forward \
  102. --strip=1 \
  103. --reject-file=- \
  104. < "$i"
  105. done
  106. cd ..
  107. echo "#####"
  108. echo "$FREETYPE"
  109. echo "#####"
  110. cd "$FREETYPE" || exit 1
  111. ./configure \
  112. --without-bzip2 \
  113. --without-png \
  114. --without-zlib \
  115. --without-harfbuzz \
  116. --prefix="$INST" \
  117. --enable-static \
  118. --disable-shared \
  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. ./configure \
  130. --disable-dependency-tracking \
  131. --disable-gtk-doc-html \
  132. --with-glib=no \
  133. --with-cairo=no \
  134. --with-fontconfig=no \
  135. --with-icu=no \
  136. --prefix="$INST" \
  137. --enable-static \
  138. --disable-shared \
  139. CFLAGS="$TA_CPPFLAGS $TA_CFLAGS" \
  140. CXXFLAGS="$TA_CPPFLAGS $TA_CXXFLAGS" \
  141. LDFLAGS="$TA_LDFLAGS" \
  142. PKG_CONFIG=true \
  143. FREETYPE_CFLAGS="-I$INST/include/freetype2" \
  144. FREETYPE_LIBS="-L$INST/lib -lfreetype"
  145. make
  146. make install
  147. cd ..
  148. echo "#####"
  149. echo "$TTFAUTOHINT"
  150. echo "#####"
  151. cd "$TTFAUTOHINT" || exit 1
  152. ./configure \
  153. --disable-dependency-tracking \
  154. --without-qt \
  155. --without-doc \
  156. --prefix="$INST" \
  157. --enable-static \
  158. --disable-shared \
  159. --with-freetype-config="$INST/bin/freetype-config" \
  160. CFLAGS="$TA_CPPFLAGS $TA_CFLAGS" \
  161. CXXFLAGS="$TA_CPPFLAGS $TA_CXXFLAGS" \
  162. LDFLAGS="$TA_LDFLAGS" \
  163. PKG_CONFIG=true \
  164. HARFBUZZ_CFLAGS="-I$INST/include/harfbuzz" \
  165. HARFBUZZ_LIBS="-L$INST/lib -lharfbuzz"
  166. make LDFLAGS="$TA_LDFLAGS -all-static"
  167. make install-strip
  168. cd ..
  169. echo "#####"
  170. echo "binary: $INST/bin/ttfautohint"
  171. echo "#####"
  172. # eof