postpone handling of assignments until the point where we need them
[pet.git] / m4 / ax_submodule.m4
blob8129312d0eb4314ba398f90dbc04873c33b5e822
1 AC_DEFUN([_AX_SUBMODULE],
4 m4_if(m4_bregexp($3,|,choice),choice,
5         [AC_ARG_WITH($2,
6                 [AS_HELP_STRING([--with-$1=$3],
7                                 [Which $1 to use [default=$4]])])])
8 case "system" in
9 $3)
10         AC_ARG_WITH($2_prefix,
11                     [AS_HELP_STRING([--with-$1-prefix=DIR],
12                                     [Prefix of $1 installation])])
13         AC_ARG_WITH($2_exec_prefix,
14                     [AS_HELP_STRING([--with-$1-exec-prefix=DIR],
15                                     [Exec prefix of $1 installation])])
16 esac
17 m4_if(m4_bregexp($3,build,build),build,
18         [AC_ARG_WITH($2_builddir,
19                 [AS_HELP_STRING([--with-$1-builddir=DIR],
20                                 [Location of $1 builddir])])])
21 if test "x$with_$2_prefix" != "x" -a "x$with_$2_exec_prefix" = "x"; then
22         with_$2_exec_prefix=$with_$2_prefix
24 if test "x$with_$2_prefix" != "x" -o "x$with_$2_exec_prefix" != "x"; then
25         if test "x$with_$2" != "x" -a "x$with_$2" != "xsystem"; then
26                 AC_MSG_ERROR([Setting $with_$2_prefix implies use of system $1])
27         fi
28         with_$2="system"
30 if test "x$with_$2_builddir" != "x"; then
31         if test "x$with_$2" != "x" -a "x$with_$2" != "xbuild"; then
32                 AC_MSG_ERROR([Setting $with_$2_builddir implies use of build $1])
33         fi
34         with_$2="build"
35         $2_srcdir=`echo @abs_srcdir@ | $with_$2_builddir/config.status --file=-`
36         AC_MSG_NOTICE($1 sources in $$2_srcdir)
38 if test "x$with_$2_exec_prefix" != "x"; then
39         export PKG_CONFIG_PATH="$with_$2_exec_prefix/lib/pkgconfig${PKG_CONFIG_PATH+:$PKG_CONFIG_PATH}"
41 case "$with_$2" in
42 $3)
43         ;;
45         case "$4" in
46         bundled)
47                 if test -d $srcdir/.git -a \
48                         -d $srcdir/$1 -a \
49                         "`cd $srcdir; git submodule status $1 | cut -c1`" = '-'; then
50                         AC_MSG_WARN([git repo detected, but submodule $1 not initialized])
51                         AC_MSG_WARN([You may want to run])
52                         AC_MSG_WARN([   git submodule init])
53                         AC_MSG_WARN([   git submodule update])
54                         AC_MSG_WARN([   sh autogen.sh])
55                 fi
56                 if test -f $srcdir/$1/configure; then
57                         with_$2="bundled"
58                 else
59                         case "system" in
60                         $3)
61                                 with_$2="system"
62                                 ;;
63                         *)
64                                 with_$2="no"
65                                 ;;
66                         esac
67                 fi
68                 ;;
69         *)
70                 with_$2="$4"
71                 ;;
72         esac
73         ;;
74 esac
75 AC_MSG_CHECKING([which $1 to use])
76 AC_MSG_RESULT($with_$2)
80 AC_DEFUN([AX_SUBMODULE], [
81         _AX_SUBMODULE($1, m4_bpatsubst([$1],
82                         [[^_abcdefghijklmnopqrstuvwxyz0123456789]],[_]), $2, $3)