Plan 9 from Bell Labs’s /usr/web/sources/contrib/gabidiaz/root/sys/man/2perl/ExtUtils::Embed

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  | will give a
.\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
.\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
.    de IX
.    tm Index:\\$1\t\\n%\t"\\$2"
..
.    nr % 0
.    rr F
.\}
.\"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "ExtUtils::Embed 3"
.TH ExtUtils::Embed 3 "2002-11-24" "perl v5.8.0" "Perl Programmers Reference Guide"
.SH "NAME"
ExtUtils::Embed \- Utilities for embedding Perl in C/C++ applications
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 3
\& perl -MExtUtils::Embed -e xsinit 
\& perl -MExtUtils::Embed -e ccopts 
\& perl -MExtUtils::Embed -e ldopts
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
ExtUtils::Embed provides utility functions for embedding a Perl interpreter
and extensions in your C/\*(C+ applications.  
Typically, an application \fBMakefile\fR will invoke ExtUtils::Embed
functions while building your application.  
.SH "@EXPORT"
.IX Header "@EXPORT"
ExtUtils::Embed exports the following functions:
.PP
\&\fIxsinit()\fR, \fIldopts()\fR, \fIccopts()\fR, \fIperl_inc()\fR, \fIccflags()\fR, 
\&\fIccdlflags()\fR, \fIxsi_header()\fR, \fIxsi_protos()\fR, \fIxsi_body()\fR
.SH "FUNCTIONS"
.IX Header "FUNCTIONS"
.IP "\fIxsinit()\fR" 4
.IX Item "xsinit()"
Generate C/\*(C+ code for the \s-1XS\s0 initializer function.
.Sp
When invoked as \f(CW`perl \-MExtUtils::Embed \-e xsinit \-\-`\fR
the following options are recognized:
.Sp
\&\fB\-o\fR <output filename> (Defaults to \fBperlxsi.c\fR)
.Sp
\&\fB\-o \s-1STDOUT\s0\fR will print to \s-1STDOUT\s0.
.Sp
\&\fB\-std\fR (Write code for extensions that are linked with the current Perl.)
.Sp
Any additional arguments are expected to be names of modules
to generate code for.
.Sp
When invoked with parameters the following are accepted and optional:
.Sp
\&\f(CW\*(C`xsinit($filename,$std,[@modules])\*(C'\fR
.Sp
Where,
.Sp
\&\fB$filename\fR is equivalent to the \fB\-o\fR option.
.Sp
\&\fB$std\fR is boolean, equivalent to the \fB\-std\fR option.  
.Sp
\&\fB[@modules]\fR is an array ref, same as additional arguments mentioned above.
.IP "Examples" 4
.IX Item "Examples"
.Vb 1
\& perl -MExtUtils::Embed -e xsinit -- -o xsinit.c Socket
.Ve
.Sp
This will generate code with an \fBxs_init\fR function that glues the perl \fBSocket::bootstrap\fR function 
to the C \fBboot_Socket\fR function and writes it to a file named \fIxsinit.c\fR.
.Sp
Note that \fBDynaLoader\fR is a special case where it must call \fBboot_DynaLoader\fR directly.
.Sp
.Vb 1
\& perl -MExtUtils::Embed -e xsinit
.Ve
.Sp
This will generate code for linking with \fBDynaLoader\fR and 
each static extension found in \fB$Config{static_ext}\fR.
The code is written to the default file name \fBperlxsi.c\fR.
.Sp
.Vb 1
\& perl -MExtUtils::Embed -e xsinit -- -o xsinit.c -std DBI DBD::Oracle
.Ve
.Sp
Here, code is written for all the currently linked extensions along with code
for \fB\s-1DBI\s0\fR and \fBDBD::Oracle\fR.
.Sp
If you have a working \fBDynaLoader\fR then there is rarely any need to statically link in any 
other extensions.
.IP "\fIldopts()\fR" 4
.IX Item "ldopts()"
Output arguments for linking the Perl library and extensions to your
application.
.Sp
When invoked as \f(CW`perl \-MExtUtils::Embed \-e ldopts \-\-`\fR
the following options are recognized:
.Sp
\&\fB\-std\fR 
.Sp
Output arguments for linking the Perl library and any extensions linked
with the current Perl.
.Sp
\&\fB\-I\fR <path1:path2>
.Sp
Search path for ModuleName.a archives.  
Default path is \fB@INC\fR.
Library archives are expected to be found as 
\&\fB/some/path/auto/ModuleName/ModuleName.a\fR
For example, when looking for \fBSocket.a\fR relative to a search path, 
we should find \fBauto/Socket/Socket.a\fR  
.Sp
When looking for \fBDBD::Oracle\fR relative to a search path,
we should find \fBauto/DBD/Oracle/Oracle.a\fR
.Sp
Keep in mind that you can always supply \fB/my/own/path/ModuleName.a\fR
as an additional linker argument.
.Sp
\&\fB\-\-\fR  <list of linker args>
.Sp
Additional linker arguments to be considered.
.Sp
Any additional arguments found before the \fB\-\-\fR token 
are expected to be names of modules to generate code for.
.Sp
When invoked with parameters the following are accepted and optional:
.Sp
\&\f(CW\*(C`ldopts($std,[@modules],[@link_args],$path)\*(C'\fR
.Sp
Where:
.Sp
\&\fB$std\fR is boolean, equivalent to the \fB\-std\fR option.  
.Sp
\&\fB[@modules]\fR is equivalent to additional arguments found before the \fB\-\-\fR token.
.Sp
\&\fB[@link_args]\fR is equivalent to arguments found after the \fB\-\-\fR token.
.Sp
\&\fB$path\fR is equivalent to the \fB\-I\fR option.
.Sp
In addition, when ldopts is called with parameters, it will return the argument string
rather than print it to \s-1STDOUT\s0.
.IP "Examples" 4
.IX Item "Examples"
.Vb 1
\& perl -MExtUtils::Embed -e ldopts
.Ve
.Sp
This will print arguments for linking with \fBlibperl.a\fR, \fBDynaLoader\fR and 
extensions found in \fB$Config{static_ext}\fR.  This includes libraries
found in \fB$Config{libs}\fR and the first ModuleName.a library
for each extension that is found by searching \fB@INC\fR or the path 
specified by the \fB\-I\fR option.  
In addition, when ModuleName.a is found, additional linker arguments
are picked up from the \fBextralibs.ld\fR file in the same directory.
.Sp
.Vb 1
\& perl -MExtUtils::Embed -e ldopts -- -std Socket
.Ve
.Sp
This will do the same as the above example, along with printing additional arguments for linking with the \fBSocket\fR extension.
.Sp
.Vb 1
\& perl -MExtUtils::Embed -e ldopts -- DynaLoader
.Ve
.Sp
This will print arguments for linking with just the \fBDynaLoader\fR extension
and \fBlibperl.a\fR.
.Sp
.Vb 1
\& perl -MExtUtils::Embed -e ldopts -- -std Msql -- -L/usr/msql/lib -lmsql
.Ve
.Sp
Any arguments after the second '\-\-' token are additional linker
arguments that will be examined for potential conflict.  If there is no
conflict, the additional arguments will be part of the output.  
.IP "\fIperl_inc()\fR" 4
.IX Item "perl_inc()"
For including perl header files this function simply prints:
.Sp
.Vb 1
\& -I$Config{archlibexp}/CORE
.Ve
.Sp
So, rather than having to say:
.Sp
.Vb 1
\& perl -MConfig -e 'print "-I$Config{archlibexp}/CORE"'
.Ve
.Sp
Just say:
.Sp
.Vb 1
\& perl -MExtUtils::Embed -e perl_inc
.Ve
.IP "\fIccflags()\fR, \fIccdlflags()\fR" 4
.IX Item "ccflags(), ccdlflags()"
These functions simply print \f(CW$Config\fR{ccflags} and \f(CW$Config\fR{ccdlflags}
.IP "\fIccopts()\fR" 4
.IX Item "ccopts()"
This function combines \fIperl_inc()\fR, \fIccflags()\fR and \fIccdlflags()\fR into one.
.IP "\fIxsi_header()\fR" 4
.IX Item "xsi_header()"
This function simply returns a string defining the same \fB\s-1EXTERN_C\s0\fR macro as
\&\fBperlmain.c\fR along with #including \fBperl.h\fR and \fB\s-1EXTERN\s0.h\fR.  
.IP "xsi_protos(@modules)" 4
.IX Item "xsi_protos(@modules)"
This function returns a string of \fBboot_$ModuleName\fR prototypes for each \f(CW@modules\fR.
.IP "xsi_body(@modules)" 4
.IX Item "xsi_body(@modules)"
This function returns a string of calls to \fB\f(BInewXS()\fB\fR that glue the module \fBbootstrap\fR
function to \fBboot_ModuleName\fR for each \f(CW@modules\fR.
.Sp
\&\fB\f(BIxsinit()\fB\fR uses the xsi_* functions to generate most of its code.
.SH "EXAMPLES"
.IX Header "EXAMPLES"
For examples on how to use \fBExtUtils::Embed\fR for building C/\*(C+ applications
with embedded perl, see perlembed.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
perlembed
.SH "AUTHOR"
.IX Header "AUTHOR"
Doug MacEachern <\fIdougm@osf.org\fR>
.PP
Based on ideas from Tim Bunce <\fITim.Bunce@ig.co.uk\fR> and
\&\fBminimod.pl\fR by Andreas Koenig <\fIk@anna.in\-berlin.de\fR> and Tim Bunce.

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.