autoconf-patches
[Top][All Lists]
Advanced

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

FYI: aclibraries and eval


From: Akim Demaille
Subject: FYI: aclibraries and eval
Date: 12 Jun 2001 11:36:37 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Copyleft)

I guess there is now plenty of things that can be factored.

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        * aclibraries: New.
        * autoscan.in (@kinds): Add `libraries'.
        Use address@hidden' instead of hard coded lists.
        (%programs, %headers, %identifiers, %makevars, %libraries, %functions):
        Remove, replaced by...
        (%used): this.

Index: Makefile.am
===================================================================
RCS file: /cvs/autoconf/Makefile.am,v
retrieving revision 1.54
diff -u -u -r1.54 Makefile.am
--- Makefile.am 2001/06/11 09:03:49 1.54
+++ Makefile.am 2001/06/12 09:30:33
@@ -41,7 +41,7 @@
              acfunctions.m4 acheaders.m4 actypes.m4
 
 distpkgdataDATA = acfunctions acheaders acidentifiers acmakevars acprograms \
-                  $(m4sources)
+                  aclibraries $(m4sources)
 
 nodistpkgdataDATA = autoconf.m4f
 
Index: Makefile.in
===================================================================
RCS file: /cvs/autoconf/Makefile.in,v
retrieving revision 1.136
diff -u -u -r1.136 Makefile.in
--- Makefile.in 2001/06/11 09:03:49 1.136
+++ Makefile.in 2001/06/12 09:30:33
@@ -1,4 +1,4 @@
-# Makefile.in generated automatically by automake 1.4-p2 from Makefile.am
+# Makefile.in generated automatically by automake 1.4-p3 from Makefile.am
 
 # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
@@ -86,7 +86,7 @@
 m4sources = m4sugar.m4 m4sh.m4               autoconf.m4              
acgeneral.m4 acoldnames.m4 acspecific.m4 aclang.m4 acversion.m4              
acfunctions.m4 acheaders.m4 actypes.m4
 
 
-distpkgdataDATA = acfunctions acheaders acidentifiers acmakevars acprograms    
               $(m4sources)
+distpkgdataDATA = acfunctions acheaders acidentifiers acmakevars acprograms    
               aclibraries $(m4sources)
 
 
 nodistpkgdataDATA = autoconf.m4f
Index: aclibraries
===================================================================
RCS file: aclibraries
diff -N aclibraries
--- /dev/null   Sat Apr 14 17:46:23 2001
+++ aclibraries Tue Jun 12 02:30:33 2001
@@ -0,0 +1,26 @@
+# aclibraries -- autoscan's mapping from libraries to Autoconf macros
+# Copyright 2001
+# 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.
+
+# Ones that have their own macros.
+
+# Others, checked with AC_CHECK_LIB.
+
+# Local Variables:
+# mode: shell-script
+# End:
Index: autoscan.in
===================================================================
RCS file: /cvs/autoconf/autoscan.in,v
retrieving revision 1.48
diff -u -u -r1.48 autoscan.in
--- autoscan.in 2001/06/12 08:40:03 1.48
+++ autoscan.in 2001/06/12 09:30:33
@@ -26,20 +26,22 @@
 use strict;
 
 use vars qw($autoconf $datadir $initfile $me $name $verbose
-            @cfiles @makefiles @shfiles
-            %c_keywords %programs %headers %identifiers %makevars
-            %libraries %functions %printed);
+            @cfiles @makefiles @shfiles %c_keywords %printed);
 
 ($me = $0) =~ s,.*/,,;
 $verbose = 0;
 
+# $USED{KIND}{ITEM} is set if ITEM is used in the program.
+# It is set to its list of locations.
+my %used = ();
+
 # $MACRO{KIND}{ITEM} is the macro to use to test ITEM.
 my %macro = ();
 
 # $NEEDED_MACROS{MACRO} is an array of locations requiring MACRO.
 my %needed_macros = ();
 
-my @kinds = qw (functions headers identifiers programs makevars);
+my @kinds = qw (functions headers identifiers programs makevars libraries);
 
 # For each kind, the default macro.
 my %generic_macro =
@@ -184,12 +186,12 @@
   # Taken from K&R 1st edition p. 180.
   # ANSI C, GNU C, and C++ keywords can introduce portability problems,
   # so don't ignore them.
-  foreach my $word (qw (int char float double struct union long short
-                        unsigned auto extern register typedef static
-                        goto return sizeof break continue if else for
-                        do while switch case default))
+
+  foreach (qw (int char float double struct union long short unsigned
+              auto extern register typedef static goto return sizeof break
+              continue if else for do while switch case default))
     {
-      $c_keywords{$word} = 0;
+      $c_keywords{$_} = 0;
     }
 
   # The data file format supports only one line of macros per function.
@@ -266,7 +268,7 @@
 
   foreach $file (@cfiles)
     {
-      push (@{$programs{"cc"}}, $file);
+      push (@{$used{'programs'}{"cc"}}, $file);
       scan_c_file ($file);
     }
 
@@ -286,14 +288,12 @@
       print "makefiles:", join(" ", @makefiles), "\n";
       print "shfiles:", join(" ", @shfiles), "\n";
 
-      foreach my $class (qw (functions identifiers headers
-                            makevars libraries programs))
+      foreach my $kind (@kinds)
        {
-         print "\n$class:\n";
-         my $h = eval "\\\%$class";
-         foreach my $word (sort keys %$h)
+         print "\n$kind:\n";
+         foreach my $word (sort keys %{$used{$kind}})
            {
-             print "$word: @{$h->{$word}}\n";
+             print "$word: @{$used{$kind}{$word}}\n";
            }
        }
     }
@@ -330,7 +330,7 @@
       # Preprocessor directives.
       if (/^\s*\#\s*include\s*<([^>]*)>/)
        {
-         push (@{$headers{$1}}, "$file:$.");
+         push (@{$used{'headers'}{$1}}, "$file:$.");
        }
       # Ignore other preprocessor directives.
       next if /^\s*\#/;
@@ -343,12 +343,12 @@
       # Maybe we should ignore function definitions (in column 0)?
       while (s/\b([a-zA-Z_]\w*)\s*\(/ /)
        {
-         push (@{$functions{$1}}, "$file:$.")
+         push (@{$used{'functions'}{$1}}, "$file:$.")
            if !defined $c_keywords{$1};
        }
       while (s/\b([a-zA-Z_]\w*)\b/ /)
        {
-         push (@{$identifiers{$1}}, "$file:$.")
+         push (@{$used{'identifiers'}{$1}}, "$file:$.")
            if !defined $c_keywords{$1};
        }
     }
@@ -374,17 +374,17 @@
       # Variable assignments.
       while (s/\b([a-zA-Z_]\w*)\s*=/ /)
        {
-         push (@{$makevars{$1}}, "$file:$.");
+         push (@{$used{'makevars'}{$1}}, "$file:$.");
        }
       # Libraries.
       while (s/\B-l([a-zA-Z_]\w*)\b/ /)
        {
-         push (@{$libraries{$1}}, "$file:$.");
+         push (@{$used{'libraries'}{$1}}, "$file:$.");
        }
       # Tokens in the code.
       while (s/\b([a-zA-Z_]\w*)\b/ /)
        {
-         push (@{$programs{$1}}, "$file:$.");
+         push (@{$used{'programs'}{$1}}, "$file:$.");
        }
     }
   close(MFILE);
@@ -408,7 +408,7 @@
       # Tokens in the code.
       while (s/\b([a-zA-Z_]\w*)\b/ /)
        {
-         push (@{$programs{$1}}, "$file:$.");
+         push (@{$used{'programs'}{$1}}, "$file:$.");
        }
     }
   close(MFILE);
@@ -438,13 +438,13 @@
 sub output_programs ()
 {
   print CONF "\n# Checks for programs.\n";
-  foreach my $word (sort keys %programs)
+  foreach my $word (sort keys %{$used{'programs'}})
     {
-      print_unique ($macro{'programs'}{$word}, @{$programs{$word}});
+      print_unique ($macro{'programs'}{$word}, @{$used{'programs'}{$word}});
     }
-  foreach my $word (sort keys %makevars)
+  foreach my $word (sort keys %{$used{'makevars'}})
     {
-      print_unique ($macro{'makevars'}{$word}, @{$makevars{$word}});
+      print_unique ($macro{'makevars'}{$word}, @{$used{'makevars'}{$word}});
     }
 }
 
@@ -454,7 +454,7 @@
 sub output_libraries ()
 {
   print CONF "\n# Checks for libraries.\n";
-  foreach my $word (sort keys %libraries)
+  foreach my $word (sort keys %{$used{'libraries'}})
     {
       print CONF "# FIXME: Replace `main' with a function in `-l$word':\n";
       print CONF "AC_CHECK_LIB([$word], [main])\n";
