ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/App-Staticperl/mkbundle
(Generate patch)

Comparing App-Staticperl/mkbundle (file contents):
Revision 1.17 by root, Wed Feb 9 09:52:27 2011 UTC vs.
Revision 1.32 by root, Mon Jul 18 07:34:48 2011 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2 2
3############################################################################# 3#############################################################################
4# cannot load modules till after the tracer BEGIN block 4# cannot load modules till after the tracer BEGIN block
5 5
6our $VERBOSE = 1; 6our $VERBOSE = 1;
7our $STRIP = "pod"; # none, pod or ppi 7our $STRIP = "pod"; # none, pod or ppi
8our $UNISTRIP = 1; # always on, try to strip unicore swash data 8our $UNISTRIP = 1; # always on, try to strip unicore swash data
9our $PERL = 0; 9our $PERL = 0;
10our $APP; 10our $APP;
11our $VERIFY = 0; 11our $VERIFY = 0;
12our $STATIC = 0; 12our $STATIC = 0;
13our $PACKLIST = 0; 13our $PACKLIST = 0;
14our $IGNORE_ENV = 0;
15our $ALLOW_DYNAMIC = 0;
16our $HAVE_DYNAMIC; # maybe useful?
14 17
15our $OPTIMISE_SIZE = 0; # optimise for raw file size instead of for compression? 18our $OPTIMISE_SIZE = 0; # optimise for raw file size instead of for compression?
16 19
17our $CACHE; 20our $CACHE;
18our $CACHEVER = 1; # do not change unless you know what you are doing 21our $CACHEVER = 1; # do not change unless you know what you are doing
82 }; 85 };
83 86
84 while (<$R_TRACER>) { 87 while (<$R_TRACER>) {
85 if (/use (.*)$/) { 88 if (/use (.*)$/) {
86 my $mod = $1; 89 my $mod = $1;
90 my $eval;
91
92 if ($mod =~ /^'.*'$/ or $mod =~ /^".*"$/) {
93 $eval = "require $mod";
94 } elsif ($mod =~ y%/.%%) {
95 $eval = "require q\x00$mod\x00";
96 } else {
87 my $pkg = ++$pkg; 97 my $pkg = ++$pkg;
88 my $eval = $mod = $mod =~ /[^A-Za-z0-9_:]/
89 ? "require $mod"
90 : "{ package $pkg; use $mod; }"; 98 $eval = "{ package $pkg; use $mod; }";
99 }
100
91 eval $eval; 101 eval $eval;
92 warn "ERROR: $@ (while loading '$mod')\n" 102 warn "ERROR: $@ (while loading '$mod')\n"
93 if $@; 103 if $@;
94 } elsif (/eval (.*)$/) { 104 } elsif (/eval (.*)$/) {
95 my $eval = $1; 105 my $eval = $1;
182 192
183sub dump_string { 193sub dump_string {
184 my ($fh, $data) = @_; 194 my ($fh, $data) = @_;
185 195
186 if (length $data) { 196 if (length $data) {
197 if ($^O eq "MSWin32") {
198 # 16 bit system, strings can't be longer than 64k. seriously.
199 print $fh "{\n";
187 for ( 200 for (
188 my $ofs = 0; 201 my $ofs = 0;
202 length (my $substr = substr $data, $ofs, 20);
203 $ofs += 20
204 ) {
205 $substr = join ",", map ord, split //, $substr;
206 print $fh " $substr,\n";
207 }
208 print $fh " 0 }\n";
209 } else {
210 for (
211 my $ofs = 0;
189 length (my $substr = substr $data, $ofs, 80); 212 length (my $substr = substr $data, $ofs, 80);
190 $ofs += 80 213 $ofs += 80
191 ) { 214 ) {
192 $substr =~ s/([^\x20-\x21\x23-\x5b\x5d-\x7e])/sprintf "\\%03o", ord $1/ge; 215 $substr =~ s/([^\x20-\x21\x23-\x5b\x5d-\x7e])/sprintf "\\%03o", ord $1/ge;
193 $substr =~ s/\?/\\?/g; # trigraphs... 216 $substr =~ s/\?/\\?/g; # trigraphs...
194 print $fh " \"$substr\"\n"; 217 print $fh " \"$substr\"\n";
218 }
195 } 219 }
196 } else { 220 } else {
197 print $fh " \"\"\n"; 221 print $fh " \"\"\n";
198 } 222 }
199} 223}
266} 290}
267 291
268############################################################################# 292#############################################################################
269 293
270sub cmd_boot { 294sub cmd_boot {
271 $pm{"//boot"} = $_[0]; 295 $pm{"!boot"} = $_[0];
272} 296}
273 297
274sub cmd_add { 298sub cmd_add {
275 $_[0] =~ /^(.*)(?:\s+(\S+))$/ 299 $_[0] =~ /^(.*?)(?:\s+(\S+))?$/
276 or die "$_[0]: cannot parse"; 300 or die "$_[0]: cannot parse";
277 301
278 my $file = $1; 302 my $file = $1;
279 my $as = defined $2 ? $2 : "/$1"; 303 my $as = defined $2 ? $2 : $1;
280 304
281 $pm{$as} = $file; 305 $pm{$as} = $file;
282 $pmbin{$as} = 1 if $_[1]; 306 $pmbin{$as} = 1 if $_[1];
283} 307}
284 308
329 353
330use Getopt::Long; 354use Getopt::Long;
331 355
332sub parse_argv { 356sub parse_argv {
333 GetOptions 357 GetOptions
358 "perl" => \$PERL,
359 "app=s" => \$APP,
360
361 "verbose|v" => sub { ++$VERBOSE },
362 "quiet|q" => sub { --$VERBOSE },
363
334 "strip=s" => \$STRIP, 364 "strip=s" => \$STRIP,
335 "cache=s" => \$CACHE, # internal option 365 "cache=s" => \$CACHE, # internal option
336 "verbose|v" => sub { ++$VERBOSE },
337 "quiet|q" => sub { --$VERBOSE },
338 "perl" => \$PERL,
339 "app=s" => \$APP,
340 "eval|e=s" => sub { trace_eval $_[1] }, 366 "eval|e=s" => sub { trace_eval $_[1] },
341 "use|M=s" => sub { trace_module $_[1] }, 367 "use|M=s" => sub { trace_module $_[1] },
342 "boot=s" => sub { cmd_boot $_[1] }, 368 "boot=s" => sub { cmd_boot $_[1] },
343 "add=s" => sub { cmd_add $_[1], 0 }, 369 "add=s" => sub { cmd_add $_[1], 0 },
344 "addbin=s" => sub { cmd_add $_[1], 1 }, 370 "addbin=s" => sub { cmd_add $_[1], 1 },
345 "incglob=s" => sub { cmd_incglob $_[1] }, 371 "incglob=s" => sub { cmd_incglob $_[1] },
346 "include|i=s" => sub { cmd_include $_[1], 1 }, 372 "include|i=s" => sub { cmd_include $_[1], 1 },
347 "exclude|x=s" => sub { cmd_include $_[1], 0 }, 373 "exclude|x=s" => sub { cmd_include $_[1], 0 },
374 "usepacklists!" => \$PACKLIST,
375
348 "static!" => \$STATIC, 376 "static!" => \$STATIC,
349 "usepacklists!" => \$PACKLIST,
350 "staticlib=s" => sub { cmd_staticlib $_[1] }, 377 "staticlib=s" => sub { cmd_staticlib $_[1] },
378 "allow-dynamic!"=> \$ALLOW_DYNAMIC,
379 "ignore-env" => \$IGNORE_ENV,
380
351 "<>" => sub { cmd_file $_[0] }, 381 "<>" => sub { cmd_file $_[0] },
352 or exit 1; 382 or exit 1;
353} 383}
354 384
355Getopt::Long::Configure ("bundling", "no_auto_abbrev", "no_ignore_case"); 385Getopt::Long::Configure ("bundling", "no_auto_abbrev", "no_ignore_case");
462 push @libs, "$autodir/$base$Config{_a}"; 492 push @libs, "$autodir/$base$Config{_a}";
463 push @static_ext, $pm; 493 push @static_ext, $pm;
464 } 494 }
465 495
466 # dynamic object 496 # dynamic object
467 die "ERROR: found shared object - can't link statically ($_)\n"
468 if -f "$autodir/$base.$Config{dlext}"; 497 if (-f "$autodir/$base.$Config{dlext}") {
498 if ($ALLOW_DYNAMIC) {
499 my $as = "!$auto/$base.$Config{dlext}";
500 $pm{$as} = "$autodir/$base.$Config{dlext}";
501 $pmbin{$as} = 1;
502
503 $HAVE_DYNAMIC = 1;
504
505 print "+ added dynamic object $as\n"
506 if $VERBOSE >= 3;
507 } else {
508 die "ERROR: found shared object '$autodir/$base.$Config{dlext}' but --allow-dynamic not given, aborting.\n"
509 }
510 }
469 511
470 if ($PACKLIST && open my $fh, "<:perlio", "$autodir/.packlist") { 512 if ($PACKLIST && open my $fh, "<:perlio", "$autodir/.packlist") {
471 print "found .packlist for $pm\n" 513 print "found .packlist for $pm\n"
472 if $VERBOSE >= 3; 514 if $VERBOSE >= 3;
473 515
707} 749}
708 750
709length $data < 2**25 751length $data < 2**25
710 or die "ERROR: bundle too large (only 32MB supported)\n"; 752 or die "ERROR: bundle too large (only 32MB supported)\n";
711 753
712my $varpfx = "bundle_" . substr +(Digest::MD5::md5_hex $data), 0, 16; 754my $varpfx = "bundle";
713 755
714############################################################################# 756#############################################################################
715# output 757# output
716 758
717print "generating $PREFIX.h... " 759print "generating $PREFIX.h... "
720{ 762{
721 open my $fh, ">", "$PREFIX.h" 763 open my $fh, ">", "$PREFIX.h"
722 or die "$PREFIX.h: $!\n"; 764 or die "$PREFIX.h: $!\n";
723 765
724 print $fh <<EOF; 766 print $fh <<EOF;
725/* do not edit, automatically created by mkstaticbundle */ 767/* do not edit, automatically created by staticperl */
726 768
727#include <EXTERN.h> 769#include <EXTERN.h>
728#include <perl.h> 770#include <perl.h>
729#include <XSUB.h> 771#include <XSUB.h>
730 772
731/* public API */ 773/* public API */
732EXTERN_C PerlInterpreter *staticperl; 774EXTERN_C PerlInterpreter *staticperl;
733EXTERN_C void staticperl_xs_init (pTHX); 775EXTERN_C void staticperl_xs_init (pTHX);
734EXTERN_C void staticperl_init (void); 776EXTERN_C void staticperl_init (XSINIT_t xs_init); /* argument can be 0 */
735EXTERN_C void staticperl_cleanup (void); 777EXTERN_C void staticperl_cleanup (void);
736 778
737EOF 779EOF
738} 780}
739 781
748 790
749open my $fh, ">", "$PREFIX.c" 791open my $fh, ">", "$PREFIX.c"
750 or die "$PREFIX.c: $!\n"; 792 or die "$PREFIX.c: $!\n";
751 793
752print $fh <<EOF; 794print $fh <<EOF;
753/* do not edit, automatically created by mkstaticbundle */ 795/* do not edit, automatically created by staticperl */
754 796
755#include "bundle.h" 797#include "bundle.h"
756 798
757/* public API */ 799/* public API */
758PerlInterpreter *staticperl; 800PerlInterpreter *staticperl;
790# bootstrap 832# bootstrap
791 833
792# boot file for staticperl 834# boot file for staticperl
793# this file will be eval'ed at initialisation time 835# this file will be eval'ed at initialisation time
794 836
837# lines marked with "^D" are only used when $HAVE_DYNAMIC
795my $bootstrap = ' 838my $bootstrap = '
796BEGIN { 839BEGIN {
797 package ' . $PACKAGE . '; 840 package ' . $PACKAGE . ';
798 841
799 PerlIO::scalar->bootstrap; 842 # the path prefix to use when putting files into %INC
843 our $inc_prefix;
800 844
801 @INC = sub { 845 # the @INC hook to use when we have PerlIO::scalar available
846 my $perlio_inc = sub {
802 my $data = find "$_[1]" 847 my $data = find "$_[1]"
803 or return; 848 or return;
804 849
805 $INC{$_[1]} = $_[1]; 850 $INC{$_[1]} = "$inc_prefix$_[1]";
806 851
807 open my $fh, "<", \$data; 852 open my $fh, "<", \$data;
808 $fh 853 $fh
809 }; 854 };
855
856D if (defined &PerlIO::scalar::bootstrap) {
857 # PerlIO::scalar statically compiled in
858 PerlIO::scalar->bootstrap;
859 @INC = $perlio_inc;
860D } else {
861D # PerlIO::scalar not available, use slower method
862D @INC = sub {
863D # always check if PerlIO::scalar might now be available
864D if (defined &PerlIO::scalar::bootstrap) {
865D # switch to the faster perlio_inc hook
866D @INC = map { $_ == $_[0] ? $perlio_inc : $_ } @INC;
867D goto &$perlio_inc;
868D }
869D
870D my $data = find "$_[1]"
871D or return;
872D
873D $INC{$_[1]} = "$inc_prefix$_[1]";
874D
875D sub {
876D $data =~ /\G([^\n]*\n?)/g
877D or return;
878D
879D $_ = $1;
880D 1
881D }
882D };
883D }
810} 884}
811'; 885';
812 886
813$bootstrap .= "require '//boot';" 887$bootstrap .= "require '!boot';"
814 if exists $pm{"//boot"}; 888 if exists $pm{"!boot"};
815 889
890if ($HAVE_DYNAMIC) {
891 $bootstrap =~ s/^D/ /mg;
892} else {
893 $bootstrap =~ s/^D.*$//mg;
894}
895
896$bootstrap =~ s/#.*$//mg;
816$bootstrap =~ s/\s+/ /g; 897$bootstrap =~ s/\s+/ /g;
817$bootstrap =~ s/(\W) /$1/g; 898$bootstrap =~ s/(\W) /$1/g;
818$bootstrap =~ s/ (\W)/$1/g; 899$bootstrap =~ s/ (\W)/$1/g;
819 900
820print $fh "const char bootstrap [] = "; 901print $fh "const char bootstrap [] = ";
866 } 947 }
867 948
868 XSRETURN (0); 949 XSRETURN (0);
869 950
870 found: 951 found:
871 ST (0) = res; 952 ST (0) = sv_2mortal (res);
872 sv_2mortal (ST (0));
873 } 953 }
874 954
875 XSRETURN (1); 955 XSRETURN (1);
876} 956}
877 957
890 970
891 for (i = 0; i < $varpfx\_count; ++i) 971 for (i = 0; i < $varpfx\_count; ++i)
892 { 972 {
893 U32 idx = $varpfx\_index [i]; 973 U32 idx = $varpfx\_index [i];
894 974
895 PUSHs (newSVpvn ($varpfx\_data + (idx & 0x1FFFFFFU), idx >> 25)); 975 PUSHs (sv_2mortal (newSVpvn ($varpfx\_data + (idx & 0x1FFFFFFU), idx >> 25)));
896 } 976 }
897 } 977 }
898 978
899 XSRETURN ($varpfx\_count); 979 XSRETURN ($varpfx\_count);
900} 980}
908void 988void
909staticperl_xs_init (pTHX) 989staticperl_xs_init (pTHX)
910{ 990{
911EOF 991EOF
912 992
913@static_ext = ("DynaLoader", sort @static_ext); 993@static_ext = sort @static_ext;
914 994
915# prototypes 995# prototypes
916for (@static_ext) { 996for (@static_ext) {
917 s/\.pm$//; 997 s/\.pm$//;
918 (my $cname = $_) =~ s/\//__/g; 998 (my $cname = $_) =~ s/\//__/g;
932 s/\.pm$//; 1012 s/\.pm$//;
933 1013
934 (my $cname = $_) =~ s/\//__/g; 1014 (my $cname = $_) =~ s/\//__/g;
935 (my $pname = $_) =~ s/\//::/g; 1015 (my $pname = $_) =~ s/\//::/g;
936 1016
937 my $bootstrap = $pname eq "DynaLoader" ? "boot" : "bootstrap"; 1017 my $bootstrap = $pname eq "DynaLoader" ? "boot_DynaLoader" : "bootstrap";
938 1018
939 print $fh " newXS (\"$pname\::$bootstrap\", boot_$cname, file);\n"; 1019 print $fh " newXS (\"$pname\::$bootstrap\", boot_$cname, file);\n";
940} 1020}
941 1021
942print $fh <<EOF; 1022print $fh <<EOF;
1023 #ifdef _WIN32
1024 /* windows perls usually trail behind unix perls 8-10 years in exporting symbols */
1025
1026 if (!PL_preambleav)
1027 PL_preambleav = newAV ();
1028
1029 av_unshift (PL_preambleav, 1);
1030 av_store (PL_preambleav, 0, newSVpv (bootstrap, sizeof (bootstrap) - 1));
1031 #else
943 Perl_av_create_and_unshift_one (&PL_preambleav, newSVpv (bootstrap, sizeof (bootstrap) - 1)); 1032 Perl_av_create_and_unshift_one (&PL_preambleav, newSVpv (bootstrap, sizeof (bootstrap) - 1));
1033 #endif
1034
1035 if (PL_oldname)
1036 ((XSINIT_t)PL_oldname)(aTHX);
944} 1037}
945EOF 1038EOF
946 1039
947############################################################################# 1040#############################################################################
948# optional perl_init/perl_destroy 1041# optional perl_init/perl_destroy
1042
1043if ($IGNORE_ENV) {
1044 $IGNORE_ENV = <<EOF;
1045 unsetenv ("PERL_UNICODE");
1046 unsetenv ("PERL_HASH_SEED_DEBUG");
1047 unsetenv ("PERL_DESTRUCT_LEVEL");
1048 unsetenv ("PERL_SIGNALS");
1049 unsetenv ("PERL_DEBUG_MSTATS");
1050 unsetenv ("PERL5OPT");
1051 unsetenv ("PERLIO_DEBUG");
1052 unsetenv ("PERLIO");
1053 unsetenv ("PERL_HASH_SEED");
1054EOF
1055} else {
1056 $IGNORE_ENV = "";
1057}
949 1058
950if ($APP) { 1059if ($APP) {
951 print $fh <<EOF; 1060 print $fh <<EOF;
952 1061
953int 1062int
963 args [3] = "--"; 1072 args [3] = "--";
964 1073
965 for (i = 1; i < argc; ++i) 1074 for (i = 1; i < argc; ++i)
966 args [i + 3] = argv [i]; 1075 args [i + 3] = argv [i];
967 1076
1077$IGNORE_ENV
968 PERL_SYS_INIT3 (&argc, &argv, &environ); 1078 PERL_SYS_INIT3 (&argc, &argv, &environ);
969 staticperl = perl_alloc (); 1079 staticperl = perl_alloc ();
970 perl_construct (staticperl); 1080 perl_construct (staticperl);
971 1081
972 PL_exit_flags |= PERL_EXIT_DESTRUCT_END; 1082 PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
990main (int argc, char *argv []) 1100main (int argc, char *argv [])
991{ 1101{
992 extern char **environ; 1102 extern char **environ;
993 int exitstatus; 1103 int exitstatus;
994 1104
1105$IGNORE_ENV
995 PERL_SYS_INIT3 (&argc, &argv, &environ); 1106 PERL_SYS_INIT3 (&argc, &argv, &environ);
996 staticperl = perl_alloc (); 1107 staticperl = perl_alloc ();
997 perl_construct (staticperl); 1108 perl_construct (staticperl);
998 1109
999 PL_exit_flags |= PERL_EXIT_DESTRUCT_END; 1110 PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
1011EOF 1122EOF
1012} else { 1123} else {
1013 print $fh <<EOF; 1124 print $fh <<EOF;
1014 1125
1015EXTERN_C void 1126EXTERN_C void
1016staticperl_init (void) 1127staticperl_init (XSINIT_t xs_init)
1017{ 1128{
1018 static char *args[] = { 1129 static char *args[] = {
1019 "staticperl", 1130 "staticperl",
1020 "-e", 1131 "-e",
1021 "0" 1132 "0"
1023 1134
1024 extern char **environ; 1135 extern char **environ;
1025 int argc = sizeof (args) / sizeof (args [0]); 1136 int argc = sizeof (args) / sizeof (args [0]);
1026 char **argv = args; 1137 char **argv = args;
1027 1138
1139$IGNORE_ENV
1028 PERL_SYS_INIT3 (&argc, &argv, &environ); 1140 PERL_SYS_INIT3 (&argc, &argv, &environ);
1029 staticperl = perl_alloc (); 1141 staticperl = perl_alloc ();
1030 perl_construct (staticperl); 1142 perl_construct (staticperl);
1031 PL_origalen = 1; 1143 PL_origalen = 1;
1032 PL_exit_flags |= PERL_EXIT_DESTRUCT_END; 1144 PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
1145 PL_oldname = (char *)xs_init;
1033 perl_parse (staticperl, staticperl_xs_init, argc, argv, environ); 1146 perl_parse (staticperl, staticperl_xs_init, argc, argv, environ);
1034 1147
1035 perl_run (staticperl); 1148 perl_run (staticperl);
1036} 1149}
1037 1150
1044 PERL_SYS_TERM (); 1157 PERL_SYS_TERM ();
1045} 1158}
1046EOF 1159EOF
1047} 1160}
1048 1161
1162close $fh;
1163
1049print -s "$PREFIX.c", " octets (", (length $data) , " data octets).\n\n" 1164print -s "$PREFIX.c", " octets (", (length $data) , " data octets).\n\n"
1050 if $VERBOSE >= 1; 1165 if $VERBOSE >= 1;
1051 1166
1052############################################################################# 1167#############################################################################
1053# libs, cflags 1168# libs, cflags
1169
1170my $ccopts;
1054 1171
1055{ 1172{
1056 print "generating $PREFIX.ccopts... " 1173 print "generating $PREFIX.ccopts... "
1057 if $VERBOSE >= 1; 1174 if $VERBOSE >= 1;
1058 1175
1059 my $str = "$Config{ccflags} $Config{optimize} $Config{cppflags} -I$Config{archlibexp}/CORE"; 1176 $ccopts = "$Config{ccflags} $Config{optimize} $Config{cppflags} -I$Config{archlibexp}/CORE";
1060 $str =~ s/([\(\)])/\\$1/g; 1177 $ccopts =~ s/([\(\)])/\\$1/g;
1061 1178
1062 open my $fh, ">$PREFIX.ccopts" 1179 open my $fh, ">$PREFIX.ccopts"
1063 or die "$PREFIX.ccopts: $!"; 1180 or die "$PREFIX.ccopts: $!";
1064 print $fh $str; 1181 print $fh $ccopts;
1065 1182
1066 print "$str\n\n" 1183 print "$ccopts\n\n"
1067 if $VERBOSE >= 1; 1184 if $VERBOSE >= 1;
1068} 1185}
1186
1187my $ldopts;
1069 1188
1070{ 1189{
1071 print "generating $PREFIX.ldopts... "; 1190 print "generating $PREFIX.ldopts... ";
1072 1191
1073 my $str = $STATIC ? "-static " : ""; 1192 $ldopts = $STATIC ? "-static " : "";
1074 1193
1075 $str .= "$Config{ccdlflags} $Config{ldflags} @libs $Config{archlibexp}/CORE/$Config{libperl} $Config{perllibs}"; 1194 $ldopts .= "$Config{ccdlflags} $Config{ldflags} @libs $Config{archlibexp}/CORE/$Config{libperl} $Config{perllibs}";
1076 1195
1077 my %seen; 1196 my %seen;
1078 $str .= " $_" for grep !$seen{$_}++, ($extralibs =~ /(\S+)/g); 1197 $ldopts .= " $_" for reverse grep !$seen{$_}++, reverse +($extralibs =~ /(\S+)/g);
1079 1198
1080 for (@staticlibs) { 1199 for (@staticlibs) {
1081 $str =~ s/(^|\s) (-l\Q$_\E) ($|\s)/$1-Wl,-Bstatic $2 -Wl,-Bdynamic$3/gx; 1200 $ldopts =~ s/(^|\s) (-l\Q$_\E) ($|\s)/$1-Wl,-Bstatic $2 -Wl,-Bdynamic$3/gx;
1082 } 1201 }
1083 1202
1084 $str =~ s/([\(\)])/\\$1/g; 1203 $ldopts =~ s/([\(\)])/\\$1/g;
1085 1204
1086 open my $fh, ">$PREFIX.ldopts" 1205 open my $fh, ">$PREFIX.ldopts"
1087 or die "$PREFIX.ldopts: $!"; 1206 or die "$PREFIX.ldopts: $!";
1088 print $fh $str; 1207 print $fh $ldopts;
1089 1208
1090 print "$str\n\n" 1209 print "$ldopts\n\n"
1091 if $VERBOSE >= 1; 1210 if $VERBOSE >= 1;
1092} 1211}
1093 1212
1094if ($PERL or defined $APP) { 1213if ($PERL or defined $APP) {
1095 $APP = "perl" unless defined $APP; 1214 $APP = "perl" unless defined $APP;
1096 1215
1216 my $build = "$Config{cc} $ccopts -o \Q$APP\E$Config{_exe} bundle.c $ldopts";
1217
1097 print "building $APP...\n" 1218 print "build $APP...\n"
1098 if $VERBOSE >= 1; 1219 if $VERBOSE >= 1;
1099 1220
1100 system "$Config{cc} \$(cat bundle.ccopts\) -o \Q$APP\E bundle.c \$(cat bundle.ldopts\)"; 1221 print "$build\n"
1222 if $VERBOSE >= 2;
1101 1223
1224 system $build;
1225
1102 unlink "$PREFIX.$_" 1226# unlink "$PREFIX.$_"
1103 for qw(ccopts ldopts c h); 1227# for qw(ccopts ldopts c h);
1104 1228
1105 print "\n" 1229 print "\n"
1106 if $VERBOSE >= 1; 1230 if $VERBOSE >= 1;
1107} 1231}
1108 1232

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines