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