Added fakethr.h.
[p5sagit/p5-mst-13.2.git] / cygwin32 / perlgcc
CommitLineData
5aabfad6 1#
2
3# Perl script be a wrapper around the gnu gcc. the exportable perl.exe
4# is built, special processing is done.
5# This script is caled by the gcc2 shell script when the flag
6# -buildperl is passed to gcc2
7
8print "perlgcc: building exportable perl...\n";
9
10# get all libs:
11my @libobs;
12my @obs;
13my @libFlags;
14my $libstring;
15foreach (@ARGV){
16 if( /\.[a]$/){
17 push @libobs,$_;
18 }
19 elsif(/^\-l/){
20 push @libFlags,$_;
21 }
22 if( /\.[o]$/){
23 push @obs,$_;
24 }
25}
26$libstring = join(" ",@libobs);
27$obsString = join(" ",@obs);
28$libflagString = join(" ",@libFlags);
29
30# make exports file
31my $command = "echo EXPORTS > perl.def";
32print "$command\n";
33system($command);
34
35$command ="nm $libstring | grep '^........ [TCD] _'| grep -v _impure_ptr | sed 's/[^_]*_//' >> perl.def";
36print "$command\n";
37system($command);
38
39# Build the perl.a lib to link to:
40$command ="dlltool --as=as --dllname perl.exe --def perl.def --output-lib perl.a";
41print "$command\n";
42system($command);
43
44# change name of export lib to libperlexp so that is can be understood by ld2/perlld
45$command ="mv perl.a libperlexp.a";
46print "$command\n";
47system($command);
48
49# get the full path name of a few libs:
50my $crt0 = `gcc -print-file-name=crt0.o`;
51chomp $crt0;
52my $libdir = `gcc -print-file-name=libcygwin.a`;
53chomp $libdir;
54$libdir =~ s/libcygwin\.a//g;
55
56# Link exe:
57$command = "ld --base-file perl.base -o perl.exe $crt0 $obsString $libstring -L$libdir $libflagString";
58print "$command\n";
59system($command);
60
61$command = "dlltool --as=as --dllname perl.exe --def perl.def --base-file perl.base --output-exp perl.exp";
62print "$command\n";
63system($command);
64
65$command = "ld --base-file perl.base perl.exp -o perl.exe $crt0 $obsString $libstring -L$libdir $libflagString";
66print "$command\n";
67system($command);
68
69$command = "dlltool --as=as --dllname perl.exe --def perl.def --base-file perl.base --output-exp perl.exp";
70print "$command\n";
71system($command);
72
73$command = "ld perl.exp -o perl.exe $crt0 $obsString $libstring -L$libdir $libflagString";
74print "$command\n";
75system($command);
76
77print "perlgcc: Completed\n";