Werner Lemberg | b0db0fc | 2005-03-05 17:05:35 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Werner Lemberg | c326372 | 2009-01-06 21:00:47 +0000 | [diff] [blame] | 3 | # Copyright 2005, 2006, 2007, 2008, 2009 by |
Werner Lemberg | 60a04df | 2005-06-04 23:04:30 +0000 | [diff] [blame] | 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 | |
Werner Lemberg | b0db0fc | 2005-03-05 17:05:35 +0000 | [diff] [blame] | 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 | |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 23 | get_major_version () |
| 24 | { |
Werner Lemberg | c326372 | 2009-01-06 21:00:47 +0000 | [diff] [blame] | 25 | echo $1 | sed -e 's/\([0-9][0-9]*\)\..*/\1/g' |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | get_minor_version () |
| 29 | { |
Werner Lemberg | c326372 | 2009-01-06 21:00:47 +0000 | [diff] [blame] | 30 | echo $1 | sed -e 's/[0-9][0-9]*\.\([0-9][0-9]*\).*/\1/g' |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | get_patch_version () |
| 34 | { |
Werner Lemberg | b211651 | 2008-09-12 16:27:48 +0000 | [diff] [blame] | 35 | # tricky: some version numbers don't include a patch |
| 36 | # separated with a point, but something like 1.4-p6 |
Werner Lemberg | c326372 | 2009-01-06 21:00:47 +0000 | [diff] [blame] | 37 | patch=`echo $1 | sed -e 's/[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*/\1/g'` |
Werner Lemberg | b211651 | 2008-09-12 16:27:48 +0000 | [diff] [blame] | 38 | if test "$patch" = "$1"; then |
Werner Lemberg | c326372 | 2009-01-06 21:00:47 +0000 | [diff] [blame] | 39 | patch=`echo $1 | sed -e 's/[0-9][0-9]*\.[0-9][0-9]*\-p\([0-9][0-9]*\).*/\1/g'` |
Werner Lemberg | b211651 | 2008-09-12 16:27:48 +0000 | [diff] [blame] | 40 | # if there isn't any patch number, default to 0 |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 41 | if test "$patch" = "$1"; then |
Werner Lemberg | b211651 | 2008-09-12 16:27:48 +0000 | [diff] [blame] | 42 | patch=0 |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 43 | fi |
Werner Lemberg | b211651 | 2008-09-12 16:27:48 +0000 | [diff] [blame] | 44 | fi |
| 45 | echo $patch |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | # $1: version to check |
| 49 | # $2: minimum version |
Werner Lemberg | b211651 | 2008-09-12 16:27:48 +0000 | [diff] [blame] | 50 | |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 51 | compare_to_minimum_version () |
| 52 | { |
Werner Lemberg | b211651 | 2008-09-12 16:27:48 +0000 | [diff] [blame] | 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 |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 61 | return |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 62 | fi |
Werner Lemberg | b211651 | 2008-09-12 16:27:48 +0000 | [diff] [blame] | 63 | fi |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 64 | |
Werner Lemberg | b211651 | 2008-09-12 16:27:48 +0000 | [diff] [blame] | 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 |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 73 | return |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 74 | fi |
Werner Lemberg | b211651 | 2008-09-12 16:27:48 +0000 | [diff] [blame] | 75 | fi |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 76 | |
Werner Lemberg | b211651 | 2008-09-12 16:27:48 +0000 | [diff] [blame] | 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 |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 84 | } |
| 85 | |
Werner Lemberg | b211651 | 2008-09-12 16:27:48 +0000 | [diff] [blame] | 86 | # check the version of a given tool against a minimum version number |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 87 | # |
Werner Lemberg | b211651 | 2008-09-12 16:27:48 +0000 | [diff] [blame] | 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 | |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 95 | check_tool_version () |
| 96 | { |
| 97 | field=$5 |
suzuki toshiya | ad6954a | 2010-02-13 02:25:04 +0900 | [diff] [blame] | 98 | # assume the output of "[TOOL] --version" is "toolname (GNU toolname foo bar) version" |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 99 | if test "$field"x = x; then |
suzuki toshiya | ad6954a | 2010-02-13 02:25:04 +0900 | [diff] [blame] | 100 | field=3 # default to 3 for all GNU autotools, after filtering enclosed string |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 101 | fi |
suzuki toshiya | ad6954a | 2010-02-13 02:25:04 +0900 | [diff] [blame] | 102 | version=`$1 --version | head -1 | sed 's/([^)]*)/()/g' | cut -d ' ' -f $field` |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 103 | version_check=`compare_to_minimum_version $version $4` |
| 104 | if test "$version_check"x = 0x; then |
Werner Lemberg | b211651 | 2008-09-12 16:27:48 +0000 | [diff] [blame] | 105 | echo "ERROR: Your version of the \`$2' tool is too old." |
| 106 | echo " Minimum version $4 is required (yours is version $version)." |
| 107 | echo " Please upgrade or use the $3 variable to point to a more recent one." |
| 108 | echo "" |
| 109 | exit 1 |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 110 | fi |
| 111 | } |
| 112 | |
Werner Lemberg | 4df5b26 | 2006-05-08 07:10:29 +0000 | [diff] [blame] | 113 | if test ! -f ./builds/unix/configure.raw; then |
Werner Lemberg | c326372 | 2009-01-06 21:00:47 +0000 | [diff] [blame] | 114 | echo "You must be in the same directory as \`autogen.sh'." |
| 115 | echo "Bootstrapping doesn't work if srcdir != builddir." |
| 116 | exit 1 |
Werner Lemberg | b0db0fc | 2005-03-05 17:05:35 +0000 | [diff] [blame] | 117 | fi |
| 118 | |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 119 | # On MacOS X, the GNU libtool is named `glibtool'. |
| 120 | HOSTOS=`uname` |
| 121 | LIBTOOLIZE=libtoolize |
| 122 | if test "$HOSTOS"x = Darwinx; then |
| 123 | LIBTOOLIZE=glibtoolize |
| 124 | fi |
| 125 | |
| 126 | if test "$ACLOCAL"x = x; then |
| 127 | ACLOCAL=aclocal |
| 128 | fi |
| 129 | |
| 130 | if test "$AUTOCONF"x = x; then |
| 131 | AUTOCONF=autoconf |
| 132 | fi |
| 133 | |
Werner Lemberg | b211651 | 2008-09-12 16:27:48 +0000 | [diff] [blame] | 134 | check_tool_version $ACLOCAL aclocal ACLOCAL 1.10.1 |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 135 | check_tool_version $LIBTOOLIZE libtoolize LIBTOOLIZE 2.2.4 |
Werner Lemberg | b211651 | 2008-09-12 16:27:48 +0000 | [diff] [blame] | 136 | check_tool_version $AUTOCONF autoconf AUTOCONF 2.62 |
David Turner | 28534d6 | 2008-09-01 21:35:21 +0000 | [diff] [blame] | 137 | |
Werner Lemberg | 4df5b26 | 2006-05-08 07:10:29 +0000 | [diff] [blame] | 138 | # This sets freetype_major, freetype_minor, and freetype_patch. |
| 139 | eval `sed -nf version.sed include/freetype/freetype.h` |
| 140 | |
| 141 | # We set freetype-patch to an empty value if it is zero. |
| 142 | if test "$freetype_patch" = ".0"; then |
| 143 | freetype_patch= |
| 144 | fi |
| 145 | |
Werner Lemberg | b0db0fc | 2005-03-05 17:05:35 +0000 | [diff] [blame] | 146 | cd builds/unix |
| 147 | |
Werner Lemberg | 4df5b26 | 2006-05-08 07:10:29 +0000 | [diff] [blame] | 148 | echo "generating \`configure.ac'" |
| 149 | sed -e "s;@VERSION@;$freetype_major$freetype_minor$freetype_patch;" \ |
Werner Lemberg | c326372 | 2009-01-06 21:00:47 +0000 | [diff] [blame] | 150 | < configure.raw > configure.ac |
Werner Lemberg | 4df5b26 | 2006-05-08 07:10:29 +0000 | [diff] [blame] | 151 | |
Werner Lemberg | 1ea53e8 | 2005-04-13 18:12:36 +0000 | [diff] [blame] | 152 | run aclocal -I . --force |
Werner Lemberg | b796adb | 2008-06-10 17:15:35 +0000 | [diff] [blame] | 153 | run $LIBTOOLIZE --force --copy --install |
Werner Lemberg | 1ea53e8 | 2005-04-13 18:12:36 +0000 | [diff] [blame] | 154 | run autoconf --force |
Werner Lemberg | b0db0fc | 2005-03-05 17:05:35 +0000 | [diff] [blame] | 155 | |
| 156 | chmod +x mkinstalldirs |
| 157 | chmod +x install-sh |
| 158 | |
| 159 | cd ../.. |
| 160 | |
| 161 | chmod +x ./configure |
| 162 | |
| 163 | # EOF |