I wrote a bash command that uses an extensive perl module library. I know that I can install a custom bash command in usr/bin
simply enough, but I have never had dependencies for a command before.
My makefile, for better or worse, looks like this
install:
cp program.pl /usr/bin/program -f -v
chmod +x /usr/bin/program -v
it's short, but I don't really need to compile anything. program.pl is a short perl script that uses Getopt::Long
to interact with the module. I have been installing the module separately using MakeMaker as documented here.
my file structure feels a bit overkill for how simple the command should be, but due to how MakeMaker works, it ended up like this
program/
program.pl
makefile
perl/
Makefile.PL
MANIFEST
lib/
Program/
Package01.pm
Package02.pm
Package03.pm
and, instead of running a recursive make in the root directory, I have been running make in both places, which I know isn't right (while also being annoying).
I see that all these modules just wind up in /usr/local/share/perl/5.34.0/Program
but I'd rather it be a little more portable than putting it there myself in my root makefile. What is the correct way to do this? I would like to make this command public eventually and I don't want to mess up an install
It sounds like program.pl and Program::PackageXX.pm are a bundle.
If so, you should Perl's installer to install not just the modules but the script.
Makefile.PL
MANIFEST
bin/
program.pl
lib/
App/
Program.pm
Program/01.pm
Program/02.pm
Program/03.pm
Makefile.PL
:
#!perl
use strict;
use warnings
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'App::Program',
VERSION_FROM => 'lib/App/Program.pm',
ABSTRACT_FROM => 'lib/App/Program.pm',
AUTHOR => 'Name E<lt>name[at]cpan.orgE<gt>',
PREREQ_PM => { ... },
EXE_FILES => [ 'bin/program.pl' ],
...,
);
(App::... is the preferred namespace for such things.)
Then, simply install the distro as normal.
perl Makefile.PL
make test
make install
This will install the script in the dir given by
perl -V:installsitescript
It should already be in your PATH. If not, add it.