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

[MacPerl] XS Lite Installment #2



The first installment saw us build a real twinkie example using a very
minimal library set. Here we'll test the concept of using what's available
in CW Pro, and nothing but, to build something a bit more real.

Recall that all we're really modifying is the libraries specified in
ExtBuildRules.mk. This should be a working copy, with a pristine,
unsullied copy parked someplace safe. :-) The library variables are
DYNAMIC_STDLIBS_PPC and DYNAMIC_STDLIBS_CFM68K. (Note: I am just
concentrating on shared library builds, and in point of fact, instead of
BuildProgram all, I use BuildProgram dynamic).

Let's try one of Matthias' Toolbox modules. In MPW, set the working
directory to "HD:MacPerl_Src:perl:ext:Mac:Controls". Incant the usual
'perl Makefile.PL'.

These are the new libraries in ExtBuildRules.mk:

PPC -
	PerlStub
	...MWPPCLibraries:InterfaceLib
	...MWPPCLibraries:MSL RuntimePPC.Lib
	...MWPPCLibraries:MSL C.PPC (NL).Lib

CFM68K -
	I'm not sure about this one. I managed to get it to compile and 
	link with the addition of just '...MW68KLibraries:InterfaceLib'
	to the 2 libs that were used in Example 1. Maybe this is OK, maybe
	it isn't. I've got no way of testing it.

Do BuildProgram all (or dynamic), and BuildProgram install (or
install_dynamic).

Zap over to MacPerl. DON'T run Toolbox modules using the perl tool in MPW
Shell. Modify the script t/ControlWindow.t to 'use blib;', or temporarily
modify your @INC under MP Preferences to search blib:lib first. You'll see
that this script, with our newly-built "Controls" shared library, does
what it's supposed to do. (Click the close box to stop).

Note: adding InterfaceLib is automatic, as we're using Toolbox routines.
The linker also tells us, if that's all we add, that it needs code for
memcpy(), so I throw in the C library. Why (NL)? Well, the MWCPPC compiler
does LF <=> CR conversion/mapping by default under MPW, which is actually
what we want (in the CW IDE, this is NOT the default). This corresponds to
the -mapcr compiler option. So, depending on whether we have -mapcr or
-nomapcr, you need to select the C/C++ libs accordingly: the (NL) stands
for a library built with the -mapcr option.

Down the road, or Real Soon Now, we'll tackle using the MPW build process
to handle multiple source files. SQL::Statement and XML::Parser, both of
which are available as binaries from Chris Nandor's spot on CPAN, are
typical examples of this. As he can tell you, there are a few tweaks that
need to be done in these situations.

Re using the IDE. I'm not sure why anyone would want to. :-) Seriously,
h2xs and xsubpp are much easier to use from MPW. Other than that, although
I haven't really looked at it, setting up a CW .mcp project to build a
shared library for a MacPerl extension isn't much of a leap. I'll play
with that maybe a bit on the weekend, unless someone beats me to it. :-)

Arved



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