* MODULES.html.sh: Add glob to Enhanced POSIX.2001 section.
[pspp] / m4 / glob.m4
1 # glob.m4 serial 1
2 dnl Copyright (C) 2005 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.
6
7 # The glob module assumes you want GNU glob, with glob_pattern_p etc,
8 # rather than vanilla POSIX glob.  This means your your code should
9 # always include <glob.h> for the glob prototypes.
10
11 AC_DEFUN([gl_GLOB_SUBSTITUTE],
12 [
13   gl_PREREQ_GLOB
14
15   GLOB_H=glob.h
16   AC_LIBOBJ([glob])
17   AC_DEFINE([GLOB_PREFIX], [[rpl_]],
18     [Define to rpl_ if the glob replacement functions and variables
19      should be used.])
20   AC_SUBST([GLOB_H])
21 ])
22
23 AC_DEFUN([gl_GLOB],
24 [ GLOB_H=
25   AC_CHECK_HEADERS([glob.h], [], [GLOB_H=glob.h])
26
27   if test -z "$GLOB_H"; then
28     AC_COMPILE_IFELSE(
29 [[#include <gnu-versions.h>
30 char a[_GNU_GLOB_INTERFACE_VERSION == 1 ? 1 : -1];]],
31       [], [GLOB_H=glob.h])
32   fi
33
34   if test -n "$GLOB_H"; then
35     gl_GLOB_SUBSTITUTE
36   fi
37 ])
38
39 # Prerequisites of lib/glob.*.
40 AC_DEFUN([gl_PREREQ_GLOB],
41 [ AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])dnl
42   AC_REQUIRE([AC_HEADER_DIRENT])dnl
43   AC_CHECK_HEADERS_ONCE([sys/cdefs.h unistd.h])dnl
44   AC_CHECK_FUNCS_ONCE([getlogin_r getpwnam_r])dnl
45   AC_CHECK_HEADERS([sys/cdefs.h], [SYS_CDEFS_H=yes], [SYS_CDEFS_H=no])
46   if test $SYS_CDEFS_H = no; then
47     AC_DEFINE(MISSING_SYS_CDEFS_H, 1,
48       [Define to `1' if <sys/cdefs.h> is *not* available on this system.])
49   fi
50   :])