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