Move first_prereq test to m4 code.
[ira/wip.git] / source / build / m4 / check_make.m4
1 dnl SMB Build Environment make Checks
2 dnl -------------------------------------------------------
3 dnl  Copyright (C) Stefan (metze) Metzmacher 2004
4 dnl  Copyright (C) Jelmer Vernooij 2005
5 dnl  Released under the GNU GPL
6 dnl -------------------------------------------------------
7 dnl
8
9 AC_PATH_PROG(MAKE,make)
10
11 AC_CACHE_CHECK([whether we have GNU make], samba_cv_gnu_make, [
12 if $ac_cv_path_MAKE --version | head -1 | grep GNU 2>/dev/null >/dev/null
13 then
14         samba_cv_gnu_make=yes
15 else
16         samba_cv_gnu_make=no
17 fi
18 ])
19
20 GNU_MAKE=$samba_cv_gnu_make
21 AC_SUBST(GNU_MAKE)
22
23 if test "x$GNU_MAKE" = x"yes"; then
24         AC_CACHE_CHECK([GNU make version], samba_cv_gnu_make_version,[
25                 samba_cv_gnu_make_version=`$ac_cv_path_MAKE --version | head -1 | cut -d " " -f 3 2>/dev/null`
26         ])
27         GNU_MAKE_VERSION=$samba_cv_gnu_make_version
28         AC_SUBST(GNU_MAKE_VERSION)
29 fi
30
31
32 new_make=no
33 AC_MSG_CHECKING([for GNU make >= 3.81])
34 if test x$GNU_MAKE = x"yes"; then
35         if $PERL -e " \$_ = '$GNU_MAKE_VERSION'; s/@<:@^\d\.@:>@.*//g; exit (\$_ < 3.81);"; then
36                 new_make=yes
37         fi
38 fi
39 AC_MSG_RESULT($new_make)
40 automatic_dependencies=no
41 AX_CFLAGS_GCC_OPTION([-M -MT conftest.d -MF conftest.o], [], [ automatic_dependencies=$new_make ], [])
42 AC_MSG_CHECKING([Whether to use automatic dependencies])
43 AC_ARG_ENABLE(automatic-dependencies,
44 [  --enable-automatic-dependencies Enable automatic dependencies],
45 [ automatic_dependencies=$enableval ], 
46 [ automatic_dependencies=no ])
47 AC_MSG_RESULT($automatic_dependencies)
48 AC_SUBST(automatic_dependencies)
49
50 FIRST_PREREQ="\$*.c"
51 AC_SUBST(FIRST_PREREQ)
52
53 if test x$GNU_MAKE = xyes; then
54         FIRST_PREREQ="\$<"
55 fi
56