diff --git a/ts/GNUmakefile b/ts/GNUmakefile new file mode 100644 index 0000000..c84daf8 --- /dev/null +++ b/ts/GNUmakefile @@ -0,0 +1,30 @@ +include GNUmakevars + +CONFDIR=../../configure +CONFDIR_exists=$(shell [ -d $(CONFDIR) ] && echo ok) + +all: configure ts + +clean: + rm ts + +install: \ + $(BINDIR)/ts \ + +ts: ts.pl + +%: %.pl customize + sh ./customize < $< > $@ + chmod +x $@ + +customize: configure + sh ./configure + +ifeq ($(CONFDIR_exists),ok) + +configure: $(CONFDIR)/start $(CONFDIR)/perl $(CONFDIR)/finish + cat $^ > $@ + +endif + +include GNUmakerules diff --git a/ts/configure b/ts/configure new file mode 100644 index 0000000..9279c24 --- /dev/null +++ b/ts/configure @@ -0,0 +1,34 @@ +#!/bin/sh +# +echo "#!/bin/sh" > customize.$$ +echo "sed \\" > customize.$$ +chmod +x customize.$$ + +################################################################ +# find a working perl: +# +for i in /usr/bin/perl /usr/local/bin/perl /usr/bin/perl5 /usr/local/bin/perl5 +do + if $i -e 'exit ($] < 5.000)' + then + echo $i works + perl="$i" + break + fi +done +if [ -z "$perl" ] +then + echo could not find a working perl command, sorry. + exit 1 +fi +echo " -e 's,@@@perl@@@,$perl,g' \\" >> customize.$$ + + +################################################################ +# finish +# Add trailing newline and rename temp file to final name +# +echo >> customize.$$ + +mv customize.$$ customize + diff --git a/ts/ts.pl b/ts/ts.pl index 1a55fa9..0039843 100644 --- a/ts/ts.pl +++ b/ts/ts.pl @@ -1,8 +1,8 @@ -#!/usr/bin/perl -wT +#!@@@perl@@@ -wT use strict; use POSIX; while (<>) { chomp; - $now = strftime('%Y-%m-%dT%H:%M:%S', localtime); + my $now = strftime('%Y-%m-%dT%H:%M:%S', localtime); print "$now $_\n"; }