1# SPDX-License-Identifier: FSFAP
2#
3# ===========================================================================
4#     https://www.gnu.org/software/autoconf-archive/ax_restore_flags.html
5# ===========================================================================
6#
7# SYNOPSIS
8#
9#   AX_RESTORE_FLAGS([namespace])
10#
11# DESCRIPTION
12#
13#   Restore common compilation flags from temporary variables.
14#
15#   Compilation flags includes: CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS, LIBS,
16#   OBJCFLAGS.
17#
18#   By default these flags are restored to a global (empty) namespace, but
19#   user could restore from specific NAMESPACE by using
20#   AX_RESTORE_FLAGS(NAMESPACE) macro.
21#
22#   Typical usage is like:
23#
24#     AX_SAVE_FLAGS(mypackage)
25#     CPPFLAGS="-Imypackagespath ${CPPFLAGS}"
26#     dnl ... do some detection ...
27#     AX_RESTORE_FLAGS(mypackage)
28#
29# LICENSE
30#
31#   Copyright (c) 2009 Filippo Giunchedi <filippo@esaurito.net>
32#   Copyright (c) 2011 The Board of Trustees of the Leland Stanford Junior University
33#   Copyright (c) 2011 Russ Allbery <rra@stanford.edu>
34#   Copyright (c) 2013 Bastien ROUCARIES <roucaries.bastien+autoconf@gmail.com>
35#
36#   Copying and distribution of this file, with or without modification, are
37#   permitted in any medium without royalty provided the copyright notice
38#   and this notice are preserved. This file is offered as-is, without any
39#   warranty.
40
41#serial 7
42
43# save one flag in name space
44AC_DEFUN([_AX_RESTORE_ONE_FLAG],[dnl
45  AS_VAR_PUSHDEF([_ax_restore_flag_var], [$2[]_$1[]_ax_save_flags])
46  AS_VAR_COPY($2[],_ax_restore_flag_var)
47  AS_VAR_POPDEF([_ax_restore_flag_var])
48])
49
50AC_DEFUN([AX_RESTORE_FLAGS], [dnl
51   m4_foreach([FLAG], dnl
52	      [_AX_SAVE_FLAGS_LIST()], dnl
53	      [_AX_RESTORE_ONE_FLAG([$1],FLAG)])
54])
55