build: Add ./configure --disable-php option.
[libguestfs.git] / autogen.sh
1 #!/bin/bash -
2 # libguestfs
3 # Copyright (C) 2009 Red Hat Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 #
19 # Rebuild the autotools environment.
20
21 set -e
22 set -v
23
24 # ocaml/.depend is updated automatically. However, as it's included by
25 # ocaml/Makefile.am we need to bootstrap it here.
26 touch ocaml/.depend
27
28 # Ensure that whenever we pull in a gnulib update or otherwise change to a
29 # different version (i.e., when switching branches), we also rerun ./bootstrap.
30 curr_status=.git-module-status
31 t=$(git submodule status|sed 's/^[ +-]//;s/ .*//')
32 if test "$t" = "$(cat $curr_status 2>/dev/null)"; then
33     : # good, it's up to date
34 else
35     echo running bootstrap...
36     ./bootstrap && echo "$t" > $curr_status
37 fi
38
39 CONFIGUREDIR=.
40
41 # Run configure in BUILDDIR if it's set
42 if [ ! -z "$BUILDDIR" ]; then
43     mkdir -p $BUILDDIR
44     cd $BUILDDIR
45
46     CONFIGUREDIR=..
47 fi
48
49 # Ensure that an ocaml package is present for build-from sources.
50 # This is *not* for anything that is required at configure-time
51 # when configure is run from a distribution tarball.  From those,
52 # nothing ocaml-related is required.
53 # ocamlfind cannot detect the presence of -devel packages directly,
54 # so if $pkg ends in -devel, first check for the base package, and
55 # if that's found, check for the existence of $base.cmxa in the
56 # resulting directory.
57 require_ocaml_pkg()
58 {
59   pkg=$1
60   case $pkg in
61     *-devel)
62       local base=${pkg%%-devel}
63       local dir=$(ocamlfind query "$base") || return 1
64       test -f "$dir/$base.cmxa" || return 1
65       ;;
66     *) ocamlfind query "$pkg" > /dev/null 2>&1 || return 1;;
67   esac
68   return 0
69 }
70
71 { require_ocaml_pkg xml-light && require_ocaml_pkg xml-light-devel; } \
72   || { echo "you must have ocaml, ocamlfind, ocaml-xml-light" \
73          "and ocaml-xml-light-devel" >&2; exit 1; }
74
75 # If no arguments were specified and configure has run before, use the previous
76 # arguments
77 if test $# == 0 && test -x ./config.status; then
78     ./config.status --recheck
79 else
80     $CONFIGUREDIR/configure "$@"
81 fi