mc-gnulib-common.m4 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # gnulib-common.m4
  2. # serial 101
  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.
  7. AC_PREREQ([2.62])
  8. # gl_CONDITIONAL(conditional, condition)
  9. # is like AM_CONDITIONAL(conditional, condition), except that it does not
  10. # produce an error
  11. # configure: error: conditional "..." was never defined.
  12. # Usually this means the macro was only invoked conditionally.
  13. # when only invoked conditionally. Instead, in that case, both the _TRUE
  14. # and the _FALSE case are disabled.
  15. AC_DEFUN([gl_CONDITIONAL],
  16. [
  17. pushdef([AC_CONFIG_COMMANDS_PRE], [:])dnl
  18. AM_CONDITIONAL([$1], [$2])
  19. popdef([AC_CONFIG_COMMANDS_PRE])dnl
  20. if test -z "${[$1]_TRUE}" && test -z "${[$1]_FALSE}"; then
  21. [$1]_TRUE='#'
  22. [$1]_FALSE='#'
  23. fi
  24. ])
  25. dnl gl_CONDITIONAL_HEADER([foo.h])
  26. dnl takes a shell variable GL_GENERATE_FOO_H (with value true or false) as input
  27. dnl and produces
  28. dnl - an AC_SUBSTed variable FOO_H that is either a file name or empty, based
  29. dnl on whether GL_GENERATE_FOO_H is true or false,
  30. dnl - an Automake conditional GL_GENERATE_FOO_H that evaluates to the value of
  31. dnl the shell variable GL_GENERATE_FOO_H.
  32. AC_DEFUN([gl_CONDITIONAL_HEADER],
  33. [
  34. m4_pushdef([gl_header_name], AS_TR_SH(m4_toupper($1)))
  35. m4_pushdef([gl_generate_var], [GL_GENERATE_]AS_TR_SH(m4_toupper($1)))
  36. m4_pushdef([gl_generate_cond], [GL_GENERATE_]AS_TR_SH(m4_toupper($1)))
  37. case "$gl_generate_var" in
  38. false) gl_header_name='' ;;
  39. true)
  40. dnl It is OK to use a .h file in lib/ from within tests/, but not vice
  41. dnl versa.
  42. if test -z "$gl_header_name"; then
  43. gl_header_name="${gl_source_base_prefix}$1"
  44. fi
  45. ;;
  46. *) echo "*** gl_generate_var is not set correctly" 1>&2; exit 1 ;;
  47. esac
  48. AC_SUBST(gl_header_name)
  49. gl_CONDITIONAL(gl_generate_cond, [$gl_generate_var])
  50. m4_popdef([gl_generate_cond])
  51. m4_popdef([gl_generate_var])
  52. m4_popdef([gl_header_name])
  53. ])