I have software written in Perl, now I want to release it and I want it to be an installation package like the other GNU software, which can be installed by typing:
./configure; make; make install
I noticed that in autoconf's package, most of the code is written in Perl and the Perl scripts are generated by running "make". That's exactly what I want to do. How would I go about doing that?
===
Added
Thank you for your nice answer! But what I wrote is not a module, it's actually a set of scripts which will do something in a pipe, the only thing I need to setup is the locations of some program I used in the Perl scripts. Is there any suggestion on this?
The process used by ExtUtils::MakeMaker and Module::Install is very similar.
perl Makefile.PL
make
make test
make install
If you're set on using the specific command chain you posted, you can place the following in file configure:
#!/bin/sh
perl Makefile.PL
If you're not set on using the specific command chain you posted, there's also Module::Build.
perl Build.PL
./Build
./Build test
./Build install
I use Module::Build personally.
In the Makefile.am that's where your perl scripts reside, add the line
dist_bin_SCRIPTS = your_perl_program
Related
I have found it necessary to expand upon a CPAN module. (Unicode::CharName goes up to Unicode 4.1; I need some characters from Unicode 5.0 & 5.1).
I've made the changes needed and have my own CharName.pm module.
I now would like to use it with my various Perls. I currently use:
Strawberry Perl for Windows
git for Windows MINGW64; My .bashrc sets
$PATH to Strawberry perl and $PERL5LIB=/c/Strawberry/perl/vendor/lib:/c/Strawberry/perl/site/lib
WSL Ubuntu
Where should I put my version of Unicode::CharName, so that it over-rides the ones installed by CPAN?
I don't want to have to change any scripts that currently
use Unicode::CharName;
Using cpanm you could download the module, patch it, and install it as normal:
$ cpanm --look Unicode::CharName
# new shell opens
$ patch lib/Unicode/CharName.pm custom.patch # or whatever process
$ perl Makefile.PL
$ make install
$ exit
You can also install it to a local::lib to avoid overwriting it globally, by adding the -l local/ option to the cpanm command. Then you can add the absolute path of this local::lib to your PERL5LIB or via -I or use lib. If you specified /path/to/local for the -l option, it would be /path/to/local/lib/perl5.
Manually copying files rather than going through the normal installation process is likely to lead to problems. Many distributions depend on the installation process to build the modules correctly. Also, you will need to install the module separately for each Perl you want to use it for; installed Perl modules are not generally cross-compatible between Perl versions or architectures. (A strictly simple pure-Perl module can be an exception to these rules, but the only module I feel comfortable abusing this way is App::cpanminus, because it was designed to do this.)
My app, Alambic, uses The Great Mojolicious framework, and defines commands that can be executed with e.g. $ script/alambic alambic init.
Now when I look at Joel Berger's Galileo and other great pieces of work, I find they have a system command that can be directly invoked in a shell, e.g. $ galileo init. I looked into the mojolicious doc but found nothing to do that for my app. Now I'm not even sure if it's Mojolicious or the Perl CPAN Build process that makes it possible.. Any hint would be greatly appreciated.
I'll provide the complete answer here as a complement to #simbabque 's comment.
So for a Mojolicious application, one has to make it installable (i.e. cpan-aware) in order to have the binaries copied to a directory in the path. More specifically for Alambic I had to:
Setup InstallablePaths (I decided to go for Module::Build), see the documentation for the module
Create a Build.PL file
Run the Module::Build sequence to build the module:
perl Build.PL
./Build manifest
./Build
./Build test
./Build install
During the install step, binaries are copied to a Perl-managed directory that is in the $PATH. After that step the alambic command was available as a command in my shell.
Note: For one to have her/his own commands available on the CLI, the Mojolicious application has to define one or more commands of course.
I have simple perl script and I want to make install script which install dependencies (perl modules) and copy my file.perl to /usr/share/path asking about password if necessary. I found that there are some solutions for installing perl modules (Makefile.PL, Build.PL etc.). But my script isn't module. How should I attempt it?
Makefile.PL/ExtUtils::MakeMaker support a EXE_FILES parm for perl script, you can see how App::Ack do this or check this tutorial. Just set the prefix to your directory and it should do the work for you.
I just mangaged to install the perl/Tk module after much struggle. I realise I don't understand what dmake or make etc is actually doing.
I am using strawberry perl installed at C:\strawberry.
Fisrt I unpacked the module to another directory and ran perl makefile.pl which worked fine. Then I tried dmake which did not work. I guess that will be obvious to people who know how this works.
When I placed the module as a sub-directory of C:\strawberry I could run perl makefile.pl, dmake, dmake test and dmake install.
My guess is that dmake install is adding some executable files to the interpreter and to work the module must be in a subdirectory. Is there any article anywhere that explains what it is doing in detail?
When you see a Makefile.PL file, that means it's a module who's install system is ExtUtils::MakeMaker.
EU::MM is the classic system for installing Perl modules dating back to the dawn of CPAN. It relied on the fact that the program make--a common, and powerful dependency tracking tool--was available on almost every unix system, as well as relying on all sorts of unixy patterns and behaviors.
Makefile.PL is a Perl script that the author of the module maintains. It reads information about your system from Perl itself, and uses that to create a Makefile. This Makefile instructs make on actions to perform. For more information on make, check out The Wikipedia page on Make. Essentially though, what make does is look at rules, that tell it what files to 'make'. It recursively looks at all the rules to create the 'target' (eg, when you typed make install, 'install' was the target) and then follows them until (a) it reaches the target or (b) it explodes horribly. We all hope for (a), but (b) is often the case as well. :)
Unfortunately, in Windows-land, we don't have make. Or a compiler. Usually, anyway.
dmake is a make program that happens to run pretty well on Windows. Strawberry Perl packages up all the things you need to actually build in a unix-like environment on Windows into a convenient package, making what you just did actually possible.
This may be taking your question too literally, but dmake has a -v option (for verbose)
dmake -v
dmake -v target
that will display information about exactly what dmake is doing during an installation.
Here is my situation: I know almost nothing about Perl but it is the only language available on a porting machine. I only have permissions to write in my local work area and not the Perl install location. I need to use the Parallel::ForkManager Perl module from CPAN
How do I use this Parallel::ForkManager without doing a central install? Is there an environment variable that I can set so it is located?
Thanks
JD
From perlfaq8: How do I keep my own module/library directory?:
When you build modules, tell Perl where to install the modules.
For C-based distributions, use the INSTALL_BASE option
when generating Makefiles:
perl Makefile.PL INSTALL_BASE=/mydir/perl
You can set this in your CPAN.pm configuration so modules automatically install
in your private library directory when you use the CPAN.pm shell:
% cpan
cpan> o conf makepl_arg INSTALL_BASE=/mydir/perl
cpan> o conf commit
For C-based distributions, use the --install_base option:
perl Build.PL --install_base /mydir/perl
You can configure CPAN.pm to automatically use this option too:
% cpan
cpan> o conf mbuild_arg --install_base /mydir/perl
cpan> o conf commit
INSTALL_BASE tells these tools to put your modules into
F. See L for details on how to run your newly
installed moudles.
There is one caveat with INSTALL_BASE, though, since it acts
differently than the PREFIX and LIB settings that older versions of
ExtUtils::MakeMaker advocated. INSTALL_BASE does not support
installing modules for multiple versions of Perl or different
architectures under the same directory. You should consider if you
really want that , and if you do, use the older PREFIX and LIB
settings. See the ExtUtils::Makemaker documentation for more details.
Download package form CPAN to a folder:
wget http://search.cpan.org/CPAN/authors/id/S/SZ/SZABGAB/Parallel-ForkManager-1.06.tar.gz
gunzip Parallel-ForkManager-1.06.tar.gz
tar -xvf Parallel-ForkManager-1.06.tar
before this create a folder in home to store your local modules, now go into downloaded folder and run follwing cmmands:
perl Makefile.PL PREFIX=/home/username/myModules
make
make test
make install
get the path to ForkManager from the installed folder,/home/username/myModules
and locate Parallel folder and get the full path to this.
Now in your perl file put these at the beggining
use lib '/home/username/myModules/bin.../Parallel';
use parallel::ForkManager;
--That should do it.
Check out this post from Mark Dominus
Excerpt:
Set PREFIX=X when building the Makefile
Set INSTALLDIRS=vendor and VENDORPREFIX=X when building the Makefile
Or maybe instead of VENDORPREFIX you need to set INSTALLVENDORLIB or something
Or maybe instead of setting them while building the Makefile you need to set them while running the make install target
Set LIB=X/lib when building the Makefile
Use PAR
Use local::lib
Mark also gives another solution in his blog which takes a bit more space to desribe but boils down to running make and make test but not make install and then using the stuff in blib/.
There's the PERL5LIB environment variable, and -I on the command line when it comes to using the module. There are mechanisms for telling CPAN and CPANPLUS.
There is information in question 5 of the CPAN manual (perldoc CPAN, or look at CPAN itself).
use lib 'directory';
use Parallel::ForkManager;
You can use the -I (capital i) command-line switch followed by the directory where you'll place the module; or try the "use lib" directive followed by the directory.
Yes Even You Can Use CPAN
perl Makefile.PL LIB=/my/perl_modules/lib/
make
make install
PERL5LIB=$PERL5LIB:/my/perl_modules/lib/
perl myperlcode.pl
use cpanm -l $DIR_NAME option.
perlbrew lets you use a local perl and installs it's packages to a local directory.
\curl -L https://install.perlbrew.pl | bash
perlbrew init # put this in .bash_profile etc
perlbrew install 5.27.11
perlbrew switch 5.27.11
See also https://opensource.com/article/18/7/perlbrew.
Consider using cpanminus, a suggested on this other thread