(gl_SYS__SYSTEM_CONFIGURATION): New macro.
[gnulib.git] / m4 / physmem.m4
1 # physmem.m4 serial 2
2 dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
3 dnl This file is free software, distributed under the terms of the GNU
4 dnl General Public License.  As a special exception to the GNU General
5 dnl Public License, this file may be distributed as part of a program
6 dnl that contains a configuration script generated by Autoconf, under
7 dnl the same distribution terms as the rest of that program.
8
9 # Check for the external symbol, _system_configuration,
10 # a struct with member `physmem'.
11 AC_DEFUN([gl_SYS__SYSTEM_CONFIGURATION],
12   [AC_CACHE_CHECK(for external symbol _system_configuration,
13                   gl_cv_var__system_configuration,
14     [AC_LINK_IFELSE([AC_LANG_PROGRAM(
15                       [[#include <sys/systemcfg.h>
16                       ]],
17                       [double x = _system_configuration.physmem;])],
18       [gl_cv_var__system_configuration=yes],
19       [gl_cv_var__system_configuration=no])])
20
21     if test $gl_cv_var__system_configuration = yes; then
22       AC_DEFINE(HAVE__SYSTEM_CONFIGURATION, 1,
23                 [Define to 1 if you have the external variable,
24                 _system_configuration with a member named physmem.])
25     fi
26   ]
27 )
28
29 AC_DEFUN([gl_PHYSMEM],
30 [
31   # Prerequisites of lib/physmem.c.
32   AC_CHECK_HEADERS_ONCE(unistd.h)
33   AC_CHECK_HEADERS([sys/pstat.h sys/sysmp.h sys/sysinfo.h \
34     machine/hal_sysinfo.h sys/table.h sys/param.h sys/sysctl.h \
35     sys/systemcfg.h],,, [AC_INCLUDES_DEFAULT])
36
37   AC_CHECK_FUNCS(pstat_getstatic pstat_getdynamic sysmp getsysinfo sysctl table)
38   AC_REQUIRE([gl_SYS__SYSTEM_CONFIGURATION])
39 ])