ttfautohint-build.sh 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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-Nov-24.
  9. # The MIT License (MIT)
  10. # Copyright (c) 2018 Werner Lemberg
  11. # Permission is hereby granted, free of charge, to any person obtaining a copy of
  12. # this software and associated documentation files (the "Software"), to deal in
  13. # the Software without restriction, including without limitation the rights to
  14. # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  15. # the Software, and to permit persons to whom the Software is furnished to do so,
  16. # subject to the following conditions:
  17. # The above copyright notice and this permission notice shall be included in all
  18. # copies or substantial portions of the Software.
  19. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  21. # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  22. # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  23. # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  24. # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. #
  26. # User configuration.
  27. #
  28. # The build directory.
  29. BUILD="$HOME/ttfautohint-build"
  30. # The library versions.
  31. FREETYPE_VERSION="2.8.1"
  32. HARFBUZZ_VERSION="1.7.4"
  33. TTFAUTOHINT_VERSION="1.7"
  34. # Necessary patches (lists of at most 10 URLs each separated by whitespace,
  35. # to be applied in order).
  36. FREETYPE_PATCHES=""
  37. HARFBUZZ_PATCHES=""
  38. TTFAUTOHINT_PATCHES=""
  39. #
  40. # Nothing to configure below this comment.
  41. #
  42. FREETYPE="freetype-$FREETYPE_VERSION"
  43. HARFBUZZ="harfbuzz-$HARFBUZZ_VERSION"
  44. TTFAUTOHINT="ttfautohint-$TTFAUTOHINT_VERSION"
  45. if test -d "$BUILD" -o -f "$BUILD"; then
  46. echo "Build directory \`$BUILD' must not exist."
  47. exit 1
  48. fi
  49. INST="$BUILD/local"
  50. mkdir "$BUILD"
  51. mkdir "$INST"
  52. cd "$BUILD" || exit 1
  53. echo "#####"
  54. echo "Download all necessary archives and patches."
  55. echo "#####"
  56. curl -L -O "http://download.savannah.gnu.org/releases/freetype/$FREETYPE.tar.gz"
  57. curl -O "https://www.freedesktop.org/software/harfbuzz/release/$HARFBUZZ.tar.bz2"
  58. curl -L -O "http://download.savannah.gnu.org/releases/freetype/$TTFAUTOHINT.tar.gz"
  59. count=0
  60. for i in $FREETYPE_PATCHES
  61. do
  62. curl -o ft-patch-$count.diff "$i"
  63. count=`expr $count + 1`
  64. done
  65. count=0
  66. for i in $HARFBUZZ_PATCHES
  67. do
  68. curl -o hb-patch-$count.diff "$i"
  69. count=`expr $count + 1`
  70. done
  71. count=0
  72. for i in $TTFAUTOHINT_PATCHES
  73. do
  74. curl -o ta-patch-$count.diff "$i"
  75. count=`expr $count + 1`
  76. done
  77. # Our environment variables.
  78. TA_CPPFLAGS="-I$INST/include"
  79. TA_CFLAGS="-g -O2"
  80. TA_CXXFLAGS="-g -O2"
  81. TA_LDFLAGS="-L$INST/lib -L$INST/lib64"
  82. echo "#####"
  83. echo "Extract archives."
  84. echo "#####"
  85. tar -xzvf "$FREETYPE.tar.gz"
  86. tar -xjvf "$HARFBUZZ.tar.bz2"
  87. tar -xzvf "$TTFAUTOHINT.tar.gz"
  88. echo "#####"
  89. echo "Apply patches."
  90. echo "#####"
  91. cd "$FREETYPE" || exit 1
  92. for i in ../ft-patch-*.diff
  93. do
  94. test -f "$i" || continue
  95. patch -p1 -N -r - < "$i"
  96. done
  97. cd ..
  98. cd "$HARFBUZZ" || exit 1
  99. for i in ../hb-patch-*.diff
  100. do
  101. test -f "$i" || continue
  102. patch -p1 -N -r - < "$i"
  103. done
  104. cd ..
  105. cd "$TTFAUTOHINT" || exit 1
  106. for i in ../ta-patch-*.diff
  107. do
  108. test -f "$i" || continue
  109. patch -p1 -N -r - < "$i"
  110. done
  111. cd ..
  112. echo "#####"
  113. echo "$FREETYPE"
  114. echo "#####"
  115. cd "$FREETYPE" || exit 1
  116. # The space in `PKG_CONFIG' ensures that the created `freetype-config' file
  117. # doesn't find a working pkg-config, falling back to the stored strings
  118. # (which is what we want).
  119. ./configure \
  120. --without-bzip2 \
  121. --without-png \
  122. --without-zlib \
  123. --without-harfbuzz \
  124. --prefix="$INST" \
  125. --enable-static \
  126. --disable-shared \
  127. PKG_CONFIG=" " \
  128. CFLAGS="$TA_CPPFLAGS $TA_CFLAGS" \
  129. CXXFLAGS="$TA_CPPFLAGS $TA_CXXFLAGS" \
  130. LDFLAGS="$TA_LDFLAGS"
  131. make
  132. make install
  133. cd ..
  134. echo "#####"
  135. echo "$HARFBUZZ"
  136. echo "#####"
  137. cd "$HARFBUZZ" || exit 1
  138. # Value `true' for `PKG_CONFIG' ensures that XXX_CFLAGS and XXX_LIBS
  139. # get actually used.
  140. ./configure \
  141. --disable-dependency-tracking \
  142. --disable-gtk-doc-html \
  143. --with-glib=no \
  144. --with-cairo=no \
  145. --with-fontconfig=no \
  146. --with-icu=no \
  147. --prefix="$INST" \
  148. --enable-static \
  149. --disable-shared \
  150. CFLAGS="$TA_CPPFLAGS $TA_CFLAGS" \
  151. CXXFLAGS="$TA_CPPFLAGS $TA_CXXFLAGS" \
  152. LDFLAGS="$TA_LDFLAGS" \
  153. PKG_CONFIG=true \
  154. FREETYPE_CFLAGS="$TA_CPPFLAGS/freetype2" \
  155. FREETYPE_LIBS="$TA_LDFLAGS -lfreetype"
  156. make
  157. make install
  158. cd ..
  159. echo "#####"
  160. echo "$TTFAUTOHINT"
  161. echo "#####"
  162. cd "$TTFAUTOHINT" || exit 1
  163. # Value `true' for `PKG_CONFIG' ensures that XXX_CFLAGS and XXX_LIBS
  164. # get actually used.
  165. ./configure \
  166. --disable-dependency-tracking \
  167. --without-qt \
  168. --without-doc \
  169. --prefix="$INST" \
  170. --enable-static \
  171. --disable-shared \
  172. --with-freetype-config="$INST/bin/freetype-config" \
  173. CFLAGS="$TA_CPPFLAGS $TA_CFLAGS" \
  174. CXXFLAGS="$TA_CPPFLAGS $TA_CXXFLAGS" \
  175. LDFLAGS="$TA_LDFLAGS" \
  176. PKG_CONFIG=true \
  177. HARFBUZZ_CFLAGS="$TA_CPPFLAGS/harfbuzz" \
  178. HARFBUZZ_LIBS="$TA_LDFLAGS -lharfbuzz"
  179. make LDFLAGS="$TA_LDFLAGS -all-static"
  180. make install-strip
  181. cd ..
  182. echo "#####"
  183. echo "binary: $INST/bin/ttfautohint"
  184. echo "#####"
  185. # eof