1N/A# List explicitly here the variables you want Configure to 1N/A# generate. Metaconfig only looks for shell variables, so you 1N/A# have to mention them as if they were shell variables, not 1N/A# %Config entries. Thus you write 1N/A# to ensure Configure will look for $Config{startperl}. 1N/A# This forces PL files to create target in same directory as PL file. 1N/A# This is so that make depend always knows where to find PL derivatives. 1N/Aopen OUT,
">$file" or die "Can't create $file: $!";
1N/Aprint "Extracting $file (with variable substitutions)\n";
1N/A# In this section, perl variables will be expanded during extraction. 1N/A# You can use $Config{...} to use Configure variables. 1N/A eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}' 1N/A# In the following, perl variables are not expanded during extraction. 1N/Ah2xs - convert .h C header files to Perl extensions 1N/AB<h2xs> [B<OPTIONS> ...] [headerfile ... [extra_libraries]] 1N/AB<h2xs> B<-h>|B<-?>|B<--help> 1N/AI<h2xs> builds a Perl extension from C header files. The extension 1N/Awill include functions which can be used to retrieve the value of any 1N/A#define statement which was in the C header files. 1N/AThe I<module_name> will be used for the name of the extension. If 1N/Amodule_name is not supplied then the name of the first header file 1N/Awill be used, with the first character capitalized. 1N/AIf the extension might need extra libraries, they should be included 1N/Athe libraries actually exist and how they should be loaded. The extra 1N/Alibraries should be specified in the form -lm -lposix, etc, just as on 1N/Athe library path determined by Configure. That path can be augmented 1N/Aextra-libraries argument. 1N/A=item B<-A>, B<--omit-autoload> 1N/AOmit all autoload facilities. This is the same as B<-c> but also 1N/Aremoves the S<C<use AutoLoader>> statement from the .pm file. 1N/A=item B<-B>, B<--beta-version> 1N/AUse an alpha/beta style version number. Causes version number to 1N/Abe "0.00_01" unless B<-v> is specified. 1N/A=item B<-C>, B<--omit-changes> 1N/AOmits creation of the F<Changes> file, and adds a HISTORY section to 1N/A=item B<-F>, B<--cpp-flags>=I<addflags> 1N/AAdditional flags to specify to C preprocessor when scanning header for 1N/Afunction declarations. Writes these options in the generated F<Makefile.PL> 1N/A=item B<-M>, B<--func-mask>=I<regular expression> 1N/A=item B<-O>, B<--overwrite-ok> 1N/AAllows a pre-existing extension directory to be overwritten. 1N/A=item B<-P>, B<--omit-pod> 1N/AOmit the autogenerated stub POD section. 1N/A=item B<-X>, B<--omit-XS> 1N/AOmit the XS portion. Used to generate templates for a module which is not 1N/AXS-based. C<-c> and C<-f> are implicitly enabled. 1N/A=item B<-a>, B<--gen-accessors> 1N/AGenerate an accessor method for each element of structs and unions. The 1N/Agenerated methods are named after the element name; will return the current 1N/Avalue of the element if called without additional arguments; and will set 1N/Athe element to the supplied value (and return the new value) if called with 1N/Aan additional argument. Embedded structures and unions are returned as a 1N/Apointer rather than the complete structure, to facilitate chained calls. 1N/AThese methods all apply to the Ptr type for the structure; additionally 1N/Atwo methods are constructed for the structure type itself, C<_to_ptr> 1N/Awhich returns a Ptr type pointing to the same structure, and a C<new> 1N/Amethod to construct and return a new structure, initialised to zeroes. 1N/A=item B<-b>, B<--compat-version>=I<version> 1N/AGenerates a .pm file which is backwards compatible with the specified 1N/AFor versions < 5.6.0, the changes are. 1N/A - no use of 'our' (uses 'use vars' instead) 1N/ASpecifying a compatibility version higher than the version of perl you 1N/Aare using to run h2xs will have no effect. If unspecified h2xs will default 1N/Ato compatibility with the version of perl you are using to run h2xs. 1N/A=item B<-c>, B<--omit-constant> 1N/AOmit C<constant()> from the .xs file and corresponding specialised 1N/AC<AUTOLOAD> from the .pm file. 1N/A=item B<-d>, B<--debugging> 1N/ATurn on debugging messages. 1N/A=item B<-e>, B<--omit-enums>=[I<regular expression>] 1N/AIf I<regular expression> is not given, skip all constants that are defined in 1N/Aa C enumeration. Otherwise skip only those constants that are defined in an 1N/Aenum whose name matches I<regular expression>. 1N/ASince I<regular expression> is optional, make sure that this switch is followed 1N/Aby at least one other switch if you omit I<regular expression> and have some 1N/Apending arguments such as header-file names. This is ok: 1N/A h2xs -e -n Module::Foo foo.h 1N/A h2xs -n Module::Foo -e foo.h 1N/AIn the latter, foo.h is taken as I<regular expression>. 1N/A=item B<-f>, B<--force> 1N/AAllows an extension to be created for a header even if that header is 1N/Anot found in standard include directories. 1N/A=item B<-g>, B<--global> 1N/AInclude code for safely storing static data in the .xs file. 1N/AExtensions that do no make use of static data can ignore this option. 1N/A=item B<-h>, B<-?>, B<--help> 1N/APrint the usage, help and version for this h2xs and exit. 1N/A=item B<-k>, B<--omit-const-func> 1N/AFor function arguments declared as C<const>, omit the const attribute in the 1N/A=item B<-m>, B<--gen-tied-var> 1N/AB<Experimental>: for each variable declared in the header file(s), declare 1N/Aa perl variable of the same name magically tied to the C variable. 1N/A=item B<-n>, B<--name>=I<module_name> 1N/ASpecifies a name to be used for the extension, e.g., S<-n RPC::DCE> 1N/A=item B<-o>, B<--opaque-re>=I<regular expression> 1N/AUse "opaque" data type for the C types matched by the regular 1N/Aexpression, even if these types are C<typedef>-equivalent to types 1N/Afrom typemaps. Should not be used without B<-x>. 1N/AThis may be useful since, say, types which are C<typedef>-equivalent 1N/Ato integers may represent OS-related handles, and one may want to work 1N/Awith these handles in OO-way, as in C<$handle-E<gt>do_something()>. 1N/AUse C<-o .> if you want to handle all the C<typedef>ed types as opaque 1N/AThe type-to-match is whitewashed (except for commas, which have no 1N/Awhitespace before them, and multiple C<*> which have no whitespace 1N/A=item B<-p>, B<--remove-prefix>=I<prefix> 1N/ASpecify a prefix which should be removed from the Perl function names, 1N/Ae.g., S<-p sec_rgy_> This sets up the XS B<PREFIX> keyword and removes 1N/Athe prefix from functions that are autoloaded via the C<constant()> 1N/A=item B<-s>, B<--const-subs>=I<sub1,sub2> 1N/ACreate a perl subroutine for the specified macros rather than autoload 1N/Awith the constant() subroutine. These macros are assumed to have a 1N/Areturn type of B<char *>, e.g., 1N/AS<-s sec_rgy_wildcard_name,sec_rgy_wildcard_sid>. 1N/A=item B<-t>, B<--default-type>=I<type> 1N/ASpecify the internal type that the constant() mechanism uses for macros. 1N/AThe default is IV (signed integer). Currently all macros found during the 1N/Aheader scanning process will be assumed to have this type. Future versions 1N/Aof C<h2xs> may gain the ability to make educated guesses. 1N/A=item B<--use-new-tests> 1N/AWhen B<--compat-version> (B<-b>) is present the generated tests will use 1N/AC<Test::More> rather than C<Test> which is the default for versions before 1N/A5.7.2 . C<Test::More> will be added to PREREQ_PM in the generated 1N/A=item B<--use-old-tests> 1N/AWill force the generation of test code that uses the older C<Test> module. 1N/A=item B<--skip-exporter> 1N/ADo not use C<Exporter> and/or export any symbol. 1N/A=item B<--skip-ppport> 1N/ADo not use C<Devel::PPPort>: no portability to older version. 1N/A=item B<--skip-autoloader> 1N/ADo not use the module C<AutoLoader>; but keep the constant() function 1N/Aand C<sub AUTOLOAD> for constants. 1N/A=item B<--skip-strict> 1N/ADo not use the pragma C<strict>. 1N/A=item B<--skip-warnings> 1N/ADo not use the pragma C<warnings>. 1N/A=item B<-v>, B<--version>=I<version> 1N/ASpecify a version number for this extension. This version number is added 1N/Ato the templates. The default is 0.01, or 0.00_01 if C<-B> is specified. 1N/AThe version specified should be numeric. 1N/A=item B<-x>, B<--autogen-xsubs> 1N/AAutomatically generate XSUBs basing on function declarations in the 1N/Aheader file. The package C<C::Scan> should be installed. If this 1N/Aoption is specified, the name of the header file may look like 1N/AC<NAME1,NAME2>. In this case NAME1 is used instead of the specified 1N/Astring, but XSUBs are emitted only for the declarations included from 1N/Ahand-editing. Such may be objects which cannot be converted from/to a 1N/Apointer (like C<long long>), pointers to functions, or arrays. See 1N/Aalso the section on L<LIMITATIONS of B<-x>>. 1N/A # Default behavior, extension is Rusers 1N/A # Same, but extension is RUSERS 1N/A # Without constant() or AUTOLOAD 1N/A # Creates templates for an extension named RPC 1N/A # Extension is ONC::RPC. 1N/A # Extension is Lib::Foo which works at least with Perl5.005_03. 1N/A # Constants are created for all #defines and enums h2xs can find 1N/A h2xs -b 5.5.3 -n Lib::Foo foo.h 1N/A # Extension is Lib::Foo which works at least with Perl5.005_03. 1N/A # Constants are created for all #defines but only for enums 1N/A # whose names do not start with 'bar_'. 1N/A h2xs -b 5.5.3 -e '^bar_' -n Lib::Foo foo.h 1N/A # Extension is DCE::rgynbase 1N/A # prefix "sec_rgy_" is dropped from perl function names 1N/A # Extension is DCE::rgynbase 1N/A # prefix "sec_rgy_" is dropped from perl function names 1N/A # subroutines are created for sec_rgy_wildcard_name and 1N/A # sec_rgy_wildcard_sid 1N/A h2xs -n DCE::rgynbase -p sec_rgy_ \ 1N/A # Make XS without defines in perl.h, but with function declarations 1N/A # visible from perl.h. Name of the extension is perl1. 1N/A # When scanning perl.h, define -DEXT=extern -DdEXT= -DINIT(x)= 1N/A # Extra backslashes below because the string is passed to shell. 1N/A # Note that a directory with perl header files would 1N/A # be added automatically to include path. 1N/A h2xs -xAn perl1 -F "-DEXT=extern -DdEXT= -DINIT\(x\)=" perl.h 1N/A # Same with function declaration in proto.h as visible from perl.h. 1N/A h2xs -xAn perl2 perl.h,proto.h 1N/A # Same but select only functions which match /^av_/ 1N/A h2xs -M '^av_' -xAn perl2 perl.h,proto.h 1N/A # Same but treat SV* etc as "opaque" types 1N/A h2xs -o '^[S]V \*$' -M '^av_' -xAn perl2 perl.h,proto.h 1N/A=head2 Extension based on F<.h> and F<.c> files 1N/ASuppose that you have some C files implementing some functionality, 1N/Aand the corresponding header files. How to create an extension which 1N/Amakes this functionality accessable in Perl? The example below 1N/Aassumes that the header files are F<interface_simple.h> and 1N/AI<interface_hairy.h>, and you want the perl module be named as 1N/AC<Ext::Ension>. If you need some preprocessor directives and/or 1N/Alinking with external libraries, see the flags C<-F>, C<-L> and C<-l> 1N/A=item Find the directory name 1N/AStart with a dummy run of h2xs: 1N/A h2xs -Afn Ext::Ension 1N/AThe only purpose of this step is to create the needed directories, and 1N/Alet you know the names of these directories. From the output you can 1N/ACopy your header files and C files to this directory F<Ext/Ension>. 1N/A=item Create the extension 1N/ARun h2xs, overwriting older autogenerated files: 1N/A h2xs -Oxan Ext::Ension interface_simple.h interface_hairy.h 1N/Ah2xs looks for header files I<after> changing to the extension 1N/Adirectory, so it will find your header files OK. 1N/A=item Archive and test 1N/AIt is important to do C<make dist> as early as possible. This way you 1N/Acan easily merge(1) your changes to autogenerated files if you decide 1N/Ato edit your C<.h> files and rerun h2xs. 1N/ADo not forget to edit the documentation in the generated F<.pm> file. 1N/AConsider the autogenerated files as skeletons only, you may invent 1N/Abetter interfaces than what h2xs could guess. 1N/AConsider this section as a guideline only, some other options of h2xs 1N/Amay better suit your needs. 1N/ANo environment variables are used. 1N/ALarry Wall and others 1N/AL<perl>, L<perlxstut>, L<ExtUtils::MakeMaker>, and L<AutoLoader>. 1N/AThe usual warnings if it cannot read or write the files involved. 1N/A=head1 LIMITATIONS of B<-x> 1N/AF<h2xs> would not distinguish whether an argument to a C function 1N/Awhich is of the form, say, C<int *>, is an input, output, or 1N/Ashould be better rewritten as 1N/Aif C<n> is an input parameter. 1N/AAdditionally, F<h2xs> has no facilities to intuit that a function 1N/Atakes a pair of address and length of data at this address, so it is better 1N/Ato rewrite this function as 1N/A RETVAL = foo(s, len); 1N/A char *s = SvPV(sv,len); 1N/A MODULE = foo PACKAGE = foo PREFIX = my_ 1N/ASee L<perlxs> and L<perlxstut> for additional details. 1N/A usage "You must provide the backwards compatibility version in X.Y.Z form. " 1N/A # check if it is numeric 1N/A use warnings 'numeric';
1N/A# -X implies -c and -f 1N/Ausage "Must supply header file or module name\n" 1N/A if ($^O
eq 'VMS') {
# Consider overrides of default location 1N/A # XXXX This is not equivalent to what the older version did: 1N/A # it was looking at $hadsys header-file per header-file... 1N/A push @
paths, ($
hadsys ?
'GNU_CC_Include[vms]' :
'GNU_CC_Include[000000]');
1N/A warn "Nesting of headerfile ignored with -n\n";
1N/A # Minor trickery: we can't chdir() before we processed the headers 1N/A # (so know the name of the extension), but the header may be in the 1N/A # extension directory... 1N/A die "Can't find $tmp_path_h in @dirs\n" 1N/A # Scan the header file (we should deal with nested header files) 1N/A # Record the names of simple #define constants into const_names 1N/A # Function prototypes are processed below. 1N/A open(
CH,
"<$rel_path_h") ||
die "Can't open $rel_path_h: $!\n";
1N/A # Preprocess all tri-graphs 1N/A # including things stuck in quoted string constants. 1N/A s/\?\?=/
#/g; # | ??=| #| 1N/A s/\?\?\!/|/g;
# | ??!| || 1N/A s/\?\?
'/^/g; # | ??'| ^|
1N/A s/\?\?\(/[/g;
# | ??(| [| 1N/A s/\?\?\)/]/g;
# | ??)| ]| 1N/A s/\?\?\-/~/g;
# | ??-| ~| 1N/A s/\?\?\//\\/g;
# | ??/| \| 1N/A s/\?\?</{/g;
# | ??<| {| 1N/A s/\?\?>/}/g;
# | ??>| }| 1N/A if (/^[ \t]*
#[ \t]*define\s+([\$\w]+)\b(?!\()\s*(?=[^"\s])(.*)/) { 1N/A $
rest =~ s!/\*.*?(\*/|\n)|//.*!!g;
# Remove comments 1N/A # Cannot do: (-1) and ((LHANDLE)3) are OK: 1N/A #print("Skip non-wordy $def => $rest\n"), 1N/A # next defines if $rest =~ /[^\w\$]/; 1N/A print(
"Skip stringy $def => $rest\n")
if $
opt_d;
1N/A next if /^_.*
_h_*$/i;
# special case, but for what? 1N/A warn "can't remove $opt_p prefix from '$_'!\n";
1N/A # Work from miniperl too - on "normal" systems 1N/A no warnings 'uninitialized';
1N/A # Remove C and C++ comments 1N/A $
src =~ s
#/\*[^*]*\*+([^/*][^*]*\*+)*/|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|.[^/"'\\]*)#$2#gs; 1N/A # skip enums matching $opt_e 1N/A }
# if (!defined $opt_e or $opt_e) 1N/A# Save current directory so that C::Scan can use it 1N/A# As Ilya suggested, use a name that contains - and then it can't clash with 1N/A# the names of any packages. A directory 'fallback' will clash with any 1N/A# new pragmata down the fallback:: tree, but that seems unlikely. 1N/Amy $
ext =
chdir 'ext' ?
'ext/' :
'';
1N/A warn "Overwriting existing $ext$modpname!!!\n" if -e $
modpname;
1N/A die "Won't overwrite existing $ext$modpname\n" if -e $
modpname;
1N/Achdir($
modpname) ||
die "Can't chdir $ext$modpname: $!\n";
1N/Aif( ! $
opt_X ){
# use XS, unless it was disabled 1N/A open(
XS,
">$modfname.xs") ||
die "Can't create $ext$modpname/$modfname.xs: $!\n";
1N/A warn "Scanning typemaps...\n";
1N/A warn "Scanning $filename for functions...\n";
1N/A $c->
set(
'includeDirs' => [
"$Config::Config{archlib}/CORE", $
cwd]);
1N/A warn "Can't handle variable '$type $var $post', skipping.\n";
1N/A warn "Scanning $filename for typedefs...\n";
1N/A # eval {require 'dumpvar.pl'; ::dumpValue($td)} or warn $@ if $opt_d; 1N/A for my $i (
0..$
#$fdecls_parsed) { 1N/A print "... Function $fdecls_parsed->[$i][1] passes -M mask.\n" 1N/A # Sort declarations: 1N/A # Remove macros which expand to typedefs 1N/A # Add some other possible but meaningless values for macros 1N/A $
td{
"$_$k"} =
"$_$k" for (
'',
'signed ',
'unsigned ');
1N/A # eval {require 'dumpvar.pl'; ::dumpValue( [\@td, \%td] ); 1} or warn $@; 1N/A # print("found '$k'=>'$v'\n"), 1N/A # Now %bad_macs contains names of bad macros 1N/A print "Ignoring macro $k which expands to a typedef name '$bad_macs{$k}'\n" if $
opt_d;
1N/Aopen(
PM,
">$modpmname") ||
die "Can't create $ext$modpname/$modpmname: $!\n";
1N/Awarn "Writing $ext$modpname/$modpmname\n";
1N/A # we'll have an AUTOLOAD(), and it will have $AUTOLOAD and 1N/Aprint PM <<
"END" if $
use_Dyna;
# use DynaLoader, unless XS was disabled 1N/A# Are we using AutoLoader or not? 1N/A unless ($
opt_c) {
# we're doing the AUTOLOAD 1N/A print PM "use AutoLoader;\n";
1N/A print PM "use AutoLoader qw(AUTOLOAD);\n" 1N/A print PM "use vars qw($vars);";
1N/A# Items to export into callers namespace by default. Note: do not export 1N/A# names by default without a very good reason. Use EXPORT_OK instead. 1N/A# This allows declaration use $module ':all'; 1N/A# If you do not need this, moving things directly into \@EXPORT or \@EXPORT_OK 1N/A$
tmp .=
"our \$VERSION = '$TEMPLATE_VERSION';\n";
1N/A $
tmp .=
"our \$XS_VERSION = \$VERSION;\n" unless $
opt_X;
1N/A $
tmp .=
"\$VERSION = eval \$VERSION; # see L<perlmodstyle>\n";
1N/A printf PM "our(@{[ join ', ', map '$'.$_, @vdecls ]});\n\n";
1N/Aif( ! $
opt_X ){
# print bootstrap, unless XS is disabled 1N/A# tying the variables can happen only after bootstrap 1N/A@{[
join "\n",
map " _tievar_$_(\$$_);", @
vdecls ]}
1N/A# Preloaded methods go here. 1N/A# Autoload methods go after $after, and are processed by the autosplit program. 1N/A$
email ||=
'a.u.thor@a.galaxy.far.far.away';
1N/A#=item $TEMPLATE_VERSION 1N/A#Original version; created by h2xs $H2XS_VERSION with options 1N/A#=head2 Exportable constants 1N/A# @{[join "\n ", @const_names]} 1N/A#=head2 Exportable functions 1N/A# $exp_doc .= <<EOD if $opt_p; 1N/A#When accessing these functions from Perl, prefix C<$opt_p> should be removed. 1N/A# @{[join "\n ", @known_fnames{@fnames}]} 1N/A# Prefix the default licence with hash symbols. 1N/A# Is this just cargo cult - it seems that the first thing that happens to this 1N/A# block is that all the hashes are then s///g out. 1N/A## Below is stub documentation for your module. You'd better edit it! 1N/A#$module - Perl extension for blah blah blah 1N/A#Stub documentation for $module, created by h2xs. It looks like the 1N/A#author of the extension was negligent enough to leave the stub 1N/A#Mention other useful documentation such as the documentation of 1N/A#related modules or operating system documentation (such as man pages 1N/A#in UNIX), or any relevant external documentation such as RFCs or 1N/A#If you have a mailing list set up for your module, mention it here. 1N/A#If you have a web site set up for your module, mention it here. 1N/A#$author, E<lt>${email}E<gt> 1N/A#=head1 COPYRIGHT AND LICENSE 1N/A$
pod =~ s/^\
#//gm unless $opt_P; 1N/Aif( ! $
opt_X ){
# print XS, unless it is disabled 1N/Awarn "Writing $ext$modpname/$modfname.xs\n";
1N/A if ($^O
eq 'VMS') { $h =~ s
#.*vms\]#sys/# or $h =~ s#.*[:>\]]##; } 1N/A print XS qq{
#include <$h>\n}; 1N/A#define MY_CXT_KEY "${module}::_guts" XS_VERSION 1N/A # This converts only the guys which do not have trailing part in the typedef 1N/A print "Is-Pointer: Type mutation via typedefs: $otype ==> $type\n" 1N/A # This converts only the guys which do not have trailing part in the typedef 1N/A print "Is-Struct: Type mutation via typedefs: $otype ==> $type\n" 1N/A # We write the "sample" files used when this module is built by perl without 1N/A # ExtUtils::Constant. 1N/A # h2xs will later check that these are the same as those generated by the 1N/A mkdir "$fallbackdirname" or die "Cannot mkdir $fallbackdirname: $!\n";
1N/A warn "Writing $ext$modpname/$fallbackdirname/$constscfname\n";
1N/A warn "Writing $ext$modpname/$fallbackdirname/$constsxsfname\n";
1N/A print XS "#include \"$constscfname\"\n";
1N/A# Now switch from C to XS by issuing the first MODULE declaration: 1N/A# If a constant() function was #included then output a corresponding 1N/Aprint XS "INCLUDE: $constsxsfname\n" unless $
opt_c;
1N/A croak(
"Your vendor has not defined the $module macro $_");
1N/A croak(
"Size \%d of packed data != expected \%d",
1N/A croak(
"THIS is not of type $name");
1N/A @$_[
0,
1],
"$item->[2]_$_->[2]",
"$item->[2].$_->[2]",
1N/A $
type eq $
ttype ?
"THIS->$item->[-1]" :
"&(THIS->$item->[-1])" 1N/A @$_[
0,
1],
"$item->[2]_$_->[2]",
"$item->[2].$_->[2]",
1N/A#=head2 Object and class methods for C<$name>/C<$ptrname> 1N/A#The principal Perl representation of a C object of type C<$name> is an 1N/A#object of class C<$ptrname> which is a reference to an integer 1N/A#representation of a C pointer. To create such an object, one may use 1N/A# my \$buffer = $name->new(); 1N/A# my \$obj = \$buffer->_to_ptr(); 1N/A#This exersizes the following two methods, and an additional class 1N/A#C<$name>, the internal representation of which is a reference to a 1N/A#packed string with the C structure. Keep in mind that \$buffer should 1N/A#better survive longer than \$obj. 1N/A#=item C<\$object_of_type_$name-E<gt>_to_ptr()> 1N/A#Converts an object of type C<$name> to an object of type C<$ptrname>. 1N/A#=item C<$name-E<gt>new()> 1N/A#Creates an empty object of type C<$name>. The corresponding packed 1N/A#string is zeroed out. 1N/A#return the current value of the corresponding element if called 1N/A#without additional arguments. Set the element to the supplied value 1N/A#(and return the new value) if called with an additional argument. 1N/A#Applicable to objects of type C<$ptrname>. 1N/A# Should be called before any actual call to normalize_type(). 1N/A # We do not want to read ./typemap by obvios reasons. 1N/A # Start with useful default values 1N/A # skip directories, binary files etc. 1N/A warn " Scanning $typemap\n";
1N/A warn(
"Warning: ignoring non-text typemap file '$typemap'\n"),
next 1N/A or warn (
"Warning: could not open typemap file '$typemap': $!\n"),
next;
1N/A next if /^\s*($|\
#)/ ; 1N/A # This may reference undefined functions: 1N/A close(
TYPEMAP)
or die "Cannot close $typemap: $!";
1N/A # If $do_keep_deep_const this is heuristical only 1N/A =
"(?:\\b(?:(?:__const__|const)$keep_deep_const|static|inline|__inline__)\\b\\s*)*";
1N/A print "Type $type matches -o mask\n" if $
opt_d;
1N/A print "Type mutation via typedefs: $otype ==> $type\n" if $
opt_d;
1N/A # XXX good do better if our UV happens to be long long 1N/A open TM,
">typemap" or die "Cannot open typemap file for write: $!";
1N/A############################################################################# 1N/A croak(\
"Size %d of packed data != expected %d\", 1N/A croak(\
"$var is not of type ${ntype}\") 1N/A############################################################################# 1N/A close TM or die "Cannot close typemap file for write: $!";
1N/A# the contents of the Makefile that is written. 1N/A (\$] >=
5.005 ?
## Add these new keywords supported since 5.005 1N/Aif (!$
opt_X) {
# print C stuff, unless XS is disabled 1N/A my $I = (((
glob '*.h') || (
glob '*.hh')) ?
'-I.' :
'');
1N/A # Insert -I. if you add *.h files later: 1N/A LIBS => [
'$extralibs'],
# e.g., '-lm' 1N/A DEFINE =>
'$opt_F',
# e.g., '-DHAVE_SOMETHING' 1N/A my $C =
grep {$_
ne "$modfname.c"}
1N/A (
glob '*.c'), (
glob '*.cc'), (
glob '*.C');
1N/A # Un-comment this if you add C files to link with later: 1N/A # If you edit these definitions to change the constants used by this module, 1N/A # you will need to use the generated $constscfname and $constsxsfname 1N/A # files to replace their "fallback" counterparts before distributing your 1N/A foreach my \$
file (
'$constscfname',
'$constsxsfname') {
1N/AFiles "$ext$modpname/$fallbackdirname/$file" and "$ext$modpname/$file" differ.
1N/A# Create a simple README since this is a CPAN requirement 1N/A# and it doesnt hurt to have one 1N/Amy $
rmhead =
"$modpname version $TEMPLATE_VERSION";
1N/Aunless (-d
"$testdir") {
1N/A mkdir "$testdir" or die "Cannot mkdir $testdir: $!\n";
1N/Awarn "Writing $ext$modpname/$testfile\n";
1N/Aopen EX,
">$testfile" or die "Can't create $ext$modpname/$testfile: $!\n";
1N/A# Before `make install' is performed this script should be runnable with 1N/A# `make test'. After `make install' it should work as `perl $modpname.t' 1N/A######################### 1N/A# change 'tests => $tests' to 'tests => last_test_to_print'; 1N/Aok(
1);
# If we made it this far, we're ok. 1N/A next if (
eval "my \\\$a = \$constname; 1");
1N/A print "# pass: \$\@";
1N/A print "# fail: \$\@";
1N/A print "not ok 2\\n";
1N/A next if (
eval "my \\\$a = \$constname; 1");
1N/A print "# pass: \$\@";
1N/A print "# fail: \$\@";
1N/A######################### 1N/A# Insert your test code below, the $test_mod module is use()ed here so read 1N/A# its man page ( perldoc $test_mod ) for help writing this test script. 1N/Aclose(
EX) ||
die "Can't close $ext$modpname/$testfile: $!\n";
1N/A @
ARGS =
map {/[\s\
"\'\`\$*?^|&<>\[\]\{\}\(\)]/ ? "'$_'" : $_} @ARGS; 1N/Aopen(
MANI,
'>MANIFEST')
or die "Can't create MANIFEST: $!";
1N/A eval {
opendir(D,
'.');};
1N/A unless ($@) { @
files =
readdir(D);
closedir(D); }
1N/A # Clip trailing '.' for portability -- non-VMS OSs don't expect it 1N/A # Fix up for case-sensitive file systems 1N/A $_ =
"\U$_" if $_
eq 'manifest' or $_
eq 'changes';
1N/Aclose OUT or die "Can't close $file: $!";
1N/Achmod 0755, $
file or die "Can't reset permissions for $file: $!\n";
1N/Aexec(
"$Config{'eunicefix'} $file")
if $
Config{
'eunicefix'}
ne ':';