autogen.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #!/bin/sh
  2. # Copyright 2005, 2006, 2007, 2008, 2009, 2010 by
  3. # David Turner, Robert Wilhelm, and Werner Lemberg.
  4. #
  5. # This file is part of the FreeType project, and may only be used, modified,
  6. # and distributed under the terms of the FreeType project license,
  7. # LICENSE.TXT. By continuing to use, modify, or distribute this file you
  8. # indicate that you have read the license and understand and accept it
  9. # fully.
  10. run ()
  11. {
  12. echo "running \`$*'"
  13. eval $*
  14. if test $? != 0 ; then
  15. echo "error while running \`$*'"
  16. exit 1
  17. fi
  18. }
  19. get_major_version ()
  20. {
  21. echo $1 | sed -e 's/\([0-9][0-9]*\)\..*/\1/g'
  22. }
  23. get_minor_version ()
  24. {
  25. echo $1 | sed -e 's/[0-9][0-9]*\.\([0-9][0-9]*\).*/\1/g'
  26. }
  27. get_patch_version ()
  28. {
  29. # tricky: some version numbers don't include a patch
  30. # separated with a point, but something like 1.4-p6
  31. patch=`echo $1 | sed -e 's/[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*/\1/g'`
  32. if test "$patch" = "$1"; then
  33. patch=`echo $1 | sed -e 's/[0-9][0-9]*\.[0-9][0-9]*\-p\([0-9][0-9]*\).*/\1/g'`
  34. # if there isn't any patch number, default to 0
  35. if test "$patch" = "$1"; then
  36. patch=0
  37. fi
  38. fi
  39. echo $patch
  40. }
  41. # $1: version to check
  42. # $2: minimum version
  43. compare_to_minimum_version ()
  44. {
  45. MAJOR1=`get_major_version $1`
  46. MAJOR2=`get_major_version $2`
  47. if test $MAJOR1 -lt $MAJOR2; then
  48. echo 0
  49. return
  50. else
  51. if test $MAJOR1 -gt $MAJOR2; then
  52. echo 1
  53. return
  54. fi
  55. fi
  56. MINOR1=`get_minor_version $1`
  57. MINOR2=`get_minor_version $2`
  58. if test $MINOR1 -lt $MINOR2; then
  59. echo 0
  60. return
  61. else
  62. if test $MINOR1 -gt $MINOR2; then
  63. echo 1
  64. return
  65. fi
  66. fi
  67. PATCH1=`get_patch_version $1`
  68. PATCH2=`get_patch_version $2`
  69. if test $PATCH1 -lt $PATCH2; then
  70. echo 0
  71. else
  72. echo 1
  73. fi
  74. }
  75. # check the version of a given tool against a minimum version number
  76. #
  77. # $1: tool path
  78. # $2: tool usual name (e.g. `aclocal')
  79. # $3: tool variable (e.g. `ACLOCAL')
  80. # $4: minimum version to check against
  81. # $5: option field index used to extract the tool version from the
  82. # output of --version
  83. check_tool_version ()
  84. {
  85. field=$5
  86. # assume the output of "[TOOL] --version" is "toolname (GNU toolname foo bar) version"
  87. if test "$field"x = x; then
  88. field=3 # default to 3 for all GNU autotools, after filtering enclosed string
  89. fi
  90. version=`$1 --version | head -1 | sed 's/([^)]*)/()/g' | cut -d ' ' -f $field`
  91. version_check=`compare_to_minimum_version $version $4`
  92. if test "$version_check"x = 0x; then
  93. echo "ERROR: Your version of the \`$2' tool is too old."
  94. echo " Minimum version $4 is required (yours is version $version)."
  95. echo " Please upgrade or use the $3 variable to point to a more recent one."
  96. echo ""
  97. exit 1
  98. fi
  99. }
  100. if test ! -f ./builds/unix/configure.raw; then
  101. echo "You must be in the same directory as \`autogen.sh'."
  102. echo "Bootstrapping doesn't work if srcdir != builddir."
  103. exit 1
  104. fi
  105. # On MacOS X, the GNU libtool is named `glibtool'.
  106. HOSTOS=`uname`
  107. if test "$LIBTOOLIZE"x != x; then
  108. :
  109. elif test "$HOSTOS"x = Darwinx; then
  110. LIBTOOLIZE=glibtoolize
  111. else
  112. LIBTOOLIZE=libtoolize
  113. fi
  114. if test "$ACLOCAL"x = x; then
  115. ACLOCAL=aclocal
  116. fi
  117. if test "$AUTOCONF"x = x; then
  118. AUTOCONF=autoconf
  119. fi
  120. check_tool_version $ACLOCAL aclocal ACLOCAL 1.10.1
  121. check_tool_version $LIBTOOLIZE libtoolize LIBTOOLIZE 2.2.4
  122. check_tool_version $AUTOCONF autoconf AUTOCONF 2.62
  123. # This sets freetype_major, freetype_minor, and freetype_patch.
  124. eval `sed -nf version.sed include/freetype/freetype.h`
  125. # We set freetype-patch to an empty value if it is zero.
  126. if test "$freetype_patch" = ".0"; then
  127. freetype_patch=
  128. fi
  129. cd builds/unix
  130. echo "generating \`configure.ac'"
  131. sed -e "s;@VERSION@;$freetype_major$freetype_minor$freetype_patch;" \
  132. < configure.raw > configure.ac
  133. run aclocal -I . --force
  134. run $LIBTOOLIZE --force --copy --install
  135. run autoconf --force
  136. chmod +x mkinstalldirs
  137. chmod +x install-sh
  138. cd ../..
  139. chmod +x ./configure
  140. # EOF