#!/usr/bin/perl ### libwhisker make file to build library from development subpackages eval "use Config;"; if(!$@){ $HAVE_CONFIG=1; } eval "use Cwd;"; if(!$@){ $HAVE_CWD=1; } $|++; $VERSION = '1.7'; $LIB = 'LW.pm'; $COMPONENTS = 'libs'; $PRELIB = 'prelib.wpl'; $GLOBALS = 'globals.wpl'; #### end config ###################################################### %build=(); $CWD=''; if($ARGV[0] eq ''){ print <', ' 'x(20-length($lib)); eval "use $lib"; if(!$@){ print "yes (version "; print eval '$'.$lib.'::VERSION', ")\n"; } else { print "no\n"; } } print "\n"; next; } if($COMM eq 'clean'){ unlink $LIB; print "Clean.\n"; next; } if($COMM eq 'uninstall'){ die("Can not uninstall without Config.pm") if(!$HAVE_CONFIG); $CWD=&cwd if($HAVE_CWD); my $where=$Config{'installsitelib'}; chdir($where); if(-e $LIB){ unlink $LIB; print STDOUT "libwhisker uninstalled.\n"; } else { print STDOUT "libwhisker not installed.\n"; } exit if(!$HAVE_CWD); chdir($CWD); next; } if($COMM eq 'nopod'){ $NOPOD=1; if(!(-e $LIB)){ $ARGV[0]='lib'; $BUILDEXIT=0; } } if($COMM eq 'install'){ $INSTALL=1; if(!(-e $LIB)){ $ARGV[0]='lib'; $BUILDEXIT=0; } } if($COMM eq 'liblite'){ $CWD=&cwd if($HAVE_CWD); open(OUT,">$LIB"); print OUT "# libwhisker v$VERSION-lite\n"; chdir($COMPONENTS); open(IN,"<$PRELIB") || puke($PRELIB); while(){ print OUT; } close(IN); print OUT "\$LW::VERSION=\"$VERSION-lite\";\n"; open(IN,"<$GLOBALS") || puke($GLOBALS); while(){ print OUT; } close(IN); open(IN,'){ print OUT if(!m/^#GPL/); } close(IN); print OUT "1;\n"; print STDOUT "libwhisker-lite built.\n"; close(OUT); exit if(!$HAVE_CWD); chdir($CWD); next; } if($COMM eq 'lib' || $COMM eq 'selfload'){ $CWD=&cwd if($HAVE_CWD); open(OUT,">$LIB"); print OUT "# libwhisker v$VERSION\n"; opendir(DIR,$COMPONENTS); chdir($COMPONENTS); open(IN,"<$PRELIB") || puke($PRELIB); while(){ print OUT; } close(IN); print OUT "\$LW::VERSION=\"$VERSION\";\n"; if($COMM eq 'selfload'){ print OUT "use SelfLoader;\n";} open(IN,"<$GLOBALS") || puke($GLOBALS); while(){ print OUT; } close(IN); if($COMM eq 'selfload'){ print OUT "1;\n__DATA__\n";} &readlibs; print OUT "1;\n"; print STDOUT "libwhisker built.\n"; close(OUT); closedir(DIR); exit if(!$HAVE_CWD); chdir($CWD); next if $BUILDEXIT; } if($NOPOD){ open(OUT,">$LIB.nopod"); open(IN,"<$LIB"); &strip_pod; close(OUT); close(IN); unlink $LIB; rename "$LIB.nopod",$LIB; print STDOUT "POD removed.\n"; next; } if($INSTALL){ die("Can not install without Config.pm") if(!$HAVE_CONFIG); $CWD=&cwd if($HAVE_CWD); my $where=$Config{'installsitelib'}; open(IN,"<$LIB"); chdir($where); open(OUT,">$LIB"); while(){ print OUT; } close(IN); close(OUT); if(-s "$LIB"){ print STDOUT "libwhisker installed to $where\n"; } else { print STDOUT "Error installing libwhisker\n"; } exit if(!$HAVE_CWD); chdir($CWD); } } # while($COMM) sub puke { my $file = shift; print STDOUT "Build error: missing $file\n"; eval "close(OUT)"; exit; } sub readlibs { my $file; my @FF=(); while($file=readdir(DIR)){ push(@FF,$file); } my @FE = sort @FF; foreach $file (@FE){ next if(defined $build{$file}); if($file=~/(.+)\.dpl$/){ if(!-e "$1.pl"){ $build{$file}++; open(IN,"<$file"); while(){ print OUT if(!m/^#GPL/); } close(IN); } else { $file = $1.pl; } } if($file=~/(.+)\.pl$/){ $build{$file}++; open(IN,"<$file"); while(){ print OUT if(!m/^#GPL/); } close(IN); if(-e "$1.dpl"){ $build{"$1.dpl"}++; open(IN,"<$1.dpl"); while(){ print OUT if(!m/^#GPL/); } close(IN); } } } } sub strip_pod { $inpod=0; $last=''; while(){ $line=$_; next if($line=~/^##############################/); $inpod=1 if($line=~/^=pod/); if(!$inpod){ print OUT $line if(!($line eq "\n" && $last eq "\n")); } $inpod=0 if($line=~/^=cut/); $last = $line; } }