home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Updates / Perl / Non-RPC / !Perl / riscos / ExtUtils / MM_RISCOS.pm
Text File  |  1999-02-20  |  9KB  |  307 lines

  1. package ExtUtils::MM_RISCOS;
  2.  
  3. unshift @MM::ISA, 'ExtUtils::MM_RISCOS';
  4.  
  5. use vars qw($Revision);
  6. $Revision = '0.01 (3-May-1998)';
  7.  
  8. Exporter::import('ExtUtils::MakeMaker',
  9.     qw( $Verbose &neatvalue));
  10.  
  11. =item dlsyms (o)
  12.  
  13. Used by AIX and VMS to define DL_FUNCS and DL_VARS and write the *.exp
  14. files.
  15.  
  16. =cut
  17.  
  18. sub dlsyms {
  19.     my($self,%attribs) = @_;
  20.  
  21.     return '' unless $self->needs_linking();
  22.  
  23.     my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
  24.     my($vars)  = $attribs{DL_VARS} || $self->{DL_VARS} || [];
  25.     my(@m);
  26.  
  27.     push(@m,"
  28. dynamic :: $self->{BASEEXT}.map
  29.  
  30. ") unless $self->{SKIPHASH}{'dynamic'}; # dynamic and static are subs, so...
  31.  
  32.     push(@m,"
  33. static :: $self->{BASEEXT}.map
  34.  
  35. ") unless $self->{SKIPHASH}{'static'};  # we avoid a warning if we tick them
  36.  
  37.     push(@m,"
  38. $self->{BASEEXT}.map: Makefile.PL
  39. ",'    $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::Mksymlists; \\
  40.     Mksymlists("NAME" => "',$self->{NAME},'", "DL_FUNCS" => ',
  41.     neatvalue($funcs),', "DL_VARS" => ', neatvalue($vars), ');\'
  42. ');
  43.  
  44.     join('',@m);
  45. }
  46.  
  47. =item dynamic_lib (o)
  48.  
  49. Defines how to produce the *.so (or equivalent) files.
  50.  
  51. =cut
  52.  
  53. sub dynamic_lib {
  54.     my($self, %attribs) = @_;
  55.     return '' unless $self->needs_linking(); #might be because of a subdir
  56.  
  57.     return '' unless $self->has_link_code;
  58.  
  59.     my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
  60.     my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
  61.     my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":";
  62.     my($ldfrom) = '$(LDFROM)';
  63.     $armaybe = 'ar' if ($^O eq 'dec_osf' and $armaybe eq ':');
  64.     my(@m);
  65.     push(@m,'
  66. # This section creates the dynamically loadable $(INST_DYNAMIC)
  67. # from $(OBJECT) and possibly $(MYEXTLIB).
  68. ARMAYBE = '.$armaybe.'
  69. OTHERLDFLAGS = '.$otherldflags.'
  70. INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
  71.  
  72. $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
  73. ');
  74.     if ($armaybe ne ':'){
  75.     $ldfrom = 'tmp$(LIB_EXT)';
  76.     push(@m,'    $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
  77.     push(@m,'    $(RANLIB) '."$ldfrom\n");
  78.     }
  79.     $ldfrom = "-all $ldfrom -none" if ($^O eq 'dec_osf');
  80.  
  81.     # Brain dead solaris linker does not use LD_RUN_PATH?
  82.     # This fixes dynamic extensions which need shared libs
  83.     my $ldrun = '';
  84.     $ldrun = join ' ', map "-R$_", split /:/, $self->{LD_RUN_PATH}
  85.        if ($^O eq 'solaris');
  86.  
  87.     # The IRIX linker also doesn't use LD_RUN_PATH
  88.     $ldrun = qq{-rpath "$self->{LD_RUN_PATH}"}
  89.     if ($^O eq 'irix' && $self->{LD_RUN_PATH});
  90.  
  91.     push(@m,'    miniperl /PerlDev:dynamic_ld -o $@ '.$ldrun.' $(LDDLFLAGS) '.$ldfrom.
  92.         ' $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) $(EXPORT_LIST)');
  93.     push @m, '
  94.     $(CHMOD) $(PERM_RWX) $@
  95. ';
  96.  
  97.     push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
  98.  
  99.     if (defined $self->{PERL_SRC} and $self->{INSTALLDIRS} eq "perl") {
  100.     my $wanted = "$self->{PERL_SRC}/$self->{NAME}.wanted";
  101.     $wanted =~ s/::/./g;
  102.     push(@m,"
  103. dynamic_externals:    $wanted
  104.  
  105. $wanted:".'    $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
  106.     miniperl /perldev:extractsym_wrapper -o $@ '.$ldrun.' $(LDDLFLAGS) '.$ldfrom.
  107.         ' $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS)');
  108.     }
  109.     join('',@m);
  110. }
  111. #    push(@m,'    miniperl /PerlDev:dynamic_obj $(LD) $@  $(LDFROM) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) $(EXPORT_LIST)');
  112.  
  113. sub init_others {
  114.     my($self) = @_;
  115.  
  116.     $self->{FIRST_MAKEFILE} ||= "Makefile";
  117.     $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
  118.     $self->{MAKE_APERL_FILE} ||= "Makefile.aperl";
  119.     $self->{TOUCH} ||= "touch";
  120.     $self->{TEST_F} ||= "test -f";
  121.     $self->{CP} ||= "cp";
  122.     $self->{MV} ||= "mv";
  123.     $self->{CHMOD} ||= "chmod";
  124.     $self->{UMASK_NULL} ||= "umask 0";
  125.  
  126.     $self->{NOOP} = '*| noop';
  127.     $self->{CP} = "miniperl -S unix_cp";
  128.     $self->{MV} = "miniperl -S unix_mv";
  129.     $self->{RM_F} = "miniperl -S unix_rm -f";    # Keep CLI length below 256
  130.     $self->{RM_RF} = "miniperl -S unix_rm -rf";
  131.     $self->{NOECHO}  = '@';
  132.     $self->{DEV_NULL} = "> null: 2>&1";
  133.     &ExtUtils::MM_Unix::init_others;
  134. }
  135.  
  136. sub constants {
  137.     # Hack *only* the bit that gets written to the makefile, as MakeMaker itself
  138.     # calls $self->{PERL} and expects it to be Unix style
  139.     my $self = $_[0];
  140.     local $self->{PERL} = RISCOS::Filespec::riscosify $self->{PERL};
  141.     &ExtUtils::MM_Unix::constants;
  142. }
  143.  
  144. =item tools_other (o)
  145.  
  146. Defines SHELL, LD, TOUCH, CP, MV, RM_F, RM_RF, CHMOD, UMASK_NULL in
  147. the Makefile. Also defines the perl programs MKPATH,
  148. WARN_IF_OLD_PACKLIST, MOD_INSTALL. DOC_INSTALL, and UNINSTALL.
  149.  
  150. =cut
  151.  
  152. sub tools_other {
  153.     my($self) = shift;
  154.     my @m;
  155.     my $bin_sh = $Config{sh} || '/bin/sh';
  156.     push @m, qq{
  157. SHELL = $bin_sh
  158. };
  159.  
  160.     for (qw/ CHMOD CP LD MV NOOP RM_F RM_RF TEST_F TOUCH UMASK_NULL DEV_NULL/ ) {
  161.     push @m, "$_ = $self->{$_}\n";
  162.     }
  163.  
  164.     push @m, q{
  165. # The following is a portable way to say mkdir -p
  166. # To see which directories are created, change the if 0 to if 1
  167. MKPATH = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mkpath
  168.  
  169. # This helps us to minimize the effect of the .exists files A yet
  170. # better solution would be to have a stable file in the perl
  171. # distribution with a timestamp of zero. But this solution doesn't
  172. # need any changes to the core distribution and works with older perls
  173. EQUALIZE_TIMESTAMP = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e eqtime
  174. };
  175.  
  176.  
  177.     return join "", @m if $self->{PARENT};
  178.  
  179.     push @m, q{
  180. # Here we warn users that an old packlist file was found somewhere,
  181. # and that they should call some uninstall routine
  182. WARN_IF_OLD_PACKLIST = $(PERL) -we 'exit unless -f $$ARGV[0];' \
  183. -e 'print qq{WARNING: I have found an old package in\n};' \
  184. -e 'print qq{\t$$ARGV[0].\n};' \
  185. -e 'print qq{Please make sure the two installations are not conflicting\n};'
  186.  
  187. UNINST=0
  188. VERBINST=1
  189.  
  190. MOD_INSTALL = $(PERL) -I$(INST_LIB) -I$(PERL_LIB) -MExtUtils::Install \
  191. -e "install({@ARGV},'$(VERBINST)',0,'$(UNINST)');"
  192.  
  193. DOC_INSTALL = $(PERL) -e '$$\=qq{\n\n};' \
  194. -e 'print qq{=head2 }, scalar(localtime), qq{: C<}, shift, qq{>}, qq{ L<}, shift, qq{>};' \
  195. -e 'print qq{=over 4};' \
  196. -e 'while (defined($$key = shift) and defined($$val = shift)){print qq{=item *};print qq{C<$$key: $$val>};}' \
  197. -e 'print qq{=back};'
  198.  
  199. UNINSTALL =   $(PERL) -MExtUtils::Install \
  200. -e 'uninstall($$ARGV[0],1,1); print "\nUninstall is deprecated. Please check the";' \
  201. -e 'print " packlist above carefully.\n  There may be errors. Remove the";' \
  202. -e 'print " appropriate files manually.\n  Sorry for the inconveniences.\n"'
  203. };
  204.  
  205.     return join "", @m;
  206. }
  207.  
  208.  
  209. =item test_via_harness (o)
  210.  
  211. Helper method to write the test targets
  212.  
  213. =cut
  214. # Sort this not to ../erpl
  215. sub test_via_harness {
  216.     my($self, $perl, $tests) = @_;
  217.     # $perl = RISCOS::Filespec::riscosify $perl;
  218.     "\t$perl".q! -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;' !."$tests\n";
  219. }
  220. 1;
  221.  
  222.  
  223. =item subdir_x (o)
  224.  
  225. Helper subroutine for subdirs
  226.  
  227. =cut
  228.  
  229. sub subdir_x {
  230.     my($self, $subdir) = @_;
  231.     my(@m);
  232.     qq{
  233.  
  234. subdirs ::
  235.     $self->{NOECHO}dumbshell -c "cd $subdir && \$(MAKE) all \$(PASTHRU)"
  236.  
  237. };
  238. }
  239.  
  240.  
  241. =item export_list
  242.  
  243. This is internal method that returns name of a file that is
  244. passed to linker to define symbols to be exported.
  245. UNIX does not have one but OS2 and Win32 do.
  246.  
  247. =cut 
  248.  
  249. sub export_list
  250. {
  251.  my ($self) = @_;
  252.  return "$self->{BASEEXT}.map";
  253. }
  254.  
  255. =item static_lib (o)
  256.  
  257. Defines how to produce the *.a (or equivalent) files.
  258.  
  259. =cut
  260.  
  261. sub static_lib {
  262.     my($self) = @_;
  263. # Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC
  264. #    return '' unless $self->needs_linking(); #might be because of a subdir
  265.  
  266.     return '' unless $self->has_link_code;
  267.  
  268.     my(@m);
  269.     push(@m, <<'END');
  270. $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)/.exists
  271.     $(RM_RF) $@
  272. END
  273.     # If this extension has it's own library (eg SDBM_File)
  274.     # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
  275.     push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB};
  276.  
  277.     push @m,
  278. q{    $(AR) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@
  279.     $(CHMOD) $(PERM_RWX) $@
  280.     }.$self->{NOECHO}.q{miniperl -le 'print "$(EXTRALIBS)"' > $(INST_ARCHAUTODIR)/extralibs.ld
  281. };
  282.     # Old mechanism - still available:
  283.     push @m,
  284. "\t$self->{NOECHO}".q{miniperl -le 'print "$(EXTRALIBS)"' >> $(PERL_SRC)/ext.libs
  285. }    if $self->{PERL_SRC} && $self->{EXTRALIBS};
  286.     push @m, "\n";
  287.  
  288.     push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
  289.     join('', "\n",@m);
  290. }
  291.  
  292. __END__
  293.  
  294. =head1 NAME
  295.  
  296. ExtUtils::MM_RISCOS - methods to override UN*X behaviour in ExtUtils::MakeMaker
  297.  
  298. =head1 SYNOPSIS
  299.  
  300.  use ExtUtils::MM_RISCOS; # Done internally by ExtUtils::MakeMaker if needed
  301.  
  302. =head1 DESCRIPTION
  303.  
  304. See ExtUtils::MM_Unix for a documentation of the methods provided
  305. there. This package overrides the implementation of these methods, not
  306. the semantics.
  307.