Modify Makefile.am and configure.ac only if they actually change.
[sliver-openvswitch.git] / boot.sh
1 #! /bin/sh -e
2
3 have_ext=$(if test -e ext/automake.mk; then echo yes; else echo no; fi)
4 for opt
5 do
6     case $opt in
7         (--enable-ext) have_ext=yes ;;
8         (--disable-ext) have_ext=no ;;
9         (--help) cat <<EOF
10 $0: bootstrap OpenFlow from a Git repository
11 usage: $0 [OPTIONS]
12 The recognized options are:
13   --enable-ext      include openflowext
14   --disable-ext     exclude openflowext
15 By default, openflowext is included if it is present.
16 EOF
17         exit 0
18         ;;
19         (*) echo "unknown option $opt; use --help for help"; exit 1 ;;
20     esac
21 done
22
23
24 # Generate list of files in debian/ to distribute.
25 (echo '# Automatically generated by boot.sh (from Git tree).' &&
26  echo 'EXTRA_DIST += \' &&
27  git ls-files debian | grep -v '^debian/\.gitignore$' | 
28  sed -e 's/\(.*\)/      \1 \\/' -e '$s/ \\//') > debian/automake.mk
29
30 # Find the "include ext/automake.mk" line in Makefile.am and comment
31 # it out or in according to whether ext is available, and similarly
32 # for "m4_include(ext/configure.m4)" in configure.ac.
33 subst() {
34     perl -pe "$1" < "$2" > "$2.tmp"
35     if cmp -s "$2.tmp" "$2"; then
36         rm "$2.tmp"
37     else
38         mv "$2.tmp" "$2"
39     fi
40 }
41 if test "$have_ext" = yes; then
42     echo 'Enabling openflowext...'
43     OC='#'
44     NC=
45 else
46     echo 'Disabling openflowext...'
47     OC=
48     NC='#'
49 fi
50 subst "s|^$OC(include ext/automake\\.mk)\$|$NC\$1|" Makefile.am
51 subst "s|^$OC(m4_include\\(ext/configure\.m4\\))\$|$NC\$1|" configure.ac
52
53 # Bootstrap configure system from .ac/.am files
54 autoreconf --install -I config --force