aa3c5dc27e11424a60d17e5c9902b25ac786a45e
[libguestfs.git] / bootstrap
1 #!/bin/sh
2
3 usage() {
4   echo >&2 "\
5 Usage: $0 [OPTION]...
6 Bootstrap this package from the checked-out sources.
7
8 Options:
9  --gnulib-srcdir=DIRNAME  Specify the local directory where gnulib
10                           sources reside.  Use this if you already
11                           have gnulib sources on your machine, and
12                           do not want to waste your bandwidth downloading
13                           them again.
14
15 If the file bootstrap.conf exists in the current working directory, its
16 contents are read as shell variables to configure the bootstrap.
17
18 Running without arguments will suffice in most cases.
19 "
20 }
21
22 for option
23 do
24   case $option in
25   --help)
26     usage
27     exit;;
28   --gnulib-srcdir=*)
29     GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
30   *)
31     echo >&2 "$0: $option: unknown option"
32     exit 1;;
33   esac
34 done
35
36 # Get gnulib files.
37
38 case ${GNULIB_SRCDIR--} in
39 -)
40   echo "$0: getting gnulib files..."
41   git submodule init || exit $?
42   git submodule update || exit $?
43   GNULIB_SRCDIR=.gnulib
44   ;;
45 *)
46   # Redirect the gnulib submodule to the directory on the command line
47   # if possible.
48   if test -d "$GNULIB_SRCDIR"/.git && \
49         git config --file .gitmodules submodule.gnulib.url >/dev/null; then
50     git submodule init
51     GNULIB_SRCDIR=`cd $GNULIB_SRCDIR && pwd`
52     git config --replace-all submodule.gnulib.url $GNULIB_SRCDIR
53     echo "$0: getting gnulib files..."
54     git submodule update || exit $?
55     GNULIB_SRCDIR=.gnulib
56   else
57     echo >&2 "$0: invalid gnulib srcdir: $GNULIB_SRCDIR"
58     exit 1
59   fi
60   ;;
61 esac
62
63 ls po/*.po 2>/dev/null | sed 's|.*/||; s|\.po$||' > po/LINGUAS
64
65 # Create gettext configuration.
66 echo "$0: Creating po/Makevars from po/Makevars.template ..."
67 rm -f po/Makevars
68 sed '
69   /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
70   /^MSGID_BUGS_ADDRESS *=/s/=.*/= '"$MSGID_BUGS_ADDRESS"'/
71   /^XGETTEXT_OPTIONS *=/{
72     s/$/ \\/
73     a\
74         '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
75   }
76 ' po/Makevars.template >po/Makevars
77
78 gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
79 <$gnulib_tool || exit
80
81 (cd daemon && mkdir -p tests lib && $GNULIB_SRCDIR/../gnulib-tool --update)
82
83 modules='
84 gitlog-to-changelog
85 gnu-make
86 gnumakefile
87 maintainer-makefile
88 manywarnings
89 warnings
90 vc-list-files
91 '
92
93 $gnulib_tool                    \
94   --avoid=dummy                 \
95   --with-tests                  \
96   --m4-base=gnulib/m4           \
97   --source-base=gnulib/lib      \
98   --tests-base=gnulib/tests     \
99   --import $modules