1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
samba-mirror/source4/script/find_unused_makefilevars.pl
Jelmer Vernooij 3022bfef70 r7859: Merge a few scripts to one script that checks for the following unused
(used in configure.in, but their output is never used) autoconf macros:
- AC_DEFINE
- AC_CHECK_FUNC
- AC_CHECK_FUNCS
- AC_CHECK_HEADER
- AC_CHECK_HEADERS
(This used to be commit 897d7b7d39)
2007-10-10 13:18:43 -05:00

47 lines
846 B
Perl
Executable File

#!/usr/bin/perl
# Script that reads in Makefile.in and outputs the names of all
# used but undefined vars and all defined but unused vars
# Copyright Jelmer Vernooij <jelmer@samba.org>
# Arguments:
# 1: Makefile.in
#
my %references;
my %defines;
# First, make a list of defines in configure
$in = shift;
open(IN, $in);
while(<IN>) {
my $line = $_;
while($line =~ /^\b([a-zA-Z0-9_][a-zA-Z0-9_]*)\b[ \t]*=.*/sgm) {
$defines{$1} = 1;
}
while($line =~ /\$\(([a-zA-Z0-9_][a-zA-Z0-9_]*)\)/sgm) {
$references{$1} = 1;
}
}
close IN;
print "##### DEFINED BUT UNUSED: #####\n";
foreach(%defines) {
# print $_." defined\n";
if ($_ != 1) {
if ($references{$_} != 1) {
print $_."\n";
}
}
}
print "##### USED BUT UNDEFINED: #####\n";
foreach(%references) {
if ($_ != 1) {
if ($defines{$_} != 1) {
print $_."\n";
}
}
}