summaryrefslogtreecommitdiffstats
path: root/gl/m4/absolute-header.m4
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2023-02-11 06:20:24 (GMT)
committerAndreas Baumann <mail@andreasbaumann.cc>2023-02-11 06:20:24 (GMT)
commitf867d7b44080fa9716deeff4476275f9a489879f (patch)
treebc964662fc3300dc626fb6d833d8ed5c8f46eca7 /gl/m4/absolute-header.m4
parent9734c439cba0a02b087e50789e94ec9b07754608 (diff)
parentc07206f2ccc2356aa74bc6813a94c2190017d44e (diff)
downloadmonitoring-plugins-f867d7b44080fa9716deeff4476275f9a489879f.tar.gz
Merge branch 'master' into curlfixes
Diffstat (limited to 'gl/m4/absolute-header.m4')
-rw-r--r--gl/m4/absolute-header.m4100
1 files changed, 100 insertions, 0 deletions
diff --git a/gl/m4/absolute-header.m4 b/gl/m4/absolute-header.m4
new file mode 100644
index 0000000..e794764
--- /dev/null
+++ b/gl/m4/absolute-header.m4
@@ -0,0 +1,100 @@
1# absolute-header.m4 serial 17
2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Derek Price.
8
9# gl_ABSOLUTE_HEADER(HEADER1 HEADER2 ...)
10# ---------------------------------------
11# Find the absolute name of a header file, testing first if the header exists.
12# If the header were sys/inttypes.h, this macro would define
13# ABSOLUTE_SYS_INTTYPES_H to the '""' quoted absolute name of sys/inttypes.h
14# in config.h
15# (e.g. '#define ABSOLUTE_SYS_INTTYPES_H "///usr/include/sys/inttypes.h"').
16# The three "///" are to pacify Sun C 5.8, which otherwise would say
17# "warning: #include of /usr/include/... may be non-portable".
18# Use '""', not '<>', so that the /// cannot be confused with a C99 comment.
19# Note: This macro assumes that the header file is not empty after
20# preprocessing, i.e. it does not only define preprocessor macros but also
21# provides some type/enum definitions or function/variable declarations.
22AC_DEFUN([gl_ABSOLUTE_HEADER],
23[AC_REQUIRE([AC_CANONICAL_HOST])
24AC_LANG_PREPROC_REQUIRE()dnl
25m4_foreach_w([gl_HEADER_NAME], [$1],
26 [AS_VAR_PUSHDEF([gl_absolute_header],
27 [gl_cv_absolute_]m4_defn([gl_HEADER_NAME]))dnl
28 AC_CACHE_CHECK([absolute name of <]m4_defn([gl_HEADER_NAME])[>],
29 [gl_absolute_header],
30 [AS_VAR_PUSHDEF([ac_header_exists],
31 [ac_cv_header_]m4_defn([gl_HEADER_NAME]))dnl
32 AC_CHECK_HEADERS_ONCE(m4_defn([gl_HEADER_NAME]))dnl
33 if test AS_VAR_GET([ac_header_exists]) = yes; then
34 gl_ABSOLUTE_HEADER_ONE(m4_defn([gl_HEADER_NAME]))
35 fi
36 AS_VAR_POPDEF([ac_header_exists])dnl
37 ])dnl
38 AC_DEFINE_UNQUOTED(AS_TR_CPP([ABSOLUTE_]m4_defn([gl_HEADER_NAME])),
39 ["AS_VAR_GET([gl_absolute_header])"],
40 [Define this to an absolute name of <]m4_defn([gl_HEADER_NAME])[>.])
41 AS_VAR_POPDEF([gl_absolute_header])dnl
42])dnl
43])# gl_ABSOLUTE_HEADER
44
45# gl_ABSOLUTE_HEADER_ONE(HEADER)
46# ------------------------------
47# Like gl_ABSOLUTE_HEADER, except that:
48# - it assumes that the header exists,
49# - it uses the current CPPFLAGS,
50# - it does not cache the result,
51# - it is silent.
52AC_DEFUN([gl_ABSOLUTE_HEADER_ONE],
53[
54 AC_REQUIRE([AC_CANONICAL_HOST])
55 AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote([$1])[[>]])])
56 dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
57 dnl that contain only a #include of other header files and no
58 dnl non-comment tokens of their own. This leads to a failure to
59 dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
60 dnl and others. The workaround is to force preservation of comments
61 dnl through option -C. This ensures all necessary #line directives
62 dnl are present. GCC supports option -C as well.
63 case "$host_os" in
64 aix*) gl_absname_cpp="$ac_cpp -C" ;;
65 *) gl_absname_cpp="$ac_cpp" ;;
66 esac
67changequote(,)
68 case "$host_os" in
69 mingw*)
70 dnl For the sake of native Windows compilers (excluding gcc),
71 dnl treat backslash as a directory separator, like /.
72 dnl Actually, these compilers use a double-backslash as
73 dnl directory separator, inside the
74 dnl # line "filename"
75 dnl directives.
76 gl_dirsep_regex='[/\\]'
77 ;;
78 *)
79 gl_dirsep_regex='\/'
80 ;;
81 esac
82 dnl A sed expression that turns a string into a basic regular
83 dnl expression, for use within "/.../".
84 gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
85 gl_header_literal_regex=`echo '$1' \
86 | sed -e "$gl_make_literal_regex_sed"`
87 gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
88 s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
89 s|^/[^/]|//&|
90 p
91 q
92 }'
93changequote([,])
94 dnl eval is necessary to expand gl_absname_cpp.
95 dnl Ultrix and Pyramid sh refuse to redirect output of eval,
96 dnl so use subshell.
97 AS_VAR_SET([gl_cv_absolute_]AS_TR_SH([[$1]]),
98[`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
99 sed -n "$gl_absolute_header_sed"`])
100])