* 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>
+
+ * 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)
acfunctions.m4 acheaders.m4 actypes.m4
distpkgdataDATA = acfunctions acheaders acidentifiers acmakevars acprograms \
- $(m4sources)
+ aclibraries $(m4sources)
nodistpkgdataDATA = autoconf.m4f
-# 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
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
--- /dev/null
+# 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:
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 =
'headers' => 'AC_CHECK_HEADERS',
'identifiers' => 'AC_CHECK_TYPES',
'programs' => 'AC_CHECK_PROGS'
+ 'libraries' => 'AC_CHECK_LIB'
);
# 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.
foreach $file (@cfiles)
{
- push (@{$programs{"cc"}}, $file);
+ push (@{$used{'programs'}{"cc"}}, $file);
scan_c_file ($file);
}
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";
}
}
}
# Preprocessor directives.
if (/^\s*\#\s*include\s*<([^>]*)>/)
{
- push (@{$headers{$1}}, "$file:$.");
+ push (@{$used{'headers'}{$1}}, "$file:$.");
}
# Ignore other preprocessor directives.
next if /^\s*\#/;
# 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};
}
}
# 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);
# Tokens in the code.
while (s/\b([a-zA-Z_]\w*)\b/ /)
{
- push (@{$programs{$1}}, "$file:$.");
+ push (@{$used{'programs'}{$1}}, "$file:$.");
}
}
close(MFILE);
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}});
}
}
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";
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})
{
{
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}});
}
}
}
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})
{
{
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}});
}
}
}
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})
{
{
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}});
}
}
}
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 =
'headers' => 'AC_CHECK_HEADERS',
'identifiers' => 'AC_CHECK_TYPES',
'programs' => 'AC_CHECK_PROGS'
+ 'libraries' => 'AC_CHECK_LIB'
);
# 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.
foreach $file (@cfiles)
{
- push (@{$programs{"cc"}}, $file);
+ push (@{$used{'programs'}{"cc"}}, $file);
scan_c_file ($file);
}
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";
}
}
}
# Preprocessor directives.
if (/^\s*\#\s*include\s*<([^>]*)>/)
{
- push (@{$headers{$1}}, "$file:$.");
+ push (@{$used{'headers'}{$1}}, "$file:$.");
}
# Ignore other preprocessor directives.
next if /^\s*\#/;
# 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};
}
}
# 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);
# Tokens in the code.
while (s/\b([a-zA-Z_]\w*)\b/ /)
{
- push (@{$programs{$1}}, "$file:$.");
+ push (@{$used{'programs'}{$1}}, "$file:$.");
}
}
close(MFILE);
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}});
}
}
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";
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})
{
{
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}});
}
}
}
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})
{
{
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}});
}
}
}
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})
{
{
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}});
}
}
}
--- /dev/null
+# 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: