summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2004-01-13 22:24:56 +0000
committerStefan Metzmacher <metze@samba.org>2004-01-13 22:24:56 +0000
commite0469838c8dc55f17f7f5eb3b584ee1f382db5d4 (patch)
tree90811e4ddd5b8c79196af4efd4dd10b8b3b4239f
parent17b5c26819252c01fab506887b0442f081a029f3 (diff)
downloadsamba-e0469838c8dc55f17f7f5eb3b584ee1f382db5d4.tar.gz
samba-e0469838c8dc55f17f7f5eb3b584ee1f382db5d4.tar.bz2
samba-e0469838c8dc55f17f7f5eb3b584ee1f382db5d4.zip
a script which find unused or undefined vars in Makefile or Makefile.in
call it like: script/find_unused_makefilevars.pl Makefile or script/find_unused_makefilevars.pl Makefile.in metze (This used to be commit ebecb6d05b97dc5bac8d9e48f8fad75dfbb44a74)
-rwxr-xr-xsource4/script/find_unused_makefilevars.pl45
1 files changed, 45 insertions, 0 deletions
diff --git a/source4/script/find_unused_makefilevars.pl b/source4/script/find_unused_makefilevars.pl
new file mode 100755
index 0000000000..697ed54f5c
--- /dev/null
+++ b/source4/script/find_unused_makefilevars.pl
@@ -0,0 +1,45 @@
+#!/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
+
+# 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";
+ }
+ }
+}