5.005_03-MAINT_TRIAL_5 utils/h2xs fixing -A & more
authorMichael G. Schwern <schwern@pobox.com>
Tue, 9 Feb 1999 04:13:12 +0000 (23:13 -0500)
committerGurusamy Sarathy <gsar@cpan.org>
Mon, 15 Feb 1999 06:04:02 +0000 (06:04 +0000)
Message-ID: <19990209041312.A15788@toldyouso.com>

p4raw-id: //depot/perl@2935

utils/h2xs.PL

index 47f7ada..f1d4045 100644 (file)
@@ -71,7 +71,7 @@ in the extra-libraries argument.
 =item B<-A>
 
 Omit all autoload facilities.  This is the same as B<-c> but also removes the
-S<C<require AutoLoader>> statement from the .pm file.
+S<C<use AutoLoader>> statement from the .pm file.
 
 =item B<-F>
 
@@ -89,7 +89,7 @@ Omit the autogenerated stub POD section.
 =item B<-X>
 
 Omit the XS portion.  Used to generate templates for a module which is not
-XS-based.
+XS-based.  C<-c> and C<-f> are implicitly enabled.
 
 =item B<-c>
 
@@ -224,7 +224,7 @@ version: $H2XS_VERSION
     -F   Additional flags for C preprocessor (used with -x).
     -O   Allow overwriting of a pre-existing extension directory.
     -P   Omit the stub POD section.
-    -X   Omit the XS portion.
+    -X   Omit the XS portion (implies both -c and -f).
     -c   Omit the constant() function and specialised AUTOLOAD from the XS file.
     -d   Turn on debugging messages.
     -f   Force creation of the extension even if the C header does not exist.
@@ -248,7 +248,13 @@ usage if $opt_h;
 if( $opt_v ){
        $TEMPLATE_VERSION = $opt_v;
 }
+
+# -A implies -c.
 $opt_c = 1 if $opt_A;
+
+# -X implies -c and -f
+$opt_c = $opt_f = 1 if $opt_X;
+
 %const_xsub = map { $_,1 } split(/,+/, $opt_s) if $opt_s;
 
 while (my $arg = shift) {
@@ -426,46 +432,22 @@ print PM <<"END" if ! $opt_X;  # use DynaLoader, unless XS was disabled
 require DynaLoader;
 END
 
-# require autoloader if XS is disabled.
-# if XS is enabled, require autoloader unless autoloading is disabled.
-if( ($opt_X && (! $opt_A)) || (!$opt_X) ) {
-       print PM <<"END";
-require AutoLoader;
-END
-}
-
-if( $opt_X || ($opt_c && ! $opt_A) ){
-       # we won't have our own AUTOLOAD(), so we'll inherit it.
-       if( ! $opt_X ) { # use DynaLoader, unless XS was disabled
-               print PM <<"END";
 
-\@ISA = qw(Exporter AutoLoader DynaLoader);
-END
+# Are we using AutoLoader or not?
+unless ($opt_A) { # no autoloader whatsoever.
+       unless ($opt_c) { # we're doing the AUTOLOAD
+               print PM "use AutoLoader;\n";
        }
-       else{
-               print PM <<"END";
-
-\@ISA = qw(Exporter AutoLoader);
-END
+       else {
+               print PM "use AutoLoader qw(AUTOLOAD);\n"
        }
 }
-else{
-       # 1) we have our own AUTOLOAD(), so don't need to inherit it.
-       # or
-       # 2) we don't want autoloading mentioned.
-       if( ! $opt_X ){ # use DynaLoader, unless XS was disabled
-               print PM <<"END";
 
-\@ISA = qw(Exporter DynaLoader);
-END
-       }
-       else{
-               print PM <<"END";
-
-\@ISA = qw(Exporter);
-END
-       }
-}
+# Determine @ISA.
+my $myISA = '@ISA = qw(Exporter';      # We seem to always want this.
+$myISA .= ' DynaLoader'        unless $opt_X;  # no XS
+$myISA .= ');';
+print PM "\n$myISA\n\n";
 
 print PM<<"END";
 # Items to export into callers namespace by default. Note: do not export
@@ -519,8 +501,14 @@ else {
 print PM <<"END";
 
 # Preloaded methods go here.
+END
+
+print PM <<"END" unless $opt_A;
 
 # Autoload methods go after $after, and are processed by the autosplit program.
+END
+
+print PM <<"END";
 
 1;
 __END__