forked from GNOME/jhbuild
-
Notifications
You must be signed in to change notification settings - Fork 3
/
autogen.sh
executable file
·283 lines (242 loc) · 8.28 KB
/
autogen.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#!/bin/sh
#
# JHBuild configuration script.
#
# For installation instructions please refer to the JHBuild manual:
# yelp /jhbuild-source-dir/doc/C/index.docbook
#
# Or refer to the on-line JHBuild manual at:
#
# http://library.gnome.org/devel/jhbuild/stable/getting-started.html.en
#
# Usage:
# ./autogen.sh [OPTION]
# Available OPTION are:
# --simple-install Configure without using autotools. This setting is
# set automatically if autotools and yelp-tools
# are not installed.
# --prefix=PREFIX Install JHBuild to PREFIX. Defaults to ~/.local
#
# If autotools and yelp-tools are available, this configuration script
# will configure JHBuild to install via autotools.
#
# If autotools and yelp-tools are not available, this configuration
# script will configure JHBuild to install via a plain Makefile.
#
# autogen.sh is used to configure JHBuild because the most common way to obtain
# JHBuild is via git and a 'configure' should not be checked into git.
#
# autogen.sh supports i18n using the package gettext. If gettext is not
# available english is used. To enable i18n autogen.sh builds mo files from po
# files using po/Makefile.plain. The mo files are in $srcdir/mo.
PKG_NAME=jhbuild
FALSE=1
TRUE=0
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
test -z "$MAKE" && MAKE=make
setup_i18n()
{
# Check msgfmt (from gettext) is installed to provide i18n for this script
hash msgfmt 2>&-
msgfmtl_available=$?
# Build mo from po files so i18n works for this script. mo files can't be
# checked in to git so they must be built here.
if [ $msgfmtl_available -eq 0 ]; then
# -s is for silent
# -C is for change directory
$make_from_environment -s -C $srcdir/po -f Makefile.plain
fi
# Check gettext.sh is installed to provide i18n for this script
hash gettext.sh 2>&-
gettext_sh_available=$?
if [ $gettext_sh_available -eq 0 ]; then
export TEXTDOMAINDIR=$srcdir/mo
export TEXTDOMAIN=jhbuild
. gettext.sh
fi
# Check gettext is installed to provide i18n for this script
hash gettext 2>&-
gettext_available=$?
}
# parse_commandline parses the commandline and sets shell variables accordingly.
# - sets $enable_autotools if --simple-install specified.
# - sets shell variables from long form options. e.g if commandline contains
# '--prefix=/opt' then shell variable prefix is set to '/opt'. Shell variable
# names must start with a letter or underscore and not contain special
# characters. Invalid variable names are ignored.
# parse_commandline is not using getopt as getopt doesn't support the long form
# on Solaris, BSD and MacOS.
parse_commandline()
{
enable_autotools=$TRUE
while [ -n "$1" ]; do
case "$1" in
--simple-install)
enable_autotools=$FALSE
;;
--prefix=*)
prefix="$(echo "$1" | cut -d= -f2)"
;;
esac
shift
done
}
# configure JHBuild to build and install without autotools via a plain
# Makefile. Sets up a Makefile.inc and copies Makefile.plain or
# Makefile.windows to Makefile
configure_without_autotools()
{
eval_gettext "Configuring \$PKG_NAME without autotools"; echo
makefile="$srcdir/Makefile.plain"
if [ "x$MSYSTEM" != "x" ]; then
makefile="$srcdir/Makefile.windows"
fi
# setup the defaults. The following can changed from the commandline.
# e.g. ./autogen.sh --prefix=${HOME}/jhbuildhome
[ -z $prefix ] && prefix=${HOME}/.local
[ -z $bindir ] && bindir=${prefix}/bin
[ -z $datarootdir ] && datarootdir=${prefix}/share
[ -z $desktopdir ] && desktopdir=${datarootdir}/applications
# Check to see if $srcdir/Makefile.inc is writable
if [ -f $srcdir/Makefile.inc ]; then
if [ ! -w $srcdir/Makefile.inc ]; then
eval_gettext "Unable to create file \$srcdir/Makefile.inc"; echo
exit 1
fi
else
if [ ! -w $srcdir ]; then
eval_gettext "Unable to create file \$srcdir/Makefile.inc"; echo
exit 1
fi
fi
echo "# This file is automatically generated by JHBuild's autogen.sh" \
> $srcdir/Makefile.inc
echo "# Do NOT edit. This file will be overwritten when autogen.sh is next" \
"run." >> $srcdir/Makefile.inc
echo "prefix=$prefix" >> $srcdir/Makefile.inc
echo "bindir=$bindir" >> $srcdir/Makefile.inc
echo "datarootdir=$datarootdir" >> $srcdir/Makefile.inc
echo "desktopdir=$desktopdir" >> $srcdir/Makefile.inc
if [ $msgfmtl_available -ne 0 ]; then
echo "DISABLE_GETTEXT=yes" >> $srcdir/Makefile.inc
fi
if [ ! -f $makefile ]; then
eval_gettext "Unable to read file \$makefile"; echo
exit 1
fi
cp $makefile $srcdir/Makefile || {
eval_gettext "Unable to copy \$makefile to \$srcdir/Makefile"
echo
exit 1
}
eval_gettext "Now type \`make' to compile \$PKG_NAME"; echo
}
# configure JHBuild to build and install via autotools.
configure_with_autotools()
{
test -d m4 || mkdir m4
test -d build-aux || mkdir build-aux
(test -f $srcdir/configure.ac) || {
echo "**Error**: Directory "\`$srcdir\'" does not look like the top-level project directory"
exit 1
}
if [ "$#" = 0 -a "x$NOCONFIGURE" = "x" ]; then
echo "**Warning**: I am going to run \`configure' with no arguments." >&2
echo "If you wish to pass any to it, please specify them on the" >&2
echo \`$0\'" command line." >&2
echo "" >&2
fi
set -x
( cd "$srcdir" && aclocal --install ) || exit 1
( cd "$srcdir" && autoreconf --verbose --force --install -Wno-portability ) || exit 1
if [ "$NOCONFIGURE" = "" ]; then
$srcdir/configure "$@" || exit 1
if [ "$1" = "--help" ]; then exit 0 else
echo "Now type \`make\' to compile $PKG_NAME" || exit 1
fi
else
echo "Skipping configure process."
fi
set +x
}
# Check for make. make is required to provide i18n for this script and to
# build and install JHBuild
make_from_environment=`echo $MAKE | cut -d' ' -f1`
hash $make_from_environment 2>&-
if [ $? -ne 0 ]; then
echo "\`$make_from_environment' is required to configure & build $PKG_NAME"
exit 1
fi
setup_i18n
if [ $gettext_available -ne 0 ]; then
# If gettext is not installed fallback to echo in english
gettext() { echo -n $1; }
# eval_gettext substitutes variables of the form: \$var
eval_gettext()
{
escaped_string=${1/\'/\\\'}
eval echo -n ${escaped_string/\`/\\\`}
}
fi
if [ ! -f $srcdir/jhbuild/main.py ]; then
eval_gettext "**Error**: Directory \`\$srcdir' does not look like the top-level \$PKG_NAME directory"
echo
exit 1
fi
# Check autotools is installed: autoconf, automake and pkgconfig.
hash aclocal 2>& -
autoconf_available=$?
hash automake 2>& -
automake_available=$?
hash pkg-config 2>& -
pkg_config_available=$?
# Check autopoint is installed.
hash autopoint 2>& -
autopoint_available=$?
# Check yelp-tools is installed.
hash yelp-build 2>&-
yelp_tools_available=$?
parse_commandline $*
autotools_dependencies_met=$FALSE
if [ $autoconf_available -eq $TRUE -a \
$automake_available -eq $TRUE -a \
$pkg_config_available -eq $TRUE -a \
$autopoint_available -eq $TRUE -a \
$yelp_tools_available -eq $TRUE ]; then
autotools_dependencies_met=$TRUE
fi
# As a hack, force use of autotools if NOCONFIGURE is specified; this
# allows the gnome-ostree build system to work which doesn't have
# yelp, but also can't pass options to autogen.sh
force_autotools=$FALSE
if test -n "$NOCONFIGURE"; then
force_autotools=$TRUE
fi
use_autotools=$FALSE
if [ $enable_autotools -eq $TRUE -a $autotools_dependencies_met -eq $TRUE ]; then
use_autotools=$TRUE
fi
if [ $force_autotools -eq $TRUE ]; then
use_autotools=$TRUE
fi
if [ $use_autotools -eq $TRUE ]; then
configure_with_autotools $*
else
if [ $autoconf_available -ne $TRUE ]; then
gettext "WARNING: aclocal not available (usually part of package 'autoconf')"; echo
fi
if [ $automake_available -ne $TRUE ]; then
gettext "WARNING: automake not available (usually part of package 'automake')"; echo
fi
if [ $autopoint_available -ne $TRUE ]; then
gettext "WARNING: autopoint not available (usually part of package 'gettext')"; echo
fi
if [ $pkg_config_available -ne $TRUE ]; then
gettext "WARNING: pkg-config not available (usually part of package 'pkgconfig')"; echo
fi
if [ $yelp_tools_available -ne $TRUE ]; then
gettext "WARNING: yelp-tools not available (usually part of package 'yelp-tools')"; echo
fi
configure_without_autotools
fi