blob: cd6b09360fcebc15686a12ec0876c63ba7728de2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#!/usr/bin/perl
$JPL_HOME = $ENV{JPL_HOME}
or die "You have not run setvars to set your environment variables.\n" .
"See the JPL README file for more information.\n";
use Config;
eval `$JPL_HOME/setvars -perl`;
chop($WHAT = `pwd`);
$WHAT =~ s#.*/##;
if ($^O eq 'linux') {
$flags = "-Dbool=char"; # avoid builtin bool altogether
$libs = "-lc -lm -ldl";
} else {
$flags = "";
$libs = "-lc -lm -ldl";
}
# Needed for JNI
if ($^O eq 'solaris') {
$libs .= " -lthread";
}
chop($cwd = `pwd`);
($jpldir = $cwd) =~ s#/[^/]*$##;
open(MAKEFILE, ">Makefile");
print MAKEFILE <<"SUBS";
CC = $Config{cc}
WHAT = $WHAT
PERL = perl$]
ARCHNAME = $Config{archname}
JAVA_HOME = $ENV{JAVA_HOME}
JPL_HOME = $ENV{JPL_HOME}
PERLARCHDIR = $Config{archlib}
FLAGS = $Config{cccdlflags} $Config{ccdlflags} $Config{lddlflags} $flags
INCL = -I\$(PERLARCHDIR)/CORE \\
-I\$(JAVA_HOME)/include \\
-I\$(JAVA_HOME)/include/$^O \\
-I\$(JAVA_HOME)/include/genunix
LIBS = $libs
SUBS
print MAKEFILE <<'NOSUBS';
.SUFFIXES: .jpl .class
.jpl.class:
$(PERL) -MJPL::Compile -e "file('$*.jpl')"
all: $(WHAT).class lib$(WHAT).so
debug: $(WHAT)_g.class lib$(WHAT)_g.so
lib$(WHAT).so: $(WHAT).c $(JPL_HOME)/lib/$(ARCHNAME)/libPerlInterpreter.so
$(CC) $(FLAGS) $(INCL) $(WHAT).c \
$(PERLARCHDIR)/CORE/libperl.so \
$(JPL_HOME)/lib/$(ARCHNAME)/libPerlInterpreter.so \
$(LIBS) \
-o lib$(WHAT).so
lib$(WHAT)_g.so: $(WHAT).c $(JPL_HOME)/lib/$(ARCHNAME)/libPerlInterpreter_g.so
$(CC) -g $(FLAGS) $(INCL) $(WHAT).c \
$(PERLARCHDIR)/CORE/libperl.so \
$(JPL_HOME)/lib/$(ARCHNAME)/libPerlInterpreter_g.so \
$(LIBS) \
-o lib$(WHAT)_g.so
test: all
java $(WHAT)
install: all
cp *.class $(JPL_HOME)/lib
cp lib$(WHAT).so $(JPL_HOME)/lib/$(ARCHNAME)
cp $(WHAT).pl $(JPL_HOME)/perl
clean:
rm -f $(WHAT).c $(WHAT).h \
$(WHAT)*.class $(WHAT)*.pl lib$(WHAT).so $(WHAT)*.java
distclean: clean
rm -f Makefile
NOSUBS
close MAKEFILE;
|