4
votes

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?

2
A "makefile.pl" tag would have been good - Tom
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
Did you check perldoc ExtUtils::MakeMaker? - Dummy00001

2 Answers

1
votes

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).

0
votes

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