Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

171 lines
6.4KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_elisp.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_ELISP_CONFIG_FILE(FILENAME)
  8. # AX_ELISP_CHECK(SYMBOL,DESCRIPTION,BODY,SUCCESS-EXPR)
  9. # AX_ELISP_CHECK_FEATURE(SYMBOL)
  10. # AX_ELISP_CHECK_FBOUNDP(SYMBOL,[FEATURE [...]])
  11. # AX_ELISP_CHECK_BOUNDP(SYMBOL,[FEATURE [...]])
  12. #
  13. # DESCRIPTION
  14. #
  15. # This is a simple library to check the Emacs reality by way of Emacs Lisp
  16. # forms evaluated under $EMACS --batch -Q. This means you MUST have the
  17. # shell variable EMACS set to a valid Emacs executable prior to the first
  18. # call to any of the AX_ELISP_CHECK et al macros. Those work by saving
  19. # their results to the file defined by calling AX_ELISP_CONFIG_FILE so you
  20. # MUST call that prior, too. For example:
  21. #
  22. # dnl Arrange to save config answers in $top_builddir/lisp/config.el.
  23. # AX_ELISP_CONFIG_FILE([lisp/config.el])
  24. #
  25. # dnl Set shell variable EMACS and AC_SUBST it, too.
  26. # dnl (NB: This is a separate Autoconf Archive macro.)
  27. # AX_PROG_EMACS
  28. #
  29. # In the following detailed descriptions, SYMBOL stands for an Emacs Lisp
  30. # symbol, which may contain hyphens, e.g., 'define-error' or 'org-src'.
  31. # Likewise, FEATURE is an Emacs Lisp symbol (naming a feature). BODY and
  32. # SUCCESS-EXPR are Emacs Lisp forms, zero or more for BODY and exactly one
  33. # for SUCCESS-EXPR. In these forms you must take care to avoid apostrophe
  34. # (U+27). Instead of 'foo, write (quote foo).
  35. #
  36. # * AX_ELISP_CONFIG_FILE(FILENAME)
  37. #
  38. # This arranges for future AX_ELISP_CHECK (et al) calls to save their
  39. # results in FILENAME. May be called multiple times. FILENAME should be
  40. # relative to the top build dir.
  41. #
  42. # * AX_ELISP_CHECK(SYMBOL,DESCRIPTION,BODY,SUCCESS-EXPR)
  43. #
  44. # This is the general macro that the other AX_ELISP_CHECK* macros use. It
  45. # constructs a short Emacs Lisp file comprising BODY and evaluates it via
  46. # $EMACS --batch -Q. The exit value of this script depends on the result
  47. # of evaluating SUCCESS-EXPR: non-nil is success and nil is failure. On
  48. # success, append SYMBOL on a line of its own to the config file. This
  49. # macro uses AC_CACHE_CHECK and passes DESCRIPTION to it.
  50. #
  51. # * AX_ELISP_CHECK_FEATURE(FEATURE)
  52. #
  53. # This checks if (require (quote FEATURE)) is successful. If so, add
  54. # featurep-FEATURE to the config file (NB the "featurep-" prefix).
  55. #
  56. # * AX_ELISP_CHECK_FBOUNDP(SYMBOL,[FEATURE [...]])
  57. #
  58. # This checks if (fboundp (quote SYMBOL)) is successful. If so, append
  59. # SYMBOL to the config file. Optional 2nd arg is a space-separated list of
  60. # features to require prior to the fboundp check.
  61. #
  62. # * AX_ELISP_CHECK_BOUNDP(SYMBOL,[FEATURE [...]])
  63. #
  64. # This checks if (boundp (quote SYMBOL)) is successful. If so, append
  65. # SYMBOL to the config file. Optional 2nd arg is a space-separated list of
  66. # features to require prior to the boundp check.
  67. #
  68. # LICENSE
  69. #
  70. # Copyright (c) 2016-2017 Thien-Thi Nguyen
  71. #
  72. # This program is free software; you can redistribute it and/or modify it
  73. # under the terms of the GNU General Public License as published by the
  74. # Free Software Foundation; either version 3 of the License, or (at your
  75. # option) any later version.
  76. #
  77. # This program is distributed in the hope that it will be useful, but
  78. # WITHOUT ANY WARRANTY; without even the implied warranty of
  79. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  80. # Public License for more details.
  81. #
  82. # You should have received a copy of the GNU General Public License along
  83. # with this program. If not, see <https://www.gnu.org/licenses/>.
  84. #
  85. # As a special exception, the respective Autoconf Macro's copyright owner
  86. # gives unlimited permission to copy, distribute and modify the configure
  87. # scripts that are the output of Autoconf when processing the Macro. You
  88. # need not follow the terms of the GNU General Public License when using
  89. # or distributing such scripts, even though portions of the text of the
  90. # Macro appear in them. The GNU General Public License (GPL) does govern
  91. # all other use of the material that constitutes the Autoconf Macro.
  92. #
  93. # This special exception to the GPL applies to versions of the Autoconf
  94. # Macro released by the Autoconf Archive. When you make and distribute a
  95. # modified version of the Autoconf Macro, you may extend this special
  96. # exception to the GPL to apply to your modified version as well.
  97. #serial 2
  98. AC_DEFUN([AX_ELISP_CONFIG_FILE],[dnl
  99. dnl 1 -- relative filename (from 'top_srcdir')
  100. m4_define([AX_ELISP__CONFIG_FILENAME],[$1])dnl
  101. ])dnl
  102. AC_DEFUN([AX_ELISP__PREP],[dnl
  103. AS_IF([AS_VAR_TEST_SET([EMACS])],,dnl
  104. [AC_MSG_ERROR([No value for EMACS])])
  105. dnl FIXME: Check at autoconf-time that AX_ELISP__CONFIG_FILENAME is set.
  106. dnl (If not, or if the value is unsuitable, throw fatal error.)
  107. rm -f AX_ELISP__CONFIG_FILENAME
  108. touch AX_ELISP__CONFIG_FILENAME
  109. ])dnl
  110. AC_DEFUN([AX_ELISP_CHECK],[dnl
  111. dnl 1 -- Emacs Lisp symbol to add to config file if "success"
  112. dnl 2 -- description
  113. dnl 3 -- Emacs Lisp body (zero or more forms)
  114. dnl 4 -- Emacs Lisp expression for "success"
  115. AC_REQUIRE([AX_ELISP__PREP])dnl
  116. AS_VAR_PUSHDEF([CV],[elisp_cv_$1])dnl
  117. AC_CACHE_CHECK([$2],[CV],[dnl
  118. cat >conftest.el <<AX_ELISP__EOF
  119. $3
  120. (kill-emacs (if $4 0 1))
  121. AX_ELISP__EOF
  122. AS_IF([$EMACS --batch -Q -l conftest.el 1>&5 2>&5],[CV=yes],[CV=no])])
  123. AS_IF([test yes = $[]CV],[echo "$1" >> AX_ELISP__CONFIG_FILENAME])
  124. AS_VAR_POPDEF([CV])dnl
  125. ])dnl
  126. AC_DEFUN([AX_ELISP_CHECK_FEATURE],[dnl
  127. dnl 1 -- Emacs Lisp symbol (a feature name)
  128. AC_REQUIRE([AX_ELISP__PREP])dnl
  129. AX_ELISP_CHECK([featurep-$1],[if $EMACS supports feature '$1'],[dnl
  130. (require (quote $1))
  131. ],[dnl
  132. (featurep (quote $1))
  133. ])])
  134. AC_DEFUN([AX_ELISP_CHECK_FBOUNDP],[dnl
  135. dnl 1 -- Emacs Lisp symbol
  136. dnl 2 -- (optional) space-separated list of features to 'require'
  137. AX_ELISP_CHECK([$1],[if '$1' is defined],[dnl
  138. m4_foreach([FEATURE],m4_split(m4_normalize($2)),[dnl
  139. (require 'FEATURE)
  140. ])],[(fboundp '$1)])])dnl
  141. AC_DEFUN([AX_ELISP_CHECK_BOUNDP],[dnl
  142. dnl 1 -- Emacs Lisp symbol
  143. dnl 2 -- (optional) space-separated list of features to 'require'
  144. AX_ELISP_CHECK([$1],[if '$1' is defined],[dnl
  145. m4_foreach([FEATURE],m4_split(m4_normalize($2)),[dnl
  146. (require 'FEATURE)
  147. ])],[(boundp '$1)])])dnl
  148. dnl TODO:
  149. dnl - Add error checking (see FIXME in code).
  150. dnl - Validate m4 mumblings -- is this the right crazy?!
  151. dnl - Add customization of $EMACS invocation.
  152. dnl
  153. dnl Local variables:
  154. dnl mode: autoconf
  155. dnl End:
  156. dnl ax_elisp.m4 ends here