AX_SUBMODULE: drop options that are meaningless given possible choices
[isl.git] / m4 / ax_submodule.m4
blob17e357f85c8bc444fc77815fa3fd8c3b1428a28d
1 AC_DEFUN([AX_SUBMODULE],
4 m4_if(m4_bregexp($2,|,choice),choice,
5         [AC_ARG_WITH($1,
6                 [AS_HELP_STRING([--with-$1=$2],
7                                 [Which $1 to use [default=$3]])])])
8 case "system" in
9 $2)
10         AC_ARG_WITH($1_prefix,
11                     [AS_HELP_STRING([--with-$1-prefix=DIR],
12                                     [Prefix of $1 installation])])
13         AC_ARG_WITH($1_exec_prefix,
14                     [AS_HELP_STRING([--with-$1-exec-prefix=DIR],
15                                     [Exec prefix of $1 installation])])
16 esac
17 m4_if(m4_bregexp($2,build,build),build,
18         [AC_ARG_WITH($1_builddir,
19                 [AS_HELP_STRING([--with-$1-builddir=DIR],
20                                 [Location of $1 builddir])])])
21 if test "x$with_$1_prefix" != "x" -a "x$with_$1_exec_prefix" = "x"; then
22         with_$1_exec_prefix=$with_$1_prefix
24 if test "x$with_$1_prefix" != "x" -o "x$with_$1_exec_prefix" != "x"; then
25         if test "x$with_$1" != "x" -a "x$with_$1" != "xsystem"; then
26                 AC_MSG_ERROR([Setting $with_$1_prefix implies use of system $1])
27         fi
28         with_$1="system"
30 if test "x$with_$1_builddir" != "x"; then
31         if test "x$with_$1" != "x" -a "x$with_$1" != "xbuild"; then
32                 AC_MSG_ERROR([Setting $with_$1_builddir implies use of build $1])
33         fi
34         with_$1="build"
35         $1_srcdir=`echo @abs_srcdir@ | $with_$1_builddir/config.status --file=-`
36         AC_MSG_NOTICE($1 sources in $$1_srcdir)
38 case "$with_$1" in
39 $2)
40         ;;
42         case "$3" in
43         bundled)
44                 if test -d $srcdir/.git -a \
45                         -d $srcdir/$1 -a \
46                         ! -d $srcdir/$1/.git; then
47                         AC_MSG_WARN([git repo detected, but submodule $1 not initialized])
48                         AC_MSG_WARN([You may want to run])
49                         AC_MSG_WARN([   git submodule init])
50                         AC_MSG_WARN([   git submodule update])
51                         AC_MSG_WARN([   sh autogen.sh])
52                 fi
53                 if test -f $srcdir/$1/configure; then
54                         with_$1="bundled"
55                 else
56                         with_$1="no"
57                 fi
58                 ;;
59         *)
60                 with_$1="$3"
61                 ;;
62         esac
63         ;;
64 esac
65 AC_MSG_CHECKING([which $1 to use])
66 AC_MSG_RESULT($with_$1)