@@ -469,7 +469,7 @@
   my @have_headers;
 
   print CONF "\n# Checks for header files.\n";
-  foreach my $word (sort keys %headers)
+  foreach my $word (sort keys %{$used{'headers'}})
     {
       if (defined $macro{'headers'}{$word})
        {
@@ -477,11 +477,12 @@
            {
              push (@have_headers, $word);
              push (@{$needed_macros{"AC_CHECK_HEADERS([$word])"}},
-                   @{$headers{$word}});
+                   @{$used{'headers'}{$word}});
            }
          else
            {
-             print_unique ($macro{'headers'}{$word}, @{$headers{$word}});
+             print_unique ($macro{'headers'}{$word},
+                           @{$used{'headers'}{$word}});
            }
        }
     }
@@ -497,7 +498,7 @@
   my @have_types;
 
   print CONF "\n# Checks for typedefs, structures, and compiler 
characteristics.\n";
-  foreach my $word (sort keys %identifiers)
+  foreach my $word (sort keys %{$used{'identifiers'}})
     {
       if (defined $macro{'identifiers'}{$word})
        {
@@ -505,12 +506,12 @@
            {
              push (@have_types, $word);
              push (@{$needed_macros{"AC_CHECK_TYPES([$word])"}},
-                   @{$identifiers{$word}});
+                   @{$used{'identifiers'}{$word}});
            }
          else
            {
              print_unique ($macro{'identifiers'}{$word},
-                           @{$identifiers{$word}});
+                           @{$used{'identifiers'}{$word}});
            }
        }
     }
@@ -526,7 +527,7 @@
   my @have_funcs;
 
   print CONF "\n# Checks for library functions.\n";
-  foreach my $word (sort keys %functions)
+  foreach my $word (sort keys %{$used{'functions'}})
     {
       if (defined $macro{'functions'}{$word})
        {
@@ -534,12 +535,12 @@
            {
              push (@have_funcs, $word);
              push (@{$needed_macros{"AC_CHECK_FUNCS([$word])"}},
-                   @{$functions{$word}});
+                   @{$used{'functions'}{$word}});
            }
          else
            {
              print_unique ($macro{'functions'}{$word},
-                           @{$functions{$word}});
+                           @{$used{'functions'}{$word}});
            }
        }
     }



reply via email to

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