From f508c6526654a0308ba4f35e40591236baa0a3c8 Mon Sep 17 00:00:00 2001 From: Perl 5 Porters Date: Tue, 2 Jan 1996 00:50:55 +0000 Subject: perl 5.002beta1h patch: utils/h2xs.PL Add version stuff. The old version didn't have a number. This one's called 1.12. --- utils/h2xs.PL | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 108 insertions(+), 15 deletions(-) (limited to 'utils/h2xs.PL') diff --git a/utils/h2xs.PL b/utils/h2xs.PL index b7bf49654d..535ec4108f 100644 --- a/utils/h2xs.PL +++ b/utils/h2xs.PL @@ -41,7 +41,9 @@ h2xs - convert .h C header files to Perl extensions =head1 SYNOPSIS -B [B<-Acfh>] [B<-n> module_name] [headerfile [extra_libraries]] +B [B<-APcf>] [B<-v> version] [B<-n> module_name] [headerfile [extra_libraries]] + +B B<-h> =head1 DESCRIPTION @@ -66,24 +68,37 @@ in the extra-libraries argument. =over 5 -=item B<-n> I +=item B<-A> -Specifies a name to be used for the extension, e.g., S<-n RPC::DCE> +Omit all autoload facilities. This is the same as B<-c> but also removes the +S> statement from the .pm file. -=item B<-f> +=item B<-P> -Allows an extension to be created for a header even if that header is -not found in /usr/include. +Omit the autogenerated stub POD section. =item B<-c> Omit C from the .xs file and corresponding specialised C from the .pm file. -=item B<-A> +=item B<-f> -Omit all autoload facilities. This is the same as B<-c> but also removes the -S> statement from the .pm file. +Allows an extension to be created for a header even if that header is +not found in /usr/include. + +=item B<-h> + +Print the usage, help and version for this h2xs and exit. + +=item B<-n> I + +Specifies a name to be used for the extension, e.g., S<-n RPC::DCE> + +=item B<-v> I + +Specify a version number for this extension. This version number is added +to the templates. The default is 0.01. =back @@ -126,7 +141,7 @@ Larry Wall and others =head1 SEE ALSO -L, L, L +L, L, L, and L. =head1 DIAGNOSTICS @@ -134,27 +149,36 @@ The usual warnings if it can't read or write the files involved. =cut +my( $H2XS_VERSION ) = '$Revision: 1.12 $' =~ /\$Revision:\s+([^\s]+)/; +my $TEMPLATE_VERSION = '0.01'; use Getopt::Std; sub usage{ warn "@_\n" if @_; - die 'h2xs [-Acfh] [-n module_name] [headerfile [extra_libraries]] + die "h2xs [-APcfh] [-v version] [-n module_name] [headerfile [extra_libraries]] +version: $H2XS_VERSION -f Force creation of the extension even if the C header does not exist. -n Specify a name to use for the extension (recommended). -c Omit the constant() function and specialised AUTOLOAD from the XS file. -A Omit all autoloading facilities (implies -c). + -P Omit the stub POD section. + -v Specify a version number for this extension. -h Display this help message extra_libraries are any libraries that might be needed for loading the extension, e.g. -lm would try to link in the math library. -'; +"; } -getopts("Acfhn:") || usage; +getopts("APcfhv:n:") || usage; usage if $opt_h; + +if( $opt_v ){ + $TEMPLATE_VERSION = $opt_v; +} $opt_c = 1 if $opt_A; $path_h = shift; @@ -262,6 +286,8 @@ print PM<<"END"; \@EXPORT = qw( @const_names ); +\$VERSION = '$TEMPLATE_VERSION'; + END print PM <<"END" unless $opt_c; @@ -290,7 +316,7 @@ sub AUTOLOAD { END print PM <<"END"; -bootstrap $module; +bootstrap $module \$VERSION; # Preloaded methods go here. @@ -300,6 +326,43 @@ bootstrap $module; __END__ END +$author = "A. U. Thor"; +$email = 'a.u.thor@a.galaxy.far.far.away'; + +$pod = <<"END" unless $opt_P; +## Below is the stub of documentation for your module. You better edit it! +# +#=head1 NAME +# +#$module - Perl extension for blah blah blah +# +#=head1 SYNOPSIS +# +# use $module; +# blah blah blah +# +#=head1 DESCRIPTION +# +#Stub documentation for $module was created by h2xs. It looks like the +#author of the extension was negligent enough to leave the stub +#unedited. +# +#Blah blah blah. +# +#=head1 AUTHOR +# +#$author, $email +# +#=head1 SEE ALSO +# +#perl(1). +# +#=cut +END + +$pod =~ s/^\#//gm unless $opt_P; +print PM $pod unless $opt_P; + close PM; @@ -418,12 +481,42 @@ use ExtUtils::MakeMaker; END print PL "WriteMakefile(\n"; print PL " 'NAME' => '$module',\n"; -print PL " 'VERSION' => '0.1',\n"; +print PL " 'VERSION' => '$TEMPLATE_VERSION',\n"; print PL " 'LIBS' => ['$extralibs'], # e.g., '-lm' \n"; print PL " 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING' \n"; print PL " 'INC' => '', # e.g., '-I/usr/include/other' \n"; print PL ");\n"; +close(PL) || die "Can't close $ext$modpname/Makefile.PL: $!\n"; + +warn "Writing $ext$modpname/test.pl\n"; +open(EX, ">test.pl") || die "Can't create $ext$modpname/test.pl: $!\n"; +print EX <<'_END_'; +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. + +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN {print "1..1\n";} +END {print "not ok 1\n" unless $loaded;} +_END_ +print EX <<_END_; +use $module; +_END_ +print EX <<'_END_'; +$loaded = 1; +print "ok 1\n"; + +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): +_END_ +close(EX) || die "Can't close $ext$modpname/test.pl: $!\n"; system '/bin/ls > MANIFEST' or system 'ls > MANIFEST'; !NO!SUBS! -- cgit v1.2.1