~ubuntu-branches/ubuntu/gutsy/m4/gutsy

« back to all changes in this revision

Viewing changes to m4/include_next.m4

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-08-01 14:00:55 UTC
  • mfrom: (1.5.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070801140055-ob48jo517shsyvgk
Tags: 1.4.10-0ubuntu1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# include_next.m4 serial 3
 
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 From Paul Eggert and Derek Price.
 
8
 
 
9
AC_DEFUN([gl_INCLUDE_NEXT],
 
10
[
 
11
  AC_LANG_PREPROC_REQUIRE()
 
12
  AC_CACHE_CHECK([whether the preprocessor supports include_next],
 
13
    [gl_cv_have_include_next],
 
14
    [AC_PREPROC_IFELSE([#include_next <stddef.h>],
 
15
       [gl_cv_have_include_next=yes],
 
16
       [gl_cv_have_include_next=no])])
 
17
  if test $gl_cv_have_include_next = yes; then
 
18
 
 
19
    dnl FIXME: Remove HAVE_INCLUDE_NEXT and update everything that uses it
 
20
    dnl to use @INCLUDE_NEXT@ instead.
 
21
    AC_DEFINE([HAVE_INCLUDE_NEXT], 1,
 
22
              [Define if your compiler supports the #include_next directive.])
 
23
 
 
24
    INCLUDE_NEXT=include_next
 
25
  else
 
26
    INCLUDE_NEXT=include
 
27
  fi
 
28
  AC_SUBST([INCLUDE_NEXT])
 
29
])
 
30
 
 
31
# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...)
 
32
# ------------------------------------------
 
33
# For each arg foo.h, if #include_next works, define NEXT_FOO_H to be
 
34
# '<foo.h>'; otherwise define it to be
 
35
# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
 
36
# That way, a header file with the following line:
 
37
#       #@INCLUDE_NEXT@ @NEXT_FOO_H@
 
38
# behaves (after sed substitution) as if it contained
 
39
#       #include_next <foo.h>
 
40
# even if the compiler does not support include_next.
 
41
# The three "///" are to pacify Sun C 5.8, which otherwise would say
 
42
# "warning: #include of /usr/include/... may be non-portable".
 
43
# Use `""', not `<>', so that the /// cannot be confused with a C99 comment.
 
44
AC_DEFUN([gl_CHECK_NEXT_HEADERS],
 
45
[
 
46
  AC_REQUIRE([gl_INCLUDE_NEXT])
 
47
  AC_CHECK_HEADERS_ONCE([$1])
 
48
 
 
49
  AC_FOREACH([gl_HEADER_NAME], [$1],
 
50
    [AS_VAR_PUSHDEF([gl_next_header],
 
51
                    [gl_cv_next_]m4_quote(m4_defn([gl_HEADER_NAME])))
 
52
     if test $gl_cv_have_include_next = yes; then
 
53
       AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
 
54
     else
 
55
       AC_CACHE_CHECK(
 
56
         [absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>],
 
57
         m4_quote(m4_defn([gl_next_header])),
 
58
         [AS_VAR_PUSHDEF([gl_header_exists],
 
59
                         [ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME])))
 
60
          if test AS_VAR_GET(gl_header_exists) = yes; then
 
61
            AC_LANG_CONFTEST(
 
62
              [AC_LANG_SOURCE(
 
63
                 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
 
64
               )])
 
65
            dnl eval is necessary to expand ac_cpp.
 
66
            dnl Ultrix and Pyramid sh refuse to redirect output of eval,
 
67
            dnl so use subshell.
 
68
            AS_VAR_SET([gl_next_header],
 
69
              ['"'`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
 
70
               sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{
 
71
                 s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#
 
72
                 s#^/[^/]#//&#
 
73
                 p
 
74
                 q
 
75
               }'`'"'])
 
76
          else
 
77
            AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
 
78
          fi
 
79
          AS_VAR_POPDEF([gl_header_exists])])
 
80
     fi
 
81
     AC_SUBST(
 
82
       AS_TR_CPP([NEXT_]m4_quote(m4_defn([gl_HEADER_NAME]))),
 
83
       [AS_VAR_GET([gl_next_header])])
 
84
     AS_VAR_POPDEF([gl_next_header])])
 
85
])