automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

76-tags-in-tags-am.patch


From: Akim Demaille
Subject: 76-tags-in-tags-am.patch
Date: Mon, 19 Mar 2001 10:23:06 +0100

This patch introduces one semantical difference: tags-recursive is
bound to tags, not TAGS as was before.  I think (i) it is cleaner, and
(ii) anyway it seems to me that TAGS itself performs its own
recursion:

     TAGS: $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
        $(TAGS_FILES) $(LISP)
         tags=; \
         here=`pwd`; \
=>       list='$(SUBDIRS)'; for subdir in $$list; do \
=>          if test "$$subdir" = .; then :; else \
=>      test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
=>          fi; \
=>       done; \
         list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \
         unique=`for i in $$list; do \
        if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
           done | \
           $(AWK) '    { files[$$0] = 1; } \
           END { for (i in files) print i; }'`; \
         test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
           || etags $(ETAGS_ARGS) $$tags  $$unique $(LISP)


I suppose that having two recursions is wrong, but my patch only makes
it more visible, it should be easier now to choose the one we want.

Another question is why don't we use the regular -am, -recursive
mechanism?  Given that we always output a `tags' and `TAGS' target, it
should be equivalent and much simpler: just RECURSIVE_TARGATS +=
tags-recursive.


Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * automake.in (%dependencies): Add 'tags'.
        (&handle_tags): Move the handling of subdirs and of directories
        where a dummy TAGS is needed into...
        * tags.am: here.
        Hook `tags-recursive' to `tags', not `TAGS'.
        Condition the main targets to `%?TAGS%'.

Index: Makefile.in
--- Makefile.in Thu, 15 Mar 2001 23:01:04 +0100 akim (am/h/16_Makefile.i 1.61 
644)
+++ Makefile.in Sun, 18 Mar 2001 20:52:28 +0100 akim (am/h/16_Makefile.i 1.61 
644)
@@ -356,13 +356,13 @@
          (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
           || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
        done && test -z "$$fail"
+
 tags-recursive:
        list='$(SUBDIRS)'; for subdir in $$list; do \
-         test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); 
\
+         test "$$subdir" = . || \
+           (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
        done

-tags: TAGS
-
 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
        list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \
        unique=`for i in $$list; do \
@@ -372,7 +372,7 @@
               END { for (i in files) print i; }'`; \
        mkid -fID $$unique $(LISP)

-TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+TAGS: $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
                $(TAGS_FILES) $(LISP)
        tags=; \
        here=`pwd`; \
@@ -573,6 +573,8 @@
 mostlyclean: mostlyclean-recursive

 mostlyclean-am: mostlyclean-aminfo mostlyclean-generic mostlyclean-vti
+
+tags: TAGS tags-recursive

 uninstall-am: uninstall-binSCRIPTS uninstall-dist_pkgdataDATA \
        uninstall-dist_scriptDATA uninstall-info-am
