(copy_dir_dir): get rid of extra string duplication.
[midnight-commander.git] / m4.include / ac_onceonly.m4
blobb86700f912acfc2873e655ca53d050056e57519d
1 # onceonly.m4 serial 5 (gettext-0.15)
2 dnl Copyright (C) 2002-2003, 2006 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.
7 dnl This file defines some "once only" variants of standard autoconf macros.
8 dnl   AC_CHECK_HEADERS_ONCE          like  AC_CHECK_HEADERS
9 dnl   AC_CHECK_FUNCS_ONCE            like  AC_CHECK_FUNCS
10 dnl   AC_CHECK_DECLS_ONCE            like  AC_CHECK_DECLS
11 dnl   AC_REQUIRE([AC_FUNC_STRCOLL])  like  AC_FUNC_STRCOLL
12 dnl The advantage is that the check for each of the headers/functions/decls
13 dnl will be put only once into the 'configure' file. It keeps the size of
14 dnl the 'configure' file down, and avoids redundant output when 'configure'
15 dnl is run.
16 dnl The drawback is that the checks cannot be conditionalized. If you write
17 dnl   if some_condition; then gl_CHECK_HEADERS(stdlib.h); fi
18 dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to
19 dnl empty, and the check will be inserted before the body of the AC_DEFUNed
20 dnl function.
22 dnl This file is only needed in autoconf <= 2.59.  Newer versions of autoconf
23 dnl have this macro built-in.  But about AC_CHECK_DECLS_ONCE: note that in
24 dnl autoconf >= 2.60 the symbol separator is a comma, whereas here it is
25 dnl whitespace.
27 dnl Autoconf version 2.57 or newer is recommended.
28 AC_PREREQ(2.54)
30 # AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of
31 # AC_CHECK_HEADERS(HEADER1 HEADER2 ...).
32 AC_DEFUN([AC_CHECK_HEADERS_ONCE], [
33   :
34   AC_FOREACH([gl_HEADER_NAME], [$1], [
35     AC_DEFUN([gl_CHECK_HEADER_]m4_quote(translit(m4_defn([gl_HEADER_NAME]),
36                                                  [-./], [___])), [
37       AC_CHECK_HEADERS(gl_HEADER_NAME)
38     ])
39     AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME,
40                                                    [-./], [___])))
41   ])
44 # AC_CHECK_FUNCS_ONCE(FUNC1 FUNC2 ...) is a once-only variant of
45 # AC_CHECK_FUNCS(FUNC1 FUNC2 ...).
46 AC_DEFUN([AC_CHECK_FUNCS_ONCE], [
47   :
48   AC_FOREACH([gl_FUNC_NAME], [$1], [
49     AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [
50       AC_CHECK_FUNCS(m4_defn([gl_FUNC_NAME]))
51     ])
52     AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]))
53   ])
56 # AC_CHECK_DECLS_ONCE(DECL1 DECL2 ...) is a once-only variant of
57 # AC_CHECK_DECLS(DECL1, DECL2, ...).
58 AC_DEFUN([AC_CHECK_DECLS_ONCE], [
59   :
60   AC_FOREACH([gl_DECL_NAME], [$1], [
61     AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [
62       AC_CHECK_DECLS(m4_defn([gl_DECL_NAME]))
63     ])
64     AC_REQUIRE([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]))
65   ])