ttfautohint-build.sh 3.9 KB

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