#!/usr/bin/perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if $running_under_some_shell;
BEGIN { pop @INC if $INC[-1] eq '.' }
use warnings;
=head1 NAME
h2xs - convert .h C header files to Perl extensions
=head1 SYNOPSIS
B<h2xs> [B<OPTIONS> ...] [headerfile ... [extra_libraries]]
B<h2xs> B<-h>|B<-?>|B<--help>
=head1 DESCRIPTION
I<h2xs> builds a Perl extension from C header files. The extension
will include functions which can be used to retrieve the value of any
#define statement which was in the C header files.
The I<module_name> will be used for the name of the extension. If
module_name is not supplied then the name of the first header file
will be used, with the first character capitalized.
If the extension might need extra libraries, they should be included
here. The extension Makefile.PL will take care of checking whether
the libraries actually exist and how they should be loaded. The extra
libraries should be specified in the form -lm -lposix, etc, just as on
the cc command line. By default, the Makefile.PL will search through
the library path determined by Configure. That path can be augmented
by including arguments of the form B<-L/another/library/path> in the
extra-libraries argument.
In spite of its name, I<h2xs> may also be used to create a skeleton pure
Perl module. See the B<-X> option.
=head1 OPTIONS
=over 5
=item B<-A>, B<--omit-autoload>
Omit all autoload facilities. This is the same as B<-c> but also
removes the S<C<use AutoLoader>> statement from the .pm file.
=item B<-B>, B<--beta-version>
Use an alpha/beta style version number. Causes version number to
be "0.00_01" unless B<-v> is specified.
=item B<-C>, B<--omit-changes>
Omits creation of the F<Changes> file, and adds a HISTORY section to
the POD template.
=item B<-F>, B<--cpp-flags>=I<addflags>
Additional flags to specify to C preprocessor when scanning header for
function declarations. Writes these options in the generated F<Makefile.PL>
too.
=item B<-M>, B<--func-mask>=I<regular expression>
selects functions/macros to process.
=item B<-O>, B<--overwrite-ok>
Allows a pre-existing extension directory to be overwritten.
=item B<-P>, B<--omit-pod>
Omit the autogenerated stub POD section.
=item B<-X>, B<--omit-XS>
Omit the XS portion. Used to generate a skeleton pure Perl module.
C<-c> and C<-f> are implicitly enabled.
=item B<-a>, B<--gen-accessors>
Generate an accessor method for each element of structs and unions. The
generated methods are named after the element name; will return the current
value of the element if called without additional arguments; and will set
the element to the supplied value (and return the new value) if called with
an additional argument. Embedded structures and unions are returned as a
pointer rather than the complete structure, to facilitate chained calls.
These methods all apply to the Ptr type for the structure; additionally
two methods are constructed for the structure type itself, C<_to_ptr>
which returns a Ptr type pointing to the same structure, and a C<new>
method to construct and return a new structure, initialised to zeroes.
=item B<-b>, B<--compat-version>=I<version>
Generates a .pm file which is backwards compatible with the specified
perl version.
For versions < 5.6.0, the changes are.
- no use of 'our' (uses 'use vars' instead)
- no 'use warnings'
Specifying a compatibility version higher than the version of perl you
are using to run h2xs will have no effect. If unspecified h2xs will default
to compatibility with the version of perl you are using to run h2xs.
=item B<-c>, B<--omit-constant>
Omit C<constant()> from the .xs file and corresponding specialised
C<AUTOLOAD> from the .pm file.
=item B<-d>, B<--debugging>
Turn on debugging messages.
=item B<-e>, B<--omit-enums>=[I<regular expression>]
If I<regular expression> is not given, skip all constants that are defined in
a C enumeration. Otherwise skip only those constants that are defined in an
enum whose name matches I<regular expression>.
Since I<regular expression> is optional, make sure that this switch is followed
by at least one other switch if you omit I<regular expression> and have some
pending arguments such as header-file names. This is ok:
h2xs -e -n Module::Foo foo.h
This is not ok:
h2xs -n Module::Foo -e foo.h
In the latter, foo.h is taken as I<regular expression>.
=item B<-f>, B<--force>
Allows an extension to be created for a header even if that header is
not found in standard include directories.
=item B<-g>, B<--global>
Include code for safely storing static data in the .xs file.
Extensions that do no make use of static data can ignore this option.
=item B<-h>, B<-?>, B<--help>
Print the usage, help and version for this h2xs and exit.
=item B<-k>, B<--omit-const-func>
For function arguments declared as C<const>, omit the const attribute in the
generated XS code.
=item B<-m>, B<--gen-tied-var>
B<Experimental>: for each variable declared in the header file(s), declare
a perl variable of the same name magically tied to the C variable.
=item B<-n>, B<--name>=I<module_name>
Specifies a name to be used for the extension, e.g., S<-n RPC::DCE>
=item B<-o>, B<--opaque-re>=I<regular expression>
Use "opaque" data type for the C types matched by the regular
expression, even if these types are C<typedef>-equivalent to types
from typemaps. Should not be used without B<-x>.
This may be useful since, say, types which are C<typedef>-equivalent
to integers may represent OS-related handles, and one may want to work
with these handles in OO-way, as in C<$handle-E<gt>do_something()>.
Use C<-o .> if you want to handle all the C<typedef>ed types as opaque
types.
The type-to-match is whitewashed (except for commas, which have no
whitespace before them, and multiple C<*> which have no whitespace
between them).
=item B<-p>, B<--remove-prefix>=I<prefix>
Specify a prefix which should be removed from the Perl function names,
e.g., S<-p sec_rgy_> This sets up the XS B<PREFIX> keyword and removes
the prefix from functions that are autoloaded via the C<constant()>
mechanism.
=item B<-s>, B<--const-subs>=I<sub1,sub2>
Create a perl subroutine for the specified macros rather than autoload
with the constant() subroutine. These macros are assumed to have a
return type of B<char *>, e.g.,
S<-s sec_rgy_wildcard_name,sec_rgy_wildcard_sid>.
=item B<-t>, B<--default-type>=I<type>
Specify the internal type that the constant() mechanism uses for macros.
The default is IV (signed integer). Currently all macros found during the
header scanning process will be assumed to have this type. Future versions
of C<h2xs> may gain the ability to make educated guesses.
=item B<--use-new-tests>
When B<--compat-version> (B<-b>) is present the generated tests will use
C<Test::More> rather than C<Test> which is the default for versions before
5.6.2. C<Test::More> will be added to PREREQ_PM in the generated
C<Makefile.PL>.
=item B<--use-old-tests>
Will force the generation of test code that uses the older C<Test> module.
=item B<--skip-exporter>
Do not use C<Exporter> and/or export any symbol.
=item B<--skip-ppport>
Do not use C<Devel::PPPort>: no portability to older version.
=item B<--skip-autoloader>
Do not use the module C<AutoLoader>; but keep the constant() function
and C<sub AUTOLOAD> for constants.
=item B<--skip-strict>
Do not use the pragma C<strict>.
=item B<--skip-warnings>
Do not use the pragma C<warnings>.
=item B<-v>, B<--version>=I<version>
Specify a version number for this extension. This version number is added
to the templates. The default is 0.01, or 0.00_01 if C<-B> is specified.
The version specified should be numeric.
=item B<-x>, B<--autogen-xsubs>
Automatically generate XSUBs basing on function declarations in the
header file. The package C<C::Scan> should be installed. If this
option is specified, the name of the header file may look like
C<NAME1,NAME2>. In this case NAME1 is used instead of the specified
string, but XSUBs are emitted only for the declarations included from
file NAME2.
Note that some types of arguments/return-values for functions may
result in XSUB-decl