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