]> git.sur5r.net Git - i3/i3status/blob - m4/ax_check_gnu_make.m4
Merge pull request #333 from stapelberg/sysconfdir
[i3/i3status] / m4 / ax_check_gnu_make.m4
1 # ===========================================================================
2 #     http://www.gnu.org/software/autoconf-archive/ax_check_gnu_make.html
3 # ===========================================================================
4 #
5 # SYNOPSIS
6 #
7 #   AX_CHECK_GNU_MAKE()
8 #
9 # DESCRIPTION
10 #
11 #   This macro searches for a GNU version of make. If a match is found:
12 #
13 #     * The makefile variable `ifGNUmake' is set to the empty string, otherwise
14 #       it is set to "#". This is useful for including a special features in a
15 #       Makefile, which cannot be handled by other versions of make.
16 #     * The variable `_cv_gnu_make_command` is set to the command to invoke
17 #       GNU make if it exists, the empty string otherwise.
18 #     * The variable `ax_cv_gnu_make_command` is set to the command to invoke
19 #       GNU make by copying `_cv_gnu_make_command`, otherwise it is unset.
20 #     * If GNU Make is found, its version is extracted from the output of
21 #       `make --version` as the last field of a record of space-separated
22 #       columns and saved into the variable `ax_check_gnu_make_version`.
23 #
24 #   Here is an example of its use:
25 #
26 #   Makefile.in might contain:
27 #
28 #     # A failsafe way of putting a dependency rule into a makefile
29 #     $(DEPEND):
30 #             $(CC) -MM $(srcdir)/*.c > $(DEPEND)
31 #
32 #     @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
33 #     @ifGNUmake@ include $(DEPEND)
34 #     @ifGNUmake@ endif
35 #
36 #   Then configure.in would normally contain:
37 #
38 #     AX_CHECK_GNU_MAKE()
39 #     AC_OUTPUT(Makefile)
40 #
41 #   Then perhaps to cause gnu make to override any other make, we could do
42 #   something like this (note that GNU make always looks for GNUmakefile
43 #   first):
44 #
45 #     if  ! test x$_cv_gnu_make_command = x ; then
46 #             mv Makefile GNUmakefile
47 #             echo .DEFAULT: > Makefile ;
48 #             echo \  $_cv_gnu_make_command \$@ >> Makefile;
49 #     fi
50 #
51 #   Then, if any (well almost any) other make is called, and GNU make also
52 #   exists, then the other make wraps the GNU make.
53 #
54 # LICENSE
55 #
56 #   Copyright (c) 2008 John Darrington <j.darrington@elvis.murdoch.edu.au>
57 #   Copyright (c) 2015 Enrico M. Crisostomo <enrico.m.crisostomo@gmail.com>
58 #
59 #   Copying and distribution of this file, with or without modification, are
60 #   permitted in any medium without royalty provided the copyright notice
61 #   and this notice are preserved. This file is offered as-is, without any
62 #   warranty.
63
64 #serial 8
65
66 AC_DEFUN([AX_CHECK_GNU_MAKE],dnl
67   [AC_PROG_AWK
68   AC_CACHE_CHECK([for GNU make],[_cv_gnu_make_command],[dnl
69     _cv_gnu_make_command="" ;
70 dnl Search all the common names for GNU make
71     for a in "$MAKE" make gmake gnumake ; do
72       if test -z "$a" ; then continue ; fi ;
73       if "$a" --version 2> /dev/null | grep GNU 2>&1 > /dev/null ; then
74         _cv_gnu_make_command=$a ;
75         AX_CHECK_GNU_MAKE_HEADLINE=$("$a" --version 2> /dev/null | grep "GNU Make")
76         ax_check_gnu_make_version=$(echo ${AX_CHECK_GNU_MAKE_HEADLINE} | ${AWK} -F " " '{ print $(NF); }')
77         break ;
78       fi
79     done ;])
80 dnl If there was a GNU version, then set @ifGNUmake@ to the empty string, '#' otherwise
81   AS_VAR_IF([_cv_gnu_make_command], [""], [AS_VAR_SET([ifGNUmake], ["#"])],   [AS_VAR_SET([ifGNUmake], [""])])
82   AS_VAR_IF([_cv_gnu_make_command], [""], [AS_UNSET(ax_cv_gnu_make_command)], [AS_VAR_SET([ax_cv_gnu_make_command], [${_cv_gnu_make_command}])])
83   AC_SUBST([ifGNUmake])
84 ])