Get rid of the warning about ignoring the return value of fgets
[cloog/uuh.git] / m4 / ax_submodule.m4
blob57e3a56e0472fb08b112b15c3bb9255ed2869628
1 AC_DEFUN([AX_SUBMODULE],
4 AC_ARG_WITH($1,
5         [AS_HELP_STRING([--with-$1=$2],
6                         [Which $1 to use])])
7 case "system" in
8 $2)
9         AC_ARG_WITH($1_prefix,
10                     [AS_HELP_STRING([--with-$1-prefix=DIR],
11                                     [Prefix of $1 installation])])
12         AC_ARG_WITH($1_exec_prefix,
13                     [AS_HELP_STRING([--with-$1-exec-prefix=DIR],
14                                     [Exec prefix of $1 installation])])
15 esac
16 case "build" in
17 $2)
18         AC_ARG_WITH($1_builddir,
19                     [AS_HELP_STRING([--with-$1-builddir=DIR],
20                                     [Location of $1 builddir])])
21 esac
22 if test "x$with_$1_prefix" != "x" -a "x$with_$1_exec_prefix" = "x"; then
23         with_$1_exec_prefix=$with_$1_prefix
25 if test "x$with_$1_prefix" != "x" -o "x$with_$1_exec_prefix" != "x"; then
26         if test "x$with_$1" != "x" -a "x$with_$1" != "xsystem"; then
27                 AC_MSG_ERROR([Setting $with_$1_prefix implies use of system $1])
28         fi
29         with_$1="system"
31 if test "x$with_$1_builddir" != "x"; then
32         if test "x$with_$1" != "x" -a "x$with_$1" != "xbuild"; then
33                 AC_MSG_ERROR([Setting $with_$1_builddir implies use of build $1])
34         fi
35         with_$1="build"
36         $1_srcdir=`echo @abs_srcdir@ | $with_$1_builddir/config.status --file=-`
37         AC_MSG_NOTICE($1 sources in $$1_srcdir)
39 case "$with_$1" in
40 $2)
41         ;;
43         if test -d $srcdir/.git -a \
44                 -d $srcdir/$1 -a \
45                 ! -d $srcdir/$1/.git; then
46                 AC_MSG_WARN(
47 [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 -a "$3" != "no"; then
54                 with_$1="bundled"
55         else
56                 with_$1="$3"
57         fi
58         ;;
59 esac
60 AC_MSG_CHECKING([which $1 to use])
61 AC_MSG_RESULT($with_$1)