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
8 print "perlgcc: building exportable perl...\n";
26 $libstring = join(" ",@libobs);
27 $obsString = join(" ",@obs);
28 $libflagString = join(" ",@libFlags);
31 my $command = "echo EXPORTS > perl.def";
33 system($command) == 0 or die "system() failed.\n";
35 $command ="nm $libstring | grep '^........ [TCD] _'| grep -v _impure_ptr | sed 's/[^_]*_//' >> perl.def";
37 system($command) == 0 or die "system() failed.\n";
39 # Build the perl.a lib to link to:
40 $command ="dlltool --as=as --dllname perl.exe --def perl.def --output-lib perl.a";
42 system($command) == 0 or die "system() failed.\n";
44 # change name of export lib to libperlexp so that is can be understood by ld2/perlld
45 $command ="mv perl.a libperlexp.a";
47 system($command) == 0 or die "system() failed.\n";
49 # get the full path name of a few libs:
50 my $crt0 = `gcc -print-file-name=crt0.o`;
52 my $libdir = `gcc -print-file-name=libcygwin.a`;
54 $libdir =~ s/libcygwin\.a//g;
56 # when $crt0 and $libdir get used in the system calls below, the \'s
57 # from the gcc -print-file-name get used to create special characters,
58 # such as \n, \t. Replace the \'s with /'s so that this does not
64 $command = "ld --base-file perl.base -o perl.exe $crt0 $obsString $libstring -L$libdir $libflagString";
66 system($command) == 0 or die "system() failed.\n";
68 $command = "dlltool --as=as --dllname perl.exe --def perl.def --base-file perl.base --output-exp perl.exp";
70 system($command) == 0 or die "system() failed.\n";
72 $command = "ld --base-file perl.base perl.exp -o perl.exe $crt0 $obsString $libstring -L$libdir $libflagString";
74 system($command) == 0 or die "system() failed.\n";
76 $command = "dlltool --as=as --dllname perl.exe --def perl.def --base-file perl.base --output-exp perl.exp";
78 system($command) == 0 or die "system() failed.\n";
80 $command = "ld perl.exp -o perl.exe $crt0 $obsString $libstring -L$libdir $libflagString";
82 system($command) == 0 or die "system() failed.\n";
84 print "perlgcc: Completed\n";