Simplify macrology that creates unistd.h.
[gnulib.git] / m4 / unistd_h.m4
1 # unistd_h.m4 serial 4
2 dnl Copyright (C) 2006-2007 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 dnl Written by Simon Josefsson
8
9 AC_DEFUN([gl_HEADER_UNISTD],
10 [
11   dnl Use AC_REQUIRE here, so that the default behavior below is expanded
12   dnl once only, before all statements that occur in other macros.
13   AC_REQUIRE([gl_HEADER_UNISTD_DEFAULTS])
14
15   AC_CHECK_HEADERS([unistd.h], [], [
16     UNISTD_H='unistd.h'
17   ])
18   dnl This module decides to build unistd.h if it is missing.
19   dnl The fchdir module decides to build unistd.h if fchdir() is missing.
20   dnl Therefore check for the prerequisites of lib/unistd.h always.
21   gl_PREREQ_UNISTD
22 ])
23
24 dnl Prerequisites of lib/unistd.h.
25 AC_DEFUN([gl_PREREQ_UNISTD],
26 [
27   AC_CHECK_HEADERS_ONCE([unistd.h])
28   if test $ac_cv_header_unistd_h = yes; then
29     gl_ABSOLUTE_HEADER([unistd.h])
30     ABSOLUTE_UNISTD_H=\"$gl_cv_absolute_unistd_h\"
31   fi
32   AC_SUBST([ABSOLUTE_UNISTD_H])
33 ])
34
35 AC_DEFUN([gl_HEADER_UNISTD_DEFAULTS],
36 [
37   UNISTD_H=
38   AC_SUBST(UNISTD_H)
39 ])