diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-09-10 14:48:25 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2009-09-10 14:49:10 +0100 |
commit | 4d984b75f1859fc27f556ee42f31a04df42a2004 (patch) | |
tree | fdcdc90251d570e0d3039d85edac6206427154c1 /lib/ExtUtils | |
parent | 2d528fa53012fb0e14d6dfff409204b6c73bb9ce (diff) | |
download | perl-4d984b75f1859fc27f556ee42f31a04df42a2004.tar.gz |
Move ExtUtils::CBuilder from lib to ext.
Diffstat (limited to 'lib/ExtUtils')
-rw-r--r-- | lib/ExtUtils/CBuilder.pm | 322 | ||||
-rw-r--r-- | lib/ExtUtils/CBuilder/Base.pm | 293 | ||||
-rw-r--r-- | lib/ExtUtils/CBuilder/Changes | 279 | ||||
-rw-r--r-- | lib/ExtUtils/CBuilder/Platform/Unix.pm | 40 | ||||
-rw-r--r-- | lib/ExtUtils/CBuilder/Platform/VMS.pm | 294 | ||||
-rw-r--r-- | lib/ExtUtils/CBuilder/Platform/Windows.pm | 684 | ||||
-rw-r--r-- | lib/ExtUtils/CBuilder/Platform/aix.pm | 31 | ||||
-rw-r--r-- | lib/ExtUtils/CBuilder/Platform/cygwin.pm | 30 | ||||
-rw-r--r-- | lib/ExtUtils/CBuilder/Platform/darwin.pm | 22 | ||||
-rw-r--r-- | lib/ExtUtils/CBuilder/Platform/dec_osf.pm | 18 | ||||
-rw-r--r-- | lib/ExtUtils/CBuilder/Platform/os2.pm | 80 | ||||
-rw-r--r-- | lib/ExtUtils/CBuilder/t/00-have-compiler.t | 43 | ||||
-rw-r--r-- | lib/ExtUtils/CBuilder/t/01-basic.t | 81 | ||||
-rw-r--r-- | lib/ExtUtils/CBuilder/t/02-link.t | 99 |
14 files changed, 0 insertions, 2316 deletions
diff --git a/lib/ExtUtils/CBuilder.pm b/lib/ExtUtils/CBuilder.pm deleted file mode 100644 index eb859ae409..0000000000 --- a/lib/ExtUtils/CBuilder.pm +++ /dev/null @@ -1,322 +0,0 @@ -package ExtUtils::CBuilder; - -use File::Spec (); -use File::Path (); -use File::Basename (); - -use vars qw($VERSION @ISA); -$VERSION = '0.2602'; -$VERSION = eval $VERSION; - -# Okay, this is the brute-force method of finding out what kind of -# platform we're on. I don't know of a systematic way. These values -# came from the latest (bleadperl) perlport.pod. - -my %OSTYPES = qw( - aix Unix - bsdos Unix - dgux Unix - dynixptx Unix - freebsd Unix - linux Unix - hpux Unix - irix Unix - darwin Unix - machten Unix - next Unix - openbsd Unix - netbsd Unix - dec_osf Unix - svr4 Unix - svr5 Unix - sco_sv Unix - unicos Unix - unicosmk Unix - solaris Unix - sunos Unix - cygwin Unix - os2 Unix - gnu Unix - gnukfreebsd Unix - haiku Unix - - dos Windows - MSWin32 Windows - - os390 EBCDIC - os400 EBCDIC - posix-bc EBCDIC - vmesa EBCDIC - - MacOS MacOS - VMS VMS - VOS VOS - riscos RiscOS - amigaos Amiga - mpeix MPEiX - ); - -# We only use this once - don't waste a symbol table entry on it. -# More importantly, don't make it an inheritable method. -my $load = sub { - my $mod = shift; - eval "use $mod"; - die $@ if $@; - @ISA = ($mod); -}; - -{ - my @package = split /::/, __PACKAGE__; - - if (grep {-e File::Spec->catfile($_, @package, 'Platform', $^O) . '.pm'} @INC) { - $load->(__PACKAGE__ . "::Platform::$^O"); - - } elsif (exists $OSTYPES{$^O} and - grep {-e File::Spec->catfile($_, @package, 'Platform', $OSTYPES{$^O}) . '.pm'} @INC) { - $load->(__PACKAGE__ . "::Platform::$OSTYPES{$^O}"); - - } else { - $load->(__PACKAGE__ . "::Base"); - } -} - -sub os_type { $OSTYPES{$^O} } - -1; -__END__ - -=head1 NAME - -ExtUtils::CBuilder - Compile and link C code for Perl modules - -=head1 SYNOPSIS - - use ExtUtils::CBuilder; - - my $b = ExtUtils::CBuilder->new(%options); - $obj_file = $b->compile(source => 'MyModule.c'); - $lib_file = $b->link(objects => $obj_file); - -=head1 DESCRIPTION - -This module can build the C portions of Perl modules by invoking the -appropriate compilers and linkers in a cross-platform manner. It was -motivated by the C<Module::Build> project, but may be useful for other -purposes as well. However, it is I<not> intended as a general -cross-platform interface to all your C building needs. That would -have been a much more ambitious goal! - -=head1 METHODS - -=over 4 - -=item new - -Returns a new C<ExtUtils::CBuilder> object. A C<config> parameter -lets you override C<Config.pm> settings for all operations performed -by the object, as in the following example: - - # Use a different compiler than Config.pm says - my $b = ExtUtils::CBuilder->new( config => - { ld => 'gcc' } ); - -A C<quiet> parameter tells C<CBuilder> to not print its C<system()> -commands before executing them: - - # Be quieter than normal - my $b = ExtUtils::CBuilder->new( quiet => 1 ); - -=item have_compiler - -Returns true if the current system has a working C compiler and -linker, false otherwise. To determine this, we actually compile and -link a sample C library. The sample will be compiled in the system -tempdir or, if that fails for some reason, in the current directory. - -=item compile - -Compiles a C source file and produces an object file. The name of the -object file is returned. The source file is specified in a C<source> -parameter, which is required; the other parameters listed below are -optional. - -=over 4 - -=item C<object_file> - -Specifies the name of the output file to create. Otherwise the -C<object_file()> method will be consulted, passing it the name of the -C<source> file. - -=item C<include_dirs> - -Specifies any additional directories in which to search for header -files. May be given as a string indicating a single directory, or as -a list reference indicating multiple directories. - -=item C<extra_compiler_flags> - -Specifies any additional arguments to pass to the compiler. Should be -given as a list reference containing the arguments individually, or if -this is not possible, as a string containing all the arguments -together. - -=back - -The operation of this method is also affected by the -C<archlibexp>, C<cccdlflags>, C<ccflags>, C<optimize>, and C<cc> -entries in C<Config.pm>. - -=item link - -Invokes the linker to produce a library file from object files. In -scalar context, the name of the library file is returned. In list -context, the library file and any temporary files created are -returned. A required C<objects> parameter contains the name of the -object files to process, either in a string (for one object file) or -list reference (for one or more files). The following parameters are -optional: - - -=over 4 - -=item lib_file - -Specifies the name of the output library file to create. Otherwise -the C<lib_file()> method will be consulted, passing it the name of -the first entry in C<objects>. - -=item module_name - -Specifies the name of the Perl module that will be created by linking. -On platforms that need to do prelinking (Win32, OS/2, etc.) this is a -required parameter. - -=item extra_linker_flags - -Any additional flags you wish to pass to the linker. - -=back - -On platforms where C<need_prelink()> returns true, C<prelink()> -will be called automatically. - -The operation of this method is also affected by the C<lddlflags>, -C<shrpenv>, and C<ld> entries in C<Config.pm>. - -=item link_executable - -Invokes the linker to produce an executable file from object files. In -scalar context, the name of the executable file is returned. In list -context, the executable file and any temporary files created are -returned. A required C<objects> parameter contains the name of the -object files to process, either in a string (for one object file) or -list reference (for one or more files). The optional parameters are -the same as C<link> with exception for - - -=over 4 - -=item exe_file - -Specifies the name of the output executable file to create. Otherwise -the C<exe_file()> method will be consulted, passing it the name of the -first entry in C<objects>. - -=back - -=item object_file - - my $object_file = $b->object_file($source_file); - -Converts the name of a C source file to the most natural name of an -output object file to create from it. For instance, on Unix the -source file F<foo.c> would result in the object file F<foo.o>. - -=item lib_file - - my $lib_file = $b->lib_file($object_file); - -Converts the name of an object file to the most natural name of a -output library file to create from it. For instance, on Mac OS X the -object file F<foo.o> would result in the library file F<foo.bundle>. - -=item exe_file - - my $exe_file = $b->exe_file($object_file); - -Converts the name of an object file to the most natural name of an -executable file to create from it. For instance, on Mac OS X the -object file F<foo.o> would result in the executable file F<foo>, and -on Windows it would result in F<foo.exe>. - - -=item prelink - -On certain platforms like Win32, OS/2, VMS, and AIX, it is necessary -to perform some actions before invoking the linker. The -C<ExtUtils::Mksymlists> module does this, writing files used by the -linker during the creation of shared libraries for dynamic extensions. -The names of any files written will be returned as a list. - -Several parameters correspond to C<ExtUtils::Mksymlists::Mksymlists()> -options, as follows: - - Mksymlists() prelink() type - -------------|-------------------|------------------- - NAME | dl_name | string (required) - DLBASE | dl_base | string - FILE | dl_file | string - DL_VARS | dl_vars | array reference - DL_FUNCS | dl_funcs | hash reference - FUNCLIST | dl_func_list | array reference - IMPORTS | dl_imports | hash reference - VERSION | dl_version | string - -Please see the documentation for C<ExtUtils::Mksymlists> for the -details of what these parameters do. - -=item need_prelink - -Returns true on platforms where C<prelink()> should be called -during linking, and false otherwise. - -=item extra_link_args_after_prelink - -Returns list of extra arguments to give to the link command; the arguments -are the same as for prelink(), with addition of array reference to the -results of prelink(); this reference is indexed by key C<prelink_res>. - -=back - -=head1 TO DO - -Currently this has only been tested on Unix and doesn't contain any of -the Windows-specific code from the C<Module::Build> project. I'll do -that next. - -=head1 HISTORY - -This module is an outgrowth of the C<Module::Build> project, to which -there have been many contributors. Notably, Randy W. Sims submitted -lots of code to support 3 compilers on Windows and helped with various -other platform-specific issues. Ilya Zakharevich has contributed -fixes for OS/2; John E. Malmberg and Peter Prymmer have done likewise -for VMS. - -=head1 AUTHOR - -Ken Williams, kwilliams@cpan.org - -=head1 COPYRIGHT - -Copyright (c) 2003-2005 Ken Williams. All rights reserved. - -This library is free software; you can redistribute it and/or -modify it under the same terms as Perl itself. - -=head1 SEE ALSO - -perl(1), Module::Build(3) - -=cut diff --git a/lib/ExtUtils/CBuilder/Base.pm b/lib/ExtUtils/CBuilder/Base.pm deleted file mode 100644 index 1184953183..0000000000 --- a/lib/ExtUtils/CBuilder/Base.pm +++ /dev/null @@ -1,293 +0,0 @@ -package ExtUtils::CBuilder::Base; - -use strict; -use File::Spec; -use File::Basename; -use Cwd (); -use Config; -use Text::ParseWords; -use IO::File; - -use vars qw($VERSION); -$VERSION = '0.2602'; - -sub new { - my $class = shift; - my $self = bless {@_}, $class; - - $self->{properties}{perl} = $class->find_perl_interpreter - or warn "Warning: Can't locate your perl binary"; - - while (my ($k,$v) = each %Config) { - $self->{config}{$k} = $v unless exists $self->{config}{$k}; - } - return $self; -} - -sub find_perl_interpreter { - my $perl; - File::Spec->file_name_is_absolute($perl = $^X) - or -f ($perl = $Config::Config{perlpath}) - or ($perl = $^X); - return $perl; -} - -sub add_to_cleanup { - my $self = shift; - foreach (@_) { - $self->{files_to_clean}{$_} = 1; - } -} - -sub cleanup { - my $self = shift; - foreach my $file (keys %{$self->{files_to_clean}}) { - unlink $file; - } -} - -sub object_file { - my ($self, $filename) = @_; - - # File name, minus the suffix - (my $file_base = $filename) =~ s/\.[^.]+$//; - return "$file_base$self->{config}{obj_ext}"; -} - -sub arg_include_dirs { - my $self = shift; - return map {"-I$_"} @_; -} - -sub arg_nolink { '-c' } - -sub arg_object_file { - my ($self, $file) = @_; - return ('-o', $file); -} - -sub arg_share_object_file { - my ($self, $file) = @_; - return ($self->split_like_shell($self->{config}{lddlflags}), '-o', $file); -} - -sub arg_exec_file { - my ($self, $file) = @_; - return ('-o', $file); -} - -sub arg_defines { - my ($self, %args) = @_; - return map "-D$_=$args{$_}", keys %args; -} - -sub compile { - my ($self, %args) = @_; - die "Missing 'source' argument to compile()" unless defined $args{source}; - - my $cf = $self->{config}; # For convenience - - $args{object_file} ||= $self->object_file($args{source}); - - my @include_dirs = $self->arg_include_dirs - (@{$args{include_dirs} || []}, - $self->perl_inc()); - - my @defines = $self->arg_defines( %{$args{defines} || {}} ); - - my @extra_compiler_flags = $self->split_like_shell($args{extra_compiler_flags}); - my @cccdlflags = $self->split_like_shell($cf->{cccdlflags}); - my @ccflags = $self->split_like_shell($cf->{ccflags}); - my @optimize = $self->split_like_shell($cf->{optimize}); - my @flags = (@include_dirs, @defines, @cccdlflags, @extra_compiler_flags, - $self->arg_nolink, - @ccflags, @optimize, - $self->arg_object_file($args{object_file}), - ); - - my @cc = $self->split_like_shell($cf->{cc}); - - $self->do_system(@cc, @flags, $args{source}) - or die "error building $args{object_file} from '$args{source}'"; - - return $args{object_file}; -} - -sub have_compiler { - my ($self) = @_; - return $self->{have_compiler} if defined $self->{have_compiler}; - - my $result; - my $attempts = 3; - # tmpdir has issues for some people so fall back to current dir - DIR: for my $dir ( File::Spec->tmpdir, '.' ) { - - # don't clobber existing files (rare, but possible) - my $rand = int(rand(2**31)); - my $tmpfile = File::Spec->catfile($dir, "compilet-$rand.c"); - if ( -e $tmpfile ) { - redo DIR if $attempts--; - next DIR; - } - - { - my $FH = IO::File->new("> $tmpfile") or die "Can't create $tmpfile: $!"; - print $FH "int boot_compilet() { return 1; }\n"; - } - - my ($obj_file, @lib_files); - eval { - local $^W = 0; - $obj_file = $self->compile(source => $tmpfile); - @lib_files = $self->link(objects => $obj_file, module_name => 'compilet'); - }; - $result = $@ ? 0 : 1; - - foreach (grep defined, $tmpfile, $obj_file, @lib_files) { - 1 while unlink; - } - last DIR if $result; - } - - return $self->{have_compiler} = $result; -} - -sub lib_file { - my ($self, $dl_file) = @_; - $dl_file =~ s/\.[^.]+$//; - $dl_file =~ tr/"//d; - return "$dl_file.$self->{config}{dlext}"; -} - - -sub exe_file { - my ($self, $dl_file) = @_; - $dl_file =~ s/\.[^.]+$//; - $dl_file =~ tr/"//d; - return "$dl_file$self->{config}{_exe}"; -} - -sub need_prelink { 0 } - -sub extra_link_args_after_prelink { return } - -sub prelink { - my ($self, %args) = @_; - - ($args{dl_file} = $args{dl_name}) =~ s/.*::// unless $args{dl_file}; - - require ExtUtils::Mksymlists; - ExtUtils::Mksymlists::Mksymlists( # dl. abbrev for dynamic library - DL_VARS => $args{dl_vars} || [], - DL_FUNCS => $args{dl_funcs} || {}, - FUNCLIST => $args{dl_func_list} || [], - IMPORTS => $args{dl_imports} || {}, - NAME => $args{dl_name}, # Name of the Perl module - DLBASE => $args{dl_base}, # Basename of DLL file - FILE => $args{dl_file}, # Dir + Basename of symlist file - VERSION => (defined $args{dl_version} ? $args{dl_version} : '0.0'), - ); - - # Mksymlists will create one of these files - return grep -e, map "$args{dl_file}.$_", qw(ext def opt); -} - -sub link { - my ($self, %args) = @_; - return $self->_do_link('lib_file', lddl => 1, %args); -} - -sub link_executable { - my ($self, %args) = @_; - return $self->_do_link('exe_file', lddl => 0, %args); -} - -sub _do_link { - my ($self, $type, %args) = @_; - - my $cf = $self->{config}; # For convenience - - my $objects = delete $args{objects}; - $objects = [$objects] unless ref $objects; - my $out = $args{$type} || $self->$type($objects->[0]); - - my @temp_files; - @temp_files = - $self->prelink(%args, - dl_name => $args{module_name}) if $args{lddl} && $self->need_prelink; - - my @linker_flags = ($self->split_like_shell($args{extra_linker_flags}), - $self->extra_link_args_after_prelink(%args, dl_name => $args{module_name}, - prelink_res => \@temp_files)); - - my @output = $args{lddl} ? $self->arg_share_object_file($out) : $self->arg_exec_file($out); - my @shrp = $self->split_like_shell($cf->{shrpenv}); - my @ld = $self->split_like_shell($cf->{ld}); - - $self->do_system(@shrp, @ld, @output, @$objects, @linker_flags) - or die "error building $out from @$objects"; - - return wantarray ? ($out, @temp_files) : $out; -} - - -sub do_system { - my ($self, @cmd) = @_; - print "@cmd\n" if !$self->{quiet}; - return !system(@cmd); -} - -sub split_like_shell { - my ($self, $string) = @_; - - return () unless defined($string); - return @$string if UNIVERSAL::isa($string, 'ARRAY'); - $string =~ s/^\s+|\s+$//g; - return () unless length($string); - - return Text::ParseWords::shellwords($string); -} - -# if building perl, perl's main source directory -sub perl_src { - # N.B. makemaker actually searches regardless of PERL_CORE, but - # only squawks at not finding it if PERL_CORE is set - - return unless $ENV{PERL_CORE}; - - my $Updir = File::Spec->updir; - my $dir = File::Spec->curdir; - - # Try up to 5 levels upwards - for (0..10) { - if ( - -f File::Spec->catfile($dir,"config_h.SH") - && - -f File::Spec->catfile($dir,"perl.h") - && - -f File::Spec->catfile($dir,"lib","Exporter.pm") - ) { - return Cwd::realpath( $dir ); - } - - $dir = File::Spec->catdir($dir, $Updir); - } - - warn "PERL_CORE is set but I can't find your perl source!\n"; - return ''; # return empty string if $ENV{PERL_CORE} but can't find dir ??? -} - -# directory of perl's include files -sub perl_inc { - my $self = shift; - - $self->perl_src() || File::Spec->catdir($self->{config}{archlibexp},"CORE"); -} - -sub DESTROY { - my $self = shift; - local($., $@, $!, $^E, $?); - $self->cleanup(); -} - -1; diff --git a/lib/ExtUtils/CBuilder/Changes b/lib/ExtUtils/CBuilder/Changes deleted file mode 100644 index 2e011eed39..0000000000 --- a/lib/ExtUtils/CBuilder/Changes +++ /dev/null @@ -1,279 +0,0 @@ -Revision history for Perl extension ExtUtils::CBuilder. - -0.2602 - Sat Jul 4 10:57:12 EDT 2009 - - Bugs fixed: - - Fixed 00-have-compiler.t if $^X is a relative path [David Wheeler] - -0.2601 - Wed Jul 1 09:37:39 EDT 2009 - - Bugs fixed: - - On VMS, cleans up extra files generated during testing - [John E. Malmberg, Craig Berry] - -0.26 - Mon Jun 29 20:11:52 EDT 2009 - - - No changes from 0.25_01 - -0.25_01 - Sat Jun 27 23:13:20 EDT 2009 - - - Changed test library to Test::More - - - Added tests for have_compiler - - - Skips tests that need a compiler if have_compiler is false - - - have_compiler will try to compile in the current directory - if compiling in tmpdir fails for whatever reason - -0.25 - Fri Jun 26 16:18:13 EDT 2009 - - - Slight diagnostic improvements in link.t - -0.24_01 - Sun Mar 8 14:50:10 2009 - - - On Windows, don't generate "mt" command when CRT is statically - linked. [Jan Dubois] - - - On Cygwin, examine $Config{useshrplib} to see whether we're - supposed to be linking with a shared perl library or not. [Reini - Urban] - - - In link_executable() on Cygwin, trust $Config{ld} rather than using - $Config{cc} for linking. [Reini Urban] - - - Add 'haiku' as a Unix-like platform. [Ingo Weinhold] - -0.24 - Fri Aug 15 22:01:48 2008 - - - Added 'gnu' and 'gnukfreebsd' as Unix variants. [Niko Tyni] - - - Brought in some VMS fixes from bleadperl: "Correct and complete - CBuilder's handling of external libraries when linking on VMS." - [Craig Berry] - -0.23 - Sat Apr 19 22:28:03 2008 - - - Fixed some problems (some old, some new) with Strawberry Perl on - Windows. [Alberto Simo~es] - - - Will now install in the core perl lib directory when the user's - perl is new enough to have us in core. [Yi Ma Mao] - -0.22 - Fri Feb 8 21:52:21 2008 - - - Replaced the split_like_shell() method on Windows with a - near-no-op, which is probably more correct and has the benefit of - not messing up UNC paths. [John R. LoVerso, see - http://rt.cpan.org/Ticket/Display.html?id=26545] - - - Fixed extra_compiler_flags on Windows, they were being - ignored. [Robert May] - -0.21 - Tue Oct 30 06:46:01 2007 - - - Clean up perl_src path using Cwd::realpath(). Only affects usage - as part of the perl core. - - - Protect $., $@, $!, $^E, and $? from any clobbering that might - occur in our DESTROY method. [Zefram] - - - From bleadperl, a patch to clean up debug symbol files (.pdb for - VC++, .tds for BCC) when running have_compiler(). [Steve Hay & - Steve Peters] - -0.19 - Sun May 13 14:29:18 2007 - - - When building as part of the perl core (so this is irrelevant for - people downloading from CPAN) we now try a little harder to find - the perl sources. [Jos Boumans] - - - Fixed a part of the manifest thingy that got broken on 64-bit - Windows platforms in version 0.18. [Steve Hay, Jan Dubois] - -0.18 - Mon Mar 26 21:29:09 2007 - - - Various OS/2 fixes: - + Put .LIB file near .DEF file - + Got library-file building working better - + Handled libperl_overrides better - [Ilya Zakharevich] - - - On Windows: embed manifest files in DLLs built with Module-Build - when using VC8. [Steve Hay] - - - Added a workaround for a config error on dec_osf: the linker is - $Config{cc}, not $Config{ld}. [Jarkko Hietaniemi] - - - Borland's compiler "response files" will not pass through macro - definitions that contain quotes. The quotes get stripped and there - seems to be no way to escape them. So we leave macros on the - command line. [Randy W. Sims] - -0.18 Sat Mar 25 13:35:47 CST 2006 - - - Yet more fixes for arg_defines() on VMS. [Craig A. Berry and John - E. Malmberg] - -0.17 Wed Mar 15 22:46:15 CST 2006 - - - When we're being run from an uninstalled perl distribution - (e.g. one that's in the process of being built and tested), we - search for perl first in the current working directory. [Randy - Sims] - - - More fixing of the arg_defines() method on VMS. [Craig A. Berry and - John E. Malmberg] - -0.16 Mon Mar 13 17:08:21 CST 2006 - - - Fix quoting of command line arguments on Windows. [Yitzchak - Scott-Thoennes] - - - Provided a custom arg_defines() on VMS that does essentially the - same thing for /define that version 0.14 did for /include. [Craig - A. Berry] - - - Documented the existing 'quiet' parameter, which silences the - printing of system() commands. [Suggested by Yitzchak - Scott-Thoennes] - -0.15 Mon Oct 3 17:10:32 CDT 2005 - - - Several OS/2 fixes have been made, including: 1) adding the - necessary version string to DLLs, 2) passing the executable's name - to 'ldopts' without the .exe extension, 3) avoiding calling 'env' - via the 'shrpenv' thingy, since it triggers a fork() bug. [Ilya - Zakharevich] - - - Integrate a couple cleanup-related changes from bleadperl that - somehow never got into this copy. [Steve Hay] - - - Added a new 'defines' parameter to compile(), which gives a - platform-independant way to specify various -Dfoo=bar (or the - equivalent) compiler defines. [Randy W. Sims] - -0.14 Mon Sep 19 13:40:37 CDT 2005 - - - Several fixes have been made for VMS, including: 1) there can only - be one /include qualifier, so merge multiple /includes into one; 2) - make sure the executable is named the same way that dynaloader will - look for it; 3) make sure the option files for the exported symbols - and the PERLSHR image are passed properly to the linker. [John - E. Malmberg] - -0.13 Wed Aug 24 20:05:59 CDT 2005 - - - Several temporary files weren't being cleaned up during testing, - because the 'cleanup' mechanism was never properly implemented. - This is now fixed. [Steve Hay] - -0.12 Mon May 30 16:40:10 CDT 2005 - - - In order to integrate into the perl core, patches were contributed - that a) put a $VERSION variable in each .pm file, b) add a 'quiet' - parameter to new() to shut up some of the command-echoing, c) - checks for the perl source headers in the CORE/ directory in the - perl source tree, not in the post-installation location, and d) - adjusts the CWD when running the regression tests under the perl - core. [Yitzchak Scott-Thoennes] - - - Various parts of the code were looking for the CORE/ directory in - $Config{archlib}, $Config{installarchlib}, and $Config{archlibexp}. - Only the latter is correct, so we use that everywhere now. - [Curt Tilmes] - - - For Unix-ish platforms, link_executable() will now prefer - $Config{cc} to $Config{ld}, because that typically works - better. [Jarkko Hietaniemi and H.Merijn Brand] - - - Prelinking (invoking ExtUtils::Mksymlists to create options-files) - is now only done when we're building dynamic libraries. [Yitzchak - Scott-Thoennes] - -0.11 Tue Apr 5 20:58:41 CDT 2005 - - - Added a licensing statement to CBuilder.pm. [Spotted by Chip - Salzenberg] - -0.10 Mon Mar 14 20:18:19 CST 2005 - - - Split out a few simple routines that format how compile switches - are formatted, so that we can override them for platforms like VMS - where they're very different. - - - Fix compile() and link() on VMS. [Help from Michael Schwern and - Peter Prymmer] - -0.09 Tue Feb 8 17:57:41 CST 2005 - - - Fixed a broken link_executable() method on cygwin - it now uses - 'gcc' instead of $Config{ld} for the linking, because the latter is - actually a shell script which calls a perl script which calls gcc - in a way that only works for creating shared libraries, not - executables. - -0.08 Tue Jan 18 21:54:11 CST 2005 - - - Fixed a testing error in which I had the prototype wrong for the - main() function. [Jose Pedro Oliveira] - -0.07 Wed Jan 12 21:50:34 CST 2005 - - - Added the link_executable() method, which provides the ability to - create standalone executables. This is NOT yet implemented on - Windows, and therefore the tests for it are skipped on Win32. - [Alberto Manuel Brandao Simoes] - - - Integrated the latest split_like_shell() for Windows from - Module::Build (really need to find a better home for this code...), - which now does a much better job of handling quotes and backslashes - and so on. [Randy Sims] - - - Fixed a couple of Windows problems related to the output-file name - in link(), and some clobbering of the 'include_dirs' parameter to - compile(). [Randy Sims] - -0.06 Mon Dec 27 22:51:36 CST 2004 - - - Fixed a bug on Unix environments in which our work-around for - shell-commands like "FOO=BAR cc" (which is supposed to be turned - into "env FOO=BAR cc" to actually work) wasn't being called. - -0.05 Wed Oct 13 23:09:09 CDT 2004 - - - Fixed a bug in split_like_shell() in which leading whitespace was - creating an empty word, manifesting as something like "gcc - no - such file or directory" during tests. [Spotted by Warren L. Dodge] - - - Incorporate another split_like_shell() fix from Module::Build. - -0.04 Sun Oct 10 00:31:08 CDT 2004 - - - Changed the split_like_shell() method to use the shellwords() - function from Text::ParseWords (a core module since 5.0), which - does a much better job than the split() we were using. - - -0.03 Fri May 14 23:12:23 CDT 2004 - - - Fixed minor problems with the Build.PL file, the module names - should be quoted. - - - The VMS module declared itself with the wrong package name. - - -0.02 Fri Feb 20 10:17:40 CST 2004 - - - Fixed a bug in .../Platform/Windows.pm, in which compile() was - ignoring an 'include_dirs' argument. [Randy Sims] - - - Fixed a bug in .../Platform/Windows.pm, in which output files were - being created in the root directory \ when they should be created - in the current directory. [Randy Sims] - - -0.01 Mon Jan 12 08:12:35 CST 2004 - - - Original release, taken from Module::Build's C-building code, with - patching help from Randy Sims. diff --git a/lib/ExtUtils/CBuilder/Platform/Unix.pm b/lib/ExtUtils/CBuilder/Platform/Unix.pm deleted file mode 100644 index 8672e3ef88..0000000000 --- a/lib/ExtUtils/CBuilder/Platform/Unix.pm +++ /dev/null @@ -1,40 +0,0 @@ -package ExtUtils::CBuilder::Platform::Unix; - -use strict; -use ExtUtils::CBuilder::Base; - -use vars qw($VERSION @ISA); -$VERSION = '0.2602'; -@ISA = qw(ExtUtils::CBuilder::Base); - -sub link_executable { - my $self = shift; - - # On some platforms (which ones??) $Config{cc} seems to be a better - # bet for linking executables than $Config{ld}. Cygwin is a notable - # exception. - local $self->{config}{ld} = - $self->{config}{cc} . " " . $self->{config}{ldflags}; - return $self->SUPER::link_executable(@_); -} - -sub link { - my $self = shift; - my $cf = $self->{config}; - - # Some platforms (notably Mac OS X 10.3, but some others too) expect - # the syntax "FOO=BAR /bin/command arg arg" to work in %Config - # (notably $Config{ld}). It usually works in system(SCALAR), but we - # use system(LIST). We fix it up here with 'env'. - - local $cf->{ld} = $cf->{ld}; - if (ref $cf->{ld}) { - unshift @{$cf->{ld}}, 'env' if $cf->{ld}[0] =~ /^\s*\w+=/; - } else { - $cf->{ld} =~ s/^(\s*\w+=)/env $1/; - } - - return $self->SUPER::link(@_); -} - -1; diff --git a/lib/ExtUtils/CBuilder/Platform/VMS.pm b/lib/ExtUtils/CBuilder/Platform/VMS.pm deleted file mode 100644 index 97434a3930..0000000000 --- a/lib/ExtUtils/CBuilder/Platform/VMS.pm +++ /dev/null @@ -1,294 +0,0 @@ -package ExtUtils::CBuilder::Platform::VMS; - -use strict; -use ExtUtils::CBuilder::Base; - -use vars qw($VERSION @ISA); -$VERSION = '0.2602'; -@ISA = qw(ExtUtils::CBuilder::Base); - -use File::Spec::Functions qw(catfile catdir); - -# We do prelink, but don't want the parent to redo it. - -sub need_prelink { 0 } - -sub arg_defines { - my ($self, %args) = @_; - - s/"/""/g foreach values %args; - - my @config_defines; - - # VMS can only have one define qualifier; add the one from config, if any. - if ($self->{config}{ccflags} =~ s{/ def[^=]+ =+ \(? ([^\/\)]*) } {}ix) { - push @config_defines, $1; - } - - return '' unless keys(%args) || @config_defines; - - return ('/define=(' - . join(',', - @config_defines, - map "\"$_" . ( length($args{$_}) ? "=$args{$_}" : '') . "\"", - keys %args) - . ')'); -} - -sub arg_include_dirs { - my ($self, @dirs) = @_; - - # VMS can only have one include list, add the one from config. - if ($self->{config}{ccflags} =~ s{/inc[^=]+(?:=)+(?:\()?([^\/\)]*)} {}i) { - unshift @dirs, $1; - } - return unless @dirs; - - return ('/include=(' . join(',', @dirs) . ')'); -} - -sub _do_link { - my ($self, $type, %args) = @_; - - my $objects = delete $args{objects}; - $objects = [$objects] unless ref $objects; - - if ($args{lddl}) { - - # prelink will call Mksymlists, which creates the extension-specific - # linker options file and populates it with the boot symbol. - - my @temp_files = $self->prelink(%args, dl_name => $args{module_name}); - - # We now add the rest of what we need to the linker options file. We - # should replicate the functionality of C<ExtUtils::MM_VMS::dlsyms>, - # but there is as yet no infrastructure for handling object libraries, - # so for now we depend on object files being listed individually on the - # command line, which should work for simple cases. We do bring in our - # own version of C<ExtUtils::Liblist::Kid::ext> so that any additional - # libraries (including PERLSHR) can be added to the options file. - - my @optlibs = $self->_liblist_ext( $args{'libs'} ); - - my $optfile = 'sys$disk:[]' . $temp_files[0]; - open my $opt_fh, '>>', $optfile - or die "_do_link: Unable to open $optfile: $!"; - for my $lib (@optlibs) {print $opt_fh "$lib\n" if length $lib } - close $opt_fh; - - $objects->[-1] .= ','; - push @$objects, $optfile . '/OPTIONS,'; - - # This one not needed for DEC C, but leave for completeness. - push @$objects, $self->perl_inc() . 'perlshr_attr.opt/OPTIONS'; - } - - return $self->SUPER::_do_link($type, %args, objects => $objects); -} - -sub arg_nolink { return; } - -sub arg_object_file { - my ($self, $file) = @_; - return "/obj=$file"; -} - -sub arg_exec_file { - my ($self, $file) = @_; - return ("/exe=$file"); -} - -sub arg_share_object_file { - my ($self, $file) = @_; - return ("$self->{config}{lddlflags}=$file"); -} - - -sub lib_file { - my ($self, $dl_file) = @_; - $dl_file =~ s/\.[^.]+$//; - $dl_file =~ tr/"//d; - $dl_file = $dl_file .= '.' . $self->{config}{dlext}; - - # Need to create with the same name as DynaLoader will load with. - if (defined &DynaLoader::mod2fname) { - my ($dev,$dir,$file) = File::Spec->splitpath($dl_file); - $file = DynaLoader::mod2fname([$file]); - $dl_file = File::Spec->catpath($dev,$dir,$file); - } - return $dl_file; -} - -# The following is reproduced almost verbatim from ExtUtils::Liblist::Kid::_vms_ext. -# We can't just call that because it's tied up with the MakeMaker object hierarchy. - -sub _liblist_ext { - my($self, $potential_libs,$verbose,$give_libs) = @_; - $verbose ||= 0; - - my(@crtls,$crtlstr); - @crtls = ( ($self->{'config'}{'ldflags'} =~ m-/Debug-i ? $self->{'config'}{'dbgprefix'} : '') - . 'PerlShr/Share' ); - push(@crtls, grep { not /\(/ } split /\s+/, $self->{'config'}{'perllibs'}); - push(@crtls, grep { not /\(/ } split /\s+/, $self->{'config'}{'libc'}); - # In general, we pass through the basic libraries from %Config unchanged. - # The one exception is that if we're building in the Perl source tree, and - # a library spec could be resolved via a logical name, we go to some trouble - # to ensure that the copy in the local tree is used, rather than one to - # which a system-wide logical may point. - if ($self->perl_src) { - my($lib,$locspec,$type); - foreach $lib (@crtls) { - if (($locspec,$type) = $lib =~ m{^([\w\$-]+)(/\w+)?} and $locspec =~ /perl/i) { - if (lc $type eq '/share') { $locspec .= $self->{'config'}{'exe_ext'}; } - elsif (lc $type eq '/library') { $locspec .= $self->{'config'}{'lib_ext'}; } - else { $locspec .= $self->{'config'}{'obj_ext'}; } - $locspec = catfile($self->perl_src, $locspec); - $lib = "$locspec$type" if -e $locspec; - } - } - } - $crtlstr = @crtls ? join(' ',@crtls) : ''; - - unless ($potential_libs) { - warn "Result:\n\tEXTRALIBS: \n\tLDLOADLIBS: $crtlstr\n" if $verbose; - return ('', '', $crtlstr, '', ($give_libs ? [] : ())); - } - - my(@dirs,@libs,$dir,$lib,%found,@fndlibs,$ldlib); - my $cwd = cwd(); - my($so,$lib_ext,$obj_ext) = @{$self->{'config'}}{'so','lib_ext','obj_ext'}; - # List of common Unix library names and their VMS equivalents - # (VMS equivalent of '' indicates that the library is automatically - # searched by the linker, and should be skipped here.) - my(@flibs, %libs_seen); - my %libmap = ( 'm' => '', 'f77' => '', 'F77' => '', 'V77' => '', 'c' => '', - 'malloc' => '', 'crypt' => '', 'resolv' => '', 'c_s' => '', - 'socket' => '', 'X11' => 'DECW$XLIBSHR', - 'Xt' => 'DECW$XTSHR', 'Xm' => 'DECW$XMLIBSHR', - 'Xmu' => 'DECW$XMULIBSHR'); - if ($self->{'config'}{'vms_cc_type'} ne 'decc') { $libmap{'curses'} = 'VAXCCURSE'; } - - warn "Potential libraries are '$potential_libs'\n" if $verbose; - - # First, sort out directories and library names in the input - foreach $lib (split ' ',$potential_libs) { - push(@dirs,$1), next if $lib =~ /^-L(.*)/; - push(@dirs,$lib), next if $lib =~ /[:>\]]$/; - push(@dirs,$lib), next if -d $lib; - push(@libs,$1), next if $lib =~ /^-l(.*)/; - push(@libs,$lib); - } - push(@dirs,split(' ',$self->{'config'}{'libpth'})); - - # Now make sure we've got VMS-syntax absolute directory specs - # (We don't, however, check whether someone's hidden a relative - # path in a logical name.) - foreach $dir (@dirs) { - unless (-d $dir) { - warn "Skipping nonexistent Directory $dir\n" if $verbose > 1; - $dir = ''; - next; - } - warn "Resolving directory $dir\n" if $verbose; - if (!File::Spec->file_name_is_absolute($dir)) { - $dir = catdir($cwd,$dir); - } - } - @dirs = grep { length($_) } @dirs; - unshift(@dirs,''); # Check each $lib without additions first - - LIB: foreach $lib (@libs) { - if (exists $libmap{$lib}) { - next unless length $libmap{$lib}; - $lib = $libmap{$lib}; - } - - my(@variants,$variant,$cand); - my($ctype) = ''; - - # If we don't have a file type, consider it a possibly abbreviated name and - # check for common variants. We try these first to grab libraries before - # a like-named executable image (e.g. -lperl resolves to perlshr.exe - # before perl.exe). - if ($lib !~ /\.[^:>\]]*$/) { - push(@variants,"${lib}shr","${lib}rtl","${lib}lib"); - push(@variants,"lib$lib") if $lib !~ /[:>\]]/; - } - push(@variants,$lib); - warn "Looking for $lib\n" if $verbose; - foreach $variant (@variants) { - my($fullname, $name); - - foreach $dir (@dirs) { - my($type); - - $name = "$dir$variant"; - warn "\tChecking $name\n" if $verbose > 2; - $fullname = VMS::Filespec::rmsexpand($name); - if (defined $fullname and -f $fullname) { - # It's got its own suffix, so we'll have to figure out the type - if ($fullname =~ /(?:$so|exe)$/i) { $type = 'SHR'; } - elsif ($fullname =~ /(?:$lib_ext|olb)$/i) { $type = 'OLB'; } - elsif ($fullname =~ /(?:$obj_ext|obj)$/i) { - warn "Note (probably harmless): " - ."Plain object file $fullname found in library list\n"; - $type = 'OBJ'; - } - else { - warn "Note (probably harmless): " - ."Unknown library type for $fullname; assuming shared\n"; - $type = 'SHR'; - } - } - elsif (-f ($fullname = VMS::Filespec::rmsexpand($name,$so)) or - -f ($fullname = VMS::Filespec::rmsexpand($name,'.exe'))) { - $type = 'SHR'; - $name = $fullname unless $fullname =~ /exe;?\d*$/i; - } - elsif (not length($ctype) and # If we've got a lib already, - # don't bother - ( -f ($fullname = VMS::Filespec::rmsexpand($name,$lib_ext)) or - -f ($fullname = VMS::Filespec::rmsexpand($name,'.olb')))) { - $type = 'OLB'; - $name = $fullname unless $fullname =~ /olb;?\d*$/i; - } - elsif (not length($ctype) and # If we've got a lib already, - # don't bother - ( -f ($fullname = VMS::Filespec::rmsexpand($name,$obj_ext)) or - -f ($fullname = VMS::Filespec::rmsexpand($name,'.obj')))) { - warn "Note (probably harmless): " - ."Plain object file $fullname found in library list\n"; - $type = 'OBJ'; - $name = $fullname unless $fullname =~ /obj;?\d*$/i; - } - if (defined $type) { - $ctype = $type; $cand = $name; - last if $ctype eq 'SHR'; - } - } - if ($ctype) { - # This has to precede any other CRTLs, so just make it first - if ($cand eq 'VAXCCURSE') { unshift @{$found{$ctype}}, $cand; } - else { push @{$found{$ctype}}, $cand; } - warn "\tFound as $cand (really $fullname), type $ctype\n" - if $verbose > 1; - push @flibs, $name unless $libs_seen{$fullname}++; - next LIB; - } - } - warn "Note (probably harmless): " - ."No library found for $lib\n"; - } - - push @fndlibs, @{$found{OBJ}} if exists $found{OBJ}; - push @fndlibs, map { "$_/Library" } @{$found{OLB}} if exists $found{OLB}; - push @fndlibs, map { "$_/Share" } @{$found{SHR}} if exists $found{SHR}; - $lib = join(' ',@fndlibs); - - $ldlib = $crtlstr ? "$lib $crtlstr" : $lib; - warn "Result:\n\tEXTRALIBS: $lib\n\tLDLOADLIBS: $ldlib\n" if $verbose; - wantarray ? ($lib, '', $ldlib, '', ($give_libs ? \@flibs : ())) : $lib; -} - -1; diff --git a/lib/ExtUtils/CBuilder/Platform/Windows.pm b/lib/ExtUtils/CBuilder/Platform/Windows.pm deleted file mode 100644 index 73d53ae874..0000000000 --- a/lib/ExtUtils/CBuilder/Platform/Windows.pm +++ /dev/null @@ -1,684 +0,0 @@ -package ExtUtils::CBuilder::Platform::Windows; - -use strict; -use warnings; - -use File::Basename; -use File::Spec; - -use ExtUtils::CBuilder::Base; -use IO::File; - -use vars qw($VERSION @ISA); -$VERSION = '0.2602'; -@ISA = qw(ExtUtils::CBuilder::Base); - -sub new { - my $class = shift; - my $self = $class->SUPER::new(@_); - my $cf = $self->{config}; - - # Inherit from an appropriate compiler driver class - unshift @ISA, "ExtUtils::CBuilder::Platform::Windows::" . $self->_compiler_type; - - return $self; -} - -sub _compiler_type { - my $self = shift; - my $cc = $self->{config}{cc}; - - return ( $cc =~ /cl(\.exe)?$/ ? 'MSVC' - : $cc =~ /bcc32(\.exe)?$/ ? 'BCC' - : 'GCC'); -} - -sub split_like_shell { - # Since Windows will pass the whole command string (not an argument - # array) to the target program and make the program parse it itself, - # we don't actually need to do any processing here. - (my $self, local $_) = @_; - - return @$_ if defined() && UNIVERSAL::isa($_, 'ARRAY'); - return unless defined() && length(); - return ($_); -} - -sub do_system { - # See above - my $self = shift; - my $cmd = join(" ", - grep length, - map {$a=$_;$a=~s/\t/ /g;$a=~s/^\s+|\s+$//;$a} - grep defined, @_); - return $self->SUPER::do_system($cmd); -} - -sub arg_defines { - my ($self, %args) = @_; - s/"/\\"/g foreach values %args; - return map qq{"-D$_=$args{$_}"}, keys %args; -} - -sub compile { - my ($self, %args) = @_; - my $cf = $self->{config}; - - die "Missing 'source' argument to compile()" unless defined $args{source}; - - my ($basename, $srcdir) = - ( File::Basename::fileparse($args{source}, '\.[^.]+$') )[0,1]; - - $srcdir ||= File::Spec->curdir(); - - my @defines = $self->arg_defines( %{ $args{defines} || {} } ); - - my %spec = ( - srcdir => $srcdir, - builddir => $srcdir, - basename => $basename, - source => $args{source}, - output => File::Spec->catfile($srcdir, $basename) . $cf->{obj_ext}, - cc => $cf->{cc}, - cflags => [ - $self->split_like_shell($cf->{ccflags}), - $self->split_like_shell($cf->{cccdlflags}), - $self->split_like_shell($args{extra_compiler_flags}), - ], - optimize => [ $self->split_like_shell($cf->{optimize}) ], - defines => \@defines, - includes => [ @{$args{include_dirs} || []} ], - perlinc => [ - $self->perl_inc(), - $self->split_like_shell($cf->{incpath}), - ], - use_scripts => 1, # XXX provide user option to change this??? - ); - - $self->normalize_filespecs( - \$spec{source}, - \$spec{output}, - $spec{includes}, - $spec{perlinc}, - ); - - my @cmds = $self->format_compiler_cmd(%spec); - while ( my $cmd = shift @cmds ) { - $self->do_system( @$cmd ) - or die "error building $cf->{dlext} file from '$args{source}'"; - } - - (my $out = $spec{output}) =~ tr/'"//d; - return $out; -} - -sub need_prelink { 1 } - -sub link { - my ($self, %args) = @_; - my $cf = $self->{config}; - - my @objects = ( ref $args{objects} eq 'ARRAY' ? @{$args{objects}} : $args{objects} ); - my $to = join '', (File::Spec->splitpath($objects[0]))[0,1]; - $to ||= File::Spec->curdir(); - - (my $file_base = $args{module_name}) =~ s/.*:://; - my $output = $args{lib_file} || - File::Spec->catfile($to, "$file_base.$cf->{dlext}"); - - # if running in perl source tree, look for libs there, not installed - my $lddlflags = $cf->{lddlflags}; - my $perl_src = $self->perl_src(); - $lddlflags =~ s/\Q$cf->{archlibexp}\E[\\\/]CORE/$perl_src/ if $perl_src; - - my %spec = ( - srcdir => $to, - builddir => $to, - startup => [ ], - objects => \@objects, - libs => [ ], - output => $output, - ld => $cf->{ld}, - libperl => $cf->{libperl}, - perllibs => [ $self->split_like_shell($cf->{perllibs}) ], - libpath => [ $self->split_like_shell($cf->{libpth}) ], - lddlflags => [ $self->split_like_shell($lddlflags) ], - other_ldflags => [ $self->split_like_shell($args{extra_linker_flags} || '') ], - use_scripts => 1, # XXX provide user option to change this??? - ); - - unless ( $spec{basename} ) { - ($spec{basename} = $args{module_name}) =~ s/.*:://; - } - - $spec{srcdir} = File::Spec->canonpath( $spec{srcdir} ); - $spec{builddir} = File::Spec->canonpath( $spec{builddir} ); - - $spec{output} ||= File::Spec->catfile( $spec{builddir}, - $spec{basename} . '.'.$cf->{dlext} ); - $spec{manifest} ||= File::Spec->catfile( $spec{builddir}, - $spec{basename} . '.'.$cf->{dlext}.'.manifest'); - $spec{implib} ||= File::Spec->catfile( $spec{builddir}, - $spec{basename} . $cf->{lib_ext} ); - $spec{explib} ||= File::Spec->catfile( $spec{builddir}, - $spec{basename} . '.exp' ); - if ($cf->{cc} eq 'cl') { - $spec{dbg_file} ||= File::Spec->catfile( $spec{builddir}, - $spec{basename} . '.pdb' ); - } - elsif ($cf->{cc} eq 'bcc32') { - $spec{dbg_file} ||= File::Spec->catfile( $spec{builddir}, - $spec{basename} . '.tds' ); - } - $spec{def_file} ||= File::Spec->catfile( $spec{srcdir} , - $spec{basename} . '.def' ); - $spec{base_file} ||= File::Spec->catfile( $spec{srcdir} , - $spec{basename} . '.base' ); - - $self->add_to_cleanup( - grep defined, - @{[ @spec{qw(manifest implib explib dbg_file def_file base_file map_file)} ]} - ); - - foreach my $opt ( qw(output manifest implib explib dbg_file def_file map_file base_file) ) { - $self->normalize_filespecs( \$spec{$opt} ); - } - - foreach my $opt ( qw(libpath startup objects) ) { - $self->normalize_filespecs( $spec{$opt} ); - } - - (my $def_base = $spec{def_file}) =~ tr/'"//d; - $def_base =~ s/\.def$//; - $self->prelink( dl_name => $args{module_name}, - dl_file => $def_base, - dl_base => $spec{basename} ); - - my @cmds = $self->format_linker_cmd(%spec); - while ( my $cmd = shift @cmds ) { - $self->do_system( @$cmd ); - } - - $spec{output} =~ tr/'"//d; - return wantarray - ? grep defined, @spec{qw[output manifest implib explib dbg_file def_file map_file base_file]} - : $spec{output}; -} - -# canonize & quote paths -sub normalize_filespecs { - my ($self, @specs) = @_; - foreach my $spec ( grep defined, @specs ) { - if ( ref $spec eq 'ARRAY') { - $self->normalize_filespecs( map {\$_} grep defined, @$spec ) - } elsif ( ref $spec eq 'SCALAR' ) { - $$spec =~ tr/"//d if $$spec; - next unless $$spec; - $$spec = '"' . File::Spec->canonpath($$spec) . '"'; - } elsif ( ref $spec eq '' ) { - $spec = '"' . File::Spec->canonpath($spec) . '"'; - } else { - die "Don't know how to normalize " . (ref $spec || $spec) . "\n"; - } - } -} - -# directory of perl's include files -sub perl_inc { - my $self = shift; - - my $perl_src = $self->perl_src(); - - if ($perl_src) { - File::Spec->catdir($perl_src, "lib", "CORE"); - } else { - File::Spec->catdir($self->{config}{archlibexp},"CORE"); - } -} - -1; - -######################################################################## - -=begin comment - -The packages below implement functions for generating properly -formatted commandlines for the compiler being used. Each package -defines two primary functions 'format_linker_cmd()' & -'format_compiler_cmd()' that accepts a list of named arguments (a -hash) and returns a list of formatted options suitable for invoking the -compiler. By default, if the compiler supports scripting of its -operation then a script file is built containing the options while -those options are removed from the commandline, and a reference to the -script is pushed onto the commandline in their place. Scripting the -compiler in this way helps to avoid the problems associated with long -commandlines under some shells. - -=end comment - -=cut - -######################################################################## -package ExtUtils::CBuilder::Platform::Windows::MSVC; - -sub format_compiler_cmd { - my ($self, %spec) = @_; - - foreach my $path ( @{ $spec{includes} || [] }, - @{ $spec{perlinc} || [] } ) { - $path = '-I' . $path; - } - - %spec = $self->write_compiler_script(%spec) - if $spec{use_scripts}; - - return [ grep {defined && length} ( - $spec{cc},'-nologo','-c', - @{$spec{includes}} , - @{$spec{cflags}} , - @{$spec{optimize}} , - @{$spec{defines}} , - @{$spec{perlinc}} , - "-Fo$spec{output}" , - $spec{source} , - ) ]; -} - -sub write_compiler_script { - my ($self, %spec) = @_; - - my $script = File::Spec->catfile( $spec{srcdir}, - $spec{basename} . '.ccs' ); - - $self->add_to_cleanup($script); - print "Generating script '$script'\n" if !$self->{quiet}; - - my $SCRIPT = IO::File->new( ">$script" ) - or die( "Could not create script '$script': $!" ); - - print $SCRIPT join( "\n", - map { ref $_ ? @{$_} : $_ } - grep defined, - delete( - @spec{ qw(includes cflags optimize defines perlinc) } ) - ); - - push @{$spec{includes}}, '@"' . $script . '"'; - - return %spec; -} - -sub format_linker_cmd { - my ($self, %spec) = @_; - my $cf = $self->{config}; - - foreach my $path ( @{$spec{libpath}} ) { - $path = "-libpath:$path"; - } - - my $output = $spec{output}; - - $spec{def_file} &&= '-def:' . $spec{def_file}; - $spec{output} &&= '-out:' . $spec{output}; - $spec{manifest} &&= '-manifest ' . $spec{manifest}; - $spec{implib} &&= '-implib:' . $spec{implib}; - $spec{map_file} &&= '-map:' . $spec{map_file}; - - %spec = $self->write_linker_script(%spec) - if $spec{use_scripts}; - - my @cmds; # Stores the series of commands needed to build the module. - - push @cmds, [ grep {defined && length} ( - $spec{ld} , - @{$spec{lddlflags}} , - @{$spec{libpath}} , - @{$spec{other_ldflags}} , - @{$spec{startup}} , - @{$spec{objects}} , - $spec{map_file} , - $spec{libperl} , - @{$spec{perllibs}} , - $spec{def_file} , - $spec{implib} , - $spec{output} , - ) ]; - - # Embed the manifest file for VC 2005 (aka VC 8) or higher, but not for the 64-bit Platform SDK compiler - if ($cf->{ivsize} == 4 && $cf->{cc} eq 'cl' and $cf->{ccversion} =~ /^(\d+)/ and $1 >= 14) { - push @cmds, [ - 'if', 'exist', $spec{manifest}, 'mt', '-nologo', $spec{manifest}, '-outputresource:' . "$output;2" - ]; - } - - return @cmds; -} - -sub write_linker_script { - my ($self, %spec) = @_; - - my $script = File::Spec->catfile( $spec{srcdir}, - $spec{basename} . '.lds' ); - - $self->add_to_cleanup($script); - - print "Generating script '$script'\n" if !$self->{quiet}; - - my $SCRIPT = IO::File->new( ">$script" ) - or die( "Could not create script '$script': $!" ); - - print $SCRIPT join( "\n", - map { ref $_ ? @{$_} : $_ } - grep defined, - delete( - @spec{ qw(lddlflags libpath other_ldflags - startup objects libperl perllibs - def_file implib map_file) } ) - ); - - push @{$spec{lddlflags}}, '@"' . $script . '"'; - - return %spec; -} - -1; - -######################################################################## -package ExtUtils::CBuilder::Platform::Windows::BCC; - -sub format_compiler_cmd { - my ($self, %spec) = @_; - - foreach my $path ( @{ $spec{includes} || [] }, - @{ $spec{perlinc} || [] } ) { - $path = '-I' . $path; - } - - %spec = $self->write_compiler_script(%spec) - if $spec{use_scripts}; - - return [ grep {defined && length} ( - $spec{cc}, '-c' , - @{$spec{includes}} , - @{$spec{cflags}} , - @{$spec{optimize}} , - @{$spec{defines}} , - @{$spec{perlinc}} , - "-o$spec{output}" , - $spec{source} , - ) ]; -} - -sub write_compiler_script { - my ($self, %spec) = @_; - - my $script = File::Spec->catfile( $spec{srcdir}, - $spec{basename} . '.ccs' ); - - $self->add_to_cleanup($script); - - print "Generating script '$script'\n" if !$self->{quiet}; - - my $SCRIPT = IO::File->new( ">$script" ) - or die( "Could not create script '$script': $!" ); - - # XXX Borland "response files" seem to be unable to accept macro - # definitions containing quoted strings. Escaping strings with - # backslash doesn't work, and any level of quotes are stripped. The - # result is is a floating point number in the source file where a - # string is expected. So we leave the macros on the command line. - print $SCRIPT join( "\n", - map { ref $_ ? @{$_} : $_ } - grep defined, - delete( - @spec{ qw(includes cflags optimize perlinc) } ) - ); - - push @{$spec{includes}}, '@"' . $script . '"'; - - return %spec; -} - -sub format_linker_cmd { - my ($self, %spec) = @_; - - foreach my $path ( @{$spec{libpath}} ) { - $path = "-L$path"; - } - - push( @{$spec{startup}}, 'c0d32.obj' ) - unless ( $spec{starup} && @{$spec{startup}} ); - - %spec = $self->write_linker_script(%spec) - if $spec{use_scripts}; - - return [ grep {defined && length} ( - $spec{ld} , - @{$spec{lddlflags}} , - @{$spec{libpath}} , - @{$spec{other_ldflags}} , - @{$spec{startup}} , - @{$spec{objects}} , ',', - $spec{output} , ',', - $spec{map_file} , ',', - $spec{libperl} , - @{$spec{perllibs}} , ',', - $spec{def_file} - ) ]; -} - -sub write_linker_script { - my ($self, %spec) = @_; - - # To work around Borlands "unique" commandline syntax, - # two scripts are used: - - my $ld_script = File::Spec->catfile( $spec{srcdir}, - $spec{basename} . '.lds' ); - my $ld_libs = File::Spec->catfile( $spec{srcdir}, - $spec{basename} . '.lbs' ); - - $self->add_to_cleanup($ld_script, $ld_libs); - - print "Generating scripts '$ld_script' and '$ld_libs'.\n" if !$self->{quiet}; - - # Script 1: contains options & names of object files. - my $LD_SCRIPT = IO::File->new( ">$ld_script" ) - or die( "Could not create linker script '$ld_script': $!" ); - - print $LD_SCRIPT join( " +\n", - map { @{$_} } - grep defined, - delete( - @spec{ qw(lddlflags libpath other_ldflags startup objects) } ) - ); - - # Script 2: contains name of libs to link against. - my $LD_LIBS = IO::File->new( ">$ld_libs" ) - or die( "Could not create linker script '$ld_libs': $!" ); - - print $LD_LIBS join( " +\n", - (delete $spec{libperl} || ''), - @{delete $spec{perllibs} || []}, - ); - - push @{$spec{lddlflags}}, '@"' . $ld_script . '"'; - push @{$spec{perllibs}}, '@"' . $ld_libs . '"'; - - return %spec; -} - -1; - -######################################################################## -package ExtUtils::CBuilder::Platform::Windows::GCC; - -sub format_compiler_cmd { - my ($self, %spec) = @_; - - foreach my $path ( @{ $spec{includes} || [] }, - @{ $spec{perlinc} || [] } ) { - $path = '-I' . $path; - } - - # split off any -arguments included in cc - my @cc = split / (?=-)/, $spec{cc}; - - return [ grep {defined && length} ( - @cc, '-c' , - @{$spec{includes}} , - @{$spec{cflags}} , - @{$spec{optimize}} , - @{$spec{defines}} , - @{$spec{perlinc}} , - '-o', $spec{output} , - $spec{source} , - ) ]; -} - -sub format_linker_cmd { - my ($self, %spec) = @_; - - # The Config.pm variable 'libperl' is hardcoded to the full name - # of the perl import library (i.e. 'libperl56.a'). GCC will not - # find it unless the 'lib' prefix & the extension are stripped. - $spec{libperl} =~ s/^(?:lib)?([^.]+).*$/-l$1/; - - unshift( @{$spec{other_ldflags}}, '-nostartfiles' ) - if ( $spec{startup} && @{$spec{startup}} ); - - # From ExtUtils::MM_Win32: - # - ## one thing for GCC/Mingw32: - ## we try to overcome non-relocateable-DLL problems by generating - ## a (hopefully unique) image-base from the dll's name - ## -- BKS, 10-19-1999 - File::Basename::basename( $spec{output} ) =~ /(....)(.{0,4})/; - $spec{image_base} = sprintf( "0x%x0000", unpack('n', $1 ^ $2) ); - - %spec = $self->write_linker_script(%spec) - if $spec{use_scripts}; - - foreach my $path ( @{$spec{libpath}} ) { - $path = "-L$path"; - } - - my @cmds; # Stores the series of commands needed to build the module. - - push @cmds, [ - 'dlltool', '--def' , $spec{def_file}, - '--output-exp' , $spec{explib} - ]; - - # split off any -arguments included in ld - my @ld = split / (?=-)/, $spec{ld}; - - push @cmds, [ grep {defined && length} ( - @ld , - '-o', $spec{output} , - "-Wl,--base-file,$spec{base_file}" , - "-Wl,--image-base,$spec{image_base}" , - @{$spec{lddlflags}} , - @{$spec{libpath}} , - @{$spec{startup}} , - @{$spec{objects}} , - @{$spec{other_ldflags}} , - $spec{libperl} , - @{$spec{perllibs}} , - $spec{explib} , - $spec{map_file} ? ('-Map', $spec{map_file}) : '' - ) ]; - - push @cmds, [ - 'dlltool', '--def' , $spec{def_file}, - '--output-exp' , $spec{explib}, - '--base-file' , $spec{base_file} - ]; - - push @cmds, [ grep {defined && length} ( - @ld , - '-o', $spec{output} , - "-Wl,--image-base,$spec{image_base}" , - @{$spec{lddlflags}} , - @{$spec{libpath}} , - @{$spec{startup}} , - @{$spec{objects}} , - @{$spec{other_ldflags}} , - $spec{libperl} , - @{$spec{perllibs}} , - $spec{explib} , - $spec{map_file} ? ('-Map', $spec{map_file}) : '' - ) ]; - - return @cmds; -} - -sub write_linker_script { - my ($self, %spec) = @_; - - my $script = File::Spec->catfile( $spec{srcdir}, - $spec{basename} . '.lds' ); - - $self->add_to_cleanup($script); - - print "Generating script '$script'\n" if !$self->{quiet}; - - my $SCRIPT = IO::File->new( ">$script" ) - or die( "Could not create script '$script': $!" ); - - print $SCRIPT ( 'SEARCH_DIR(' . $_ . ")\n" ) - for @{delete $spec{libpath} || []}; - - # gcc takes only one startup file, so the first object in startup is - # specified as the startup file and any others are shifted into the - # beginning of the list of objects. - if ( $spec{startup} && @{$spec{startup}} ) { - print $SCRIPT 'STARTUP(' . shift( @{$spec{startup}} ) . ")\n"; - unshift @{$spec{objects}}, - @{delete $spec{startup} || []}; - } - - print $SCRIPT 'INPUT(' . join( ',', - @{delete $spec{objects} || []} - ) . ")\n"; - - print $SCRIPT 'INPUT(' . join( ' ', - (delete $spec{libperl} || ''), - @{delete $spec{perllibs} || []}, - ) . ")\n"; - - push @{$spec{other_ldflags}}, '"' . $script . '"'; - - return %spec; -} - -1; - -__END__ - -=head1 NAME - -ExtUtils::CBuilder::Platform::Windows - Builder class for Windows platforms - -=head1 DESCRIPTION - -This module implements the Windows-specific parts of ExtUtils::CBuilder. -Most of the Windows-specific stuff has to do with compiling and -linking C code. Currently we support the 3 compilers perl itself -supports: MSVC, BCC, and GCC. - -This module inherits from C<ExtUtils::CBuilder::Base>, so any functionality -not implemented here will be implemented there. The interfaces are -defined by the L<ExtUtils::CBuilder> documentation. - -=head1 AUTHOR - -Ken Williams <ken@mathforum.org> - -Most of the code here was written by Randy W. Sims <RandyS@ThePierianSpring.org>. - -=head1 SEE ALSO - -perl(1), ExtUtils::CBuilder(3), ExtUtils::MakeMaker(3) - -=cut diff --git a/lib/ExtUtils/CBuilder/Platform/aix.pm b/lib/ExtUtils/CBuilder/Platform/aix.pm deleted file mode 100644 index 011ef81140..0000000000 --- a/lib/ExtUtils/CBuilder/Platform/aix.pm +++ /dev/null @@ -1,31 +0,0 @@ -package ExtUtils::CBuilder::Platform::aix; - -use strict; -use ExtUtils::CBuilder::Platform::Unix; -use File::Spec; - -use vars qw($VERSION @ISA); -$VERSION = '0.2602'; -@ISA = qw(ExtUtils::CBuilder::Platform::Unix); - -sub need_prelink { 1 } - -sub link { - my ($self, %args) = @_; - my $cf = $self->{config}; - - (my $baseext = $args{module_name}) =~ s/.*:://; - my $perl_inc = $self->perl_inc(); - - # Massage some very naughty bits in %Config - local $cf->{lddlflags} = $cf->{lddlflags}; - for ($cf->{lddlflags}) { - s/\Q$(BASEEXT)\E/$baseext/; - s/\Q$(PERL_INC)\E/$perl_inc/; - } - - return $self->SUPER::link(%args); -} - - -1; diff --git a/lib/ExtUtils/CBuilder/Platform/cygwin.pm b/lib/ExtUtils/CBuilder/Platform/cygwin.pm deleted file mode 100644 index 7f996dc5be..0000000000 --- a/lib/ExtUtils/CBuilder/Platform/cygwin.pm +++ /dev/null @@ -1,30 +0,0 @@ -package ExtUtils::CBuilder::Platform::cygwin; - -use strict; -use File::Spec; -use ExtUtils::CBuilder::Platform::Unix; - -use vars qw($VERSION @ISA); -$VERSION = '0.2602'; -@ISA = qw(ExtUtils::CBuilder::Platform::Unix); - -sub link_executable { - my $self = shift; - # $Config{ld} is okay. Circumvent the Unix ld=cc override in the superclass. - local $self->{config}{cc} = $self->{config}{ld}; - return $self->SUPER::link_executable(@_); -} - -sub link { - my ($self, %args) = @_; - - my $lib = $self->{config}{useshrplib} ? 'libperl.dll.a' : 'libperl.a'; - $args{extra_linker_flags} = [ - File::Spec->catfile($self->perl_inc(), $lib), - $self->split_like_shell($args{extra_linker_flags}) - ]; - - return $self->SUPER::link(%args); -} - -1; diff --git a/lib/ExtUtils/CBuilder/Platform/darwin.pm b/lib/ExtUtils/CBuilder/Platform/darwin.pm deleted file mode 100644 index 45c03a8f58..0000000000 --- a/lib/ExtUtils/CBuilder/Platform/darwin.pm +++ /dev/null @@ -1,22 +0,0 @@ -package ExtUtils::CBuilder::Platform::darwin; - -use strict; -use ExtUtils::CBuilder::Platform::Unix; - -use vars qw($VERSION @ISA); -$VERSION = '0.2602'; -@ISA = qw(ExtUtils::CBuilder::Platform::Unix); - -sub compile { - my $self = shift; - my $cf = $self->{config}; - - # -flat_namespace isn't a compile flag, it's a linker flag. But - # it's mistakenly in Config.pm as both. Make the correction here. - local $cf->{ccflags} = $cf->{ccflags}; - $cf->{ccflags} =~ s/-flat_namespace//; - $self->SUPER::compile(@_); -} - - -1; diff --git a/lib/ExtUtils/CBuilder/Platform/dec_osf.pm b/lib/ExtUtils/CBuilder/Platform/dec_osf.pm deleted file mode 100644 index 65344f2555..0000000000 --- a/lib/ExtUtils/CBuilder/Platform/dec_osf.pm +++ /dev/null @@ -1,18 +0,0 @@ -package ExtUtils::CBuilder::Platform::dec_osf; - -use strict; -use ExtUtils::CBuilder::Platform::Unix; -use File::Spec; - -use vars qw($VERSION @ISA); -@ISA = qw(ExtUtils::CBuilder::Platform::Unix); -$VERSION = '0.2602'; - -sub link_executable { - my $self = shift; - # $Config{ld} is 'ld' but that won't work: use the cc instead. - local $self->{config}{ld} = $self->{config}{cc}; - return $self->SUPER::link_executable(@_); -} - -1; diff --git a/lib/ExtUtils/CBuilder/Platform/os2.pm b/lib/ExtUtils/CBuilder/Platform/os2.pm deleted file mode 100644 index 16648901b2..0000000000 --- a/lib/ExtUtils/CBuilder/Platform/os2.pm +++ /dev/null @@ -1,80 +0,0 @@ -package ExtUtils::CBuilder::Platform::os2; - -use strict; -use ExtUtils::CBuilder::Platform::Unix; - -use vars qw($VERSION @ISA); -$VERSION = '0.2602'; -@ISA = qw(ExtUtils::CBuilder::Platform::Unix); - -sub need_prelink { 1 } - -sub prelink { - # Generate import libraries (XXXX currently near .DEF; should be near DLL!) - my $self = shift; - my %args = @_; - - my @res = $self->SUPER::prelink(%args); - die "Unexpected number of DEF files" unless @res == 1; - die "Can't find DEF file in the output" - unless $res[0] =~ m,^(.*)\.def$,si; - my $libname = "$1$self->{config}{lib_ext}"; # Put .LIB file near .DEF file - $self->do_system('emximp', '-o', $libname, $res[0]) or die "emxexp: res=$?"; - return (@res, $libname); -} - -sub _do_link { - my $self = shift; - my ($how, %args) = @_; - if ($how eq 'lib_file' - and (defined $args{module_name} and length $args{module_name})) { - - # DynaLoader::mod2fname() is a builtin func - my $lib = DynaLoader::mod2fname([split /::/, $args{module_name}]); - - # Now know the basename, find directory parts via lib_file, or objects - my $objs = ( (ref $args{objects}) ? $args{objects} : [$args{objects}] ); - my $near_obj = $self->lib_file(@$objs); - my $ref_file = ( defined $args{lib_file} ? $args{lib_file} : $near_obj ); - my $lib_dir = ($ref_file =~ m,(.*)[/\\],s ? "$1/" : '' ); - my $exp_dir = ($near_obj =~ m,(.*)[/\\],s ? "$1/" : '' ); - - $args{dl_file} = $1 if $near_obj =~ m,(.*)\.,s; # put ExportList near OBJ - $args{lib_file} = "$lib_dir$lib.$self->{config}{dlext}"; # DLL file - - # XXX _do_link does not have place to put libraries? - push @$objs, $self->perl_inc() . "/libperl$self->{config}{lib_ext}"; - $args{objects} = $objs; - } - # Some 'env' do exec(), thus return too early when run from ksh; - # To avoid 'env', remove (useless) shrpenv - local $self->{config}{shrpenv} = ''; - return $self->SUPER::_do_link($how, %args); -} - -sub extra_link_args_after_prelink { - # Add .DEF file to the link line - my ($self, %args) = @_; - - my @DEF = grep /\.def$/i, @{$args{prelink_res}}; - die "More than one .def files created by `prelink' stage" if @DEF > 1; - # XXXX No "$how" argument here, so how to test for dynamic link? - die "No .def file created by `prelink' stage" - unless @DEF or not @{$args{prelink_res}}; - - my @after_libs = ($OS2::is_aout ? () - : $self->perl_inc() . "/libperl_override$self->{config}{lib_ext}"); - # , "-L", "-lperl" - (@after_libs, @DEF); -} - -sub link_executable { - # ldflags is not expecting .exe extension given on command line; remove -Zexe - my $self = shift; - local $self->{config}{ldflags} = $self->{config}{ldflags}; - $self->{config}{ldflags} =~ s/(?<!\S)-Zexe(?!\S)//; - return $self->SUPER::link_executable(@_); -} - - -1; diff --git a/lib/ExtUtils/CBuilder/t/00-have-compiler.t b/lib/ExtUtils/CBuilder/t/00-have-compiler.t deleted file mode 100644 index cf62e97f2f..0000000000 --- a/lib/ExtUtils/CBuilder/t/00-have-compiler.t +++ /dev/null @@ -1,43 +0,0 @@ -#! perl -w - -use File::Spec; -my $perl; -BEGIN { - $perl = File::Spec->rel2abs($^X); - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - chdir '../lib/ExtUtils/CBuilder' - or die "Can't chdir to lib/ExtUtils/CBuilder: $!"; - @INC = qw(../..); - } -} - -use strict; -use Test::More; -BEGIN { - if ($^O eq 'VMS') { - # So we can get the return value of system() - require vmsish; - import vmsish; - } -} - -plan tests => 4; - -require_ok "ExtUtils::CBuilder"; - -my $b = eval { ExtUtils::CBuilder->new(quiet => 1) }; -ok( $b, "got CBuilder object" ) or diag $@; - -# test missing compiler -$b->{config}{cc} = 'djaadjfkadjkfajdf'; -$b->{config}{ld} = 'djaadjfkadjkfajdf'; -is( $b->have_compiler, 0, "have_compiler: fake missing cc" ); - -# test found compiler -$b->{have_compiler} = undef; -$b->{config}{cc} = "$perl -e1 --"; -$b->{config}{ld} = "$perl -e1 --"; -is( $b->have_compiler, 1, "have_compiler: fake present cc" ); - - diff --git a/lib/ExtUtils/CBuilder/t/01-basic.t b/lib/ExtUtils/CBuilder/t/01-basic.t deleted file mode 100644 index 79a0b0c0eb..0000000000 --- a/lib/ExtUtils/CBuilder/t/01-basic.t +++ /dev/null @@ -1,81 +0,0 @@ -#! perl -w - -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - chdir '../lib/ExtUtils/CBuilder' - or die "Can't chdir to lib/ExtUtils/CBuilder: $!"; - @INC = qw(../..); - } -} - -use strict; -use Test::More; -BEGIN { - if ($^O eq 'VMS') { - # So we can get the return value of system() - require vmsish; - import vmsish; - } -} -use ExtUtils::CBuilder; -use File::Spec; - -# TEST doesn't like extraneous output -my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE}; -my ($source_file, $object_file, $lib_file); - -my $b = ExtUtils::CBuilder->new(quiet => $quiet); - -# test plan -if ( ! $b->have_compiler ) { - plan skip_all => "no compiler available for testing"; -} -else { - plan tests => 10; -} - -ok $b, "created EU::CB object"; - -ok $b->have_compiler, "have_compiler"; - -$source_file = File::Spec->catfile('t', 'compilet.c'); -{ - local *FH; - open FH, "> $source_file" or die "Can't create $source_file: $!"; - print FH "int boot_compilet(void) { return 1; }\n"; - close FH; -} -ok -e $source_file, "source file '$source_file' created"; - -$object_file = $b->object_file($source_file); -ok 1; - -is $object_file, $b->compile(source => $source_file); - -$lib_file = $b->lib_file($object_file); -ok 1; - -my ($lib, @temps) = $b->link(objects => $object_file, - module_name => 'compilet'); -$lib =~ tr/"'//d; -is $lib_file, $lib; - -for ($source_file, $object_file, $lib_file) { - tr/"'//d; - 1 while unlink; -} - -if ($^O eq 'VMS') { - 1 while unlink 'COMPILET.LIS'; - 1 while unlink 'COMPILET.OPT'; -} - -my @words = $b->split_like_shell(' foo bar'); - -SKIP: { - skip "MSWindows", 3 if $^O =~ m/MSWin/; - is( @words, 2 ); - is( $words[0], 'foo' ); - is( $words[1], 'bar' ); -} diff --git a/lib/ExtUtils/CBuilder/t/02-link.t b/lib/ExtUtils/CBuilder/t/02-link.t deleted file mode 100644 index c748d3b75a..0000000000 --- a/lib/ExtUtils/CBuilder/t/02-link.t +++ /dev/null @@ -1,99 +0,0 @@ -#! perl -w - -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - chdir '../lib/ExtUtils/CBuilder' - or die "Can't chdir to lib/ExtUtils/CBuilder: $!"; - @INC = qw(../..); - } -} - -use strict; -use Test::More; -BEGIN { - if ($^O eq 'VMS') { - # So we can get the return value of system() - require vmsish; - import vmsish; - } -} -use ExtUtils::CBuilder; -use File::Spec; - -# TEST doesn't like extraneous output -my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE}; -my ($source_file, $object_file, $exe_file); - -my $b = ExtUtils::CBuilder->new(quiet => $quiet); - -# test plan -if ($^O eq 'MSWin32') { - plan skip_all => "link_executable() is not implemented yet on Win32"; -} -elsif ( ! $b->have_compiler ) { - plan skip_all => "no compiler available for testing"; -} -else { - plan tests => 7; -} - -ok $b, "created EU::CB object"; - -$source_file = File::Spec->catfile('t', 'compilet.c'); -{ - local *FH; - open FH, "> $source_file" or die "Can't create $source_file: $!"; - print FH "int main(void) { return 11; }\n"; - close FH; -} -ok -e $source_file, "generated '$source_file'"; - -# Compile -eval { $object_file = $b->compile(source => $source_file) }; -is $@, q{}, "no exception from compilation"; -ok -e $object_file, "found object file"; - -# Link -SKIP: { - skip "error compiling source", 3 - unless -e $object_file; - - my @temps; - eval { ($exe_file, @temps) = $b->link_executable(objects => $object_file) }; - is $@, q{}, "no exception from linking"; - ok -e $exe_file, "found executable file"; - - if ($^O eq 'os2') { # Analogue of LDLOADPATH... - # Actually, not needed now, since we do not link with the generated DLL - my $old = OS2::extLibpath(); # [builtin function] - $old = ";$old" if defined $old and length $old; - # To pass the sanity check, components must have backslashes... - OS2::extLibpath_set(".\\$old"); - } - - # Try the executable - my $ec = my_system($exe_file); - is $ec, 11, "got expected exit code from executable" - or print( $? == -1 ? "# Could not run '$exe_file'\n" - : "# Unexpected exit code '$ec'\n"); -} - -# Clean up -for ($source_file, $object_file, $exe_file) { - tr/"'//d; - 1 while unlink; -} - -if ($^O eq 'VMS') { - 1 while unlink 'COMPILET.LIS'; - 1 while unlink 'COMPILET.OPT'; -} - -sub my_system { - my $cmd = shift; - if ($^O eq 'VMS') { - return system("mcr $cmd"); - } - return system($cmd) >> 8; -} |