ttfautohint-build.sh 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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.1"
  20. HARFBUZZ_VERSION="1.5.1"
  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. HARFBUZZ_PATCHES=""
  26. TTFAUTOHINT_PATCHES=""
  27. #
  28. # Nothing to configure below this comment.
  29. #
  30. FREETYPE="freetype-$FREETYPE_VERSION"
  31. HARFBUZZ="harfbuzz-$HARFBUZZ_VERSION"
  32. TTFAUTOHINT="ttfautohint-$TTFAUTOHINT_VERSION"
  33. if test -d "$BUILD" -o -f "$BUILD"; then
  34. echo "Build directory \`$BUILD' must not exist."
  35. exit 1
  36. fi
  37. INST="$BUILD/local"
  38. mkdir "$BUILD"
  39. mkdir "$INST"
  40. cd "$BUILD" || exit 1
  41. echo "#####"
  42. echo "Download all necessary archives and patches."
  43. echo "#####"
  44. curl -L -O "http://download.savannah.gnu.org/releases/freetype/$FREETYPE.tar.gz"
  45. curl -O "https://www.freedesktop.org/software/harfbuzz/release/$HARFBUZZ.tar.bz2"
  46. curl -L -O "http://download.savannah.gnu.org/releases/freetype/$TTFAUTOHINT.tar.gz"
  47. count=0
  48. for i in $FREETYPE_PATCHES
  49. do
  50. curl -o ft-patch-$count.diff "$i"
  51. count=`expr $count + 1`
  52. done
  53. count=0
  54. for i in $HARFBUZZ_PATCHES
  55. do
  56. curl -o hb-patch-$count.diff "$i"
  57. count=`expr $count + 1`
  58. done
  59. count=0
  60. for i in $TTFAUTOHINT_PATCHES
  61. do
  62. curl -o ta-patch-$count.diff "$i"
  63. count=`expr $count + 1`
  64. done
  65. # Our environment variables.
  66. TA_CPPFLAGS="-I$INST/include"
  67. TA_CFLAGS="-g -O2"
  68. TA_CXXFLAGS="-g -O2"
  69. TA_LDFLAGS="-L$INST/lib -L$INST/lib64"
  70. echo "#####"
  71. echo "Extract archives."
  72. echo "#####"
  73. tar -xzvf "$FREETYPE.tar.gz"
  74. tar -xjvf "$HARFBUZZ.tar.bz2"
  75. tar -xzvf "$TTFAUTOHINT.tar.gz"
  76. echo "#####"
  77. echo "Apply patches."
  78. echo "#####"
  79. cd "$FREETYPE" || exit 1
  80. for i in ../ft-patch-*.diff
  81. do
  82. test -f "$i" || continue
  83. patch -p1 -N -r - < "$i"
  84. done
  85. cd ..
  86. cd "$HARFBUZZ" || exit 1
  87. for i in ../hb-patch-*.diff
  88. do
  89. test -f "$i" || continue
  90. patch -p1 -N -r - < "$i"
  91. done
  92. cd ..
  93. cd "$TTFAUTOHINT" || exit 1
  94. for i in ../ta-patch-*.diff
  95. do
  96. test -f "$i" || continue
  97. patch -p1 -N -r - < "$i"
  98. done
  99. cd ..
  100. echo "#####"
  101. echo "$FREETYPE"
  102. echo "#####"
  103. cd "$FREETYPE" || exit 1
  104. # The space in `PKG_CONFIG' ensures that the created `freetype-config' file
  105. # doesn't find a working pkg-config, falling back to the stored strings
  106. # (which is what we want).
  107. ./configure \
  108. --without-bzip2 \
  109. --without-png \
  110. --without-zlib \
  111. --without-harfbuzz \
  112. --prefix="$INST" \
  113. --enable-static \
  114. --disable-shared \
  115. PKG_CONFIG=" " \
  116. CFLAGS="$TA_CPPFLAGS $TA_CFLAGS" \
  117. CXXFLAGS="$TA_CPPFLAGS $TA_CXXFLAGS" \
  118. LDFLAGS="$TA_LDFLAGS"
  119. make
  120. make install
  121. cd ..
  122. echo "#####"
  123. echo "$HARFBUZZ"
  124. echo "#####"
  125. cd "$HARFBUZZ" || exit 1
  126. # Value `true' for `PKG_CONFIG' ensures that XXX_CFLAGS and XXX_LIBS
  127. # get actually used.
  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="$TA_CPPFLAGS/freetype2" \
  143. FREETYPE_LIBS="$TA_LDFLAGS -lfreetype"
  144. make
  145. make install
  146. cd ..
  147. echo "#####"
  148. echo "$TTFAUTOHINT"
  149. echo "#####"
  150. cd "$TTFAUTOHINT" || exit 1
  151. # Value `true' for `PKG_CONFIG' ensures that XXX_CFLAGS and XXX_LIBS
  152. # get actually used.
  153. ./configure \
  154. --disable-dependency-tracking \
  155. --without-qt \
  156. --without-doc \
  157. --prefix="$INST" \
  158. --enable-static \
  159. --disable-shared \
  160. --with-freetype-config="$INST/bin/freetype-config" \
  161. CFLAGS="$TA_CPPFLAGS $TA_CFLAGS" \
  162. CXXFLAGS="$TA_CPPFLAGS $TA_CXXFLAGS" \
  163. LDFLAGS="$TA_LDFLAGS" \
  164. PKG_CONFIG=true \
  165. HARFBUZZ_CFLAGS="$TA_CPPFLAGS/harfbuzz" \
  166. HARFBUZZ_LIBS="$TA_LDFLAGS -lharfbuzz"
  167. make LDFLAGS="$TA_LDFLAGS -all-static"
  168. make install-strip
  169. cd ..
  170. echo "#####"
  171. echo "binary: $INST/bin/ttfautohint"
  172. echo "#####"
  173. # eof