]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* aclibraries: New.
authorAkim Demaille <akim@epita.fr>
Tue, 12 Jun 2001 09:33:58 +0000 (09:33 +0000)
committerAkim Demaille <akim@epita.fr>
Tue, 12 Jun 2001 09:33:58 +0000 (09:33 +0000)
* autoscan.in (@kinds): Add `libraries'.
Use `@kinds' instead of hard coded lists.
(%programs, %headers, %identifiers, %makevars, %libraries, %functions):
Remove, replaced by...
(%used): this.

ChangeLog
Makefile.am
Makefile.in
aclibraries [new file with mode: 0644]
autoscan.in
bin/autoscan.in
lib/autoscan/libraries [new file with mode: 0644]

index 829e414f18da97d4ae851c2097f7068e6d135479..57a66dcb7d1fe49ddd8319c9cfe6bbdeb3450201 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2001-06-12  Akim Demaille  <akim@epita.fr>
+
+       * aclibraries: New.
+       * autoscan.in (@kinds): Add `libraries'.
+       Use `@kinds' instead of hard coded lists.
+       (%programs, %headers, %identifiers, %makevars, %libraries, %functions):
+       Remove, replaced by...
+       (%used): this.
+
 2001-06-12  Akim Demaille  <akim@epita.fr>
 
        * autoscan.in (%functions_macros %headers_macros)
index 413bf70d7a69037efe5c1f28efcb85c6d200ad76..13a3d60a7988b81e42ec1a4c948e6277535c56a6 100644 (file)
@@ -41,7 +41,7 @@ m4sources =  m4sugar.m4 m4sh.m4  \
              acfunctions.m4 acheaders.m4 actypes.m4
 
 distpkgdataDATA = acfunctions acheaders acidentifiers acmakevars acprograms \
-                  $(m4sources)
+                  aclibraries $(m4sources)
 
 nodistpkgdataDATA = autoconf.m4f
 
index 1f9b78f9e922c4aa427724a679b141a76cab6c7b..404ef84f2c55bfc18706ee483b2a50a6339bbe69 100644 (file)
@@ -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 @@ EXTRA_SCRIPTS = autoscan autoupdate
 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
diff --git a/aclibraries b/aclibraries
new file mode 100644 (file)
index 0000000..251d763
--- /dev/null
@@ -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 7a00dc03c797239ea9c427edf07fea7ae347dd01..324b55a1d032ae6ca6e6e03e0fec94ea1fad7454 100644 (file)
@@ -26,20 +26,22 @@ use Getopt::Long;
 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 =
@@ -48,6 +50,7 @@ my %generic_macro =
    'headers'     => 'AC_CHECK_HEADERS',
    'identifiers' => 'AC_CHECK_TYPES',
    'programs'    => 'AC_CHECK_PROGS'
+   'libraries'   => 'AC_CHECK_LIB'
   );
 
 
@@ -184,12 +187,12 @@ sub init_tables ()
   # 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 +269,7 @@ sub scan_files ()
 
   foreach $file (@cfiles)
     {
-      push (@{$programs{"cc"}}, $file);
+      push (@{$used{'programs'}{"cc"}}, $file);
       scan_c_file ($file);
     }
 
@@ -286,14 +289,12 @@ sub scan_files ()
       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 +331,7 @@ sub scan_c_file ($)
       # 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 +344,12 @@ sub scan_c_file ($)
       # 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 +375,17 @@ sub scan_makefile ($)
       # 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 +409,7 @@ sub scan_sh_file ($)
       # 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 +439,13 @@ sub print_unique ($@)
 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 +455,7 @@ sub output_programs ()
 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 +470,7 @@ sub output_headers ()
   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 +478,12 @@ sub output_headers ()
            {
              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 +499,7 @@ sub output_identifiers ()
   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 +507,12 @@ sub output_identifiers ()
            {
              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 +528,7 @@ sub output_functions ()
   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 +536,12 @@ sub output_functions ()
            {
              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}});
            }
        }
     }
index 7a00dc03c797239ea9c427edf07fea7ae347dd01..324b55a1d032ae6ca6e6e03e0fec94ea1fad7454 100644 (file)
@@ -26,20 +26,22 @@ use Getopt::Long;
 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 =
@@ -48,6 +50,7 @@ my %generic_macro =
    'headers'     => 'AC_CHECK_HEADERS',
    'identifiers' => 'AC_CHECK_TYPES',
    'programs'    => 'AC_CHECK_PROGS'
+   'libraries'   => 'AC_CHECK_LIB'
   );
 
 
@@ -184,12 +187,12 @@ sub init_tables ()
   # 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 +269,7 @@ sub scan_files ()
 
   foreach $file (@cfiles)
     {
-      push (@{$programs{"cc"}}, $file);
+      push (@{$used{'programs'}{"cc"}}, $file);
       scan_c_file ($file);
     }
 
@@ -286,14 +289,12 @@ sub scan_files ()
       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 +331,7 @@ sub scan_c_file ($)
       # 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 +344,12 @@ sub scan_c_file ($)
       # 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 +375,17 @@ sub scan_makefile ($)
       # 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 +409,7 @@ sub scan_sh_file ($)
       # 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 +439,13 @@ sub print_unique ($@)
 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 +455,7 @@ sub output_programs ()
 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 +470,7 @@ sub output_headers ()
   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 +478,12 @@ sub output_headers ()
            {
              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 +499,7 @@ sub output_identifiers ()
   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 +507,12 @@ sub output_identifiers ()
            {
              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 +528,7 @@ sub output_functions ()
   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 +536,12 @@ sub output_functions ()
            {
              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}});
            }
        }
     }
diff --git a/lib/autoscan/libraries b/lib/autoscan/libraries
new file mode 100644 (file)
index 0000000..251d763
--- /dev/null
@@ -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: