Prima::Make - module for automated Makefile creating
Prima does not use standard Make::MakeMaker module for creating its Makefile, nor it encourages to use it for the build of Prima-dependent C modules, although this is possible. For such a module it is typical to use Prima::Make inside its Makefile.PL, and use the methods that provide compilation and linking commands.
Make::MakeMaker
Prima::Make
Makefile.PL
The module implements its own basic file operations, required for a typical installer: file copying, removing, creation of distributives etc. See init for details.
use Prima::Make; # check command line exit unless init( @ARGV ); # object file extension my $o = $Prima::Config::Config{objext}; # store .pm files under /File directory setvar( 'INSTALL_LIB', $PREFIX . qd( "/File")); # compile command my $cc = cc_command_line( "a.c", "a.$o"); # so / dll name my $dl = dl_name( "a" ); # link command my $ld = ld_command_line( "a.c", "a.def", "a.$o"); open F, "> Makefile"; print F <<MAKE; a.$o: a.c \t$cc $dl: a.$o \t$ld clean: \t$^X Makefile.PL --rm a.$o $ld install: \t$^X Makefile.PL --cp $ld $INSTALL_DL a.pm $INSTALL_LIB \t$^X Makefile.PL --cpbin a.pl $INSTALL_BIN MAKE close F;
Adds LIBRARY to list of libraries, stored in @LIBS.
@LIBS
Converts FILENAME to a canonized form, by eliminating .. up-references in the path.
..
Returns suggested command for compilation of a C_FILE into output object O_FILE.
Converts NAME without an extension into shared library / dll file name by adding the OS-dependant extension. Under OS2 NAME can be modified to overcome a problem that the system does not handle dll files with name longer than 8 letters. This is the reason why under OS/2 Prima dll file is named PrimaDI.dll .
Creates a line for executing COMMAND on set of PARAMS. This method is used to overcome a problem when PARAMS array is too long to be fit into the command line. The method calls SUB for each of PARAMS array scalars, and breaks the command line at each 20 parameters. SUB is an anonymous subroutine, as an only parameter receiving PARAMS array member and returns its value adapted for COMMAND.
Returns a boolean value, reflecting whether the evironment variable is a true value, ( e.g. yes, 1, on, true ) or not.
yes
1
on
true
Reads MODULE file and extracts its version without actual MODULE load via use. If $VERSION string is found there, returns two integers - major and minor file version. Otherwise throws an exception.
use
$VERSION
Writes DEF_FILE used in linking of LIBNAME ( library or dll file ). DEF_FILE is used on Win32 and OS/2 to explicitly declare the list of exported names. These names are passed in @EXPORTS array.
Does nothing under unix environment.
Checks the command line by parsing @ARGV array ( not @main::ARGV ). First, the checks are done if the module was invoked as an utility; such a call is constructed with a command, started with a double hyphen, for example, --cp a.pm /perl/site/lib. The full list of commands and actions follows:
@ARGV
@main::ARGV
--cp a.pm /perl/site/lib
Copies SOURCE file to DEST. Can accept more than one pair.
Copies SOURCE file to DEST and modifies DEST so that it presents an executable script; during the operation, DEST can change both its extension and content. The method can accept more than one pair.
Creates a distributive archive of the given TYPE, which is either bin, zip, or tar. These correspond to binary archive, zip source archive, and tar source archive. In case of the binary archive, DISTFILE is combined with OS type string.
bin
zip
tar
Creates one or more PATH directories by calling File::Path::mkpath, which can create a directory with more than one level at a time.
File::Path::mkpath
Unlinks one or more FILEs.
If none of the options found, it is assumed that module is called for generation of Makefile. The command line is parsed to see if it contains overrided variables. This allows the user to add, for example, paths to include and library files, select installation directories, compiling and debugging switches etc etc.
Makefile
The list of the user-overridable variables is described in Variables below.
Scans C_FILE for the eventual dependencies of local include files. DEPENDENCIES and INCLUDES are hash references, used for global dependancy accounting. DEPENDENCIES keys are C files, and its values are arrays of include files. INCLUDES keys are include files, and values are always 1. All dependencies are also cached internally, so successive calls to same C or include file do not result in file scan.
The method does not handle conditional defines.
Recursively searches for FILENAME in PATH; returns two scalars - the full name and success flag.
Returns suggested command for linking of set of object files O_FILES, with an eventual DEF_FILE into DL_FILE shared library / dll file. The name of DL_FILE is returned by dl_name.
dl_name
Returns PATH with standard directory separator / mapped to the OS-default one.
/
Splits STRING by separate spaces, preserving the double-quoted text. Returns array of split text chunks.
Sets the internal VARIABLE. If the command line contains user-preferred settings, these are used. Otherwise, DEFAULT parameters are used. The operations allowed are assignment ( DEBUG=1 ) and concatenation ( INCPATH+=/usr/local/include).
DEBUG=1
INCPATH+=/usr/local/include
The variables influence many aspects of Makefile generation. The user can tune the build process by passing variables in the command line, which are parsed in init.
init
Boolean; if 1, the commands for preserving debugging symbols are emitted by cc_command_line and ld_command_line.
cc_command_line
ld_command_line
Set of include files paths.
Installation directory for executable scripts.
Installation directory for shared objects / dll files.
Installation directory for example executable scripts.
Installation directory for perl modules and include files.
Set of library files paths.
Set of library files used for linking.
An installation prefix path, under which the installed files will be copied.
Boolean flags for fast check if the current OS type is unix, win32, or os2. For extended info use $^O variable.
$^O
The module is very experimental. Many features simply were not realized, for example, documentation in pod and man files.
Dmitry Karasik, <dmitry@karasik.eu.org>.
Prima, gencls, IPA ( http://www.prima.eu.org/IPA ).
To install Prima, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Prima
CPAN shell
perl -MCPAN -e shell install Prima
For more information on module installation, please visit the detailed CPAN module installation guide.