~ubuntu-branches/ubuntu/oneiric/gnutls26/oneiric

« back to all changes in this revision

Viewing changes to lib/gl/m4/include_next.m4

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-05-20 13:07:18 UTC
  • mfrom: (12.1.11 sid)
  • Revision ID: james.westby@ubuntu.com-20110520130718-db41dybbanzfvlji
Tags: 2.10.5-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Fix build failure with --no-add-needed.
  - Build for multiarch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# include_next.m4 serial 12
2
 
dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
 
1
# include_next.m4 serial 14
 
2
dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
3
3
dnl This file is free software; the Free Software Foundation
4
4
dnl gives unlimited permission to copy and/or distribute it,
5
5
dnl with or without modifications, as long as this notice is preserved.
104
104
# For each arg foo.h, if #include_next works, define NEXT_FOO_H to be
105
105
# '<foo.h>'; otherwise define it to be
106
106
# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
 
107
# Also, if #include_next works as first preprocessing directive in a file,
 
108
# define NEXT_AS_FIRST_DIRECTIVE_FOO_H to be '<foo.h>'; otherwise define it to
 
109
# be
 
110
# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
107
111
# That way, a header file with the following line:
108
 
#       #@INCLUDE_NEXT@ @NEXT_FOO_H@
 
112
#       #@INCLUDE_NEXT@ @NEXT_FOO_H@
 
113
# or
 
114
#       #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@
109
115
# behaves (after sed substitution) as if it contained
110
 
#       #include_next <foo.h>
 
116
#       #include_next <foo.h>
111
117
# even if the compiler does not support include_next.
112
118
# The three "///" are to pacify Sun C 5.8, which otherwise would say
113
119
# "warning: #include of /usr/include/... may be non-portable".
123
129
 
124
130
  m4_foreach_w([gl_HEADER_NAME], [$1],
125
131
    [AS_VAR_PUSHDEF([gl_next_header],
126
 
                    [gl_cv_next_]m4_quote(m4_defn([gl_HEADER_NAME])))
 
132
                    [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
127
133
     if test $gl_cv_have_include_next = yes; then
128
134
       AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
129
135
     else
130
136
       AC_CACHE_CHECK(
131
 
         [absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>],
132
 
         m4_quote(m4_defn([gl_next_header])),
133
 
         [AS_VAR_PUSHDEF([gl_header_exists],
134
 
                         [ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME])))
135
 
          if test AS_VAR_GET(gl_header_exists) = yes; then
136
 
            AC_LANG_CONFTEST(
137
 
              [AC_LANG_SOURCE(
138
 
                 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
139
 
               )])
140
 
            dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
141
 
            dnl that contain only a #include of other header files and no
142
 
            dnl non-comment tokens of their own. This leads to a failure to
143
 
            dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
144
 
            dnl and others. The workaround is to force preservation of comments
145
 
            dnl through option -C. This ensures all necessary #line directives
146
 
            dnl are present. GCC supports option -C as well.
147
 
            case "$host_os" in
148
 
              aix*) gl_absname_cpp="$ac_cpp -C" ;;
149
 
              *)    gl_absname_cpp="$ac_cpp" ;;
150
 
            esac
151
 
            dnl eval is necessary to expand gl_absname_cpp.
152
 
            dnl Ultrix and Pyramid sh refuse to redirect output of eval,
153
 
            dnl so use subshell.
154
 
            AS_VAR_SET([gl_next_header],
155
 
              ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
156
 
               sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{
157
 
                 s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#
158
 
                 s#^/[^/]#//&#
159
 
                 p
160
 
                 q
161
 
               }'`'"'])
162
 
          else
163
 
            AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
164
 
          fi
165
 
          AS_VAR_POPDEF([gl_header_exists])])
 
137
         [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
 
138
         m4_defn([gl_next_header]),
 
139
         [AS_VAR_PUSHDEF([gl_header_exists],
 
140
                         [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
 
141
          if test AS_VAR_GET(gl_header_exists) = yes; then
 
142
            AC_LANG_CONFTEST(
 
143
              [AC_LANG_SOURCE(
 
144
                 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
 
145
               )])
 
146
            dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
 
147
            dnl that contain only a #include of other header files and no
 
148
            dnl non-comment tokens of their own. This leads to a failure to
 
149
            dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
 
150
            dnl and others. The workaround is to force preservation of comments
 
151
            dnl through option -C. This ensures all necessary #line directives
 
152
            dnl are present. GCC supports option -C as well.
 
153
            case "$host_os" in
 
154
              aix*) gl_absname_cpp="$ac_cpp -C" ;;
 
155
              *)    gl_absname_cpp="$ac_cpp" ;;
 
156
            esac
 
157
            dnl eval is necessary to expand gl_absname_cpp.
 
158
            dnl Ultrix and Pyramid sh refuse to redirect output of eval,
 
159
            dnl so use subshell.
 
160
            AS_VAR_SET([gl_next_header],
 
161
              ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
 
162
               sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{
 
163
                 s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
 
164
                 s#^/[^/]#//&#
 
165
                 p
 
166
                 q
 
167
               }'`'"'])
 
168
          else
 
169
            AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
 
170
          fi
 
171
          AS_VAR_POPDEF([gl_header_exists])])
166
172
     fi
167
173
     AC_SUBST(
168
 
       AS_TR_CPP([NEXT_]m4_quote(m4_defn([gl_HEADER_NAME]))),
 
174
       AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
169
175
       [AS_VAR_GET([gl_next_header])])
 
176
     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
 
177
       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
 
178
       gl_next_as_first_directive='<'gl_HEADER_NAME'>'
 
179
     else
 
180
       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
 
181
       gl_next_as_first_directive=AS_VAR_GET([gl_next_header])
 
182
     fi
 
183
     AC_SUBST(
 
184
       AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])),
 
185
       [$gl_next_as_first_directive])
170
186
     AS_VAR_POPDEF([gl_next_header])])
171
187
])