2 # Run this to generate all the initial makefiles, etc.
12 srcdir
=$
(dirname "$0")
13 test "$srcdir" || srcdir
=.
16 die
"Failed to cd into $srcdir"
19 test -f src
/libvirt.c ||
{
20 die
"$0 must live in the top-level libvirt directory"
27 while test "$#" -gt 0; do
30 # This variable will serve both as an indicator of the fact that
31 # a dry run has been requested, and to store the result of the
32 # dry run. It will be ultimately used as return code for the
33 # script: 0 means no action is necessary, 2 means that autogen.sh
34 # needs to be executed, and 1 is reserved for failures
47 gnulib_srcdir
=" $1=$2"
55 if test -d $prefix/lib64
; then
60 extra_args
="--prefix=$prefix --localstatedir=$localstatedir"
61 extra_args
="$extra_args --sysconfdir=$sysconfdir --libdir=$libdir"
65 # All remaining arguments will be passed to configure verbatim
70 no_git
="$no_git$gnulib_srcdir"
76 if test "$no_git"; then
81 # Compute the hash we'll use to determine whether rerunning bootstrap
82 # is required. The first is just the SHA1 that selects a gnulib snapshot.
83 # The second ensures that whenever we change the set of gnulib modules used
84 # by this package, we rerun bootstrap to pull in the matching set of files.
85 # The third ensures that whenever we change the set of local gnulib diffs,
86 # we rerun bootstrap to pull in those diffs.
87 git submodule status .gnulib |
awk '{ print $1 }'
88 git hash-object bootstrap.conf
89 git ls-tree
-d HEAD gnulib
/local |
awk '{ print $3 }'
92 # Only look into git submodules if we're in a git checkout
93 if test -d .git ||
test -f .git
; then
95 # Check for dirty submodules
96 if test -z "$CLEAN_SUBMODULE"; then
97 for path
in $
(git submodule status |
awk '{ print $2 }'); do
98 case "$(git diff "$path")" in
100 echo "error: $path is dirty, please investigate" >&2
101 echo "set CLEAN_SUBMODULE to discard submodule changes" >&2
107 if test "$CLEAN_SUBMODULE" && test -z "$no_git"; then
108 if test -z "$dry_run"; then
109 echo "Cleaning up submodules..."
110 git submodule foreach
'git clean -dfqx && git reset --hard' ||
{
111 die
"Cleaning up submodules failed"
116 # Update all submodules. If any of the submodules has not been
117 # initialized yet, it will be initialized now; moreover, any submodule
118 # with uncommitted changes will be returned to the expected state
119 echo "Updating submodules..."
120 git submodule update
--init ||
{
121 die
"Updating submodules failed"
124 # The expected hash, eg. the one computed after the last
125 # successful bootstrap run, is stored on disk
126 state_file
=.git-module-status
127 expected_hash
=$
(cat "$state_file" 2>/dev
/null
)
128 actual_hash
=$
(gnulib_hash
"$no_git")
130 if test "$actual_hash" = "$expected_hash" && test -f AUTHORS
; then
131 # The gnulib hash matches our expectations, and all the files
132 # that can only be generated through bootstrap are present:
133 # we just need to run autoreconf. Unless we're performing a
134 # dry run, of course...
135 if test -z "$dry_run"; then
136 echo "Running autoreconf..."
138 die
"autoreconf failed"
142 # Whenever the gnulib submodule or any of the related bits
143 # has been changed in some way (see gnulib_hash) we need to
144 # run bootstrap again. If we're performing a dry run, we
145 # change the return code instead to signal our caller
146 if test "$dry_run"; then
149 echo "Running bootstrap..."
150 .
/bootstrap
$no_git --bootstrap-sync ||
{
151 die
"bootstrap failed"
153 gnulib_hash
>"$state_file"
158 # When performing a dry run, we can stop here
159 test "$dry_run" && exit "$dry_run"
161 # If asked not to run configure, we can stop here
162 test "$NOCONFIGURE" && exit 0
164 cd "$starting_point" ||
{
165 die
"Failed to cd into $starting_point"
168 if test "$OBJ_DIR"; then
169 mkdir
-p "$OBJ_DIR" ||
{
170 die
"Failed to create $OBJ_DIR"
173 die
"Failed to cd into $OBJ_DIR"
177 # Make sure we can find GNU make and tell the user
178 # the right command to run
180 for cmd
in make gmake
; do
181 if $cmd -v 2>&1 |
grep -q "GNU Make"; then
187 die
"GNU make is required to build libvirt"
190 if test -z "$*" && test -z "$extra_args" && test -f config.status
; then
191 echo "Running config.status..."
192 .
/config.status
--recheck ||
{
193 die
"config.status failed"
196 if test -z "$*" && test -z "$extra_args"; then
197 echo "I am going to run configure with no arguments - if you wish"
198 echo "to pass any to it, please specify them on the $0 command line."
200 echo "Running configure with $extra_args $@"
202 "$srcdir/configure" $extra_args "$@" ||
{
203 die
"configure failed"
208 echo "Now type '$MAKE' to compile libvirt."