2

Instead of adding or modifying files in the directory where the sources of a Perl module are unpacked, I would like to build everything in a separate directory. Is this easily achievable with a fairly standard Makefile.PL that uses ExtUtils::MakeMaker? (By easy, I mean something like one or a few command line parameters.) If no, does any of the other build systems support this?

Update / Reason: The Perl module is a binding to a library whose build system is autoconf/automake/libtool-based. The Perl module is shipped together with this library and calling make in the top directory eventually also builds the Perl library. I am interested in building the entire project in a separate build tree. At the moment I do something similar to what runrig suggested, only using symlinks. (cp -sru $(srcdir)/. $(builddir)/.). This has worked so far, but if there is a more elegant solution, I'd like to read about it.

2
  • Why do you want to do this? What problem are you solving? I ask because the answer is "yes, but it will be a pain to setup and maintain".
    – Schwern
    Aug 12, 2011 at 1:05
  • I have updated my question. Still interested in the painful solution. :-)
    – hillu
    Aug 12, 2011 at 7:31

3 Answers 3

2

MakeMaker already copies the sources and builds them in a separate directory (that's what blib/ is). You can control the build location with the INST_* set of arguments to WriteMakefile(). This example changes the location from blib/ to foo/.

INST_ARCHLIB        => "foo/arch",
INST_LIB            => "foo/lib",
INST_BIN            => "foo/bin",
INST_SCRIPT         => "foo/script",
INST_MAN1DIR        => 'foo/man1',
INST_MAN3DIR        => 'foo/man3',

In addition you have to tell MakeMaker to cleanup the new build directory.

clean       => {
    FILES           => 'foo'
},

See "Determination of Perl Library and Installation Locations" in the ExtUtils::MakeMaker docs for more info.

1
cp -R Module-Directory-0.01 Module-Directory-0.01.copy
cd Module-Directory-0.01.copy
perl Makefile.PL
make
make test
...etc.
2
  • If I copy everything all the advantages of using Makefiles go away.
    – hillu
    Aug 11, 2011 at 21:51
  • Timestamps get messed up, I have gone with symlinks instead (see update to question).
    – hillu
    Aug 12, 2011 at 7:32
0

I ended up using symlinks:

The library to which the Perl module provides bindings uses an autoconf/automake/libtool-based build system. Makefile.PL is generated from Makefile.PL.in by configure. Makefile.PL generates Makefile-pl (Makefile has already been taken by autoconf/automake).

This is the relevant part of Makefile.am:

all: Makefile-pl src_deps
    $(MAKE) -f Makefile-pl

Makefile-pl: Makefile.PL
    perl Makefile.PL INSTALLDIRS=$(INSTALLDIRS) PREFIX=$(prefix)

I changed the second target to:

Makefile-pl: Makefile.PL
    -[ $(srcdir) != $(builddir) ] && cp -rsu $(abs_srcdir)/. $(builddir)/.
    perl Makefile.PL INSTALLDIRS=$(INSTALLDIRS) PREFIX=$(prefix)

This should work as long as building or installing the Perl module does not result in any files being modified in-place.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.