… | |
… | |
10 | our $APP; |
10 | our $APP; |
11 | our $VERIFY = 0; |
11 | our $VERIFY = 0; |
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_DLLS = 0; |
|
|
16 | our $HAVE_DLLS; # maybe useful? |
15 | |
17 | |
16 | our $OPTIMISE_SIZE = 0; # optimise for raw file size instead of for compression? |
18 | our $OPTIMISE_SIZE = 0; # optimise for raw file size instead of for compression? |
17 | |
19 | |
18 | our $CACHE; |
20 | our $CACHE; |
19 | our $CACHEVER = 1; # do not change unless you know what you are doing |
21 | our $CACHEVER = 1; # do not change unless you know what you are doing |
… | |
… | |
357 | "exclude|x=s" => sub { cmd_include $_[1], 0 }, |
359 | "exclude|x=s" => sub { cmd_include $_[1], 0 }, |
358 | "usepacklists!" => \$PACKLIST, |
360 | "usepacklists!" => \$PACKLIST, |
359 | |
361 | |
360 | "static!" => \$STATIC, |
362 | "static!" => \$STATIC, |
361 | "staticlib=s" => sub { cmd_staticlib $_[1] }, |
363 | "staticlib=s" => sub { cmd_staticlib $_[1] }, |
|
|
364 | "allow-dlls" => \$ALLOW_DLLS, |
362 | "ignore-env" => \$IGNORE_ENV, |
365 | "ignore-env" => \$IGNORE_ENV, |
363 | |
366 | |
364 | "<>" => sub { cmd_file $_[0] }, |
367 | "<>" => sub { cmd_file $_[0] }, |
365 | or exit 1; |
368 | or exit 1; |
366 | } |
369 | } |
… | |
… | |
475 | push @libs, "$autodir/$base$Config{_a}"; |
478 | push @libs, "$autodir/$base$Config{_a}"; |
476 | push @static_ext, $pm; |
479 | push @static_ext, $pm; |
477 | } |
480 | } |
478 | |
481 | |
479 | # dynamic object |
482 | # dynamic object |
480 | die "ERROR: found shared object - can't link statically ($_)\n" |
|
|
481 | if -f "$autodir/$base.$Config{dlext}"; |
483 | if (-f "$autodir/$base.$Config{dlext}") { |
|
|
484 | if ($ALLOW_DLLS) { |
|
|
485 | my $as = "&fs/perl/$auto/$base.$Config{dlext}"; |
|
|
486 | $pm{$as} = "$autodir/$base.$Config{dlext}"; |
|
|
487 | $pmbin{$as} = 1; |
|
|
488 | |
|
|
489 | $HAVE_DLLS = 1; |
|
|
490 | |
|
|
491 | print "+ added dynamic object $auto/$base.$Config{dlext}\n" |
|
|
492 | if $VERBOSE >= 3; |
|
|
493 | } else { |
|
|
494 | die "ERROR: found shared object '$_' but --allow-dlls not given, aborting.\n" |
|
|
495 | } |
|
|
496 | } |
482 | |
497 | |
483 | if ($PACKLIST && open my $fh, "<:perlio", "$autodir/.packlist") { |
498 | if ($PACKLIST && open my $fh, "<:perlio", "$autodir/.packlist") { |
484 | print "found .packlist for $pm\n" |
499 | print "found .packlist for $pm\n" |
485 | if $VERBOSE >= 3; |
500 | if $VERBOSE >= 3; |
486 | |
501 | |
… | |
… | |
803 | # bootstrap |
818 | # bootstrap |
804 | |
819 | |
805 | # boot file for staticperl |
820 | # boot file for staticperl |
806 | # this file will be eval'ed at initialisation time |
821 | # this file will be eval'ed at initialisation time |
807 | |
822 | |
|
|
823 | # lines marked with "^D" are only used when $HAVE_DLLS |
808 | my $bootstrap = ' |
824 | my $bootstrap = ' |
809 | BEGIN { |
825 | BEGIN { |
810 | package ' . $PACKAGE . '; |
826 | package ' . $PACKAGE . '; |
811 | |
827 | |
812 | PerlIO::scalar->bootstrap; |
828 | # the path prefix to use when putting files into %INC |
|
|
829 | our $inc_prefix; |
813 | |
830 | |
814 | @INC = sub { |
831 | # the @INC hook to use when we have PerlIO::scalar available |
|
|
832 | my $perlio_inc = sub { |
815 | my $data = find "$_[1]" |
833 | my $data = find "$_[1]" |
816 | or return; |
834 | or return; |
817 | |
835 | |
818 | $INC{$_[1]} = $_[1]; |
836 | $INC{$_[1]} = "$inc_prefix$_[1]"; |
819 | |
837 | |
820 | open my $fh, "<", \$data; |
838 | open my $fh, "<", \$data; |
821 | $fh |
839 | $fh |
822 | }; |
840 | }; |
|
|
841 | |
|
|
842 | D if (defined &PerlIO::scalar::bootstrap) { |
|
|
843 | # PerlIO::scalar statically compiled in |
|
|
844 | PerlIO::scalar->bootstrap; |
|
|
845 | @INC = $perlio_inc; |
|
|
846 | D } else { |
|
|
847 | D # PerlIO::scalar not available, use slower method |
|
|
848 | D @INC = sub { |
|
|
849 | D # always check if PerlIO::scalar might now be available |
|
|
850 | D if (defined &PerlIO::scalar::bootstrap) { |
|
|
851 | D # switch to the faster perlio_inc hook |
|
|
852 | D @INC = map { $_ == $_[0] ? $perlio_inc : $_ } @INC; |
|
|
853 | D goto &$perlio_inc; |
|
|
854 | D } |
|
|
855 | D |
|
|
856 | D my $data = find "$_[1]" |
|
|
857 | D or return; |
|
|
858 | D |
|
|
859 | D $INC{$_[1]} = "$inc_prefix$_[1]"; |
|
|
860 | D |
|
|
861 | D sub { |
|
|
862 | D $data =~ /\G([^\n]*\n?)/g |
|
|
863 | D or return; |
|
|
864 | D |
|
|
865 | D $_ = $1; |
|
|
866 | D 1 |
|
|
867 | D } |
|
|
868 | D }; |
|
|
869 | D } |
823 | } |
870 | } |
824 | '; |
871 | '; |
825 | |
872 | |
826 | $bootstrap .= "require '&&boot';" |
873 | $bootstrap .= "require '&&boot';" |
827 | if exists $pm{"&&boot"}; |
874 | if exists $pm{"&&boot"}; |
828 | |
875 | |
|
|
876 | if ($HAVE_DLLS) { |
|
|
877 | $bootstrap =~ s/^D/ /mg; |
|
|
878 | } else { |
|
|
879 | $bootstrap =~ s/^D.*$//mg; |
|
|
880 | } |
|
|
881 | |
|
|
882 | $bootstrap =~ s/#.*$//mg; |
829 | $bootstrap =~ s/\s+/ /g; |
883 | $bootstrap =~ s/\s+/ /g; |
830 | $bootstrap =~ s/(\W) /$1/g; |
884 | $bootstrap =~ s/(\W) /$1/g; |
831 | $bootstrap =~ s/ (\W)/$1/g; |
885 | $bootstrap =~ s/ (\W)/$1/g; |
832 | |
886 | |
833 | print $fh "const char bootstrap [] = "; |
887 | print $fh "const char bootstrap [] = "; |
… | |
… | |
879 | } |
933 | } |
880 | |
934 | |
881 | XSRETURN (0); |
935 | XSRETURN (0); |
882 | |
936 | |
883 | found: |
937 | found: |
884 | ST (0) = res; |
938 | ST (0) = sv_2mortal (res); |
885 | sv_2mortal (ST (0)); |
|
|
886 | } |
939 | } |
887 | |
940 | |
888 | XSRETURN (1); |
941 | XSRETURN (1); |
889 | } |
942 | } |
890 | |
943 | |
… | |
… | |
903 | |
956 | |
904 | for (i = 0; i < $varpfx\_count; ++i) |
957 | for (i = 0; i < $varpfx\_count; ++i) |
905 | { |
958 | { |
906 | U32 idx = $varpfx\_index [i]; |
959 | U32 idx = $varpfx\_index [i]; |
907 | |
960 | |
908 | PUSHs (newSVpvn ($varpfx\_data + (idx & 0x1FFFFFFU), idx >> 25)); |
961 | PUSHs (sv_2mortal (newSVpvn ($varpfx\_data + (idx & 0x1FFFFFFU), idx >> 25))); |
909 | } |
962 | } |
910 | } |
963 | } |
911 | |
964 | |
912 | XSRETURN ($varpfx\_count); |
965 | XSRETURN ($varpfx\_count); |
913 | } |
966 | } |
… | |
… | |
921 | void |
974 | void |
922 | staticperl_xs_init (pTHX) |
975 | staticperl_xs_init (pTHX) |
923 | { |
976 | { |
924 | EOF |
977 | EOF |
925 | |
978 | |
926 | @static_ext = ("DynaLoader", sort @static_ext); |
979 | @static_ext = sort @static_ext; |
927 | |
980 | |
928 | # prototypes |
981 | # prototypes |
929 | for (@static_ext) { |
982 | for (@static_ext) { |
930 | s/\.pm$//; |
983 | s/\.pm$//; |
931 | (my $cname = $_) =~ s/\//__/g; |
984 | (my $cname = $_) =~ s/\//__/g; |
… | |
… | |
945 | s/\.pm$//; |
998 | s/\.pm$//; |
946 | |
999 | |
947 | (my $cname = $_) =~ s/\//__/g; |
1000 | (my $cname = $_) =~ s/\//__/g; |
948 | (my $pname = $_) =~ s/\//::/g; |
1001 | (my $pname = $_) =~ s/\//::/g; |
949 | |
1002 | |
950 | my $bootstrap = $pname eq "DynaLoader" ? "boot" : "bootstrap"; |
1003 | my $bootstrap = $pname eq "DynaLoader" ? "boot_DynaLoader" : "bootstrap"; |
951 | |
1004 | |
952 | print $fh " newXS (\"$pname\::$bootstrap\", boot_$cname, file);\n"; |
1005 | print $fh " newXS (\"$pname\::$bootstrap\", boot_$cname, file);\n"; |
953 | } |
1006 | } |
954 | |
1007 | |
955 | print $fh <<EOF; |
1008 | print $fh <<EOF; |