From 90cfb3a46862fa7c720e287c9b9418438e5840e9 Mon Sep 17 00:00:00 2001 From: hjp Date: Fri, 9 Feb 2007 15:36:37 +0000 Subject: [PATCH] Automatically create GNUmakerules and GNUmakevars if they don't exist. Print usage if unknown option is given. --- agestat/GNUmakefile | 6 ++++++ agestat/GNUmakerules.sh | 5 +++++ agestat/GNUmakevars.sh | 15 +++++++++++++++ agestat/agestat.pl | 18 +++++++++++++----- 4 files changed, 39 insertions(+), 5 deletions(-) create mode 100755 agestat/GNUmakerules.sh create mode 100755 agestat/GNUmakevars.sh diff --git a/agestat/GNUmakefile b/agestat/GNUmakefile index 7012132..5846100 100644 --- a/agestat/GNUmakefile +++ b/agestat/GNUmakefile @@ -23,4 +23,10 @@ customize: configure $(BINDIR): mkdir -p $@ +GNUmakevars: GNUmakevars.sh + sh ./$^ > $@ +GNUmakerules: GNUmakerules.sh + sh ./$^ > $@ + + include GNUmakerules diff --git a/agestat/GNUmakerules.sh b/agestat/GNUmakerules.sh new file mode 100755 index 0000000..952629f --- /dev/null +++ b/agestat/GNUmakerules.sh @@ -0,0 +1,5 @@ +#!/bin/sh +echo "\$(BINDIR)/%: %" +echo -e "\tcp \$^ \$@" +echo "\$(MAN1DIR)/%: %" +echo -e "\tcp \$^ \$@" diff --git a/agestat/GNUmakevars.sh b/agestat/GNUmakevars.sh new file mode 100755 index 0000000..1443f83 --- /dev/null +++ b/agestat/GNUmakevars.sh @@ -0,0 +1,15 @@ +#!/bin/sh +prefix=${prefix:-/usr/local} +echo "BINDIR=$prefix/bin" + +for i in "$prefix/share/man/man1" "$prefix/man/man1" +do + if [ -d "$i" -a -w "$i" ] + then + echo "MAN1DIR=$i" + break; + fi +done + +echo +echo "all:" diff --git a/agestat/agestat.pl b/agestat/agestat.pl index 8e70b2b..f240fb8 100755 --- a/agestat/agestat.pl +++ b/agestat/agestat.pl @@ -1,6 +1,6 @@ #!@@@perl@@@ -w # -# $Id: agestat.pl,v 1.7 2006-02-17 13:50:23 hjp Exp $ +# $Id: agestat.pl,v 1.8 2007-02-09 15:36:37 hjp Exp $ # use strict; @@ -8,11 +8,16 @@ use File::stat; use File::Find; use Getopt::Long; +sub usage { + print STDERR "Usage: $0 [-atime|-mtime] [-scale=(k|M)]\n"; + exit 1; +} + my $now = time(); my @bucket_max; my %opts = (buckets => 'log2'); -GetOptions(\%opts, "atime", "mtime", "scale=s", "buckets=s"); +GetOptions(\%opts, "atime", "mtime", "scale=s", "buckets=s") or usage(); my $scale; if (!defined($opts{scale})) { $scale = 1; @@ -21,8 +26,7 @@ if (!defined($opts{scale})) { } elsif ($opts{scale} eq 'M') { $scale = 1024*1024; } else { - print STDERR "Usage: $0 [-atime|-mtime] [-scale=(k|M)]\n"; - exit 1; + usage(); } if ($opts{buckets} eq "log2") { @@ -102,7 +106,11 @@ for (my $i = 0; $i <= $#hist; $i++) { } # $Log: agestat.pl,v $ -# Revision 1.7 2006-02-17 13:50:23 hjp +# Revision 1.8 2007-02-09 15:36:37 hjp +# Automatically create GNUmakerules and GNUmakevars if they don't exist. +# Print usage if unknown option is given. +# +# Revision 1.7 2006/02/17 13:50:23 hjp # Fixed error when oldest file was older than oldest bucket. # Realigned columns. #