]> sourceware.org Git - automake.git/commitdiff
ansi2knr fix from Gord
authorTom Tromey <tromey@redhat.com>
Thu, 29 May 1997 06:06:01 +0000 (06:06 +0000)
committerTom Tromey <tromey@redhat.com>
Thu, 29 May 1997 06:06:01 +0000 (06:06 +0000)
ChangeLog
Makefile.am
Makefile.in
ansi2knr.c
automake.in
clean-kr.am
compile-kr.am [deleted file]
lib/am/Makefile.am
lib/ansi2knr.c

index ec987b1510c6b4212e2665f9f49b643273b1f2aa..429edbca58dfc890ab1b0b62864a761ac3450717 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+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
index 604755a7087aa60b69ec4e42aab5b193df5f7769..d77a79a7d12d30c0f5933701a3e5880a804e80e0 100644 (file)
@@ -8,14 +8,14 @@ SUBDIRS = tests m4
 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 \
index 5d08900b0cb4a563c9fabf590bdaeb4ef025c530..cdbf0d9ef5a4d8a4385960bbc50fb73ecc613232 100644 (file)
@@ -67,14 +67,14 @@ SUBDIRS = tests m4
 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
index 64a4578a2fa63d92463a77c2107f397d3ebdd03c..c6ee83309a8239e84270732e7c5ce53b56dba3bf 100644 (file)
@@ -195,26 +195,30 @@ main(argc, argv)
                        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;
index 7192ecd8d47a3db0a08133de56dfffaa7d927336..565248c98898c52dfabf660a790740487197a8f4 100755 (executable)
@@ -679,8 +679,8 @@ sub get_object_extension
     $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)
     {
@@ -736,7 +736,7 @@ sub get_object_extension
     # Check for automatic de-ANSI-fication.
     if (defined $options{'ansi2knr'})
     {
-       $extension = '$o';
+       $extension = '$U' . $extension;
        if (! $included_knr_compile)
        {
            if (! $am_c_prototypes)
@@ -748,9 +748,6 @@ sub get_object_extension
                $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')
@@ -778,8 +775,6 @@ sub get_object_extension
                                  . " && \$(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')
@@ -796,7 +791,6 @@ sub get_object_extension
                &define_variable ("ANSI2KNR", $options{'ansi2knr'});
            }
 
-           $output_rules .= &file_contents ('compile-kr');
            $output_rules .= &file_contents ('clean-kr');
 
            push (@clean, 'kr');
@@ -806,7 +800,7 @@ sub get_object_extension
        }
     }
 
-    return '.' . $l . $extension;
+    return $extension;
 }
 
 # Handle yacc and lex.
@@ -920,22 +914,21 @@ sub handle_yacc_lex_cxx
     #
     # 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)');
     }
 
     #
@@ -1135,18 +1128,22 @@ sub handle_single_transform_list
            {
                # .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
            {
@@ -5364,9 +5361,9 @@ sub initialize_per_input
     # 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 = ();
 }
 
 
index b5859e26489006a50807ddc01b6142ba494199a9..bf8c78c150eb83f3cab65e148ff380308fb1f6fe 100644 (file)
@@ -16,7 +16,7 @@
 ## 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:
 
diff --git a/compile-kr.am b/compile-kr.am
deleted file mode 100644 (file)
index 630ea75..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-## 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
index 604755a7087aa60b69ec4e42aab5b193df5f7769..d77a79a7d12d30c0f5933701a3e5880a804e80e0 100644 (file)
@@ -8,14 +8,14 @@ SUBDIRS = tests m4
 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 \
index 64a4578a2fa63d92463a77c2107f397d3ebdd03c..c6ee83309a8239e84270732e7c5ce53b56dba3bf 100644 (file)
@@ -195,26 +195,30 @@ main(argc, argv)
                        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;
This page took 0.051133 seconds and 5 git commands to generate.