… | |
… | |
12 | our $STATIC = 0; |
12 | our $STATIC = 0; |
13 | our $PACKLIST = 0; |
13 | our $PACKLIST = 0; |
14 | our $IGNORE_ENV = 0; |
14 | our $IGNORE_ENV = 0; |
15 | our $ALLOW_DYNAMIC = 0; |
15 | our $ALLOW_DYNAMIC = 0; |
16 | our $HAVE_DYNAMIC; # maybe useful? |
16 | our $HAVE_DYNAMIC; # maybe useful? |
|
|
17 | our $EXTRA_CFLAGS = ""; |
|
|
18 | our $EXTRA_LDFLAGS = ""; |
|
|
19 | our $EXTRA_LIBS = ""; |
17 | |
20 | |
18 | our $OPTIMISE_SIZE = 0; # optimise for raw file size instead of for compression? |
21 | our $OPTIMISE_SIZE = 0; # optimise for raw file size instead of for compression? |
19 | |
22 | |
20 | our $CACHE; |
23 | our $CACHE; |
21 | our $CACHEVER = 1; # do not change unless you know what you are doing |
24 | our $CACHEVER = 1; # do not change unless you know what you are doing |
… | |
… | |
76 | my $dir = find_incdir $_[1] |
79 | my $dir = find_incdir $_[1] |
77 | or return; |
80 | or return; |
78 | |
81 | |
79 | syswrite $W_TRACER, "-\n$dir\n$_[1]\n"; |
82 | syswrite $W_TRACER, "-\n$dir\n$_[1]\n"; |
80 | |
83 | |
81 | open my $fh, "<:perlio", "$dir/$_[1]" |
84 | open my $fh, "<:raw:perlio", "$dir/$_[1]" |
82 | or warn "ERROR: $dir/$_[1]: $!\n"; |
85 | or warn "ERROR: $dir/$_[1]: $!\n"; |
83 | |
86 | |
84 | $fh |
87 | $fh |
85 | }; |
88 | }; |
86 | |
89 | |
… | |
… | |
162 | my ($variant, $src, $filter) = @_; |
165 | my ($variant, $src, $filter) = @_; |
163 | |
166 | |
164 | if (length $CACHE and 2048 <= length $src and defined $variant) { |
167 | if (length $CACHE and 2048 <= length $src and defined $variant) { |
165 | my $file = "$CACHE/" . Digest::MD5::md5_hex "$CACHEVER\x00$variant\x00$src"; |
168 | my $file = "$CACHE/" . Digest::MD5::md5_hex "$CACHEVER\x00$variant\x00$src"; |
166 | |
169 | |
167 | if (open my $fh, "<:perlio", $file) { |
170 | if (open my $fh, "<:raw:perlio", $file) { |
168 | print "using cache for $file\n" |
171 | print "using cache for $file\n" |
169 | if $VERBOSE >= 7; |
172 | if $VERBOSE >= 7; |
170 | |
173 | |
171 | local $/; |
174 | local $/; |
172 | return <$fh>; |
175 | return <$fh>; |
… | |
… | |
175 | $src = $filter->($src); |
178 | $src = $filter->($src); |
176 | |
179 | |
177 | print "creating cache entry $file\n" |
180 | print "creating cache entry $file\n" |
178 | if $VERBOSE >= 8; |
181 | if $VERBOSE >= 8; |
179 | |
182 | |
180 | if (open my $fh, ">:perlio", "$file~") { |
183 | if (open my $fh, ">:raw:perlio", "$file~") { |
181 | if ((syswrite $fh, $src) == length $src) { |
184 | if ((syswrite $fh, $src) == length $src) { |
182 | close $fh; |
185 | close $fh; |
183 | rename "$file~", $file; |
186 | rename "$file~", $file; |
184 | } |
187 | } |
185 | } |
188 | } |
… | |
… | |
353 | |
356 | |
354 | use Getopt::Long; |
357 | use Getopt::Long; |
355 | |
358 | |
356 | sub parse_argv { |
359 | sub parse_argv { |
357 | GetOptions |
360 | GetOptions |
358 | "perl" => \$PERL, |
361 | "perl" => \$PERL, |
359 | "app=s" => \$APP, |
362 | "app=s" => \$APP, |
360 | |
363 | |
361 | "verbose|v" => sub { ++$VERBOSE }, |
364 | "verbose|v" => sub { ++$VERBOSE }, |
362 | "quiet|q" => sub { --$VERBOSE }, |
365 | "quiet|q" => sub { --$VERBOSE }, |
363 | |
366 | |
364 | "strip=s" => \$STRIP, |
367 | "strip=s" => \$STRIP, |
365 | "cache=s" => \$CACHE, # internal option |
368 | "cache=s" => \$CACHE, # internal option |
366 | "eval|e=s" => sub { trace_eval $_[1] }, |
369 | "eval|e=s" => sub { trace_eval $_[1] }, |
367 | "use|M=s" => sub { trace_module $_[1] }, |
370 | "use|M=s" => sub { trace_module $_[1] }, |
368 | "boot=s" => sub { cmd_boot $_[1] }, |
371 | "boot=s" => sub { cmd_boot $_[1] }, |
369 | "add=s" => sub { cmd_add $_[1], 0 }, |
372 | "add=s" => sub { cmd_add $_[1], 0 }, |
370 | "addbin=s" => sub { cmd_add $_[1], 1 }, |
373 | "addbin=s" => sub { cmd_add $_[1], 1 }, |
371 | "incglob=s" => sub { cmd_incglob $_[1] }, |
374 | "incglob=s" => sub { cmd_incglob $_[1] }, |
372 | "include|i=s" => sub { cmd_include $_[1], 1 }, |
375 | "include|i=s" => sub { cmd_include $_[1], 1 }, |
373 | "exclude|x=s" => sub { cmd_include $_[1], 0 }, |
376 | "exclude|x=s" => sub { cmd_include $_[1], 0 }, |
374 | "usepacklists!" => \$PACKLIST, |
377 | "usepacklists!" => \$PACKLIST, |
375 | |
378 | |
376 | "static!" => \$STATIC, |
379 | "static!" => \$STATIC, |
377 | "staticlib=s" => sub { cmd_staticlib $_[1] }, |
380 | "staticlib=s" => sub { cmd_staticlib $_[1] }, |
378 | "allow-dynamic!"=> \$ALLOW_DYNAMIC, |
381 | "allow-dynamic!" => \$ALLOW_DYNAMIC, |
379 | "ignore-env" => \$IGNORE_ENV, |
382 | "ignore-env" => \$IGNORE_ENV, |
380 | |
383 | |
|
|
384 | "extra-cflags=s" => \$EXTRA_CFLAGS, |
|
|
385 | "extra-ldflags=s" => \$EXTRA_LDFLAGS, |
|
|
386 | "extra-libs=s" => \$EXTRA_LIBS, |
|
|
387 | |
381 | "<>" => sub { cmd_file $_[0] }, |
388 | "<>" => sub { cmd_file $_[0] }, |
382 | or exit 1; |
389 | or exit 1; |
383 | } |
390 | } |
384 | |
391 | |
385 | Getopt::Long::Configure ("bundling", "no_auto_abbrev", "no_ignore_case"); |
392 | Getopt::Long::Configure ("bundling", "no_auto_abbrev", "no_ignore_case"); |
386 | |
393 | |
… | |
… | |
563 | or die "ERROR: $pm: path too long (only 128 octets supported)\n"; |
570 | or die "ERROR: $pm: path too long (only 128 octets supported)\n"; |
564 | |
571 | |
565 | my $src = ref $path |
572 | my $src = ref $path |
566 | ? $$path |
573 | ? $$path |
567 | : do { |
574 | : do { |
568 | open my $pm, "<", $path |
575 | open my $pm, "<:raw:perlio", $path |
569 | or die "$path: $!"; |
576 | or die "$path: $!"; |
570 | |
577 | |
571 | local $/; |
578 | local $/; |
572 | |
579 | |
573 | <$pm> |
580 | <$pm> |
… | |
… | |
977 | } |
984 | } |
978 | |
985 | |
979 | XSRETURN ($varpfx\_count); |
986 | XSRETURN ($varpfx\_count); |
980 | } |
987 | } |
981 | |
988 | |
|
|
989 | #ifdef STATICPERL_BUNDLE_INCLUDE |
|
|
990 | #include STATICPERL_BUNDLE_INCLUDE |
|
|
991 | #endif |
|
|
992 | |
982 | EOF |
993 | EOF |
983 | |
994 | |
984 | ############################################################################# |
995 | ############################################################################# |
985 | # xs_init |
996 | # xs_init |
986 | |
997 | |
… | |
… | |
1003 | char *file = __FILE__; |
1014 | char *file = __FILE__; |
1004 | dXSUB_SYS; |
1015 | dXSUB_SYS; |
1005 | |
1016 | |
1006 | newXSproto ("$PACKAGE\::find", find, file, "\$"); |
1017 | newXSproto ("$PACKAGE\::find", find, file, "\$"); |
1007 | newXSproto ("$PACKAGE\::list", list, file, ""); |
1018 | newXSproto ("$PACKAGE\::list", list, file, ""); |
|
|
1019 | |
|
|
1020 | #ifdef STATICPERL_BUNDLE_XS_INIT |
|
|
1021 | STATICPERL_BUNDLE_XS_INIT; |
|
|
1022 | #endif |
1008 | EOF |
1023 | EOF |
1009 | |
1024 | |
1010 | # calls |
1025 | # calls |
1011 | for (@static_ext) { |
1026 | for (@static_ext) { |
1012 | s/\.pm$//; |
1027 | s/\.pm$//; |
… | |
… | |
1018 | |
1033 | |
1019 | print $fh " newXS (\"$pname\::$bootstrap\", boot_$cname, file);\n"; |
1034 | print $fh " newXS (\"$pname\::$bootstrap\", boot_$cname, file);\n"; |
1020 | } |
1035 | } |
1021 | |
1036 | |
1022 | print $fh <<EOF; |
1037 | print $fh <<EOF; |
|
|
1038 | Safefree (PL_origfilename); |
|
|
1039 | PL_origfilename = savepv (PL_origargv [0]); |
|
|
1040 | sv_setpv (GvSV (gv_fetchpvs ("0", GV_ADD|GV_NOTQUAL, SVt_PV)), PL_origfilename); |
|
|
1041 | |
1023 | #ifdef _WIN32 |
1042 | #ifdef _WIN32 |
1024 | /* windows perls usually trail behind unix perls 8-10 years in exporting symbols */ |
1043 | /* windows perls usually trail behind unix perls 8-10 years in exporting symbols */ |
1025 | |
1044 | |
1026 | if (!PL_preambleav) |
1045 | if (!PL_preambleav) |
1027 | PL_preambleav = newAV (); |
1046 | PL_preambleav = newAV (); |
… | |
… | |
1171 | |
1190 | |
1172 | { |
1191 | { |
1173 | print "generating $PREFIX.ccopts... " |
1192 | print "generating $PREFIX.ccopts... " |
1174 | if $VERBOSE >= 1; |
1193 | if $VERBOSE >= 1; |
1175 | |
1194 | |
1176 | $ccopts = "$Config{ccflags} $Config{optimize} $Config{cppflags} -I\"$Config{archlibexp}/CORE\""; |
1195 | $ccopts = "$Config{ccflags} $Config{optimize} $Config{cppflags} -I$Config{archlibexp}/CORE $EXTRA_CFLAGS"; |
1177 | $ccopts =~ s/([\(\)])/\\$1/g; |
1196 | $ccopts =~ s/([\(\)])/\\$1/g; |
1178 | |
1197 | |
1179 | open my $fh, ">$PREFIX.ccopts" |
1198 | open my $fh, ">$PREFIX.ccopts" |
1180 | or die "$PREFIX.ccopts: $!"; |
1199 | or die "$PREFIX.ccopts: $!"; |
1181 | print $fh $ccopts; |
1200 | print $fh $ccopts; |
… | |
… | |
1189 | { |
1208 | { |
1190 | print "generating $PREFIX.ldopts... "; |
1209 | print "generating $PREFIX.ldopts... "; |
1191 | |
1210 | |
1192 | $ldopts = $STATIC ? "-static " : ""; |
1211 | $ldopts = $STATIC ? "-static " : ""; |
1193 | |
1212 | |
1194 | $ldopts .= "$Config{ccdlflags} $Config{ldflags} @libs $Config{archlibexp}/CORE/$Config{libperl} $Config{perllibs}"; |
1213 | $ldopts .= "$Config{ccdlflags} $Config{ldflags} $EXTRA_LDFLAGS @libs $Config{archlibexp}/CORE/$Config{libperl} $Config{perllibs} $EXTRA_LIBS"; |
1195 | |
1214 | |
1196 | my %seen; |
1215 | my %seen; |
1197 | $ldopts .= " $_" for reverse grep !$seen{$_}++, reverse ($extralibs =~ /(\S+)/g); |
1216 | $ldopts .= " $_" for reverse grep !$seen{$_}++, reverse +($extralibs =~ /(\S+)/g); |
1198 | |
1217 | |
1199 | for (@staticlibs) { |
1218 | for (@staticlibs) { |
1200 | $ldopts =~ s/(^|\s) (-l\Q$_\E) ($|\s)/$1-Wl,-Bstatic $2 -Wl,-Bdynamic$3/gx; |
1219 | $ldopts =~ s/(^|\s) (-l\Q$_\E) ($|\s)/$1-Wl,-Bstatic $2 -Wl,-Bdynamic$3/gx; |
1201 | } |
1220 | } |
1202 | |
1221 | |
… | |
… | |
1221 | print "$build\n" |
1240 | print "$build\n" |
1222 | if $VERBOSE >= 2; |
1241 | if $VERBOSE >= 2; |
1223 | |
1242 | |
1224 | system $build; |
1243 | system $build; |
1225 | |
1244 | |
1226 | # unlink "$PREFIX.$_" |
1245 | unlink "$PREFIX.$_" |
1227 | # for qw(ccopts ldopts c h); |
1246 | for qw(ccopts ldopts c h); |
1228 | |
1247 | |
1229 | print "\n" |
1248 | print "\n" |
1230 | if $VERBOSE >= 1; |
1249 | if $VERBOSE >= 1; |
1231 | } |
1250 | } |
1232 | |
1251 | |