summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2002-03-04 22:48:38 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-03-04 22:17:56 +0000
commit1cb0fb506639f41107792256805556ee04e5463a (patch)
treeedcae7d6f9d2e1e4ca67c0e7cd70b1943e06b734
parent26f1752374957703dbfe054b7fa25c12c67ca6f3 (diff)
downloadperl-1cb0fb506639f41107792256805556ee04e5463a.tar.gz
(was Re: [PATCH @13746] h2xs)
Message-ID: <20020304224837.GA4284@Bagpuss.unfortu.net> p4raw-id: //depot/perl@15023
-rw-r--r--ext/Fcntl/Fcntl.xs4
-rw-r--r--ext/Fcntl/Makefile.PL3
-rw-r--r--ext/File/Glob/Glob.xs4
-rw-r--r--ext/File/Glob/Makefile.PL3
-rw-r--r--ext/GDBM_File/GDBM_File.xs4
-rw-r--r--ext/GDBM_File/Makefile.PL3
-rw-r--r--ext/I18N/Langinfo/Langinfo.xs4
-rw-r--r--ext/I18N/Langinfo/Makefile.PL13
-rw-r--r--ext/POSIX/Makefile.PL3
-rw-r--r--ext/POSIX/POSIX.xs4
-rw-r--r--ext/Socket/Makefile.PL3
-rw-r--r--ext/Socket/Socket.xs4
-rw-r--r--ext/Sys/Syslog/Makefile.PL3
-rw-r--r--ext/Sys/Syslog/Syslog.xs4
-rw-r--r--lib/ExtUtils/Constant.pm19
-rw-r--r--lib/h2xs.t65
-rw-r--r--utils/h2xs.PL71
17 files changed, 115 insertions, 99 deletions
diff --git a/ext/Fcntl/Fcntl.xs b/ext/Fcntl/Fcntl.xs
index 9f167d07f8..c907c9ac8d 100644
--- a/ext/Fcntl/Fcntl.xs
+++ b/ext/Fcntl/Fcntl.xs
@@ -33,8 +33,8 @@
--AD October 16, 1995
*/
-#include "constants.c"
+#include "const-c.inc"
MODULE = Fcntl PACKAGE = Fcntl
-INCLUDE: constants.xs \ No newline at end of file
+INCLUDE: const-xs.inc
diff --git a/ext/Fcntl/Makefile.PL b/ext/Fcntl/Makefile.PL
index 030c8b4239..d9551a913e 100644
--- a/ext/Fcntl/Makefile.PL
+++ b/ext/Fcntl/Makefile.PL
@@ -1,11 +1,10 @@
use ExtUtils::MakeMaker;
-use ExtUtils::Constant 0.07 'WriteConstants';
+use ExtUtils::Constant 0.11 'WriteConstants';
WriteMakefile(
NAME => 'Fcntl',
MAN3PODS => {}, # Pods will be built by installman.
XSPROTOARG => '-noprototypes', # XXX remove later?
VERSION_FROM => 'Fcntl.pm',
- realclean => {FILES=> 'constants.c constants.xs'},
);
my @names = (qw(FAPPEND FASYNC FCREAT FDEFER FDSYNC FD_CLOEXEC FEXCL FLARGEFILE
diff --git a/ext/File/Glob/Glob.xs b/ext/File/Glob/Glob.xs
index 037b85cc47..bc58b6a934 100644
--- a/ext/File/Glob/Glob.xs
+++ b/ext/File/Glob/Glob.xs
@@ -14,7 +14,7 @@ START_MY_CXT
#define GLOB_ERROR (MY_CXT.x_GLOB_ERROR)
-#include "constants.c"
+#include "const-c.inc"
#ifdef WIN32
#define errfunc NULL
@@ -69,4 +69,4 @@ PPCODE:
bsd_globfree(&pglob);
}
-INCLUDE: constants.xs
+INCLUDE: const-xs.inc
diff --git a/ext/File/Glob/Makefile.PL b/ext/File/Glob/Makefile.PL
index 0ff49ebe17..3cf83f1b12 100644
--- a/ext/File/Glob/Makefile.PL
+++ b/ext/File/Glob/Makefile.PL
@@ -1,11 +1,10 @@
use ExtUtils::MakeMaker;
-use ExtUtils::Constant 0.08 'WriteConstants';
+use ExtUtils::Constant 0.11 'WriteConstants';
WriteMakefile(
NAME => 'File::Glob',
VERSION_FROM => 'Glob.pm',
MAN3PODS => {}, # Pods will be built by installman.
OBJECT => 'bsd_glob$(OBJ_EXT) Glob$(OBJ_EXT)',
- realclean => {FILES=> 'constants.c constants.xs'},
## uncomment for glob debugging (will cause make test to fail)
# DEFINE => '-DGLOB_DEBUG',
diff --git a/ext/GDBM_File/GDBM_File.xs b/ext/GDBM_File/GDBM_File.xs
index d58feeccef..5684a968e0 100644
--- a/ext/GDBM_File/GDBM_File.xs
+++ b/ext/GDBM_File/GDBM_File.xs
@@ -77,11 +77,11 @@ output_datum(pTHX_ SV *arg, char *str, int size)
#define gdbm_setopt(db,optflag,optval,optlen) not_here("gdbm_setopt")
#endif
-#include "constants.c"
+#include "const-c.inc"
MODULE = GDBM_File PACKAGE = GDBM_File PREFIX = gdbm_
-INCLUDE: constants.xs
+INCLUDE: const-xs.inc
GDBM_File
gdbm_TIEHASH(dbtype, name, read_write, mode, fatal_func = (FATALFUNC)croak)
diff --git a/ext/GDBM_File/Makefile.PL b/ext/GDBM_File/Makefile.PL
index f9dd2d203c..abdceecd5d 100644
--- a/ext/GDBM_File/Makefile.PL
+++ b/ext/GDBM_File/Makefile.PL
@@ -1,12 +1,11 @@
use ExtUtils::MakeMaker;
-use ExtUtils::Constant 0.07 'WriteConstants';
+use ExtUtils::Constant 0.11 'WriteConstants';
WriteMakefile(
NAME => 'GDBM_File',
LIBS => ["-L/usr/local/lib -lgdbm", "-ldbm"],
MAN3PODS => {}, # Pods will be built by installman.
XSPROTOARG => '-noprototypes', # XXX remove later?
VERSION_FROM => 'GDBM_File.pm',
- realclean => {FILES=> 'constants.c constants.xs'},
);
WriteConstants(
NAME => 'GDBM_File',
diff --git a/ext/I18N/Langinfo/Langinfo.xs b/ext/I18N/Langinfo/Langinfo.xs
index f1a0a1728b..39faaf1a3c 100644
--- a/ext/I18N/Langinfo/Langinfo.xs
+++ b/ext/I18N/Langinfo/Langinfo.xs
@@ -6,13 +6,13 @@
# include <langinfo.h>
#endif
-#include "constants.c"
+#include "const-c.inc"
MODULE = I18N::Langinfo PACKAGE = I18N::Langinfo
PROTOTYPES: ENABLE
-INCLUDE: constants.xs
+INCLUDE: const-xs.inc
SV*
langinfo(code)
diff --git a/ext/I18N/Langinfo/Makefile.PL b/ext/I18N/Langinfo/Makefile.PL
index 5015fce5ea..730a45fecc 100644
--- a/ext/I18N/Langinfo/Makefile.PL
+++ b/ext/I18N/Langinfo/Makefile.PL
@@ -13,10 +13,6 @@ WriteMakefile(
# Insert -I. if you add *.h files later:
'INC' => '', # e.g., '-I/usr/include/other'
'MAN3PODS' => {}, # Pods will be built by installman
- # Without this the constants xs files are spotted, and cause rules to be
- # added to delete the similarly named C files, which isn't what we want.
- XS => {'Langinfo.xs' => 'Langinfo.c'},
- realclean => {FILES=> 'constants.c constants.xs'},
# Un-comment this if you add C files to link with later:
# 'OBJECT' => '$(O_FILES)', # link all the C files too
);
@@ -46,8 +42,9 @@ if (eval {require ExtUtils::Constant; 1}) {
);
} else {
use File::Copy;
- copy ('fallback.c', 'constants.c')
- or die "Can't copy fallback.c to constants.c: $!";
- copy ('fallback.xs', 'constants.xs')
- or die "Can't copy fallback.xs to constants.xs: $!";
+ use File::Spec;
+ foreach my $file ('const-c.inc', 'const-xs.inc') {
+ my $fallback = File::Spec->catfile('fallback', $file);
+ copy ($fallback, $file) or die "Can't copy $fallback to $file: $!";
+ }
}
diff --git a/ext/POSIX/Makefile.PL b/ext/POSIX/Makefile.PL
index 6424066b47..04ba7459ba 100644
--- a/ext/POSIX/Makefile.PL
+++ b/ext/POSIX/Makefile.PL
@@ -1,5 +1,5 @@
use ExtUtils::MakeMaker;
-use ExtUtils::Constant 0.07 'WriteConstants';
+use ExtUtils::Constant 0.11 'WriteConstants';
use Config;
my @libs;
if ($^O ne 'MSWin32') {
@@ -11,7 +11,6 @@ WriteMakefile(
MAN3PODS => {}, # Pods will be built by installman.
XSPROTOARG => '-noprototypes', # XXX remove later?
VERSION_FROM => 'POSIX.pm',
- realclean => {FILES=> 'constants.c constants.xs'},
);
my @names =
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs
index b30edf18f4..238c5285ef 100644
--- a/ext/POSIX/POSIX.xs
+++ b/ext/POSIX/POSIX.xs
@@ -372,7 +372,7 @@ not_here(char *s)
return -1;
}
-#include "constants.c"
+#include "const-c.inc"
/* These were implemented in the old "constant" subroutine. They are actually
macros that take an integer argument and return an integer result. */
@@ -792,7 +792,7 @@ setcc(termios_ref, ccix, cc)
MODULE = POSIX PACKAGE = POSIX
-INCLUDE: constants.xs
+INCLUDE: const-xs.inc
void
int_macro_int(sv, iv)
diff --git a/ext/Socket/Makefile.PL b/ext/Socket/Makefile.PL
index c01d45ac8c..19f0acd49a 100644
--- a/ext/Socket/Makefile.PL
+++ b/ext/Socket/Makefile.PL
@@ -1,5 +1,5 @@
use ExtUtils::MakeMaker;
-use ExtUtils::Constant 0.07 'WriteConstants';
+use ExtUtils::Constant 0.11 'WriteConstants';
use Config;
WriteMakefile(
NAME => 'Socket',
@@ -7,7 +7,6 @@ WriteMakefile(
($Config{libs} =~ /(-lsocks\S*)/ ? (LIBS => [ "$1" ] ) : ()),
MAN3PODS => {}, # Pods will be built by installman.
XSPROTOARG => '-noprototypes', # XXX remove later?
- realclean => {FILES=> 'constants.c constants.xs'},
);
my @names = (qw(AF_802 AF_AAL AF_APPLETALK AF_CCITT AF_CHAOS AF_CTF
AF_DATAKIT AF_DECnet AF_DLI AF_ECMA AF_GOSIP AF_HYLINK
diff --git a/ext/Socket/Socket.xs b/ext/Socket/Socket.xs
index 504cbd1ed1..79e1dfd22a 100644
--- a/ext/Socket/Socket.xs
+++ b/ext/Socket/Socket.xs
@@ -211,11 +211,11 @@ not_here(char *s)
*
* --jhi */
-#include "constants.c"
+#include "const-c.inc"
MODULE = Socket PACKAGE = Socket
-INCLUDE: constants.xs
+INCLUDE: const-xs.inc
void
inet_aton(host)
diff --git a/ext/Sys/Syslog/Makefile.PL b/ext/Sys/Syslog/Makefile.PL
index 1de0148d41..1a5f1fc124 100644
--- a/ext/Sys/Syslog/Makefile.PL
+++ b/ext/Sys/Syslog/Makefile.PL
@@ -1,12 +1,11 @@
use ExtUtils::MakeMaker;
-use ExtUtils::Constant 0.07 'WriteConstants';
+use ExtUtils::Constant 0.11 'WriteConstants';
WriteMakefile(
NAME => 'Sys::Syslog',
VERSION_FROM => 'Syslog.pm',
MAN3PODS => {}, # Pods will be built by installman.
XSPROTOARG => '-noprototypes',
- realclean => {FILES=> 'constants.c constants.xs'},
);
# We hope syslogd understands /dev/log.
diff --git a/ext/Sys/Syslog/Syslog.xs b/ext/Sys/Syslog/Syslog.xs
index 157c7320e5..93f1272e91 100644
--- a/ext/Sys/Syslog/Syslog.xs
+++ b/ext/Sys/Syslog/Syslog.xs
@@ -6,11 +6,11 @@
#include <syslog.h>
#endif
-#include "constants.c"
+#include "const-c.inc"
MODULE = Sys::Syslog PACKAGE = Sys::Syslog
-INCLUDE: constants.xs
+INCLUDE: const-xs.inc
int
LOG_FAC(p)
diff --git a/lib/ExtUtils/Constant.pm b/lib/ExtUtils/Constant.pm
index 57b471f6de..8e6bf24e70 100644
--- a/lib/ExtUtils/Constant.pm
+++ b/lib/ExtUtils/Constant.pm
@@ -1,6 +1,6 @@
package ExtUtils::Constant;
use vars qw (@ISA $VERSION %XS_Constant %XS_TypeSet @EXPORT_OK %EXPORT_TAGS);
-$VERSION = '0.10';
+$VERSION = '0.11';
=head1 NAME
@@ -12,8 +12,6 @@ ExtUtils::Constant - generate XS code to import C header constants
WriteConstants(
NAME => 'Foo',
NAMES => [qw(FOO BAR BAZ)],
- C_FILE => 'constants.c',
- XS_FILE => 'constants.xs',
);
# Generates wrapper code to make the values of the constants FOO BAR BAZ
# available to perl
@@ -30,11 +28,11 @@ constants.
Generally one only needs to call the C<WriteConstants> function, and then
- #include "constants.c"
+ #include "const-c.inc"
in the C section of C<Foo.xs>
- INCLUDE constants.xs
+ INCLUDE const-xs.inc
in the XS section of C<Foo.xs>.
@@ -1113,12 +1111,15 @@ as detailed in L<"C_constant">.
=item C_FILE
The name of the file to write containing the C code. The default is
-C<constants.c>.
+C<const-c.inc>. The C<-> in the name ensures that the file can't be
+mistaken for anything related to a legitimate perl package name, and
+not naming the file C<.c> avoids having to override Makefile.PL's
+C<.xs> to C<.c> rules.
=item XS_FILE
The name of the file to write containing the XS code. The default is
-C<constants.xs>.
+C<const-xs.inc>.
=item SUBNAME
@@ -1139,8 +1140,8 @@ C<constant_10> with the default I<XS_SUBNAME>.
sub WriteConstants {
my %ARGS =
( # defaults
- C_FILE => 'constants.c',
- XS_FILE => 'constants.xs',
+ C_FILE => 'const-c.inc',
+ XS_FILE => 'const-xs.inc',
SUBNAME => 'constant',
DEFAULT_TYPE => 'IV',
@_);
diff --git a/lib/h2xs.t b/lib/h2xs.t
index d1ddc0500a..53739b2baf 100644
--- a/lib/h2xs.t
+++ b/lib/h2xs.t
@@ -16,8 +16,13 @@ BEGIN {
# use strict; # we are not really testing this
use File::Path; # for cleaning up with rmtree()
-use Test;
+use Test::More;
use File::Spec;
+use File::Find;
+use ExtUtils::Manifest;
+# Don't want its diagnostics getting in the way of ours.
+$ExtUtils::Manifest::Quiet=1;
+my $up = File::Spec->updir();
my $extracted_program = '../utils/h2xs'; # unix, nt, ...
if ($^O eq 'VMS') { $extracted_program = '[-.utils]h2xs.com'; }
@@ -55,8 +60,8 @@ specify a minimum perl version with the -b option.
Writing $name/ppport.h
Writing $name/$name.pm
Writing $name/$name.xs
-Writing $name/fallback.c
-Writing $name/fallback.xs
+Writing $name/fallback/const-c.inc
+Writing $name/fallback/const-xs.inc
Writing $name/Makefile.PL
Writing $name/README
Writing $name/t/1.t
@@ -68,8 +73,8 @@ EOXSFILES
Writing $name/ppport.h
Writing $name/$name.pm
Writing $name/$name.xs
-Writing $name/fallback.c
-Writing $name/fallback.xs
+Writing $name/fallback/const-c.inc
+Writing $name/fallback/const-xs.inc
Writing $name/Makefile.PL
Writing $name/README
Writing $name/t/1.t
@@ -81,8 +86,8 @@ EOXSFILES
Writing $name/ppport.h
Writing $name/$name.pm
Writing $name/$name.xs
-Writing $name/fallback.c
-Writing $name/fallback.xs
+Writing $name/fallback/const-c.inc
+Writing $name/fallback/const-xs.inc
Writing $name/Makefile.PL
Writing $name/README
Writing $name/t/1.t
@@ -94,8 +99,8 @@ EOXSFILES
Writing $name/ppport.h
Writing $name/$name.pm
Writing $name/$name.xs
-Writing $name/fallback.c
-Writing $name/fallback.xs
+Writing $name/fallback/const-c.inc
+Writing $name/fallback/const-xs.inc
Writing $name/Makefile.PL
Writing $name/README
Writing $name/t/1.t
@@ -116,8 +121,8 @@ EONOXSFILES
Writing $name/ppport.h
Writing $name/$name.pm
Writing $name/$name.xs
-Writing $name/fallback.c
-Writing $name/fallback.xs
+Writing $name/fallback/const-c.inc
+Writing $name/fallback/const-xs.inc
Writing $name/Makefile.PL
Writing $name/README
Writing $name/t/1.t
@@ -130,18 +135,19 @@ my $total_tests = 3; # opening, closing and deleting the header file.
for (my $i = $#tests; $i > 0; $i-=3) {
# 1 test for running it, 1 test for the expected result, and 1 for each file
# plus 1 to open and 1 to check for the use in $name.pm and Makefile.PL
+ # And 1 more for our check for "bonus" files, 2 more for ExtUtil::Manifest.
# use the () to force list context and hence count the number of matches.
- $total_tests += 6 + (() = $tests[$i] =~ /(Writing)/sg);
+ $total_tests += 9 + (() = $tests[$i] =~ /(Writing)/sg);
}
plan tests => $total_tests;
-ok (open (HEADER, ">$header"));
+ok (open (HEADER, ">$header"), "open '$header'");
print HEADER <<HEADER or die $!;
#define Camel 2
#define Dromedary 1
HEADER
-ok (close (HEADER));
+ok (close (HEADER), "close '$header'");
while (my ($args, $version, $expectation) = splice @tests, 0, 3) {
# h2xs warns about what it is writing hence the (possibly unportable)
@@ -149,7 +155,7 @@ while (my ($args, $version, $expectation) = splice @tests, 0, 3) {
# does it run?
my $prog = "$^X $lib $extracted_program $args $dupe";
@result = `$prog`;
- ok ($?, 0, "running $prog ");
+ cmp_ok ($?, "==", 0, "running $prog ");
$result = join("",@result);
# accomodate MPW # comment character prependage
@@ -160,25 +166,44 @@ while (my ($args, $version, $expectation) = splice @tests, 0, 3) {
#print "# expectation is >$expectation<\n";
#print "# result is >$result<\n";
# Was the output the list of files that were expected?
- ok ($result, $expectation, "running $prog");
+ is ($result, $expectation, "running $prog");
+
+ my (%got);
+ find (sub {$got{$File::Find::name}++ unless -d $_}, $name);
foreach ($expectation =~ /Writing\s+(\S+)/gm) {
if ($^O eq 'MacOS') {
$_ = ':' . join(':',split(/\//,$_));
$_ =~ s/$name:t:1.t/$name:t\/1.t/; # is this an h2xs bug?
}
- ok (-e $_, 1, "$_ missing");
+ ok (-e $_, "check for $_") and delete $got{$_};
+ }
+ my @extra = keys %got;
+ unless (ok (!@extra, "Are any extra files present?")) {
+ print "# These files are unexpectedly present:\n";
+ print "# $_\n" foreach sort @extra;
}
+ chdir ($name) or die "chdir $name failed: $!";
+ # Aargh. Something wants to load a bit of regexp. And we have to chdir
+ # for ExtUtils::Manifest. Caught between a rock and a hard place, so this
+ # seems the least evil thing to do:
+ push @INC, "../../lib";
+ my ($missing, $extra) = ExtUtils::Manifest::fullcheck();
+ is_deeply ($missing, [], "No files in the MANIFEST should be missing");
+ is_deeply ($extra, [], "and all files present should be in the MANIFEST");
+ pop @INC;
+ chdir ($up) or die "chdir $up failed: $!";
+
foreach my $leaf ("$name.pm", 'Makefile.PL') {
my $file = File::Spec->catfile($name, $leaf);
- if (ok (open (FILE, $file), 1, "open $file")) {
+ if (ok (open (FILE, $file), "open $file")) {
my $match = qr/use $version;/;
my $found;
while (<FILE>) {
last if $found = /$match/;
}
- ok ($found, 1, "looking for /$match/ in $file");
+ ok ($found, "looking for /$match/ in $file");
close FILE or die "close $file: $!";
}
}
@@ -186,4 +211,4 @@ while (my ($args, $version, $expectation) = splice @tests, 0, 3) {
rmtree($name);
}
-ok (unlink ($header), 1, $!);
+cmp_ok (unlink ($header), "==", 1, "unlink '$header'") or die "\$! is $!";
diff --git a/utils/h2xs.PL b/utils/h2xs.PL
index f1762c9e6d..b35d769220 100644
--- a/utils/h2xs.PL
+++ b/utils/h2xs.PL
@@ -808,7 +808,13 @@ if( @path_h ){
# Save current directory so that C::Scan can use it
my $cwd = File::Spec->rel2abs( File::Spec->curdir );
-my ($ext, $nested, @modparts, $modfname, $modpname, $constsfname);
+my ($ext, $nested, @modparts, $modfname, $modpname);
+# As Ilya suggested, use a name that contains - and then it can't clash with
+# the names of any packages. A directory 'fallback' will clash with any
+# new pragmata down the fallback:: tree, but that seems unlikely.
+my $constscfname = 'const-c.inc';
+my $constsxsfname = 'const-xs.inc';
+my $fallbackdirname = 'fallback';
$ext = chdir 'ext' ? 'ext/' : '';
@@ -823,8 +829,6 @@ else {
@modparts = ();
$modfname = $modpname = $module;
}
-# Don't trip up if someone calls their module 'constants'
-$constsfname = $modfname eq 'constants' ? 'constdefs' : 'constants';
if ($opt_O) {
@@ -1345,15 +1349,20 @@ if( ! $opt_c ) {
# ExtUtils::Constant.
# h2xs will later check that these are the same as those generated by the
# code embedded into Makefile.PL
- warn "Writing $ext$modpname/fallback.c\n";
- warn "Writing $ext$modpname/fallback.xs\n";
- WriteConstants ( C_FILE => "fallback.c",
- XS_FILE => "fallback.xs",
+ unless (-d $fallbackdirname) {
+ mkdir "$fallbackdirname" or die "Cannot mkdir $fallbackdirname: $!\n";
+ }
+ warn "Writing $ext$modpname/$fallbackdirname/$constscfname\n";
+ warn "Writing $ext$modpname/$fallbackdirname/$constsxsfname\n";
+ my $cfallback = File::Spec->catfile($fallbackdirname, $constscfname);
+ my $xsfallback = File::Spec->catfile($fallbackdirname, $constsxsfname);
+ WriteConstants ( C_FILE => $cfallback,
+ XS_FILE => $xsfallback,
DEFAULT_TYPE => $opt_t,
NAME => $module,
NAMES => \@const_names,
);
- print XS "#include \"$constsfname.c\"\n";
+ print XS "#include \"$constscfname\"\n";
}
@@ -1368,7 +1377,7 @@ END
# If a constant() function was #included then output a corresponding
# XS declaration:
-print XS "INCLUDE: $constsfname.xs\n" unless $opt_c;
+print XS "INCLUDE: $constsxsfname\n" unless $opt_c;
print XS <<"END" if $opt_g;
@@ -1817,16 +1826,7 @@ EOC
$Icomment 'INC' => '$I', # e.g., '${Ihelp}-I/usr/include/other'
END
- if (!$opt_c) {
- print PL <<"END";
- # Without this the constants xs files are spotted, and cause rules to be
- # added to delete the similarly names C files, which isn't what we want.
- 'XS' => {'$modfname.xs' => '$modfname.c'},
- realclean => {FILES => '$constsfname.c $constsfname.xs'},
-END
- }
-
- my $C = grep {$_ ne "$modfname.c" && $_ ne "fallback.c"}
+ my $C = grep {$_ ne "$modfname.c"}
(glob '*.c'), (glob '*.cc'), (glob '*.C');
my $Cpre = ($C ? '' : '# ');
my $Ccomment = ($C ? '' : <<EOC);
@@ -1840,8 +1840,8 @@ END
print PL ");\n";
if (!$opt_c) {
my $generate_code =
- WriteMakefileSnippet ( C_FILE => "$constsfname.c",
- XS_FILE => "$constsfname.xs",
+ WriteMakefileSnippet ( C_FILE => $constscfname,
+ XS_FILE => $constsxsfname,
DEFAULT_TYPE => $opt_t,
NAME => $module,
NAMES => \@const_names,
@@ -1849,17 +1849,18 @@ if (!$opt_c) {
print PL <<"END";
if (eval {require ExtUtils::Constant; 1}) {
# If you edit these definitions to change the constants used by this module,
- # you will need to use the generated $constsfname.c and $constsfname.xs
+ # you will need to use the generated $constscfname and $constsxsfname
# files to replace their "fallback" counterparts before distributing your
# changes.
$generate_code
}
else {
use File::Copy;
- copy ('fallback.c', '$constsfname.c')
- or die "Can't copy fallback.c to $constsfname.c: \$!";
- copy ('fallback.xs', '$constsfname.xs')
- or die "Can't copy fallback.xs to $constsfname.xs: \$!";
+ use File::Spec;
+ foreach my \$file ('$constscfname', '$constsxsfname') {
+ my \$fallback = File::Spec->catfile('$fallbackdirname', \$file);
+ copy (\$fallback, \$file) or die "Can't copy \$fallback to \$file: \$!";
+ }
}
END
@@ -1876,10 +1877,11 @@ EOM
} else {
my $fail;
- foreach ('c', 'xs') {
- if (compare("fallback.$_", "$constsfname.$_")) {
+ foreach my $file ($constscfname, $constsxsfname) {
+ my $fallback = File::Spec->catfile($fallbackdirname, $file);
+ if (compare($file, $fallback)) {
warn << "EOM";
-Files "$ext$modpname/fallback.$_" and "$ext$modpname/$constsfname.$_" differ.
+Files "$ext$modpname/$fallbackdirname/$file" and "$ext$modpname/$file" differ.
EOM
$fail++;
}
@@ -1887,14 +1889,14 @@ EOM
if ($fail) {
warn fill ('','', <<"EOM") . "\n";
It appears that the code in $ext$modpname/Makefile.PL does not autogenerate
-the files $ext$modpname/$constsfname.c and $ext$modpname/$constsfname.xs
+the files $ext$modpname/$constscfname and $ext$modpname/$constsxsfname
correctly.
-
+
Please report the circumstances of this bug in h2xs version $H2XS_VERSION
using the perlbug script.
EOM
} else {
- unlink "$constsfname.c", "$constsfname.xs";
+ unlink $constscfname, $constsxsfname;
}
}
}
@@ -2087,7 +2089,7 @@ EOP
warn "Writing $ext$modpname/MANIFEST\n";
open(MANI,'>MANIFEST') or die "Can't create MANIFEST: $!";
-my @files = grep { -f } (<*>, <t/*>);
+my @files = grep { -f } (<*>, <t/*>, <$fallbackdirname/*>);
if (!@files) {
eval {opendir(D,'.');};
unless ($@) { @files = readdir(D); closedir(D); }
@@ -2103,9 +2105,6 @@ if ($^O eq 'VMS') {
$_ = 'Makefile.PL' if $_ eq 'makefile.pl';
}
}
-if (!$opt_c) {
- @files = grep {$_ ne "$constsfname.c" and $_ ne "$constsfname.xs"} @files;
-}
print MANI join("\n",@files), "\n";
close MANI;
!NO!SUBS!