Bug 1888033 - [Menu Redesign] Add a secret setting and feature flag for the menu...
[gecko.git] / modules / freetype2 / autogen.sh
blobff5e46f0d2ace83a11a29bd35f3bc2e58efa105b
1 #!/bin/sh
3 # Copyright (C) 2005-2023 by
4 # David Turner, Robert Wilhelm, and Werner Lemberg.
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.
12 run ()
14 echo "running \`$*'"
15 eval $*
17 if test $? != 0 ; then
18 echo "error while running \`$*'"
19 exit 1
23 get_major_version ()
25 echo $1 | sed -e 's/\([0-9][0-9]*\)\..*/\1/g'
28 get_minor_version ()
30 echo $1 | sed -e 's/[0-9][0-9]*\.\([0-9][0-9]*\).*/\1/g'
33 get_patch_version ()
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
45 echo $patch
48 # $1: version to check
49 # $2: minimum version
51 compare_to_minimum_version ()
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
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
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
86 # check the version of a given tool against a minimum version number
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
95 check_tool_version ()
97 field=$5
98 # assume the output of "[TOOL] --version" is "toolname (GNU toolname foo bar) version"
99 if test "$field"x = x; then
100 field=3 # default to 3 for all GNU autotools, after filtering enclosed string
102 version=`$1 --version | head -1 | sed 's/([^)]*)/()/g' | cut -d ' ' -f $field`
103 version_check=`compare_to_minimum_version $version $4`
104 if test "$version_check"x = 0x; then
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
113 # Solaris 10's shell doesn't like the `!` operator to negate the exit status.
114 if test -f ./builds/unix/configure.raw; then
116 else
117 echo "You must be in the same directory as \`autogen.sh'."
118 echo "Bootstrapping doesn't work if srcdir != builddir."
119 exit 1
122 # On MacOS X, the GNU libtool is named `glibtool'.
123 HOSTOS=`uname`
124 if test "$LIBTOOLIZE"x != x; then
126 elif test "$HOSTOS"x = Darwinx; then
127 LIBTOOLIZE=glibtoolize
128 else
129 LIBTOOLIZE=libtoolize
132 if test "$ACLOCAL"x = x; then
133 ACLOCAL=aclocal
136 if test "$AUTOCONF"x = x; then
137 AUTOCONF=autoconf
140 check_tool_version $ACLOCAL aclocal ACLOCAL 1.10.1
141 check_tool_version $LIBTOOLIZE libtoolize LIBTOOLIZE 2.2.4
142 check_tool_version $AUTOCONF autoconf AUTOCONF 2.62
144 # This sets FREETYPE version.
145 eval `sed -n \
146 -e 's/^#define *\(FREETYPE_MAJOR\) *\([0-9][0-9]*\).*/\1=\2/p' \
147 -e 's/^#define *\(FREETYPE_MINOR\) *\([0-9][0-9]*\).*/\1=\2/p' \
148 -e 's/^#define *\(FREETYPE_PATCH\) *\([0-9][0-9]*\).*/\1=\2/p' \
149 include/freetype/freetype.h`
151 if test "$FREETYPE_PATCH" = "0"; then
152 FREETYPE=$FREETYPE_MAJOR.$FREETYPE_MINOR
153 else
154 FREETYPE=$FREETYPE_MAJOR.$FREETYPE_MINOR.$FREETYPE_PATCH
157 echo "FreeType $FREETYPE:"
159 cd builds/unix
161 echo "generating \`configure.ac'"
162 sed -e "s;@VERSION@;$FREETYPE;" \
163 < configure.raw > configure.ac
165 run aclocal -I . --force
166 run $LIBTOOLIZE --force --copy --install
167 run autoconf --force
169 chmod +x install-sh
171 cd ../..
173 chmod +x ./configure
175 # Copy all necessary 'dlg' files.
176 copy_submodule_files ()
178 echo "Copying files from \`subprojects/dlg' to \`src/dlg' and \`include/dlg'"
179 mkdir include/dlg 2> /dev/null
180 cp $DLG_INC_DIR/output.h include/dlg
181 cp $DLG_INC_DIR/dlg.h include/dlg
182 cp $DLG_SRC_DIR/* src/dlg
185 if test -e ".git"; then
186 DLG_INC_DIR=subprojects/dlg/include/dlg
187 DLG_SRC_DIR=subprojects/dlg/src/dlg
189 if test -d "$DLG_INC_DIR"; then
191 else
192 echo "Checking out submodule in \`subprojects/dlg':"
193 git submodule init
194 git submodule update
197 copy_submodule_files
200 # EOF