+Sat Feb 22 16:05:24 1997 Gordon Matzigkeit <gord@gnu.ai.mit.edu>
+
+ * Makefile.am (pkgdata_DATA): Under this new scheme, we no longer
+ need compile-kr.am. Delete it.
+
+ * automake.in (handle_yacc_lex_cxx, get_object_extension): Use
+ _.c, _.o, _.lo instead of ._c, ._o, .l_o for de-ansification.
+
+ * ansi2knr.c (main): Parse our arguments a little differently so
+ that we don't create null output files when we can't read the
+ input file.
+
Wed May 28 23:40:33 1997 Tom Tromey <tromey@cygnus.com>
* depend.am (.deps/.P): Depend on $(BUILT_SOURCES) again. From
bin_SCRIPTS = automake aclocal
info_TEXINFOS = automake.texi
-pkgdata_DATA = clean-kr.am clean.am clean-hdr.am compile-kr.am \
-comp-vars.am compile.am data.am dejagnu.am depend.am depend2.am \
-dist-vars.am footer.am header.am header-vars.am kr-extra.am libs.am \
-library.am libtool.am ltlib.am ltlibrary.am mans-vars.am program.am \
-progs.am remake-hdr.am remake.am scripts.am subdirs.am tags.am \
-tags-clean.am texi-vers.am texinfos.am libs-clean.am ltlib-clean.am \
-progs-clean.am data-clean.am COPYING INSTALL texinfo.tex ansi2knr.c \
-ansi2knr.1 lisp.am lisp-clean.am
+pkgdata_DATA = clean-kr.am clean.am clean-hdr.am comp-vars.am \
+compile.am data.am dejagnu.am depend.am depend2.am dist-vars.am \
+footer.am header.am header-vars.am kr-extra.am libs.am library.am \
+libtool.am ltlib.am ltlibrary.am mans-vars.am program.am progs.am \
+remake-hdr.am remake.am scripts.am subdirs.am tags.am tags-clean.am \
+texi-vers.am texinfos.am libs-clean.am ltlib-clean.am progs-clean.am \
+data-clean.am COPYING INSTALL texinfo.tex ansi2knr.c ansi2knr.1 \
+lisp.am lisp-clean.am
## These must all be executable when installed.
pkgdata_SCRIPTS = config.guess config.sub install-sh mdate-sh missing \
bin_SCRIPTS = automake aclocal
info_TEXINFOS = automake.texi
-pkgdata_DATA = clean-kr.am clean.am clean-hdr.am compile-kr.am \
-comp-vars.am compile.am data.am dejagnu.am depend.am depend2.am \
-dist-vars.am footer.am header.am header-vars.am kr-extra.am libs.am \
-library.am libtool.am ltlib.am ltlibrary.am mans-vars.am program.am \
-progs.am remake-hdr.am remake.am scripts.am subdirs.am tags.am \
-tags-clean.am texi-vers.am texinfos.am libs-clean.am ltlib-clean.am \
-progs-clean.am data-clean.am COPYING INSTALL texinfo.tex ansi2knr.c \
-ansi2knr.1 lisp.am lisp-clean.am
+pkgdata_DATA = clean-kr.am clean.am clean-hdr.am comp-vars.am \
+compile.am data.am dejagnu.am depend.am depend2.am dist-vars.am \
+footer.am header.am header-vars.am kr-extra.am libs.am library.am \
+libtool.am ltlib.am ltlibrary.am mans-vars.am program.am progs.am \
+remake-hdr.am remake.am scripts.am subdirs.am tags.am tags-clean.am \
+texi-vers.am texinfos.am libs-clean.am ltlib-clean.am progs-clean.am \
+data-clean.am COPYING INSTALL texinfo.tex ansi2knr.c ansi2knr.1 \
+lisp.am lisp-clean.am
pkgdata_SCRIPTS = config.guess config.sub install-sh mdate-sh missing \
mkinstalldirs elisp-comp ylwrap acinstall
exit(1);
}
}
- switch ( argc )
+ if (argc < 2 || argc > 3)
{
- default:
printf("Usage: ansi2knr input_file [output_file]\n");
- exit(0);
- case 2:
- out = stdout;
- break;
- case 3:
- out = fopen(argv[2], "w");
- if ( out == NULL )
- { fprintf(stderr, "Cannot open output file %s\n", argv[2]);
exit(1);
}
- }
in = fopen(argv[1], "r");
if ( in == NULL )
- { fprintf(stderr, "Cannot open input file %s\n", argv[1]);
+ {
+ fprintf(stderr, "Cannot open input file %s\n", argv[1]);
exit(1);
}
+ if (argc == 3)
+ {
+ out = fopen(argv[2], "w");
+ if ( out == NULL )
+ {
+ fprintf(stderr, "Cannot open output file %s\n", argv[2]);
+ exit(1);
+ }
+ }
+ else
+ {
+ out = stdout;
+ }
fprintf(out, "#line 1 \"%s\"\n", argv[1]);
buf = malloc(bufsize);
line = buf;
$dir_holds_sources = 1;
# Maybe require libtool library object files.
- local ($l, $extension) = ('', 'o');
- $l = 'l' if ($out =~ /^lib.*\.la$/);
+ local ($extension) = '.o';
+ $extension = '.lo' if ($out =~ /\.la$/);
if (! $included_generic_compile)
{
# Check for automatic de-ANSI-fication.
if (defined $options{'ansi2knr'})
{
- $extension = '$o';
+ $extension = '$U' . $extension;
if (! $included_knr_compile)
{
if (! $am_c_prototypes)
$am_c_prototypes = 1;
}
- push (@suffixes, '._c', '._o');
- push (@suffixes, '.l_o') if $seen_libtool;
-
# Only require ansi2knr files if they should appear in
# this directory.
if ($options{'ansi2knr'} eq 'ansi2knr')
. " && \$(MAKE) ansi2knr\n\n");
}
- &define_variable ('o', "\@U\@o");
-
# Make sure ansi2knr can be found: if no path specified,
# specify "./".
if ($options{'ansi2knr'} eq 'ansi2knr')
&define_variable ("ANSI2KNR", $options{'ansi2knr'});
}
- $output_rules .= &file_contents ('compile-kr');
$output_rules .= &file_contents ('clean-kr');
push (@clean, 'kr');
}
}
- return '.' . $l . $extension;
+ return $extension;
}
# Handle yacc and lex.
#
# Handle some ansi2knr cleanup.
#
- if (defined $options{'ansi2knr'} && keys %de_ansi_objects)
+ if (defined $options{'ansi2knr'} && keys %de_ansi_files)
{
- # Make all ._o files depend on ansi2knr. Use a sneaky little
- # hack to make it print nicely.
- &pretty_print_rule ('', '', ((sort keys %de_ansi_objects),
- ':', '$(ANSI2KNR)'));
- # The ._c files also depend on ansi2knr. We need both because
- # some makes don't apply transitivity through implicit rules.
- local (%de_ansi_sources, $x);
- foreach $x (keys %de_ansi_objects)
- {
- $x =~ s/o$/c/;
- $de_ansi_sources{$x} = 1;
- }
- &pretty_print_rule ('', '', ((sort keys %de_ansi_sources),
- ':', '$(ANSI2KNR)'));
+ # Make all _.c files depend on their corresponding .c files.
+ local ($base, @objects);
+ foreach $base (sort (keys %de_ansi_files))
+ {
+ $output_rules .= $base . "_.c: $base.c\n\t"
+ . '$(ANSI2KNR) $< ' . $base . "_.c\n";
+ push (@objects, $base . '_.o');
+ push (@objects, $base . '_.lo') if $seen_libtool;
+ }
+
+ # Make all _.o (and _.lo) files depend on ansi2knr.
+ # Use a sneaky little hack to make it print nicely.
+ &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
}
#
{
# .s is assembly. Just rewrite it. FIXME: not finished.
}
- elsif (s/\.[cly]$/._o/)
- {
- # .c is C. .l is lex. .y is yacc.
-
- # Note: first we rewrite (eg) foo.c to foo._o and push
- # the file onto the list of objects that require
- # ansi2knr. Then we rewrite ._o to $obj; $obj can be
- # simply `.o' if deansification is not really
- # required.
- $de_ansi_objects{$_} = 1;
- s/\._o$/$obj/;
- $seen_c_source = -1 unless $seen_c_source;
+ elsif (defined ($options{'ansi2knr'}) && s/_\.[cly]$/_.c/)
+ {
+ # FIXME include line number in error.
+ &am_error ("C source file \`$_' would be deleted by ansi2knr rules");
+ }
+ elsif (s/\.[cly]$//)
+ {
+ # .c is C. .l is lex. .y is yacc.
+
+ # Note: first we rewrite (eg) foo.c to foo and push
+ # the file onto the list of deansified files. Then we add
+ # $obj, which can either be `_.o', or simply `.o' if
+ # deansification is not required.
+ $de_ansi_files{$_} = 1;
+ $_ .= $obj;
+ $seen_c_source = 1;
}
else
{
# This is a list of all targets to run during "make dist".
@dist_targets = ();
- # Keys in this hash are the names of ._o files which must depend
- # on ansi2knr. Ugh.
- %de_ansi_objects = ();
+ # Keys in this hash are the basenames of files which must depend
+ # on ansi2knr.
+ %de_ansi_files = ();
}
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.
mostlyclean-kr:
- rm -f *._o *.l_o *._c _*.c _*.o
+ rm -f *_.c
clean-kr:
+++ /dev/null
-## automake - create Makefile.in from Makefile.am
-## Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
-
-## This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2, or (at your option)
-## any later version.
-
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-## 02111-1307, USA.
-.c._c:
- $(ANSI2KNR) $< > $*.tmp && mv $*.tmp $@
-
-._c._o:
- @echo "$(COMPILE) -c $<"
- @rm -f _$*.c
- @ln $< _$*.c && $(COMPILE) -c _$*.c && mv _$*.o $@ && rm _$*.c
-
-._c.l_o:
- @echo "$(LIBTOOL) --mode=compile $(COMPILE) -c $<"
- @rm -f _$*.c
- @ln $< _$*.c && $(LIBTOOL) --mode=compile $(COMPILE) -c _$*.c && mv _$*.lo $@ && rm _$*.c
-
-## This rule exists because some versions of make won't apply
-## transitivity through implicit rules.
-.c._o:
- $(ANSI2KNR) $< > $*.tmp && mv $*.tmp $*._c
- @echo "$(COMPILE) -c $*._c"
- @rm -f _$*.c
- @ln $*._c _$*.c && $(COMPILE) -c _$*.c && mv _$*.o $@ && rm _$*.c
-
-## This rule exists because some versions of make won't apply
-## transitivity through implicit rules.
-.c.l_o:
- $(ANSI2KNR) $< > $*.tmp && mv $*.tmp $*._c
- @echo "$(LIBTOOL) --mode=compile $(COMPILE) -c $*._c"
- @rm -f _$*.c
- @ln $*._c _$*.c && $(LIBTOOL) --mode=compile $(COMPILE) -c _$*.c && mv _$*.lo $@ && rm _$*.c
bin_SCRIPTS = automake aclocal
info_TEXINFOS = automake.texi
-pkgdata_DATA = clean-kr.am clean.am clean-hdr.am compile-kr.am \
-comp-vars.am compile.am data.am dejagnu.am depend.am depend2.am \
-dist-vars.am footer.am header.am header-vars.am kr-extra.am libs.am \
-library.am libtool.am ltlib.am ltlibrary.am mans-vars.am program.am \
-progs.am remake-hdr.am remake.am scripts.am subdirs.am tags.am \
-tags-clean.am texi-vers.am texinfos.am libs-clean.am ltlib-clean.am \
-progs-clean.am data-clean.am COPYING INSTALL texinfo.tex ansi2knr.c \
-ansi2knr.1 lisp.am lisp-clean.am
+pkgdata_DATA = clean-kr.am clean.am clean-hdr.am comp-vars.am \
+compile.am data.am dejagnu.am depend.am depend2.am dist-vars.am \
+footer.am header.am header-vars.am kr-extra.am libs.am library.am \
+libtool.am ltlib.am ltlibrary.am mans-vars.am program.am progs.am \
+remake-hdr.am remake.am scripts.am subdirs.am tags.am tags-clean.am \
+texi-vers.am texinfos.am libs-clean.am ltlib-clean.am progs-clean.am \
+data-clean.am COPYING INSTALL texinfo.tex ansi2knr.c ansi2knr.1 \
+lisp.am lisp-clean.am
## These must all be executable when installed.
pkgdata_SCRIPTS = config.guess config.sub install-sh mdate-sh missing \
exit(1);
}
}
- switch ( argc )
+ if (argc < 2 || argc > 3)
{
- default:
printf("Usage: ansi2knr input_file [output_file]\n");
- exit(0);
- case 2:
- out = stdout;
- break;
- case 3:
- out = fopen(argv[2], "w");
- if ( out == NULL )
- { fprintf(stderr, "Cannot open output file %s\n", argv[2]);
exit(1);
}
- }
in = fopen(argv[1], "r");
if ( in == NULL )
- { fprintf(stderr, "Cannot open input file %s\n", argv[1]);
+ {
+ fprintf(stderr, "Cannot open input file %s\n", argv[1]);
exit(1);
}
+ if (argc == 3)
+ {
+ out = fopen(argv[2], "w");
+ if ( out == NULL )
+ {
+ fprintf(stderr, "Cannot open output file %s\n", argv[2]);
+ exit(1);
+ }
+ }
+ else
+ {
+ out = stdout;
+ }
fprintf(out, "#line 1 \"%s\"\n", argv[1]);
buf = malloc(bufsize);
line = buf;