3 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
11 # gl_CONDITIONAL(conditional, condition)
12 # is like AM_CONDITIONAL(conditional, condition), except that it does not
14 # configure: error: conditional "..." was never defined.
15 # Usually this means the macro was only invoked conditionally.
16 # when only invoked conditionally. Instead, in that case, both the _TRUE
17 # and the _FALSE case are disabled.
18 AC_DEFUN([gl_CONDITIONAL],
20 pushdef([AC_CONFIG_COMMANDS_PRE], [:])dnl
21 AM_CONDITIONAL([$1], [$2])
22 popdef([AC_CONFIG_COMMANDS_PRE])dnl
23 if test -z "${[$1]_TRUE}" && test -z "${[$1]_FALSE}"; then
29 dnl gl_CONDITIONAL_HEADER([foo.h])
30 dnl takes a shell variable GL_GENERATE_FOO_H (with value true or false) as input
32 dnl - an AC_SUBSTed variable FOO_H that is either a file name or empty, based
33 dnl on whether GL_GENERATE_FOO_H is true or false,
34 dnl - an Automake conditional GL_GENERATE_FOO_H that evaluates to the value of
35 dnl the shell variable GL_GENERATE_FOO_H.
36 AC_DEFUN([gl_CONDITIONAL_HEADER],
38 m4_pushdef([gl_header_name], AS_TR_SH(m4_toupper($1)))
39 m4_pushdef([gl_generate_var], [GL_GENERATE_]AS_TR_SH(m4_toupper($1)))
40 m4_pushdef([gl_generate_cond], [GL_GENERATE_]AS_TR_SH(m4_toupper($1)))
41 case "$gl_generate_var" in
42 false) gl_header_name='' ;;
44 dnl It is OK to use a .h file in lib/ from within tests/, but not vice
46 if test -z "$gl_header_name"; then
47 gl_header_name="${gl_source_base_prefix}$1"
50 *) echo "*** gl_generate_var is not set correctly" 1>&2; exit 1 ;;
52 AC_SUBST(gl_header_name)
53 gl_CONDITIONAL(gl_generate_cond, [$gl_generate_var])
54 m4_popdef([gl_generate_cond])
55 m4_popdef([gl_generate_var])
56 m4_popdef([gl_header_name])