automake
[Top][All Lists]
Advanced

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

Re: dvi -vs- subdirs


From: Akim Demaille
Subject: Re: dvi -vs- subdirs
Date: 08 May 2001 17:45:33 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Cuyahoga Valley)

>>>>> "Tom" == Tom Tromey <address@hidden> writes:

Tom> I think the appropriate fix is to move processing for these
Tom> targets out of texinfos.am and into subdirs.am.  Akim, what do
Tom> you think?

I did not really analyze the issue yet, but your proposal goes in the
opposite direction I'm trying to walk to :(

I tried to settle subdirs.am in such a way that it's an empty body,
filled only thanks to SUBDIRS +=.  It should not know anything but how
to recurse.

I might be wrong (again, I did not analyze at all), but it seems to me
we might have to deal with something comparable to TAGS: we want to
recurse, even if the current dir is not concerned.

It is my belief that there are several *.am like these (tags and
texinfos) that should *always* be output, _but_ with a switch stating
whether the current dir is to be processed or not.

The same ways as I first tried to address the empty TAGS: target.
Instead of having it in automake, teach it to tags.am under some
condition, and always output it.

Just FYI, here is the patch I'm referring to.  It's been rejected for
a different reason: my misunderstanding the importance of TAGS vs
tags.


-------------------------------------------------- 76-tags-in-tags-am.patch

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%'.
        * tests/confsub.test: config.h.in can appear (in TAGS for instance),
        so adjust the regexp to catch exactly config.h.
        * tests/tagsub.test: tags-recursive' is hooked to `tags', not `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:
Index: tests/confsub.test
--- tests/confsub.test Wed, 14 Mar 2001 23:12:52 +0100 akim (am/d/41_confsub.te 
1.2 775)
+++ tests/confsub.test Wed, 21 Mar 2001 01:36:35 +0100 akim (am/d/41_confsub.te 
1.2 775)
@@ -33,5 +33,6 @@
 $AUTOMAKE || exit 1

 # Make sure subdir Makefile.in doesn't itself look in the subdir.
-(grep 'subdir/config.h' subdir/Makefile.in | grep -v CONFIG_HEADERS) && exit 1
+(egrep 'subdir/config\.h([^.]\.*)?$' subdir/Makefile.in |
+   grep -v CONFIG_HEADERS) && exit 1
 exit 0
Index: tests/tagsub.test
--- tests/tagsub.test Sat, 13 Jan 2001 18:11:09 +0100 akim (am/27_tagsub.tes 
1.1 775)
+++ tests/tagsub.test Wed, 21 Mar 2001 01:36:29 +0100 akim (am/27_tagsub.tes 
1.1 775)
@@ -29,4 +29,4 @@

 $AUTOMAKE || exit 1

-grep '^TAGS:.*tags-recursive' Makefile.in
+grep '^tags:.*tags-recursive' Makefile.in



reply via email to

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