source: gs2-extensions/pdf-box/trunk/java/pdf-box-setup.pl@ 23703

Last change on this file since 23703 was 23703, checked in by ak19, 13 years ago

setup.pl file added so that gliserver.pl can call it to set up the environment for PDFbox the way setup.bash does.

File size: 1.4 KB
Line 
1
2BEGIN {
3 die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
4 die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
5 unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
6 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan");
7}
8
9use Cwd;
10require util;
11
12my $env_ext = "GEXT_PDFBOX";
13my $ext_desc = "the PDFBox Extension";
14
15if (!defined $ENV{$env_ext}) {
16
17 my $ext_home = cwd();
18 $ENV{$env_ext} = $ext_home;
19
20 my $ext_bin_script = &util::filename_cat($ENV{$env_ext},"bin","script");
21 my $ext_lib = &util::filename_cat($ENV{$env_ext},"lib");
22
23 if (-d $ext_bin_script) {
24 &util::envvar_prepend("PATH",$ext_bin_script);
25 }
26
27 if (-d $ext_lib) {
28 if ($ENV{'GSDLOS'} =~ m/darwin/i) {
29 &util::envvar_prepend("DYLD_LIBRARY_PATH",$ext_lib);
30 }
31 else {
32 &util::envvar_prepend("LD_LIBRARY_PATH",$ext_lib);
33 }
34 }
35
36 my ($ext_dir,$_prefix_dir) = File::Basename::fileparse($ext_home);
37 # GSDLEXTS always uses : as a separator
38 if (defined $ENV{'GSDLEXTS'}) {
39 $ENV{'GSDLEXTS'} .= ":$ext_dir";
40 }
41 else {
42 $ENV{'GSDLEXTS'} = $ext_dir;
43 }
44
45 print STDERR "+Your environment is now setup for $ext_desc\n";
46}
47else {
48 print STDERR "+Your environment is already setup for $ext_desc\n";
49}
50
51if (scalar(@ARGV>0)) {
52
53 print STDERR "\n";
54
55 my $cmd = join(" ",map {$_ = "\"$_\""} @ARGV);
56
57 if (system($cmd)!=0) {
58 print STDERR "\nError: Failed to run '$cmd'\n";
59 print STDERR "$!\n";
60 }
61}
62
631;
Note: See TracBrowser for help on using the repository browser.