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