4

Given a Makefile.PL, how can I install two binaries and two scripts in four different locations?

To be more precise, the directory structure is as follows:

  • lib/my_package/main.pl
  • bin/daemon/daemon.pl (*)
  • bin/plugin/plugin.pl (*)
  • scripts/conf/conf.sh (*)
  • scripts/init/initd.sh (*)
  • Makefile.PL

The files marked with (*) should be installed in the following paths:

  • /usr/sbin/daemon.pl
  • /var/qmail/smtpplugins/plugin.pl
  • /usr/local/conf.sh
  • /etc/init.d/initd.sh

and the contents of my Makefile.PL

use ExtUtils::MakeMaker;

WriteMakefile(
    NAME         => "my_package",
    VERSION_FROM => "lib/my_package/main.pl"
);

What do I tell perl through the Makefile.PL to make it install those four files in their corresponding directories?

Tom
  • 6,991
  • 13
  • 60
  • 78
  • 1
    A "makefile.pl" tag would have been good – Tom Aug 09 '10 at 09:34
  • Oh, and I should mention that the names of the directories are preserved, but the names of the files have been changed to protect the innocent :) – Tom Aug 09 '10 at 09:39
  • 1
    Did you check `perldoc ExtUtils::MakeMaker`? – Dummy00001 Aug 09 '10 at 10:37
  • 1
    Related: [Which framework should I use to write modules?](http://stackoverflow.com/questions/73889/which-framework-should-i-use-to-write-modules) – Ether Aug 09 '10 at 16:16

2 Answers2

1

Two ideas from the ExtUtils::MakeMaker documentation:

Use the PL_FILES parameter. To paraphrase the documentation: PL_FILES => {'bin/install.PL' => 'an-arg'} would run bin/foobar.PL as perl bin/installPL an-arg

Or have MakeMaker add a new target to the generated makefile using the postamble feature.

Or, yes, Module::Install or Dist::Zilla (there's probably yet another Perl module to do it since I last looked, lively little language that it is).

Lee Goddard
  • 10,680
  • 4
  • 46
  • 63
0

If you switch to Module::Build, you can simply use install_path.

daxim
  • 39,270
  • 4
  • 65
  • 132