Index: automake.in
--- automake.in Thu, 15 Mar 2001 21:51:57 +0100 akim (am/f/39_automake.i 1.199 
755)
+++ automake.in Sun, 18 Mar 2001 20:45:23 +0100 akim (am/f/39_automake.i 1.199 
755)
@@ -624,6 +624,9 @@ sub initialize_per_input ()

     %dependencies =
       (
+       # Tagging.
+       'tags'  => [],
+
        # Texinfoing.
        'dvi'      => [],
        'dvi-am'   => [],
@@ -2754,37 +2757,16 @@ sub handle_data
 # Handle TAGS.
 sub handle_tags
 {
-    my @tag_deps = ();
-    if (&variable_defined ('SUBDIRS'))
-    {
-       $output_rules .= ("tags-recursive:\n"
-                         . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do 
\\\n"
-                         # Never fail here if a subdir fails; it
-                         # isn't important.
-                         . "\t  test \"\$\$subdir\" = . || (cd \$\$subdir"
-                         . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
-                         . "\tdone\n");
-       push (@tag_deps, 'tags-recursive');
-       &depend ('.PHONY', 'tags-recursive');
-    }
+    my $TAGS = 0;
+    my @config;

     if (&saw_sources_p (1)
-       || &variable_defined ('ETAGS_ARGS')
-       || @tag_deps)
+       || &variable_defined ('ETAGS_ARGS'))
     {
-       my $config = '';
-       foreach my $one_hdr (@config_headers)
-       {
-           if ($relative_dir eq dirname ($one_hdr))
-           {
-               # The config header is in this directory.  So require it.
-               $config .= ' ' if $config;
-               $config .= basename ($one_hdr);
-           }
-       }
-       $output_rules .= &file_contents ('tags',
-                                        ('CONFIG' => $config,
-                                         'DIRS'   => join (' ', @tag_deps)));
+        # FIXME: Why don't we support TAGS when there is a config file,
+        # but no sources?
+        $TAGS = 1;
+       @config = grep { $relative_dir eq dirname ($_) } @config_headers;
        &examine_variable ('TAGS_DEPENDENCIES');
     }
     elsif (&variable_defined ('TAGS_DEPENDENCIES'))
@@ -2792,13 +2774,10 @@ sub handle_tags
        &am_line_error ('TAGS_DEPENDENCIES',
                        "doesn't make sense to define `TAGS_DEPENDENCIES' 
without sources or `ETAGS_ARGS'");
     }
-    else
-    {
-       # Every Makefile must define some sort of TAGS rule.
-       # Otherwise, it would be possible for a top-level "make TAGS"
-       # to fail because some subdirectory failed.
-       $output_rules .= "tags: TAGS\nTAGS:\n\n";
-    }
+
+    $output_rules .= &file_contents ('tags',
+                                    ('TAGS'   => $TAGS,
+                                     'CONFIG' => join (' ', @config)));
 }

 # Handle multilib support.
Index: tags.am
--- tags.am Wed, 14 Mar 2001 23:16:54 +0100 akim (am/g/12_tags.am 1.9 644)
+++ tags.am Sun, 18 Mar 2001 20:52:44 +0100 akim (am/g/12_tags.am 1.9 644)
@@ -21,10 +21,26 @@
 tags: TAGS


+## --------- ##
+## Subdirs.  ##
+## --------- ##
+
+if %?SUBDIRS%
+.PHONY tags: tags-recursive
+tags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+## Never fail here if a subdir fails; it isn't important.
+         test "$$subdir" = . || \
+           (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+       done
+endif %?SUBDIRS%
+
+
 ## ---- ##
 ## ID.  ##
 ## ---- ##

+if %?TAGS%
 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 ## Make sure the list of sources is unique.
        list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \
@@ -35,13 +51,18 @@
          $(AWK) '    { files[$$0] = 1; } \
               END { for (i in files) print i; }'`; \
        mkid -fID $$unique $(LISP)
+endif %?TAGS%


 ## ------ ##
 ## TAGS.  ##
 ## ------ ##

-TAGS: %DIRS% $(HEADERS) $(SOURCES) %CONFIG% $(TAGS_DEPENDENCIES) \
+## Every Makefile must define some sort of TAGS rule.  Otherwise, it
+## would be possible for a top-level "make TAGS" to fail because some
+## subdirectory failed.
+if %?TAGS%
+TAGS: $(HEADERS) $(SOURCES) %CONFIG% $(TAGS_DEPENDENCIES) \
                $(TAGS_FILES) $(LISP)
        tags=; \
        here=`pwd`; \
@@ -64,23 +85,30 @@
 ## Make sure we have something to run etags on.
        test -z "$(ETAGS_ARGS)%CONFIG%$$unique$(LISP)$$tags" \
          || etags $(ETAGS_ARGS) $$tags %CONFIG% $$unique $(LISP)
+else %?TAGS%
+TAGS:
+endif %?TAGS%
+


 ## --------------- ##
 ## `Global' tags.  ##
 ## --------------- ##

+if %?TAGS%
 GTAGS:
        here=`CDPATH=: && cd $(top_builddir) && pwd` \
          && cd $(top_srcdir) \
          && gtags -i $$here
+endif %?TAGS%


 ## ---------- ##
 ## Cleaning.  ##
 ## ---------- ##

+if %?TAGS%
 .PHONY distclean-am: distclean-tags
-
 distclean-tags:
        -rm -f TAGS ID
+endif %?TAGS%
Index: m4/Makefile.in
--- m4/Makefile.in Thu, 15 Mar 2001 23:01:04 +0100 akim (am/h/15_Makefile.i 
1.36 644)
+++ m4/Makefile.in Sun, 18 Mar 2001 20:52:28 +0100 akim (am/h/15_Makefile.i 
1.36 644)
@@ -122,10 +122,8 @@
          echo " rm -f $(DESTDIR)$(m4datadir)/$$f"; \
          rm -f $(DESTDIR)$(m4datadir)/$$f; \
        done
-tags: TAGS
 TAGS:

-
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)

 top_distdir = ..
@@ -210,6 +208,8 @@

 mostlyclean-am: mostlyclean-generic

+tags: TAGS
+
 uninstall-am: uninstall-m4dataDATA

 .PHONY: all all-am check check-am clean clean-generic distclean \
@@ -218,7 +218,8 @@
        install-exec-am install-info install-m4dataDATA install-man \
        install-strip installcheck installcheck-am installdirs \
        maintainer-clean maintainer-clean-generic mostlyclean \
-       mostlyclean-generic uninstall uninstall-am uninstall-m4dataDATA
+       mostlyclean-generic tags uninstall uninstall-am \
+       uninstall-m4dataDATA


 # Tell versions [3.59,3.63) of GNU make to not export all variables.
Index: tests/Makefile.in
--- tests/Makefile.in Thu, 15 Mar 2001 23:01:04 +0100 akim (am/h/14_Makefile.i 
1.40 644)
+++ tests/Makefile.in Sun, 18 Mar 2001 20:52:28 +0100 akim (am/h/14_Makefile.i 
1.40 644)
@@ -374,10 +374,8 @@
        cd $(top_builddir) && \
          CONFIG_HEADERS= CONFIG_LINKS= \
          CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status
-tags: TAGS
 TAGS:

-
 check-TESTS: $(TESTS)
        @failed=0; all=0; xfail=0; xpass=0; \
        srcdir=$(srcdir); export srcdir; \
@@ -517,13 +515,15 @@

 mostlyclean-am: mostlyclean-generic

+tags: TAGS
+
 .PHONY: all all-am check check-TESTS check-am clean clean-generic \
        distclean distclean-generic distclean-local distdir dvi dvi-am \
        info info-am install install-am install-data install-data-am \
        install-exec install-exec-am install-info install-man \
        install-strip installcheck installcheck-am installdirs \
        maintainer-clean maintainer-clean-generic mostlyclean \
-       mostlyclean-generic uninstall uninstall-am
+       mostlyclean-generic tags uninstall uninstall-am


 distclean-local:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]