[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Building



For those that want to try their hand at building MacPerl or extensions,
below is the script mentioned in the 450.Extensions file on:

  http://www.ptf.com/macpetl/ptf_book/draft.html

The chapter gives instructions on building MacPerl and extensions for
MacPerl.  Please, if you can and want to, follow the directions in this
chapter, use the script, and give me any feedback you might have.

Thanks,

--Chris

#!perl -wl
#-----------------------------------------------------------------#
# copy_mw_libs.pl
#
# Copy obsolete and runtime libraries for MacPerl building
#
# Created:       Chris Nandor (pudge@pobox.com)         02-Feb-98
# Last Modified: Chris Nandor (pudge@pobox.com)         21-Feb-98
#-----------------------------------------------------------------#
use File::Find;
use File::Copy;
use File::Basename;
use Mac::Files;
use Mac::Resources;
use Mac::Memory;
use Mac::StandardFile;
use Mac::MoreFiles;
use strict;
use vars qw($c $incd $libk $libp $libc);
my($cw11, $cw11dir, $mpw, $odir, @xlib, $dir, $oint, $olib);

$cw11 = MacPerl::Answer(
    "Copy from CW11 Gold Tools CD-ROM?\n(Make sure CD-ROM is mounted.)",
    'OK', 'No', 'Cancel'
) or die 'user cancelled';

$cw11dir = 'CW11 Gold Tools:Metrowerks CodeWarrior:';
$odir    = $cw11 == 2 ? "${cw11dir}(Obsolete ANSI Libraries):" :
    get_folder('Select the obsolete libs folder:',
    dirname($Application{'CWIE'})) . ':';
$mpw     = get_folder('Select the MPW Shell folder:',
  dirname($Application{'MPS '})) . ':';

die 'folders not selected' if (length($odir) == 1 || length($mpw) == 1);

$oint = "${mpw}Interfaces:";
$olib = "${mpw}Libraries:";
$incd = "${oint}OldMWCIncludes:";
$libp = "${olib}OldMWPPCLibraries:";
$libk = "${olib}OldMW68KLibraries:";
$libc = "${olib}CFM68KLibraries:";

do_runtimes() if ($cw11 == 2);

foreach my $dir ($oint, $olib, $incd, $libk, $libp, $libc) {
    if (! -e $dir) {
        mkdir($dir, 0) || die $!;
    }
    die "$dir: not directorty" unless -d $dir;
}

open(L, ">>$incd: installlog") || die($!);
select(L);$| = 1;

find(\&get_files, $odir);


sub get_files {
    my($name, $dir, $file, $newd) = ($File::Find::name, $File::Find::dir);
    return if (
        ! -f $name ||
        $name =~ /Icon.?$/
    );
    ($file) = ($name =~ /^\Q$dir\E(.*)$/);
    $file || die($name);
    if ($file =~ /\.lib$/i) {
        if ($file =~ /PPC/i) {
            $newd = $libp;
        } else {
            $newd = $libk;
        }
    } else {
        $newd = $incd;
    }

    $file = $newd . $file;
    print $name;
    copy($name, $file)
        || die ("could not copy:\n  $name ->\n  $file\n$!");
}

sub get_folder {
    require 'GUSI.ph';
    my($prompt, $default) = @_;
    MacPerl::Choose(
        GUSI::AF_FILE(), 0, $prompt, '',
        GUSI::CHOOSE_DIR() + ($default ? &GUSI::CHOOSE_DEFAULT : 0),
        $default
    );
}

sub do_runtimes {
    my(%libs, $rlib, $rlibp, $rlibk, $rlibc);
    $rlib    = "${cw11dir}MacOS Support:Libraries:Runtime:";
    $rlibp = "${rlib}Runtime PPC:";
    $rlibk = "${rlib}Runtime 68K:";
    $rlibc = "${rlibk}CFM68K Runtime:";
    %libs = (
        "${rlibp}MWCRuntime.Lib"        => "${libp}MWCRuntime.Lib",
        "${rlibp}MWMPWCRuntime.Lib"     => "${libp}MWMPWCRuntime.Lib",
        "${rlibp}ShLibRuntime.Lib"      => "${libp}ShLibRuntime.Lib",
        "${rlibk}CPlusPlus.Lib"         => "${libk}CPlusPlus.Lib",
        "${rlibk}MPWRuntime.68K.Lib"    => "${libk}MPWRuntime.68K.Lib",
        "${rlibc}MWCFM68KRuntime.Lib"   => "${libk}MWCFM68KRuntime.Lib",
        "${rlibc}ShLibRuntimeCFM68K.Lib"=> "${libk}ShLibRuntimeCFM68K.Lib",
    );
    foreach my $clib (keys %libs) {
        copy($clib, $libs{$clib})
            || die ("could not copy:\n  $clib ->\n  $libs{$clib}\n$!");
    }
}


__END__

Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==               New Book:  MacPerl: Power and Ease               ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch