freetype2.m4 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. # Configure paths for FreeType2
  2. # Marcelo Magallon 2001-10-26, based on gtk.m4 by Owen Taylor
  3. #
  4. # serial 2
  5. # AC_CHECK_FT2([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  6. # Test for FreeType 2, and define FT2_CFLAGS and FT2_LIBS.
  7. # MINIMUM-VERSION is what libtool reports; the default is `7.0.1' (this is
  8. # FreeType 2.0.4).
  9. #
  10. AC_DEFUN([AC_CHECK_FT2],
  11. [# Get the cflags and libraries from the freetype-config script
  12. #
  13. AC_ARG_WITH([ft-prefix],
  14. dnl don't quote AS_HELP_STRING!
  15. AS_HELP_STRING([--with-ft-prefix=PREFIX],
  16. [Prefix where FreeType is installed (optional)]),
  17. [ft_config_prefix="$withval"],
  18. [ft_config_prefix=""])
  19. AC_ARG_WITH([ft-exec-prefix],
  20. dnl don't quote AS_HELP_STRING!
  21. AS_HELP_STRING([--with-ft-exec-prefix=PREFIX],
  22. [Exec prefix where FreeType is installed (optional)]),
  23. [ft_config_exec_prefix="$withval"],
  24. [ft_config_exec_prefix=""])
  25. AC_ARG_ENABLE([freetypetest],
  26. dnl don't quote AS_HELP_STRING!
  27. AS_HELP_STRING([--disable-freetypetest],
  28. [Do not try to compile and run a test FreeType program]),
  29. [],
  30. [enable_fttest=yes])
  31. if test x$ft_config_exec_prefix != x ; then
  32. ft_config_args="$ft_config_args --exec-prefix=$ft_config_exec_prefix"
  33. if test x${FT2_CONFIG+set} != xset ; then
  34. FT2_CONFIG=$ft_config_exec_prefix/bin/freetype-config
  35. fi
  36. fi
  37. if test x$ft_config_prefix != x ; then
  38. ft_config_args="$ft_config_args --prefix=$ft_config_prefix"
  39. if test x${FT2_CONFIG+set} != xset ; then
  40. FT2_CONFIG=$ft_config_prefix/bin/freetype-config
  41. fi
  42. fi
  43. AC_PATH_PROG([FT2_CONFIG], [freetype-config], [no])
  44. min_ft_version=m4_if([$1], [], [7.0.1], [$1])
  45. AC_MSG_CHECKING([for FreeType -- version >= $min_ft_version])
  46. no_ft=""
  47. if test "$FT2_CONFIG" = "no" ; then
  48. no_ft=yes
  49. else
  50. FT2_CFLAGS=`$FT2_CONFIG $ft_config_args --cflags`
  51. FT2_LIBS=`$FT2_CONFIG $ft_config_args --libs`
  52. ft_config_major_version=`$FT2_CONFIG $ft_config_args --version | \
  53. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  54. ft_config_minor_version=`$FT2_CONFIG $ft_config_args --version | \
  55. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  56. ft_config_micro_version=`$FT2_CONFIG $ft_config_args --version | \
  57. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  58. ft_min_major_version=`echo $min_ft_version | \
  59. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  60. ft_min_minor_version=`echo $min_ft_version | \
  61. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  62. ft_min_micro_version=`echo $min_ft_version | \
  63. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  64. if test x$enable_fttest = xyes ; then
  65. ft_config_is_lt=""
  66. if test $ft_config_major_version -lt $ft_min_major_version ; then
  67. ft_config_is_lt=yes
  68. else
  69. if test $ft_config_major_version -eq $ft_min_major_version ; then
  70. if test $ft_config_minor_version -lt $ft_min_minor_version ; then
  71. ft_config_is_lt=yes
  72. else
  73. if test $ft_config_minor_version -eq $ft_min_minor_version ; then
  74. if test $ft_config_micro_version -lt $ft_min_micro_version ; then
  75. ft_config_is_lt=yes
  76. fi
  77. fi
  78. fi
  79. fi
  80. fi
  81. if test x$ft_config_is_lt = xyes ; then
  82. no_ft=yes
  83. else
  84. ac_save_CFLAGS="$CFLAGS"
  85. ac_save_LIBS="$LIBS"
  86. CFLAGS="$CFLAGS $FT2_CFLAGS"
  87. LIBS="$FT2_LIBS $LIBS"
  88. #
  89. # Sanity checks for the results of freetype-config to some extent.
  90. #
  91. AC_RUN_IFELSE([
  92. AC_LANG_SOURCE([[
  93. #include <ft2build.h>
  94. #include FT_FREETYPE_H
  95. #include <stdio.h>
  96. #include <stdlib.h>
  97. int
  98. main()
  99. {
  100. FT_Library library;
  101. FT_Error error;
  102. error = FT_Init_FreeType(&library);
  103. if (error)
  104. return 1;
  105. else
  106. {
  107. FT_Done_FreeType(library);
  108. return 0;
  109. }
  110. }
  111. ]])
  112. ],
  113. [],
  114. [no_ft=yes],
  115. [echo $ECHO_N "cross compiling; assuming OK... $ECHO_C"])
  116. CFLAGS="$ac_save_CFLAGS"
  117. LIBS="$ac_save_LIBS"
  118. fi # test $ft_config_version -lt $ft_min_version
  119. fi # test x$enable_fttest = xyes
  120. fi # test "$FT2_CONFIG" = "no"
  121. if test x$no_ft = x ; then
  122. AC_MSG_RESULT([yes])
  123. m4_if([$2], [], [:], [$2])
  124. else
  125. AC_MSG_RESULT([no])
  126. if test "$FT2_CONFIG" = "no" ; then
  127. AC_MSG_WARN([
  128. The freetype-config script installed by FreeType 2 could not be found.
  129. If FreeType 2 was installed in PREFIX, make sure PREFIX/bin is in
  130. your path, or set the FT2_CONFIG environment variable to the
  131. full path to freetype-config.
  132. ])
  133. else
  134. if test x$ft_config_is_lt = xyes ; then
  135. AC_MSG_WARN([
  136. Your installed version of the FreeType 2 library is too old.
  137. If you have different versions of FreeType 2, make sure that
  138. correct values for --with-ft-prefix or --with-ft-exec-prefix
  139. are used, or set the FT2_CONFIG environment variable to the
  140. full path to freetype-config.
  141. ])
  142. else
  143. AC_MSG_WARN([
  144. The FreeType test program failed to run. If your system uses
  145. shared libraries and they are installed outside the normal
  146. system library path, make sure the variable LD_LIBRARY_PATH
  147. (or whatever is appropriate for your system) is correctly set.
  148. ])
  149. fi
  150. fi
  151. FT2_CFLAGS=""
  152. FT2_LIBS=""
  153. m4_if([$3], [], [:], [$3])
  154. fi
  155. AC_SUBST([FT2_CFLAGS])
  156. AC_SUBST([FT2_LIBS])])
  157. # end of freetype2.m4