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.

156 lines
5.2KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_am_override_var.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_AM_OVERRIDE_VAR([varname1 varname ... ])
  8. # AX_AM_OVERRIDE_FINALIZE
  9. #
  10. # DESCRIPTION
  11. #
  12. # This autoconf macro generalizes the approach given in
  13. # <http://lists.gnu.org/archive/html/automake/2005-09/msg00108.html> which
  14. # moves user specified values for variable 'varname' given at configure
  15. # time into the corresponding AM_${varname} variable and clears out
  16. # 'varname', allowing further manipulation by the configure script so that
  17. # target specific variables can be given specialized versions. 'varname
  18. # may still be specified on the make command line and will be appended as
  19. # usual.
  20. #
  21. # As an example usage, consider a project which might benefit from
  22. # different compiler flags for different components. Typically this is
  23. # done via target specific flags, e.g.
  24. #
  25. # libgtest_la_CXXFLAGS = \
  26. # -I $(top_srcdir)/tests \
  27. # -I $(top_builddir)/tests \
  28. # $(GTEST_CXXFLAGS)
  29. #
  30. # automake will automatically append $(CXXFLAGS) -- provided by the user
  31. # -- to the build rule for libgtest_la. That might be problematic, as
  32. # CXXFLAGS may contain compiler options which are inappropriate for
  33. # libgtest_la.
  34. #
  35. # The approach laid out in the referenced mailing list message is to
  36. # supply a base value for a variable during _configure_ time, during which
  37. # it is possible to amend it for specific targets. The user may
  38. # subsequently specify a value for the variable during _build_ time, which
  39. # make will apply (via the standard automake rules) to all appropriate
  40. # targets.
  41. #
  42. # For example,
  43. #
  44. # AX_AM_OVERRIDE_VAR([CXXFLAGS])
  45. #
  46. # will store the value of CXXFLAGS specified at configure time into the
  47. # AM_CXXFLAGS variable, AC_SUBST it, and clear CXXFLAGS. configure may
  48. # then create a target specific set of flags based upon AM_CXXFLAGS, e.g.
  49. #
  50. # # googletest uses variadic macros, which g++ -pedantic-errors
  51. # # is very unhappy about
  52. # AC_SUBST([GTEST_CXXFLAGS],
  53. # [`AS_ECHO_N(["$AM_CXXFLAGS"]) \
  54. # | sed s/-pedantic-errors/-pedantic/`
  55. # ]
  56. # )
  57. #
  58. # which would be used in a Makefile.am as above. Since CXXFLAGS is
  59. # cleared, the configure time value will not affect the build for
  60. # libgtest_la.
  61. #
  62. # Prior to _any other command_ which may set ${varname}, call
  63. #
  64. # AX_AM_OVERRIDE_VAR([varname])
  65. #
  66. # This will preserve the value (if any) passed to configure in
  67. # AM_${varname} and AC_SUBST([AM_${varname}). You may pass a space
  68. # separated list of variable names, or may call AX_AM_OVERRIDE_VAR
  69. # multiple times for the same effect.
  70. #
  71. # If any subsequent configure commands set ${varname} and you wish to
  72. # capture the resultant value into AM_${varname} in the case where
  73. # ${varname} was _not_ provided at configure time, call
  74. #
  75. # AX_AM_OVERRIDE_FINALIZE
  76. #
  77. # after _all_ commands which might affect any of the variables specified
  78. # in calls to AX_AM_OVERRIDE_VAR. This need be done only once, but
  79. # repeated calls will not cause harm.
  80. #
  81. # There is a bit of trickery required to allow further manipulation of the
  82. # AM_${varname} in a Makefile.am file. If AM_CFLAGS is used as is in a
  83. # Makefile.am, e.g.
  84. #
  85. # libfoo_la_CFLAGS = $(AM_CFLAGS)
  86. #
  87. # then automake will emit code in Makefile.in which sets AM_CFLAGS from
  88. # the configure'd value.
  89. #
  90. # If however, AM_CFLAGS is manipulated (i.e. appended to), you will have
  91. # to explicitly arrange for the configure'd value to be substituted:
  92. #
  93. # AM_CFLAGS = @AM_CFLAGS@
  94. # AM_CFLAGS += -lfoo
  95. #
  96. # or else automake will complain about using += before =.
  97. #
  98. # LICENSE
  99. #
  100. # Copyright (c) 2013 Smithsonian Astrophysical Observatory
  101. # Copyright (c) 2013 Diab Jerius <djerius@cfa.harvard.edu>
  102. #
  103. # Copying and distribution of this file, with or without modification, are
  104. # permitted in any medium without royalty provided the copyright notice
  105. # and this notice are preserved. This file is offered as-is, without any
  106. # warranty.
  107. #serial 2
  108. AC_DEFUN([_AX_AM_OVERRIDE_INITIALIZE],
  109. [
  110. m4_define([_mst_am_override_vars],[])
  111. ])
  112. # _AX_AM_OVERRIDE_VAR(varname)
  113. AC_DEFUN([_AX_AM_OVERRIDE_VAR],
  114. [
  115. m4_define([_mst_am_override_vars], m4_defn([_mst_am_override_vars]) $1 )
  116. _mst_am_override_$1_set=false
  117. AS_IF( [test "${$1+set}" = set],
  118. [AC_SUBST([AM_$1],["$$1"])
  119. $1=
  120. _mst_am_override_$1_set=:
  121. ]
  122. )
  123. ]) # _AX_AM_OVERRIDE_VAR
  124. # _AX_AM_OVERRIDE_FINALIZE(varname)
  125. AC_DEFUN([_AX_AM_OVERRIDE_FINALIZE],
  126. [
  127. AS_IF([$_mst_am_override_$1_set = :],
  128. [],
  129. [AC_SUBST([AM_$1],["$$1"])
  130. $1=
  131. _mst_am_override_$1_set=
  132. ]
  133. )
  134. AC_SUBST($1)
  135. ]) # _AX_AM_OVERRIDE_FINALIZE
  136. AC_DEFUN([AX_AM_OVERRIDE_VAR],
  137. [
  138. AC_REQUIRE([_AX_AM_OVERRIDE_INITIALIZE])
  139. m4_map_args_w([$1],[_AX_AM_OVERRIDE_VAR(],[)])
  140. ])# AX_OVERRIDE_VAR
  141. # AX_AM_OVERRIDE_FINALIZE
  142. AC_DEFUN([AX_AM_OVERRIDE_FINALIZE],
  143. [
  144. AC_REQUIRE([_AX_AM_OVERRIDE_INITIALIZE])
  145. m4_map_args_w(_mst_am_override_vars,[_AX_AM_OVERRIDE_FINALIZE(],[)])
  146. ]) # AX_AM_OVERRIDE_FINALIZE