Changeset 4326


Ignore:
Timestamp:
Mar 12, 2023, 1:37:24 AM (3 months ago)
Author:
Peter
Message:

We had two macros with very similar behaviour: YAT_AC_APPEND in
'yat_svn_release' and private macro _YAT_AC_APPEND_TO_FILE. Replace
with new macro YAT_AC_APPEND_TO_FILE with tested and documented
behaviour. Similarly a macro YAT_AC_WRITE_TO_FILE.

Introduce a new macro YAT_AM_LOCAL, which is recommended to use when
using any of the macros generating automake input.

Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Makefile.am

    r3990 r4326  
    161161  && $(GREP) '^includedir=quz' build_support/yat.pc
    162162
    163 include $(srcdir)/am/maintainer.am
     163include yat_am_local.am
    164164
    165165# run within maintainer-check
  • trunk/NEWS

    r4316 r4326  
    66  - htslib 1.10 (or newer) is now required (ticket #991)
    77  - GSL 2.2 (or newer) is now required (ticket #983)
     8  - YAT_AC_WRITE has been replaced by YAT_AC_WRITE_TO_FILE
     9  - YAT_AC_WRITE_APPEND has been replaced by YAT_AC_APPEND_TO_FILE
    810
    911  A complete list of closed tickets can be found here [[br]]
  • trunk/configure.ac

    r4279 r4326  
    545545AC_SUBST([lt_cv_objdir])
    546546
    547 YAT_SVN_RELEASE([am/maintainer.am],
     547YAT_AM_LOCAL([yat_am_local.am])
     548YAT_SVN_RELEASE([],
    548549  [$(YAT_MAJOR_VERSION).$(YAT_MINOR_VERSION)],
    549550  [libyat@frs.sourceforge.net:/home/frs/project/l/li/libyat],
  • trunk/m4/yat_am_macros.m4

    r4323 r4326  
    4949m4_define([yat_MOVE_IF_CHANGE], m4_default([$1], [move-if-change]))
    5050AC_SUBST([MOVE_IF_CHANGE], ['${SHELL} $(top_srcdir)/yat_MOVE_IF_CHANGE'])
    51 AX_AC_PRINT_TO_FILE(yat_MOVE_IF_CHANGE, [#!/bin/sh])
    52 _YAT_AC_APPEND_TO_FILE(yat_MOVE_IF_CHANGE,[
     51
     52YAT_AC_WRITE_TO_FILE(yat_MOVE_IF_CHANGE,dnl
     53[#!/bin/sh
    5354# Like mv ]$[1 ]$[2, but if the files are the same, just delete ]$[1.
    5455# Status is zero if successful, nonzero otherwise.
    5556
    56 usage="[$]0: usage: [$]0 SOURCE DEST"
    57 
    58 test [$]# = 2 || { echo $usage >&2 && exit 1; }
    59 
    60 if test -r "[$]2" && cmp -s "[$]1" "[$]2"; then
    61   rm -f "[$]1"
     57usage="]$[0: usage: ]$[0 SOURCE DEST"
     58
     59test ]$[# = 2 || { echo $usage >&2 && exit 1; }
     60
     61if test -r "]$[2" && cmp -s "]$[1" "]$[2"; then
     62  rm -f "]$[1"
    6263else
    63   mv -f "[$]1" "[$]2"
     64  mv -f "]$[1" "]$[2"
    6465fi
    65 ])
     66]) # YAT_AC_WRITE_TO_FILE
    6667]) # YAT_PROG_MOVE_IF_CHANGE
    6768
    6869
    69 # YAT_SVN_REVISION([AM_FILE = svn_revison.am], [REVISION_FILE = .revision])
    70 #
    71 # Create a file, AM_FILE, at Autoconf time that should be included in
     70# YAT_AM_LOCAL([am-file = yat_am_local.am])
     71# ========================================================
     72#
     73# This file and 'yat_svn_release.m4' contain several macros that
     74# create Automake snippets that need to be included in your
     75# Makefile.am. Some of macros AC_REQUIRE others, which makes it
     76# tedious to keep track of which files are generated and need to be
     77# included. If this macro has been called first, those macros append
     78# the Automake snippets to am-file instead, which makes it easier to
     79# include once.
     80AC_DEFUN([YAT_AM_LOCAL],
     81[
     82  m4_define([YAT_AM_LOCAL_FILE], [m4_default([$1], [yat_am_local.am])])
     83  _YAT_AM_TOP(YAT_AM_LOCAL_FILE)
     84])
     85
     86
     87# YAT_SVN_REVISION([am-file = svn_revison.am], [revision-file = .revision])
     88#
     89# Create a file, am-file, at Autoconf time that should be included in
    7290# your top Makefile.am. The file creates make rules for creation of a
    7391# file REVISION_FILE that will contain the current revision of the
     
    8199# You need to declare Automake variable in your Makefile.am
    82100#   'EXTRA_DIST = '
     101#
     102# You may want to use YAT_AM_LOCAL
    83103#
    84104AC_DEFUN([YAT_SVN_REVISION],
     
    98118m4_syscmd([test -d .svn || test -r ]yat_svn_revision_FILE[ || \
    99119           echo "exported" > ]yat_svn_revision_FILE[])
    100 dnl write top of am file
    101 _YAT_AM_TOP(YAT_AM_FILE)
    102120
    103121dnl write rules to create .revision
    104 _YAT_AC_APPEND_TO_FILE(YAT_AM_FILE,
    105 EXTRA_DIST += $(srcdir)/yat_svn_revision_FILE
     122_YAT_AM_LOCAL_WRITE(YAT_AM_FILE,[
     123EXTRA_DIST += $(srcdir)/]yat_svn_revision_FILE[
    106124if HAVE_SVN_WC
    107125YAT_SVN_REVISION_FORCE:
    108 $(srcdir)/yat_svn_revision_FILE: YAT_SVN_REVISION_FORCE
    109   $(AM_V_at)$(SVNVERSION) $(srcdir) > [$][@]-t \
    110   && $(MOVE_IF_CHANGE) [$][@]-t [$][@]
     126$(srcdir)/]yat_svn_revision_FILE[: YAT_SVN_REVISION_FORCE
     127  $(AM_V_at)$(SVNVERSION) $(srcdir) > ]$[@-t \
     128  && $(MOVE_IF_CHANGE) ]$[@-t ]$[@
    111129endif
    112 )
    113 dnl end AX_AC_APPEND_TO_FILE
     130])
     131dnl end YAT_AM_LOCAL_FILE
    114132m4_popdef([YAT_AM_FILE])
    115133]) # YAT_SVN_REVISION
     
    134152#   EXTRA_DIST =
    135153#
     154# You may want to use YAT_AM_LOCAL
     155#
    136156AC_DEFUN([YAT_REVISION_HEADER],
    137157[
     
    143163
    144164dnl create svn_revision.h.in
    145 AX_AC_PRINT_TO_FILE([]yat_HEADER_FILE[.in-t],[
     165YAT_AC_WRITE_TO_FILE([]yat_HEADER_FILE[.in-t],[
    146166/* created by $0 */
    147167#ifndef ]yat_REVISION_DEFINE[
    148 #define ]yat_REVISION_DEFINE[ \"@]yat_REVISION_DEFINE[@\"
     168#define ]yat_REVISION_DEFINE[ "@]yat_REVISION_DEFINE[@"
    149169#endif
    150170])
    151171m4_syscmd([sh ]yat_MOVE_IF_CHANGE[ ]yat_HEADER_FILE[.in-t ]yat_HEADER_FILE[.in])
    152172dnl write make rule for svn_revision.h
    153 _YAT_AM_TOP(yat_AM_FILE)
    154 _YAT_AC_APPEND_TO_FILE(yat_AM_FILE,
     173_YAT_AM_LOCAL_WRITE(yat_AM_FILE,[
    155174EXTRA_DIST += $(srcdir)/]yat_HEADER_FILE[.in
    156175DISTCLEANFILES += $(builddir)/]yat_HEADER_FILE[
    157176BUILT_SOURCES += $(builddir)/]yat_HEADER_FILE[
    158 $(builddir)/]yat_HEADER_FILE[: $(srcdir)/yat_HEADER_FILE.in $(srcdir)/]yat_INPUT_FILE[
     177$(builddir)/]yat_HEADER_FILE[: $(srcdir)/]yat_HEADER_FILE[.in $(srcdir)/]yat_INPUT_FILE[
    159178  $(AM_V_at)revision=$$(cat $(srcdir)/]yat_INPUT_FILE[) \
    160   && sed "s|@]yat_REVISION_DEFINE[@|$$revision|g" < $(srcdir)/]yat_HEADER_FILE.in[ \
    161   > [$][@]-t && mv [$][@]-t [$][@]
    162 )
     179  && sed "s|@]yat_REVISION_DEFINE[@|$$revision|g" < $(srcdir)/]yat_HEADER_FILE[.in \
     180  > ]$[@-t && mv ]$[@-t ]$[@
     181])
    163182m4_popdef([yat_AM_FILE])
    164183m4_popdef([yat_REVISION_DEFINE])
     
    196215                   [Define year package was last modified])
    197216dnl generate make rule for .release_year
    198 _YAT_AM_TOP(YAT_am_file)
    199 _YAT_AC_APPEND_TO_FILE(YAT_am_file,
    200 EXTRA_DIST += $(srcdir)/YAT_release_year
    201 CONFIG_STATUS_DEPENDENCIES += $(srcdir)/YAT_release_year
     217_YAT_AM_LOCAL_WRITE(YAT_am_file,[
     218EXTRA_DIST += $(srcdir)/]YAT_release_year[
     219CONFIG_STATUS_DEPENDENCIES += $(srcdir)/]YAT_release_year[
    202220RELEASE_YEAR_FORCE:
    203221if HAVE_SVN_WC
    204222$(srcdir)/YAT_release_year: RELEASE_YEAR_FORCE
    205223  $(AM_V_at)if $(SVNVERSION) $(srcdir) | grep 'M' > /dev/null; then \
    206      date -u "+%Y" > [$][@]-t \
    207      && $(MOVE_IF_CHANGE) [$][@]-t [$][@]; \
     224     date -u "+%Y" > ]$[@-t \
     225     && $(MOVE_IF_CHANGE) ]$[@-t ]$[@; \
    208226  fi
    209227endif
    210 )
     228])
    211229m4_popdef([YAT_am_file])
    212230m4_popdef([YAT_release_year])
     
    262280
    263281dnl write rules to create .timestamp
    264 _YAT_AM_TOP(YAT_AM_FILE)
    265 
    266 _YAT_AC_APPEND_TO_FILE(YAT_AM_FILE,
     282_YAT_AM_LOCAL_WRITE(YAT_AM_FILE,[
    267283## The .timestamp reflects the last change to the svn repo, i.e., it
    268284## changes via 'svn update' or 'svn commit', which is a subset of when
     
    272288.svn_timestamp: $(srcdir)/.revision
    273289  $(AM_V_at)date=$($(SVN) info $(scrdir) --show-item last-changed-date --no-newline); \
    274   date +%s --date="$$date" > [$][@]
     290  date +%s --date="$$date" > ]$[@
    275291DISTCLEANFILES += .svn_timestamp
    276292endif
    277293
    278294.timestamp: $(yat_timestamp_source)
    279   $(AM_V_at)cp $(yat_timestamp_source) [$][@]
     295  $(AM_V_at)cp $(yat_timestamp_source) ]$[@
    280296
    281297CLEANFILES += .timestamp
     
    293309  date +%s > $(distdir)/.tarball_timestamp
    294310endif
    295 
    296 ) dnl end of writing automake segment
    297 
    298 
     311]) dnl end of writing automake segment
    299312]) # YAT_SVN_TIMESTAMP
    300313
     
    309322[
    310323AC_PREREQ([2.62])
    311 AX_AC_PRINT_TO_FILE([$1],dnl
    312 [# ]$1[ generated automatically by GNU Autoconf
     324YAT_AC_WRITE_TO_FILE([$1],dnl
     325[# $1 generated automatically by GNU Autoconf
    313326]yat_am_macros_copyright[
    314327# stub rule to work around bug in Automake 1.11
    315 \$(top_srcdir)/]$1[:
     328$(top_srcdir)/$1:
    316329
    317330])
     
    319332
    320333
    321 # wrapper around AX_AC_APPEND_TO_FILE to avoid usage of variables
    322 # defined in AX_FILE_ESCAPES
    323 AC_DEFUN([_YAT_AC_APPEND_TO_FILE],
    324 [
    325 AX_AC_APPEND_TO_FILE([$1],
    326 m4_bpatsubsts([$2], [\$], [${AX_DOLLAR}],
    327                     [\\], [\\\\],
    328                     [\"], [${AX_DQ}]))
    329 
     334# _YAT_AM_LOCAL_WRITE
     335# ===================
     336#
     337#
     338AC_DEFUN([_YAT_AM_LOCAL_WRITE],
     339[  m4_ifndef([YAT_AM_LOCAL_FILE], [
     340     _YAT_AM_TOP([$1])
     341     YAT_AC_APPEND_TO_FILE([$1], [$2])
     342   ], [
     343     YAT_AC_APPEND_TO_FILE(YAT_AM_LOCAL_FILE, [$2])
     344   ])
    330345])
    331346
  • trunk/m4/yat_common.m4

    r3966 r4326  
    121121AS_VAR_POPDEF([yat_Search])
    122122]) # YAT_SEARCH_LIBS
     123
     124
     125# YAT_AC_WRITE_TO_FILE([FILE-NAME], [CONTENT])
     126# ============================================
     127#
     128# When autoconf is run, create a file 'FILE-NAME' with CONTENT.
     129# Variables that need to be expanded by M4 cannot be quoted e.g.
     130# m4_define([my_text], [yada yada])
     131# YAT_AC_WRITE_TO_FILE([foo.txt], [This is my example ]my_text[ and no less])
     132#
     133# Within a macro definition, a dollar ($) followed by 0-9, #, @, or *
     134# is expanded by M4 and to avoid that one can use the pattern
     135# YAT_AC_WRITE_TO_FILE([foo.txt], [some prefix]$[1 and suffix])
     136# which outputs: some prefix $1 and suffix
     137AC_DEFUN([YAT_AC_WRITE_TO_FILE],
     138[
     139_YAT_AC_WRITE_TO_FILE([$1], [$2], [write])
     140])
     141
     142
     143# YAT_AC_APPEND_TO_FILE([FILE-NAME], [CONTENT])
     144# =============================================
     145#
     146# Same as YAT_AC_WRITE_TO_FILE but append to file instead
     147AC_DEFUN([YAT_AC_APPEND_TO_FILE],
     148[
     149_YAT_AC_WRITE_TO_FILE([$1], [$2], [append])
     150])
     151
     152
     153# _YAT_AC_WRITE_TO_FILE([FILE-NAME], [CONTENT], [MODE])
     154# =====================================================
     155AC_DEFUN([_YAT_AC_WRITE_TO_FILE],
     156[m4_define([yat_DIRECTION_OP], [m4_case([$3], [write], [>],
     157                                    [append], [>>],
     158            [m4_fatal([invalid mode $3])])])
     159m4_syscmd([cat ]yat_DIRECTION_OP[ $1 << '_yat_EOF'
     160$2
     161_yat_EOF
     162])
     163dnl abort if syscmd failed
     164m4_if(m4_sysval, [0], [], [m4_fatal([$0: cannot write: $1])])
     165])
  • trunk/m4/yat_svn_release.m4

    r4321 r4326  
    3030#   along with yat. If not, see <http://www.gnu.org/licenses/>.
    3131#
    32 ])
    33 
    34 
    35 AC_DEFUN([YAT_AC_WRITE],
    36 [
    37 m4_esyscmd([cat > $1 << '__EOF'
    38 $2
    39 __EOF
    40 ])
    41 ])
    42 
    43 
    44 AC_DEFUN([YAT_AC_WRITE_APPEND],
    45 [
    46 m4_esyscmd([cat >> $1 << '__EOF'
    47 $2
    48 __EOF
    49 ])
    5032])
    5133
     
    6648  AC_CHECK_PROG([SCP], [scp], [scp], [false])
    6749
    68   YAT_AC_WRITE(YAT_OUTPUTFILE,
    69 [# $1 generated by Autoconf ]AC_AUTOCONF_VERSION[ from macro $0
    70 ## include this file in Makefile.am
     50  m4_ifdef([AM_PROG_LIBTOOL], [
     51    m4_pushdef([write_LIBTOOL_VERSION_cmd],
     52               [$(srcdir)/libtool --version | head -n 1 | $(SED) -e 's/.*(//' -e 's/)//' >> [$]@])
     53  ], [
     54    m4_pushdef([write_LIBTOOL_VERSION_cmd], [:])
     55  ])
     56  _YAT_AM_LOCAL_WRITE(YAT_OUTPUTFILE, [
    7157
    7258STABLE_VERSION = $2
     
    7864
    7965.PHONY: check-svn-diff check-news check-news-date check-version \
    80         check-release-tools maintainer-check release
     66        check-release-tools maintainer-check maintainer-check-local \
     67        release-tag-upload release-tag-upload-local
    8168
    8269# --------------------------------------------------------------------
     
    8875# --------------------------------------------------------------------
    8976release-tag-upload:
    90   @test -z "$(RELEASE_LOCAL)" || $(MAKE) $(AM_MAKEFLAGS) $(RELEASE_LOCAL)
     77  $(MAKE) $(AM_MAKEFLAGS) release-tag-upload-local
    9178  $(MAKE) $(AM_MAKEFLAGS) check-release-tools
    9279  $(MAKE) $(AM_MAKEFLAGS) release-check
     
    9986  $(MAKE) $(AM_MAKEFLAGS) announce.txt
    10087  $(MAKE) $(AM_MAKEFLAGS) upload
     88  $(MAKE) $(AM_MAKEFLAGS) release-tag-upload-hook
     89
     90# This is run early in release-tag-upload. Add targets to
     91# $(RELEASE_LOCAL) such as checks that needed tools to make a release
     92# are available.
     93release-tag-upload-local: $(RELEASE_LOCAL)
     94
     95# This is run late in release-tag-upload. Add targets to
     96# $(RELEASE_HOOK) if extra targets are desired.
     97release-tag-upload-hook: $(RELEASE_HOOK)
    10198
    10299$(distdir).tar.gz.MD5: $(distdir).tar.gz
     
    144141  && ./bootstrap \
    145142  && cd ../$(mc_builddir) \
    146   && ../$(mc_exportdir)/configure --srcdir=../$(mc_exportdir) \
    147      $(DISTCHECK_CONFIGURE_FLAGS) \
    148   && { test -z "$(MAINTAINER_CHECK_LOCAL)" || \
    149         $(MAKE) $(AM_MAKEFLAGS) $(MAINTAINER_CHECK_LOCAL); } \
     143  && ../$(mc_exportdir)/configure $(DISTCHECK_CONFIGURE_FLAGS) \
     144  && $(MAKE) $(AM_MAKEFLAGS) maintainer-check-local \
    150145  && $(MAKE) $(AM_MAKEFLAGS) dist || exit 1
    151146  rm -rf $(mc_builddir) $(mc_exportdir)
     147
     148# This is run during maintainer-check. Add targets to
     149# $(MAINTAINER_CHECK_LOCAL), if extra targets such as 'check' is
     150# desired during maintainer-check.
     151maintainer-check-local: $(MAINTAINER_CHECK_LOCAL)
    152152
    153153# -----------------------------------------
     
    225225# Generate an announcement
    226226announce.txt: Makefile $(distdir).tar.gz.MD5
    227   @echo "I'm happy to announce the release of $(PACKAGE_STRING)" > $][@
    228   @echo >> $][@
    229   @echo "<INSERT TEXT HERE>" >> $][@
    230   @echo >> $][@
    231   @echo "You can find the new release here:" >> $][@
    232   @echo >> $][@
    233   @echo "$(DOWNLOAD_URL)" >> $][@
    234   @echo >> $][@
    235   @echo "Here is the checksum" >> $][@
    236   @echo >> $][@
    237   @printf "MD5:    " >> $][@
    238   @cat $(distdir).tar.gz.MD5 | $(SED) 's/ .*//' >> $][@
    239   @echo >> $][@
    240   @echo "Please report bugs by email to $(PACKAGE_BUGREPORT)" >> $][@
    241   @echo >> $][@
    242   @echo "This release was bootstrapped with the following tools:" >> $][@
    243   @$(AUTOCONF) --version | head -n 1 | $(SED) -e 's/.*(//' -e 's/)//' >> $][@
    244   @$(AUTOMAKE) --version | head -n 1 | $(SED) -e 's/.*(//' -e 's/)//' >> $][@]dnl
    245 )
    246 
    247 m4_ifdef([AM_PROG_LIBTOOL],
    248 [YAT_AC_WRITE_APPEND(YAT_OUTPUTFILE,
    249 [ @$(srcdir)/libtool --version | head -n 1 | $(SED) -e 's/.*(//' -e 's/)//' >> $][@])
     227  @echo "I'm happy to announce the release of $(PACKAGE_STRING)" > ]$[@
     228  @echo >> ]$[@
     229  @echo "<INSERT TEXT HERE>" >> ]$[@
     230  @echo >> ]$[@
     231  @echo "You can find the new release here:" >> ]$[@
     232  @echo >> ]$[@
     233  @echo "$(DOWNLOAD_URL)" >> ]$[@
     234  @echo >> ]$[@
     235  @echo "Here is the checksum" >> ]$[@
     236  @echo >> ]$[@
     237  @printf "MD5:    " >> ]$[@
     238  @cat $(distdir).tar.gz.MD5 | $(SED) 's/ .*//' >> ]$[@
     239  @echo >> ]$[@
     240  @echo "Please report bugs by email to $(PACKAGE_BUGREPORT)" >> ]$[@
     241  @echo >> ]$[@
     242  @echo "This release was bootstrapped with the following tools:" >> ]$[@
     243  @$(AUTOCONF) --version | head -n 1 | $(SED) -e 's/.*(//' -e 's/)//' >> ]$[@
     244  @$(AUTOMAKE) --version | head -n 1 | $(SED) -e 's/.*(//' -e 's/)//' >> ]$[@
     245        @]write_LIBTOOL_VERSION_cmd[
     246  @echo >> ]$[@
     247  @echo You can find the list of significant changes between $(VERSION)>> ]$[@
     248  @echo and earlier versions at >> ]$[@
     249  @echo >> ]$[@
     250  @echo $(NEWS_URL) >> ]$[@
     251
    250252])
    251 
    252 YAT_AC_WRITE_APPEND(YAT_OUTPUTFILE,
    253 [ @echo >> $][@
    254   @echo You can find the list of significant changes between $(VERSION)>> $][@
    255   @echo and earlier versions at >> $][@
    256   @echo >> $][@
    257   @echo $(NEWS_URL) >> $][@
    258 ])
    259 
    260253m4_popdef([YAT_OUTPUTFILE])
     254m4_popdef([write_LIBTOOL_VERSION_cmd])
    261255]) # YAT_SVN_RELEASE
     256
     257# See file 'yat_common.m4' for new macros
     258AU_ALIAS([YAT_AC_WRITE], [YAT_AC_WRITE_TO_FILE])
     259AU_ALIAS([YAT_AC_WRITE_APPEND], [YAT_AC_APPEND_TO_FILE])
  • trunk/test/Makefile.am

    r4319 r4326  
    177177test/random_shuffle.sh \
    178178test/version_option_test.sh \
     179test/yat_ac_write_to_file_test.sh \
     180test/yat_am_local_test.sh \
    179181test/yat_config_test.sh \
    180182test/yat_config_cblas_test.sh \
  • trunk/test/defs.sh.in

    r3999 r4326  
    2424bootstrap ()
    2525{
    26     rm -rf m4
     26    $RM -rf m4
    2727    $mkdir_p m4
    2828    cp $abs_top_srcdir/m4/*.m4 m4/.
    29     rm -f m4/lt*.m4 m4/libtool.m4
     29    $RM -f m4/lt*.m4 m4/libtool.m4
    3030    res=0
    3131    export AUTOM4TE
     
    170170: ${MAKE=make}
    171171: ${PKG_CONFIG='pkg-config'}
     172: ${RM=rm}
    172173YAT_CONFIG=$abs_top_builddir/build_support/yat-config
    173174YAT_LDFLAGS="@YAT_LDFLAGS@"
  • trunk/test/yat_prog_move_if_change_test.sh

    r3114 r4326  
    4040bootstrap
    4141test -r move-if-change || exit_fail "move-if-change not generated by autoconf"
     42cat move-if-change
    4243grep MOVE_IF_CHANGE Makefile.in || exit_fail
    4344./configure $configure_opts
Note: See TracChangeset for help on using the changeset viewer.