* 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.
This commit is contained in:
Akim Demaille 2001-06-12 09:33:58 +00:00
parent c306314db9
commit 54a953b733
7 changed files with 142 additions and 77 deletions

View File

@ -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)

View 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

View 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

26
aclibraries Normal file
View File

@ -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:

View 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}});
}
}
}

View 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}});
}
}
}

26
lib/autoscan/libraries Normal file
View File

@ -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: