/modules/freetype2/builds/unix/freetype2.m4

http://github.com/zpao/v8monkey · m4 · 194 lines · 141 code · 21 blank · 32 comment · 0 complexity · ba2aae62133a468c368632952020db8c MD5 · raw file

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