This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Continue what #4494 started; introduce uid and gid formats.
[perl5.git] / jpl / install-jpl
CommitLineData
d50cb536
GS
1#!/usr/bin/perl
2
3print <<'END' if $>;
4NOTE: Since you're not running as root, the installation will su at
5the appropriate time later. You will need to supply the root password
6for the su program.
7
8END
9
10# Gather data.
11
12# JPL_SRC
13
14chop($JPL_SRC = `pwd`);
15print "JPL_SRC = $JPL_SRC\n";
16
17# JAVA_HOME
18
19foreach $dir (
20 $ENV{JAVA_HOME},
21 "/usr/java",
22 "/usr/local/java",
23 "/usr/lib/java",
24 "/usr/local/lib/java",
25) {
26 $JAVA_HOME = $dir, last if $dir and -d "$dir/bin";
27}
28die "You must set the \$JAVA_HOME environment variable first.\n"
29 unless $JAVA_HOME;
30print "JAVA_HOME = $JAVA_HOME\n";
31
32# JPL_HOME
33
34($likelyjpl = $JAVA_HOME) =~ s#(.*)/.*#$1/jpl#;
35
36print <<"END";
37
38You need to decide which directory JPL files are to be installed in.
39Applications will look in subdirectories of this directory for any JPL
40related files.
41
42You may use the current directory ($JPL_SRC)
43or you may use a directory such as $likelyjpl.
44
45END
46
47$| = 1;
48until (-d $JPL_HOME) {
49 print "Install JPL files where: [$JPL_SRC] ";
50 chop($JPL_HOME = <STDIN>);
51 $JPL_HOME ||= $JPL_SRC;
52 unless (-d $JPL_HOME) {
53 print "Warning: $JPL_HOME doesn't exist yet!\n\n";
54 print "Do you want to create it? [y] ";
55 chop($ans = <STDIN>);
56 $ans ||= 'y';
57 next unless $ans =~ /^y/i;
58
59 system "mkdir -p $JPL_HOME";
60 if ($> and not -d $JPL_HOME) {
61 warn "Couldn't create $JPL_HOME!\nTrying again as root...running su...\n";
62 system "set -x
63su root -c 'mkdir -p $JPL_HOME && chown $> $JPL_HOME && chmod 0755 $JPL_HOME'";
64 warn "Couldn't create $JPL_HOME!\n" unless -d $JPL_HOME;
65 }
66 }
67}
68print "JPL_HOME = $JPL_HOME\n";
69
70#########################################################################
71# Spit out setvars.
72
73print "Writing setvars...\n";
74
75unlink "$JPL_SRC/setvars";
76open(SETVARS, ">$JPL_HOME/setvars") or die "Can't create setvars: $!\n";
77while (<DATA>) {
78 s/^JPL_SRC=.*/JPL_SRC='$JPL_SRC'/;
79 s/^JAVA_HOME=.*/JAVA_HOME='$JAVA_HOME'/;
80 s/^JPL_HOME=.*/JPL_HOME='$JPL_HOME'/;
81 print SETVARS $_;
82}
83close SETVARS;
84chmod 0755, "$JPL_HOME/setvars";
85symlink "$JPL_HOME/setvars", "$JPL_SRC/setvars" if $JPL_HOME ne $JPL_SRC;
86
87#########################################################################
88# Pretend we're make.
89
90eval `./setvars -perl`; # Take our own medicine.
91
92print "\n\nStarting install...\n";
93
94system <<'END' and die "Couldn't install JPL\n";
95set -x
96cd JPL
97perl Makefile.PL
98make clean
99perl Makefile.PL
100make install
101END
102
103print "\nInstalling PerlInterpreter class\n";
104
105system <<'END' and die "Couldn't install PerlInterpreter\n";
106set -x
107cd PerlInterpreter
108perl Makefile.PL
109make clean
110perl Makefile.PL
111make install
112END
113
114print "\nInstalling JNI module\n";
115
116system <<'END' and die "Couldn't install JNI\n";
117set -x
118cd JNI
b83c0eaa 119perl Makefile.PL -e
d50cb536 120make clean
b83c0eaa 121perl Makefile.PL -e
d50cb536
GS
122make
123echo 'Attempting to install JNI as root'
124su root -c "make install"
125END
126
127#touch Makefile
128#make -f makefile.jv
129## These should be executed as root
130#rm -rf /usr/lib/perl5/site_perl/i586-linux/auto/JNI
131#rm -rf /usr/lib/perl5/site_perl/auto/JNI
132#rm -f /usr/lib/perl5/site_perl/JNI.pm
133#make -f makefile.jv install UNINST=1
134
135print "\nInstalling Sample JPL program\n";
136
137system <<'END' and die "Couldn't install Sample\n";
138set -x
139cd Sample
140perl Makefile.PL
141make clean
142perl Makefile.PL
143make install
144END
145
146# Test
147print "\n\nTesting Sample...\n";
148system <<'END' and die "Couldn't run Sample\n";
149set -x
150cd Sample
151JPLDEBUG=1
152export JPLDEBUG
153java Sample
154END
155
156__END__
157#!/bin/sh
158
159# You can edit this, but your changes will only last until the next
160# time you run install-jpl.
161
162# Where jpl is currently installed
163
164cd `dirname $0`
165JPL_SRC=`pwd`
166
167# Where java is installed
168
169JAVA_HOME=/usr/local/java
170export JAVA_HOME
171
172# Where jpl will be installed
173
174JPL_HOME="$JPL_SRC"
175export JPL_HOME
176
177# Which perl to run
178
179JPLPERL=perl`perl -e "print $]"`
180#JPLPERL=perl5.00404
181export JPLPERL
182
183# Some derivative variables
184archname=`$JPLPERL -MConfig -e 'print $Config{archname}'`
185 archlib=`$JPLPERL -MConfig -e 'print $Config{archlib}'`
186
187CLASSPATH=".:$JPL_HOME/lib${CLASSPATH:+:$CLASSPATH}"
188export CLASSPATH
189
b83c0eaa
GS
190LD_LIBRARY_PATH=".:$JPL_HOME/lib/$archname:$archlib/CORE${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
191export LD_LIBRARY_PATH
d50cb536
GS
192
193PERL5LIB="$JPL_HOME/perl${PERL5LIB:+:$PERL5LIB}"
194export PERL5LIB
195
196# Make sure the right java programs are selected.
197PATH="$JAVA_HOME/bin:$PATH"
198export PATH
199
200case "$1" in
201-perl)
202 cat <<END
203\$ENV{PATH} = '$PATH';
204\$ENV{JAVA_HOME} = '$JAVA_HOME';
205\$ENV{JPL_HOME} = '$JPL_HOME';
206\$ENV{JPLPERL} = '$JPLPERL';
207\$ENV{CLASSPATH} = '$CLASSPATH';
b83c0eaa 208\$ENV{LD_LIBRARY_PATH} = '$LD_LIBRARY_PATH';
d50cb536
GS
209\$ENV{PERL5LIB} = '$PERL5LIB';
210END
211 ;;
212-sh)
213 cat <<END
b83c0eaa 214 PATH='$PATH';export PATH;JAVA_HOME='$JAVA_HOME';export JAVA_HOME;JPL_HOME='$JPL_HOME';export JPL_HOME;JPLPERL='$JPLPERL';export JPLPERL;CLASSPATH='$CLASSPATH';export CLASSPATH;LD_LIBRARY_PATH='$LD_LIBRARY_PATH';export LD_LIBRARY_PATH;PERL5LIB='$PERL5LIB';export PERL5LIB
d50cb536
GS
215END
216 ;;
217-csh)
218 cat <<END
219setenv PATH '$PATH';
220setenv JAVA_HOME '$JAVA_HOME';
221setenv JPL_HOME '$JPL_HOME';
222setenv JPLPERL '$JPLPERL';
223setenv CLASSPATH '$CLASSPATH';
b83c0eaa 224setenv LD_LIBRARY_PATH '$LD_LIBRARY_PATH';
d50cb536
GS
225setenv PERL5LIB '$PERL5LIB';
226END
227 ;;
228esac
229