warnings: fix compilation with old autoconf
[gnulib/ericb.git] / m4 / net_if_h.m4
blobb9d92adf22aa02e5aac8a01762efdb938cced26d
1 # net_if_h.m4 serial 1
2 dnl Copyright (C) 2006-2017 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_HEADER_NET_IF],
9   AC_CACHE_CHECK([whether <net/if.h> is self-contained],
10     [gl_cv_header_net_if_h_selfcontained],
11     [
12       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <net/if.h>]],
13                                          [[struct if_nameindex ni;]])],
14         [gl_cv_header_net_if_h_selfcontained=yes],
15         [gl_cv_header_net_if_h_selfcontained=no])
16     ])
17   if test $gl_cv_header_net_if_h_selfcontained = yes; then
18     NET_IF_H=''
19   else
20     NET_IF_H='net/if.h'
21     AC_CHECK_HEADERS([net/if.h], [], [], [[#include <sys/socket.h>]])
22     gl_NEXT_HEADERS([net/if.h])
23     if test $ac_cv_header_net_if_h = yes; then
24       HAVE_NET_IF_H=1
25     else
26       HAVE_NET_IF_H=0
27     fi
28     AC_SUBST([HAVE_NET_IF_H])
29   fi
30   AC_SUBST([NET_IF_H])
31   AM_CONDITIONAL([GL_GENERATE_NET_IF_H], [test -n "$NET_IF_H"])