michael@0: #!/bin/sh michael@0: michael@0: # Copyright 2005-2010, 2013 by michael@0: # David Turner, Robert Wilhelm, and Werner Lemberg. michael@0: # michael@0: # This file is part of the FreeType project, and may only be used, modified, michael@0: # and distributed under the terms of the FreeType project license, michael@0: # LICENSE.TXT. By continuing to use, modify, or distribute this file you michael@0: # indicate that you have read the license and understand and accept it michael@0: # fully. michael@0: michael@0: run () michael@0: { michael@0: echo "running \`$*'" michael@0: eval $* michael@0: michael@0: if test $? != 0 ; then michael@0: echo "error while running \`$*'" michael@0: exit 1 michael@0: fi michael@0: } michael@0: michael@0: get_major_version () michael@0: { michael@0: echo $1 | sed -e 's/\([0-9][0-9]*\)\..*/\1/g' michael@0: } michael@0: michael@0: get_minor_version () michael@0: { michael@0: echo $1 | sed -e 's/[0-9][0-9]*\.\([0-9][0-9]*\).*/\1/g' michael@0: } michael@0: michael@0: get_patch_version () michael@0: { michael@0: # tricky: some version numbers don't include a patch michael@0: # separated with a point, but something like 1.4-p6 michael@0: patch=`echo $1 | sed -e 's/[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*/\1/g'` michael@0: if test "$patch" = "$1"; then michael@0: patch=`echo $1 | sed -e 's/[0-9][0-9]*\.[0-9][0-9]*\-p\([0-9][0-9]*\).*/\1/g'` michael@0: # if there isn't any patch number, default to 0 michael@0: if test "$patch" = "$1"; then michael@0: patch=0 michael@0: fi michael@0: fi michael@0: echo $patch michael@0: } michael@0: michael@0: # $1: version to check michael@0: # $2: minimum version michael@0: michael@0: compare_to_minimum_version () michael@0: { michael@0: MAJOR1=`get_major_version $1` michael@0: MAJOR2=`get_major_version $2` michael@0: if test $MAJOR1 -lt $MAJOR2; then michael@0: echo 0 michael@0: return michael@0: else michael@0: if test $MAJOR1 -gt $MAJOR2; then michael@0: echo 1 michael@0: return michael@0: fi michael@0: fi michael@0: michael@0: MINOR1=`get_minor_version $1` michael@0: MINOR2=`get_minor_version $2` michael@0: if test $MINOR1 -lt $MINOR2; then michael@0: echo 0 michael@0: return michael@0: else michael@0: if test $MINOR1 -gt $MINOR2; then michael@0: echo 1 michael@0: return michael@0: fi michael@0: fi michael@0: michael@0: PATCH1=`get_patch_version $1` michael@0: PATCH2=`get_patch_version $2` michael@0: if test $PATCH1 -lt $PATCH2; then michael@0: echo 0 michael@0: else michael@0: echo 1 michael@0: fi michael@0: } michael@0: michael@0: # check the version of a given tool against a minimum version number michael@0: # michael@0: # $1: tool path michael@0: # $2: tool usual name (e.g. `aclocal') michael@0: # $3: tool variable (e.g. `ACLOCAL') michael@0: # $4: minimum version to check against michael@0: # $5: option field index used to extract the tool version from the michael@0: # output of --version michael@0: michael@0: check_tool_version () michael@0: { michael@0: field=$5 michael@0: # assume the output of "[TOOL] --version" is "toolname (GNU toolname foo bar) version" michael@0: if test "$field"x = x; then michael@0: field=3 # default to 3 for all GNU autotools, after filtering enclosed string michael@0: fi michael@0: version=`$1 --version | head -1 | sed 's/([^)]*)/()/g' | cut -d ' ' -f $field` michael@0: version_check=`compare_to_minimum_version $version $4` michael@0: if test "$version_check"x = 0x; then michael@0: echo "ERROR: Your version of the \`$2' tool is too old." michael@0: echo " Minimum version $4 is required (yours is version $version)." michael@0: echo " Please upgrade or use the $3 variable to point to a more recent one." michael@0: echo "" michael@0: exit 1 michael@0: fi michael@0: } michael@0: michael@0: if test ! -f ./builds/unix/configure.raw; then michael@0: echo "You must be in the same directory as \`autogen.sh'." michael@0: echo "Bootstrapping doesn't work if srcdir != builddir." michael@0: exit 1 michael@0: fi michael@0: michael@0: # On MacOS X, the GNU libtool is named `glibtool'. michael@0: HOSTOS=`uname` michael@0: if test "$LIBTOOLIZE"x != x; then michael@0: : michael@0: elif test "$HOSTOS"x = Darwinx; then michael@0: LIBTOOLIZE=glibtoolize michael@0: else michael@0: LIBTOOLIZE=libtoolize michael@0: fi michael@0: michael@0: if test "$ACLOCAL"x = x; then michael@0: ACLOCAL=aclocal michael@0: fi michael@0: michael@0: if test "$AUTOCONF"x = x; then michael@0: AUTOCONF=autoconf michael@0: fi michael@0: michael@0: check_tool_version $ACLOCAL aclocal ACLOCAL 1.10.1 michael@0: check_tool_version $LIBTOOLIZE libtoolize LIBTOOLIZE 2.2.4 michael@0: check_tool_version $AUTOCONF autoconf AUTOCONF 2.62 michael@0: michael@0: # This sets freetype_major, freetype_minor, and freetype_patch. michael@0: eval `sed -nf version.sed include/freetype.h` michael@0: michael@0: # We set freetype-patch to an empty value if it is zero. michael@0: if test "$freetype_patch" = ".0"; then michael@0: freetype_patch= michael@0: fi michael@0: michael@0: cd builds/unix michael@0: michael@0: echo "generating \`configure.ac'" michael@0: sed -e "s;@VERSION@;$freetype_major$freetype_minor$freetype_patch;" \ michael@0: < configure.raw > configure.ac michael@0: michael@0: run aclocal -I . --force michael@0: run $LIBTOOLIZE --force --copy --install michael@0: run autoconf --force michael@0: michael@0: chmod +x mkinstalldirs michael@0: chmod +x install-sh michael@0: michael@0: cd ../.. michael@0: michael@0: chmod +x ./configure michael@0: michael@0: # EOF