#!/Perl/bin/Perl.exe require File::Spec; use strict; use File::Basename; use ExtUtils::MakeMaker; use Config; use LWP::Simple qw(getstore $ua is_success); if ($ENV{HTTP_proxy_user} and $ENV{HTTP_proxy_pass} and $ENV{HTTP_proxy} =~ /^http:\/\/([^@]+)$/) { my $proxy ="http://$ENV{HTTP_proxy_user}:$ENV{HTTP_proxy_pass}\@" . $1; print "setting user/pass into proxy_env...\n"; $ua->proxy(['http'], $proxy); } my $lib; my @libs = ('pgplot.dll', 'cpgplot.dll', 'libpng.dll', 'zlib.dll'); for (my $i = 0; $i < 4; $i++) { $lib = $libs[$i]; my ($version, $seq); if($i == 0) { $version = '5.2.2'; $seq = 'first'; } elsif($i == 1) { $version = '5.2.2'; $seq = 'second'; } elsif($i == 2) { $version = '1.0.8'; $seq = 'third'; } else { $version = '1.1.4.0'; $seq = 'fourth'; } my $default = $Config{binexp}; my $recommended = 'yes'; my $insert = "the $seq of four needed dynamic libraries,"; if (my $hit = is_in_path($lib)) { print <<"END"; A copy of $insert $lib was found in $hit. If this is compatible with the version ($version) used to compile the Perl module, all that is needed is to ensure $hit is in your PATH environment variable. END $recommended = 'no'; } if ($recommended eq 'yes') { print <<"END"; Cannot find $insert $lib. $lib should be placed in a directory somewhere in your PATH environment variable. I can fetch and install this for you, if you don\'t already have it. END } my $proceed = prompt("Fetch $lib?", $recommended); suggest_manual("Aborting download of $lib.", 'warn') unless ($proceed =~ /^y/i); my $remote = 'http://theoryx5.uwinnipeg.ca/ppms/scripts/' . $lib; print "Fetching $remote ... "; die "Fetching file failed" unless (is_success(getstore($remote, $lib))); print " done!\n"; suggest_manual("Cannot find $lib", 'fatal') unless -f $lib; my $base = prompt("Where should $lib be placed?", $default); $base =~ s/$lib$//i; $base =~ s!\\!/!g; $base =~ s!/$!!; unless (-d $base) { my $ans = prompt("$base does not exist. Create it?", 'no'); if ($ans =~ /^y/i) { mkdir $base; suggest_manual("Could not create $base: $!", 'fatal') unless (-d $base); } else { suggest_manual("Will not create $base.", 'fatal'); } } if (-f "$base/$lib") { my $ans = prompt("$base/$lib exists. Overwrite?", 'no'); if ($ans =~ /^n/i) { suggest_manual("Will not overwrite $base/$lib.", 'fatal'); } } use File::Copy; move($lib, "$base/$lib"); suggest_manual("Moving $lib to $base failed: $!", 'fatal') unless (-f "$base/$lib"); print "$lib has been successfully installed to $base\n"; sleep(5); } # close for loop ### Install grfont.dat ### { $lib = 'grfont.dat'; my $default = $Config{binexp}; my $recommended = 'yes'; if (my $hit = is_in_path($lib)) { print <<"END"; A copy of $lib was found in $hit. If this is a suitable version of grfont.dat, all that is needed is to ensure that your PGPLOT_FONT environment variable is set to $hit END $recommended = 'no'; } if ($recommended eq 'yes') { print <<"END"; $lib needs to be installed. It can be placed anywhere, but you need to set your PGPLOT_FONT environment variable to the full path and name of $lib. eg if $lib is placed in C:\\datfiles, then the PGPLOT_FONT environment variable needs to be set to: C:\\datfiles\\$lib I can fetch and install $lib for you, if you don\'t already have it. END } my $proceed = prompt("Fetch $lib?", $recommended); suggest_manual("Aborting download of $lib.", 'warn') unless ($proceed =~ /^y/i); my $remote = 'http://theoryx5.uwinnipeg.ca/ppms/scripts/' . $lib; print "Fetching $remote ... "; die "Fetching file failed" unless (is_success(getstore($remote, $lib))); print " done!\n"; suggest_manual("Cannot find $lib", 'fatal') unless -f $lib; my $base = prompt("Where should $lib be placed?", $default); $base =~ s/$lib$//i; $base =~ s!\\!/!g; $base =~ s!/$!!; unless (-d $base) { my $ans = prompt("$base does not exist. Create it?", 'no'); if ($ans =~ /^y/i) { mkdir $base; suggest_manual("Could not create $base: $!", 'fatal') unless (-d $base); } else { suggest_manual("Will not create $base.", 'fatal'); } } if (-f "$base/$lib") { my $ans = prompt("$base/$lib exists. Overwrite?", 'no'); if ($ans =~ /^n/i) { suggest_manual("Will not overwrite $base/$lib.", 'fatal'); } } use File::Copy; move($lib, "$base/$lib"); suggest_manual("Moving $lib to $base failed: $!", 'fatal') unless (-f "$base/$lib"); print "$lib has been successfully installed to $base\n"; sleep(5); } ### Install the (optional) graphics window grwnd.exe ### { $lib = 'grwnd.exe'; my $version = '0.9.9.7'; my $default = $Config{binexp}; my $recommended = 'yes'; if (my $hit = is_in_path($lib)) { print <<"END"; A copy of the optional graphics window $lib was found in $hit. If this is a suitable version of grwnd.exe, all that is needed is to ensure $hit is in your PATH environment variable. END $recommended = 'no'; } if ($recommended eq 'yes') { print <<"END"; If you want to use the (optional) graphics window $lib it needs to be placed in a directory somewhere in your PATH environment variable. I can fetch and install this for you, if you don\'t already have it. END } my $proceed = prompt("Fetch $lib?", $recommended); suggest_manual("Aborting download of $lib.", 'warn') unless ($proceed =~ /^y/i); my $remote = 'http://theoryx5.uwinnipeg.ca/ppms/scripts/' . $lib; print "Fetching $remote ... "; die "Fetching file failed" unless (is_success(getstore($remote, $lib))); print " done!\n"; suggest_manual("Cannot find $lib", 'fatal') unless -f $lib; my $base = prompt("Where should $lib be placed?", $default); $base =~ s/$lib$//i; $base =~ s!\\!/!g; $base =~ s!/$!!; unless (-d $base) { my $ans = prompt("$base does not exist. Create it?", 'no'); if ($ans =~ /^y/i) { mkdir $base; suggest_manual("Could not create $base: $!", 'fatal') unless (-d $base); } else { suggest_manual("Will not create $base.", 'fatal'); } } if (-f "$base/$lib") { my $ans = prompt("$base/$lib exists. Overwrite?", 'no'); if ($ans =~ /^n/i) { suggest_manual("Will not overwrite $base/$lib.", 'fatal'); } } use File::Copy; move($lib, "$base/$lib"); suggest_manual("Moving $lib to $base failed: $!", 'fatal') unless (-f "$base/$lib"); print "$lib has been successfully installed to $base\n"; sleep(5); } print <<"END"; To have the pgplot output written to png files you can set the PGPLOT_DEV environment variable to /PNG. (This often provides better mileage than provided by the grwnd.exe graphics window, which is a little buggy at times.) To have the output written to the graphics window (grwnd.exe) you can set the PGPLOT_DEV environment variable to /GW. The test suite that forms part of the PGPLOT source distribution on CPAN provides useful examples of how to use PGPLOT, as well as a a demonstration of some of its capabilities END sub suggest_manual { my ($msg, $type) = @_; print $msg, "\n"; if($type eq 'fatal') { print "Installation of $lib not completed.\n"; sleep(5); exit(0); } sleep (5); next; } sub is_in_path { my $lib = shift; my $hit; foreach my $p (File::Spec->path) { my $candidate = File::Spec->catfile($p, $lib); if (-f $candidate) { $hit = $candidate; last; } } return $hit; }