| 1 |
root |
1.1 |
#! /perl |
| 2 |
|
|
|
| 3 |
|
|
use Config; |
| 4 |
|
|
use ExtUtils::Embed; |
| 5 |
root |
1.3 |
|
| 6 |
|
|
my $glib_cflags = qx<glib-config --cflags>; |
| 7 |
|
|
my $glib_libs = qx<glib-config --libs>; |
| 8 |
|
|
|
| 9 |
|
|
s/[\r\n]//g for ($glib_cflags, $glib_libs); |
| 10 |
root |
1.2 |
|
| 11 |
|
|
%mime = ( |
| 12 |
|
|
"application/x-mperl:mperl:Embedded Perl" => "Mozilla::Plugin::Plain", |
| 13 |
|
|
"application/x-mperl-gtk:gmperl:Embedded Perl (gtk+)" => "Mozilla::Plugin::Gtk", |
| 14 |
|
|
"application/x-mperl-tk:tmperl:Embedded Perl (Tk)" => "Mozilla::Plugin::Tk", |
| 15 |
|
|
"application/x-mperl-event:emperl:Embedded Perl (Event)" => "Mozilla::Plugin::Event", |
| 16 |
|
|
); |
| 17 |
root |
1.1 |
|
| 18 |
|
|
my $ldopts = ldopts (0); |
| 19 |
|
|
my $ccopts = ccopts; |
| 20 |
|
|
|
| 21 |
|
|
$cc = $Config{cc}; |
| 22 |
|
|
$ld = $Config{ld}; |
| 23 |
|
|
$inc = "-ISDK/Include -ISDK/Common -I."; |
| 24 |
|
|
|
| 25 |
|
|
sub str($) { |
| 26 |
|
|
local $_ = shift; |
| 27 |
|
|
s/\\/\\\\/g; |
| 28 |
|
|
s/"/\\"/g; |
| 29 |
|
|
s/\r?\n/\\n\" \\\n\"/g; |
| 30 |
|
|
"\"$_\""; |
| 31 |
|
|
} |
| 32 |
|
|
|
| 33 |
|
|
$name = "Embedded Mozilla Perl Interpreter"; |
| 34 |
root |
1.2 |
$mime = join ";", keys %mime; |
| 35 |
root |
1.1 |
$desc = <<EOF; |
| 36 |
|
|
|
| 37 |
|
|
<table bgcolor="white" border="0"><tr><td><font color="black"> <h3><a |
| 38 |
|
|
href="http://mozperl.plan9.de/">Mozilla Perl Interface</a></h3><p>This |
| 39 |
|
|
plug-in allows you to execute <a href="http://www.perl.org/">perl |
| 40 |
|
|
programs</a> embedded in html pages and other nifty things. Perl is a |
| 41 |
|
|
portable (even more so than java ;) programming language used since |
| 42 |
|
|
many years on the internet. For more information on perl, visit the <a |
| 43 |
|
|
href="http://www.perl.org/">www.perl.org</a> Website. For more information |
| 44 |
|
|
on Mozilla-Perl, visit the <a href="http://mozperl.plan9.de/">Mozilla-Perl |
| 45 |
|
|
homepage (<tt>mozperl.plan9.de</tt>)</a>.</p> </font></td></tr></table> |
| 46 |
|
|
|
| 47 |
|
|
EOF |
| 48 |
|
|
|
| 49 |
|
|
%def = ( |
| 50 |
|
|
OSNAME => str$Config{osname}, |
| 51 |
|
|
OSVERS => str$Config{osvers}, |
| 52 |
|
|
PLUGIN_NAME => str$name, |
| 53 |
|
|
PLUGIN_DESC => str$desc, |
| 54 |
|
|
MIMETYPES => str$mime, |
| 55 |
|
|
PERLPATH => str$Config{perlpath}, |
| 56 |
|
|
PATHSEP => str"/", |
| 57 |
root |
1.3 |
); |
| 58 |
root |
1.1 |
|
| 59 |
root |
1.3 |
$def{HAVE_GLIB} = 1 if $glib_libs ne $glib_cflags; |
| 60 |
root |
1.1 |
|
| 61 |
|
|
if ($^O eq "Win32") { |
| 62 |
|
|
$def{IFACE} = '"npwin.cpp"'; |
| 63 |
root |
1.3 |
delete $def{HAVE_ATHENA}; |
| 64 |
root |
1.1 |
die; |
| 65 |
|
|
} else { |
| 66 |
root |
1.3 |
$def{IFACE} = str"npunix.c", |
| 67 |
|
|
|
| 68 |
|
|
$def{HAVE_ATHENA} = 1; |
| 69 |
|
|
$x_libs = "-L/usr/X11/lib -L/usr/X11R6/lib -lX11 -lXt"; |
| 70 |
|
|
$inc .= " -I/usr/X11/include -I/usr/X11R6/include"; |
| 71 |
|
|
|
| 72 |
|
|
if ($^O eq "aix") { |
| 73 |
|
|
die; |
| 74 |
|
|
} elsif ($^O eq "hpux") { |
| 75 |
|
|
die; |
| 76 |
|
|
} elsif ($^O eq "linux") { |
| 77 |
|
|
# ... |
| 78 |
|
|
} else { |
| 79 |
|
|
die "unsupported operating system $^O\n"; |
| 80 |
|
|
} |
| 81 |
root |
1.1 |
} |
| 82 |
|
|
|
| 83 |
root |
1.3 |
print "Writing ns4/interp.h\n"; |
| 84 |
root |
1.2 |
|
| 85 |
|
|
open INTERP, ">interp.h" or die "interp.h: $!"; |
| 86 |
|
|
print INTERP "static interp perl_interp[] = {\n"; |
| 87 |
|
|
while (my ($mime, $module) = each %mime) { |
| 88 |
|
|
my ($mime, $suffix, $desc) = split /:/, $mime; |
| 89 |
|
|
printf INTERP " { %s, %s, %s, %s },\n", map str$_, $mime, $suffix, $desc, $module; |
| 90 |
|
|
|
| 91 |
|
|
} |
| 92 |
|
|
print INTERP " { 0 }\n};\n"; |
| 93 |
|
|
close INTERP; |
| 94 |
|
|
|
| 95 |
root |
1.3 |
print "Writing ns4/config.h\n"; |
| 96 |
root |
1.1 |
|
| 97 |
|
|
open CONFIG, ">config.h" or die "config.h: $!"; |
| 98 |
|
|
while (my ($k, $v) = each %def) { |
| 99 |
|
|
print CONFIG "#define $k $v\n"; |
| 100 |
|
|
} |
| 101 |
root |
1.2 |
close CONFIG; |
| 102 |
root |
1.1 |
|
| 103 |
root |
1.3 |
print "Writing ns4/Makefile\n"; |
| 104 |
root |
1.1 |
|
| 105 |
|
|
open MAKEFILE, ">Makefile" or die "Makefile: $!"; |
| 106 |
|
|
print MAKEFILE <<EOF; |
| 107 |
|
|
|
| 108 |
|
|
OBJ = $Config{obj_ext} |
| 109 |
|
|
DLEXT = $Config{dlext} |
| 110 |
root |
1.3 |
CC = $cc $ccopts $glib_cflags $inc $def $Config{optimize} |
| 111 |
root |
1.1 |
LD = $ld |
| 112 |
root |
1.3 |
LIBS = $ldopts $glib_libs $x_libs |
| 113 |
root |
1.4 |
PERL = $Config{perlpath} |
| 114 |
root |
1.1 |
|
| 115 |
|
|
OBJ_LIB = np_perl\$(OBJ) |
| 116 |
|
|
|
| 117 |
|
|
all :: np_perl.\$(DLEXT) |
| 118 |
|
|
|
| 119 |
|
|
np_perl\$(OBJ): np_perl.c config.h |
| 120 |
|
|
\$(CC) $Config{cccdlflags} -c \$< |
| 121 |
|
|
|
| 122 |
|
|
np_perl.\$(DLEXT) : \$(OBJ_LIB) |
| 123 |
root |
1.3 |
\$(LD) $Config{lddlflags} -o \$@ \$(OBJ_LIB) \$(LIBS) |
| 124 |
root |
1.1 |
|
| 125 |
root |
1.4 |
genconst: genconst.c.PL |
| 126 |
|
|
\$(PERL) genconst.c.PL |
| 127 |
root |
1.5 |
\$(CC) -o genconst genconst.c |
| 128 |
root |
1.4 |
|
| 129 |
root |
1.5 |
apiconst.pl: genconst |
| 130 |
|
|
./genconst >apiconst.pl |
| 131 |
root |
1.4 |
|
| 132 |
root |
1.1 |
clean :: |
| 133 |
root |
1.4 |
rm -f genconst\$(OBJ) genconst\$(EXE) np_perl.\$(DLEXT) \$(OBJ_LIB) config.h Makefile |
| 134 |
root |
1.1 |
|
| 135 |
|
|
EOF |
| 136 |
|
|
|
| 137 |
|
|
|
| 138 |
|
|
|