From 9113b3b066fc91ae4885df87bb7119a551c4c8ce Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 12 Dec 1995 18:15:39 +0000 Subject: [PATCH] Pretty-print variable definitions. Deal with comments more sensibly. Other minor cleanups --- ChangeLog | 21 ++++++++++-- Makefile.am | 2 +- Makefile.in | 28 +++++++++------- NEWS | 1 + TODO | 8 ++--- automake.in | 84 ++++++++++++++++++++++++++++++++++++---------- automake.texi | 4 +-- lib/am/Makefile.am | 2 +- libprograms.am | 20 ----------- texi-clean.am | 6 ++-- version.texi | 2 +- 11 files changed, 112 insertions(+), 66 deletions(-) delete mode 100644 libprograms.am diff --git a/ChangeLog b/ChangeLog index 7ccd877a..86f65ac6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +Tue Dec 12 10:06:28 1995 Tom Tromey + + * Makefile.am (pkgdata_DATA): Removed libprograms.am. + + * automake.in (do_one_merge_target): Never generate trailing + whitespace. + (pretty_print): New function. + (handle_footer): Prettyprint definitions. + (am_install_var): Ditto. + (handle_source_transform): Ditto. + (handle_dist): Ditto. + (handle_libraries): Ditto. + (read_am_file): Put comments nearer appropriate code. + + * texi-clean.am (mostlyclean-info): Use continued lines, not + multiple rm's. From Jim Meyering. + Sun Dec 10 11:59:33 1995 Tom Tromey * Makefile.am (pkgdata_DATA): Cause INSTALL, install-sh, mdate-sh, @@ -228,7 +245,7 @@ Sat Dec 2 21:39:56 1995 Tom Tromey * automake.in (handle_tags): Generate TAGS rule for every directory. - + * subdirs.am (RECURSIVE): Include installcheck-recursive. * automake.in (installcheck): New variable. (generate_makefile): Initialize it. @@ -842,7 +859,7 @@ Sun Nov 12 23:59:08 1995 Tom Tromey * automake.in: Special-case when amdir=. * Makefile.am (DIST_OTHER): Removed auto-detected files. - + * automake.in: Search for commonly-used files and auto-include them in distribution diff --git a/Makefile.am b/Makefile.am index eccfe0b4..8b7fc14f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,7 +6,7 @@ TEXINFOS = automake.texi pkgdata_DATA = clean-kr.am clean.am compile-kr.am compile-vars.am \ compile.am data.am depend.am dist-subd-top.am \ dist-subd.am dist-vars.am dist.am footer.am header-vars.am \ -kr-vars.am libprograms.am libraries-vars.am \ +kr-vars.am libraries-vars.am \ libraries.am library.am mans-vars.am \ program.am programs.am remake-hdr.am \ remake-subd.am remake.am scripts.am subdirs.am tags.am tags-subd.am \ diff --git a/Makefile.in b/Makefile.in index edb4291c..4fbfa01a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -49,11 +49,13 @@ transform = @program_transform_name@ bin_SCRIPTS = automake TEXINFOS = automake.texi +# SUBDIRS = intl po +# CONFIG_HEADER = config.h pkgdata_DATA = clean-kr.am clean.am compile-kr.am compile-vars.am \ compile.am data.am depend.am dist-subd-top.am \ dist-subd.am dist-vars.am dist.am footer.am header-vars.am \ -kr-vars.am libprograms.am libraries-vars.am \ +kr-vars.am libraries-vars.am \ libraries.am library.am mans-vars.am \ program.am programs.am remake-hdr.am \ remake-subd.am remake.am scripts.am subdirs.am tags.am tags-subd.am \ @@ -64,13 +66,15 @@ INSTALL install-sh mdate-sh mkinstalldirs texinfo.tex DIST_OTHER = automake.in +# Gross. DIST_SUBDIRS = samples/cpio/*Makefile.am +# The following requires a fixed version of the Emacs 19.30 etags. ETAGS_ARGS = automake.in --lang=none \ --regex='/^@node[ \t]+\([^,]+\)/\1/' automake.texi -SCRIPTS = $(bin_SCRIPTS) +SCRIPTS= $(bin_SCRIPTS) MAKEINFO = makeinfo TEXI2DVI = texi2dvi @@ -82,10 +86,12 @@ INFOS = automake.info* INFO_DEPS = automake.info DVIS = automake.dvi -DATA = $(pkgdata_DATA) +DATA= $(pkgdata_DATA) ACLOCAL = aclocal.m4 -DIST_COMMON = mkinstalldirs configure Makefile.in stamp-vti configure.in ChangeLog THANKS README version.texi mdate-sh TODO INSTALL Makefile.am NEWS aclocal.m4 install-sh +DIST_COMMON = mkinstalldirs configure Makefile.in stamp-vti configure.in \ +ChangeLog THANKS README version.texi mdate-sh TODO INSTALL Makefile.am \ +texinfo.tex NEWS aclocal.m4 install-sh PACKAGE = @PACKAGE@ VERSION = @VERSION@ @@ -166,9 +172,9 @@ uninstall-info: done mostlyclean-info: - rm -f automake.aux automake.cp automake.cps automake.dvi - rm -f automake.fn automake.fns automake.ky automake.log - rm -f automake.pg automake.toc automake.tp automake.vr automake.op + rm -f automake.aux automake.cp automake.cps automake.dvi \ + automake.fn automake.fns automake.ky automake.log \ + automake.pg automake.toc automake.tp automake.vr automake.op clean-info: @@ -248,9 +254,9 @@ info: $(INFO_DEPS) dvi: $(DVIS) -check: +check: -installcheck: +installcheck: install-exec: install-binSCRIPTS @@ -287,10 +293,6 @@ maintainer-clean: distclean maintainer-clean-binSCRIPTS maintainer-clean-vti mai @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." -# SUBDIRS = intl po -# CONFIG_HEADER = config.h -# Gross. -# The following requires a fixed version of the Emacs 19.30 etags. # Some simple checks: # * syntax check with perl4 and perl5. # * make sure the scripts don't use 'true' diff --git a/NEWS b/NEWS index 60acb217..ac96f478 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ New in 0.26: * Added --install-missing option. +* Pretty-prints generated macros New in 0.25: * Bug fixes. diff --git a/TODO b/TODO index a47c4855..72eee6b1 100644 --- a/TODO +++ b/TODO @@ -10,7 +10,7 @@ Clean up the output: * Ensure every line has a purpose. Omit unused stuff * Eliminate extraneous rules when possible (eg 'install-am' stuff) * Make sure vertical spacing is correct -* pretty-print targets, rules, etc. +* pretty-print targets Need OTHER_SOURCES to hold sources whose objects end up in eg LIBOBJS. Dependency tracking should work here. Maybe if it doesn't exist it @@ -24,10 +24,6 @@ feel about this. Consider automatic support for ".y" files. At the very least arrange to have the corresponding ".c" file be distributed. [last half is done] -Implement better rule for copying through comments. Rule should be -that if comment immediately precedes rule or variable definition, then -comment should be put there. Else what happens now is ok. - install-info doesn't have to look in build directory for info files; just don't support this mode. @@ -94,7 +90,7 @@ For CONFIG_HEADER, automatically add its input file to the distribution. Don't hardcode the name of the configuration header. Get it from -configure.in (AC_CONFIG_HEADER). +configure.in (AC_CONFIG_HEADER). Get the list of Makefiles to create from configure.in AC_OUTPUT if none are given. diff --git a/automake.in b/automake.in index c4212e78..8c43f072 100755 --- a/automake.in +++ b/automake.in @@ -349,8 +349,7 @@ sub handle_source_transform push (@result, $_); } - $output_vars .= ($one_file . "_OBJECTS = " . join (' ', @result) - . "\n"); + &pretty_print ($one_file . "_OBJECTS =", '', @result); } else { @@ -427,8 +426,7 @@ sub handle_libraries { push (@outlist, 'lib' . $onelib . '.a'); } - $output_vars .= ($onedir . '_LIBFILES = ' - . join (' ', @outlist) . "\n"); + &pretty_print ($onedir . '_LIBFILES =', '', @outlist); } } push (@all, '$(LIBFILES)'); @@ -456,7 +454,7 @@ sub handle_libraries if (! defined $contents{'LIBFILES'}) { - $output_vars .= 'LIBFILES = ' . join (' ', @liblist) . "\n"; + &pretty_print ('LIBFILES = ', '', @liblist); } $output_vars .= &file_contents ('libraries-vars'); } @@ -518,8 +516,8 @@ sub handle_texinfo } # Some boilerplate. - $output_vars = $output_vars . &file_contents ('texinfos-vars'); - $output_rules = $output_rules . &file_contents ('texinfos'); + $output_vars .= &file_contents ('texinfos-vars'); + $output_rules .= &file_contents ('texinfos'); # How to clean. local ($crules) = &file_contents ('texi-clean'); @@ -654,8 +652,8 @@ sub handle_dist } } - $output_vars .= ("DIST_COMMON = " . join (' ', keys (%dist_common)) - . "\n\n"); + &pretty_print ("DIST_COMMON =", '', keys (%dist_common)); + $output_vars .= "\n"; # Some boilerplate. $output_vars .= &file_contents ('dist-vars'); @@ -803,11 +801,11 @@ sub handle_footer { if ($contents{'SOURCES'}) { - $output_vars .= "SOURCES = " . $contents{'SOURCES'} . "\n"; + &pretty_print ('SOURCES =', '', split (/\s+/, $contents{'SOURCES'})); } if ($contents{'OBJECTS'}) { - $output_vars .= "OBJECTS = " . $contents{'OBJECTS'} . "\n"; + &pretty_print ('OBJECTS =', '', split (/\s+/, $contents{'OBJECTS'})); } if ($contents{'SOURCES'} || $contents{'OBJECTS'}) { @@ -947,7 +945,12 @@ sub do_one_merge_target push (@values, $name . '-local'); } - $output_rules .= $name . ": " . join (' ', @values) . "\n\n"; + $output_rules .= $name . ":"; + if ($#values >= 0) + { + $output_rules .= ' ' . join (' ', @values); + } + $output_rules .= "\n\n"; } # Handle all 'clean' targets. @@ -1037,6 +1040,39 @@ sub check_gnits_standards { } +################################################################ + +# Pretty-print something. HEAD is what should be printed at the +# beginning of the first line, FILL is what should be printed at the +# beginning of every subsequent line. +sub pretty_print +{ + local ($head, $fill, @values) = @_; + + local ($column) = length ($head); + $output_vars .= $head; + + local ($bol) = 0; + foreach (@values) + { + # "71" because we also print a space. + if ($column + length ($_) > 71) + { + $output_vars .= " \\\n" . $fill; + $column = length ($fill); + $bol = 1; + } + + $output_vars .= ' ' unless ($bol); + $output_vars .= $_; + $column += length ($_) + 1; + $bol = 0; + } + + $output_vars .= "\n"; +} + + ################################################################ # Read Makefile.am and set up %contents. Simultaneously copy lines @@ -1056,6 +1092,7 @@ sub read_am_file local ($saw_bk) = 0; local ($was_rule) = 0; local ($last_var_name) = ''; + local ($saved_comments) = ''; while () { @@ -1081,6 +1118,12 @@ sub read_am_file } } } + elsif (/^\#/) + { + # Got a comment. We save comments until we get a + # non-comment, and then we add the last comments. + $saved_comments .= $_ . "\n"; + } elsif ($_ eq '@kr@') { # Special case: this means we want automatic @@ -1094,7 +1137,8 @@ sub read_am_file # Value here doesn't matter; for targets we only note # existence. $contents{$1} = 1; - $output_trailer .= $_ . "\n"; + $output_trailer .= $saved_comments . $_ . "\n"; + $saved_comments = ''; } elsif (m/^ *([A-Za-z][A-Za-z0-9_]*)[ \t]*=[ \t]*(.*)$/) { @@ -1109,7 +1153,8 @@ sub read_am_file { $contents{$1} = $2; } - $output_vars .= $_ . "\n"; + $output_vars .= $saved_comments . $_ . "\n"; + $saved_comments = ''; } elsif (m/^$/) { @@ -1117,12 +1162,13 @@ sub read_am_file # whatever we saw last. if ($was_rule) { - $output_trailer .= "\n"; + $output_trailer .= $saved_comments . "\n"; } else { - $output_vars .= "\n"; + $output_vars .= $saved_comments . "\n"; } + $saved_comments = ''; } else { @@ -1134,6 +1180,9 @@ sub read_am_file $saw_bk = (substr ($_, -1) eq "\\"); } + # Include trailing comments with variables for now. + $output_vars .= $saved_comments; + # Include some space after user code. $output_vars .= "\n"; $output_trailer .= "\n"; @@ -1384,7 +1433,8 @@ sub am_install_var if (! defined $contents{$primary} && $#used >= 0) { # Define it. - $output_vars .= $primary . " = " . join (' ', @used) . "\n\n"; + &pretty_print ($primary . '=', '', @used); + $output_vars .= "\n"; } # Push here because PRIMARY might be configure time determined. diff --git a/automake.texi b/automake.texi index 955b379c..56d10edf 100644 --- a/automake.texi +++ b/automake.texi @@ -591,7 +591,7 @@ do AC_TRY_COMPILE( [#if !defined(__STDC__) || __STDC__ != 1 choke me -#endif +#endif ], [int test (int i, double x); struct s1 @{int (*f) (int a);@}; struct s2 @{int (*f) (double a);@};], @@ -659,7 +659,7 @@ Still, sometimes there are files which must be distributed, but which are not covered in the automatic rules. These files should be listed in the @samp{DIST_OTHER} variable. -For instance, in the @code{automake} distribution, +For instance, in the @code{automake} distribution, @file{automake.in} (the source to @code{automake}) is not found automatically. So in the @file{Makefile.am}, we have: diff --git a/lib/am/Makefile.am b/lib/am/Makefile.am index eccfe0b4..8b7fc14f 100644 --- a/lib/am/Makefile.am +++ b/lib/am/Makefile.am @@ -6,7 +6,7 @@ TEXINFOS = automake.texi pkgdata_DATA = clean-kr.am clean.am compile-kr.am compile-vars.am \ compile.am data.am depend.am dist-subd-top.am \ dist-subd.am dist-vars.am dist.am footer.am header-vars.am \ -kr-vars.am libprograms.am libraries-vars.am \ +kr-vars.am libraries-vars.am \ libraries.am library.am mans-vars.am \ program.am programs.am remake-hdr.am \ remake-subd.am remake.am scripts.am subdirs.am tags.am tags-subd.am \ diff --git a/libprograms.am b/libprograms.am deleted file mode 100644 index 460ba4b8..00000000 --- a/libprograms.am +++ /dev/null @@ -1,20 +0,0 @@ -install-libprograms: $(LIBPROGRAMS) - $(top_srcdir)/mkinstalldirs $(libexecdir) - for p in $(LIBPROGRAMS); do \ - $(INSTALL_PROGRAM) $$p $(libexecdir)/`echo $$p|sed '$(transform)'`; \ - done - -uninstall-libprograms: - for p in $(LIBPROGRAMS); do \ - rm -f $(libexecdir)/`echo $$p|sed '$(transform)'`; \ - done - -mostlyclean-libprograms: - -clean-libprograms: - rm -f $(LIBPROGRAMS) - -distclean-libprograms: - -maintainer-clean-libprograms: - diff --git a/texi-clean.am b/texi-clean.am index 4c22d7a8..4da74941 100644 --- a/texi-clean.am +++ b/texi-clean.am @@ -2,9 +2,9 @@ ## too many things could be removed. In particular the ".log" ## extension might be used in other contexts by the user mostlyclean-info: - rm -f @TEXI@.aux @TEXI@.cp @TEXI@.cps @TEXI@.dvi - rm -f @TEXI@.fn @TEXI@.fns @TEXI@.ky @TEXI@.log - rm -f @TEXI@.pg @TEXI@.toc @TEXI@.tp @TEXI@.vr @TEXI@.op + rm -f @TEXI@.aux @TEXI@.cp @TEXI@.cps @TEXI@.dvi \ + @TEXI@.fn @TEXI@.fns @TEXI@.ky @TEXI@.log \ + @TEXI@.pg @TEXI@.toc @TEXI@.tp @TEXI@.vr @TEXI@.op clean-info: diff --git a/version.texi b/version.texi index 1335b001..8ed3371f 100644 --- a/version.texi +++ b/version.texi @@ -1,3 +1,3 @@ -@set UPDATED 9 December +@set UPDATED 12 December @set EDITION 0.26 @set VERSION 0.26 -- 2.43.5