Release GNU make 3.81.
[make.git] / acinclude.m4
blobc98da21e7e82bac0804b891e2e742f46ddd76d2c
1 dnl acinclude.m4 -- Extra macros needed for GNU make.
2 dnl
3 dnl Automake will incorporate this into its generated aclocal.m4.
4 dnl Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
5 dnl Free Software Foundation, Inc.
6 dnl This file is part of GNU Make.
7 dnl
8 dnl GNU Make is free software; you can redistribute it and/or modify it
9 dnl under the terms of the GNU General Public License as published by
10 dnl the Free Software Foundation; either version 2, or (at your option)
11 dnl any later version.
12 dnl
13 dnl GNU Make is distributed in the hope that it will be useful, but
14 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
15 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 dnl General Public License for more details.
17 dnl
18 dnl You should have received a copy of the GNU General Public License
19 dnl along with GNU Make; see the file COPYING.  If not, write to the
20 dnl Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
21 dnl MA 02110-1301 USA.
24 dnl ---------------------------------------------------------------------------
25 dnl Got this from the lynx 2.8 distribution.
26 dnl by T.E.Dickey <dickey@clark.net>
27 dnl and Jim Spath <jspath@mail.bcpl.lib.md.us>
28 dnl and Philippe De Muyter <phdm@macqel.be>
29 dnl
30 dnl Created: 1997/1/28
31 dnl Updated: 1997/12/23
32 dnl ---------------------------------------------------------------------------
33 dnl After checking for functions in the default $LIBS, make a further check
34 dnl for the functions that are netlib-related (these aren't always in the
35 dnl libc, etc., and have to be handled specially because there are conflicting
36 dnl and broken implementations.
37 dnl Common library requirements (in order):
38 dnl     -lresolv -lsocket -lnsl
39 dnl     -lnsl -lsocket
40 dnl     -lsocket
41 dnl     -lbsd
42 AC_DEFUN([CF_NETLIBS],[
43 cf_test_netlibs=no
44 AC_MSG_CHECKING(for network libraries)
45 AC_CACHE_VAL(cf_cv_netlibs,[
46 AC_MSG_RESULT(working...)
47 cf_cv_netlibs=""
48 cf_test_netlibs=yes
49 AC_CHECK_FUNCS(gethostname,,[
50         CF_RECHECK_FUNC(gethostname,nsl,cf_cv_netlibs,[
51                 CF_RECHECK_FUNC(gethostname,socket,cf_cv_netlibs)])])
53 # FIXME:  sequent needs this library (i.e., -lsocket -linet -lnsl), but
54 # I don't know the entrypoints - 97/7/22 TD
55 AC_CHECK_LIB(inet,main,cf_cv_netlibs="-linet $cf_cv_netlibs")
57 if test "$ac_cv_func_lsocket" != no ; then
58 AC_CHECK_FUNCS(socket,,[
59         CF_RECHECK_FUNC(socket,socket,cf_cv_netlibs,[
60                 CF_RECHECK_FUNC(socket,bsd,cf_cv_netlibs)])])
63 AC_CHECK_FUNCS(gethostbyname,,[
64         CF_RECHECK_FUNC(gethostbyname,nsl,cf_cv_netlibs)])
66 AC_CHECK_FUNCS(strcasecmp,,[
67         CF_RECHECK_FUNC(strcasecmp,resolv,cf_cv_netlibs)])
69 LIBS="$LIBS $cf_cv_netlibs"
70 test $cf_test_netlibs = no && echo "$cf_cv_netlibs" >&AC_FD_MSG
71 ])dnl
72 dnl ---------------------------------------------------------------------------
73 dnl Re-check on a function to see if we can pick it up by adding a library.
74 dnl     $1 = function to check
75 dnl     $2 = library to check in
76 dnl     $3 = environment to update (e.g., $LIBS)
77 dnl     $4 = what to do if this fails
78 dnl
79 dnl This uses 'unset' if the shell happens to support it, but leaves the
80 dnl configuration variable set to 'unknown' if not.  This is a little better
81 dnl than the normal autoconf test, which gives misleading results if a test
82 dnl for the function is made (e.g., with AC_CHECK_FUNC) after this macro is
83 dnl used (autoconf does not distinguish between a null token and one that is
84 dnl set to 'no').
85 AC_DEFUN([CF_RECHECK_FUNC],[
86 AC_CHECK_LIB($2,$1,[
87         CF_UPPER(cf_tr_func,$1)
88         AC_DEFINE_UNQUOTED(HAVE_$cf_tr_func,1,[Define if you have function $1])
89         ac_cv_func_$1=yes
90         $3="-l$2 [$]$3"],[
91         ac_cv_func_$1=unknown
92         unset ac_cv_func_$1 2>/dev/null
93         $4],
94         [[$]$3])
95 ])dnl
96 dnl ---------------------------------------------------------------------------
97 dnl Make an uppercase version of a variable
98 dnl $1=uppercase($2)
99 AC_DEFUN([CF_UPPER],
101 changequote(,)dnl
102 $1=`echo $2 | tr '[a-z]' '[A-Z]'`
103 changequote([,])dnl
104 ])dnl
107 dnl ---------------------------------------------------------------------------
108 dnl From Paul Eggert <eggert@twinsun.com>
110 AC_DEFUN([AC_STRUCT_ST_MTIM_NSEC],
111  [AC_CACHE_CHECK([for nanoseconds field of struct stat.st_mtim],
112    ac_cv_struct_st_mtim_nsec,
113    [ac_save_CPPFLAGS="$CPPFLAGS"
114     ac_cv_struct_st_mtim_nsec=no
115     # tv_nsec -- the usual case
116     # _tv_nsec -- Solaris 2.6, if
117     #   (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
118     #    && !defined __EXTENSIONS__)
119     # st__tim.tv_nsec -- UnixWare 2.1.2
120     for ac_val in tv_nsec _tv_nsec st__tim.tv_nsec; do
121       CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
122       AC_TRY_COMPILE([#include <sys/types.h>
123 #include <sys/stat.h>
124         ], [struct stat s; s.st_mtim.ST_MTIM_NSEC;],
125         [ac_cv_struct_st_mtim_nsec=$ac_val; break])
126     done
127     CPPFLAGS="$ac_save_CPPFLAGS"
128    ])
130   if test $ac_cv_struct_st_mtim_nsec != no; then
131     AC_DEFINE_UNQUOTED([ST_MTIM_NSEC], [$ac_cv_struct_st_mtim_nsec],
132         [Define if struct stat contains a nanoseconds field])
133   fi