[Top][All Lists]

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

Solution for building perl modules

From: Jeremy Slade
Subject: Solution for building perl modules
Date: Mon, 26 Mar 2001 15:24:16 -0700 (MST)

I posted a while back asking for a good solution to building perl
modules inside an automake/autoconf-based package.  The only real
response I got was 'I thought everybody used MakeMaker to do that...'

So, I looked at how to combine MakeMaker w/ automake/autoconf, and
here's what I came up with (this example is contrived, not tested

First, this requires perl be available, so I created a autoconf macro
to define PERL.  The AC_OUTPUT includes:

In the src/lib/ it builds the C++ API for my module.  The
src/perl/ is for building the perl extension that wraps the
C++ API (using SWIG in my case).  There isn't a
src/perl/, but rather a src/perl/

--- src/perl/ -----------------------
noinst_DATA = .made_mod

.made_mode = MyMod.C Makefile.perl
        $(MAKE) -fMakefile.perl
        touch $@

MyMod.C: MyMod.i
         $(SWIG) $(SWIGFLAGS) -o $@ $^

Makefile.perl: Makefile.PL
        $(PERL) $< MAKEFILE=$@

        $(MAKE) -fMakefile.perl PREFIX=$(prefix) install

CLEANFILES = *~ .made_mod MyMod.C
        if test -f Makefile.perl; them $(MAKE) -fMakefile.perl realclean; fi
        rm -f Makefile.perl Makefile.perl.old

--- src/perl/ -----------------------
use ExtUtils::MakeMaker;
WriteMakefile ( NAME => 'MyMod',
                DEFINE => '@DEFS@',
                INC => 'address@hidden@/src/lib @CPPFLAGS@',
                LIBS => 'address@hidden@/src/lib -lMyAPI_PIC ',
                INSTALLDIRS => 'perl' );

The gets processed by autoconf to expand useful macros
like @address@hidden  At build time, the Makefile.perl gets generated
from the Makefile.PL, and then Makefile.perl is used to build and
install the extension in the normal MakeMaker-defined way.

This method isn't foolproof, super robust.  For building the perl
extension, most of the 'configuration' comes from the perl,
so whatever is configured in the various other Makefiles is not
reflected in the Makefile.perl.  Perhaps that's not an issue -- what
do the experts think?  

Happy to have comments on this...

Jeremy Slade
Hewlett-Packard Company  VLSI Technology Center -
address@hidden            (970) 898-7881

reply via email to

[Prev in Thread] Current Thread [Next in Thread]