| 1 |
# -*- perl -*- |
| 2 |
|
| 3 |
# Copyright (c) 2009-2025 H.Merijn Brand |
| 4 |
|
| 5 |
require 5.008001; |
| 6 |
|
| 7 |
use strict; |
| 8 |
|
| 9 |
use ExtUtils::MakeMaker; |
| 10 |
use File::Spec; |
| 11 |
|
| 12 |
eval { require DBI; }; |
| 13 |
if ($@) { |
| 14 |
print <<"MSG"; |
| 15 |
|
| 16 |
DBD::CSV requires DBI and it cannot be loaded: |
| 17 |
$@ |
| 18 |
|
| 19 |
Please be sure your toolchain picks up the dependency requirement and |
| 20 |
installs DBI before tests start |
| 21 |
|
| 22 |
MSG |
| 23 |
sleep 10; |
| 24 |
} |
| 25 |
if ($DBI::VERSION < 1.628) { |
| 26 |
print <<"MSG"; |
| 27 |
|
| 28 |
Trying to use DBD::CSV with DBI-$DBI::VERSION is heading for failure. |
| 29 |
DBD::CSV is relying on DBD::File, bundled in the DBI release and does |
| 30 |
require features not present in this version of DBI. |
| 31 |
|
| 32 |
Please be sure your toolchain picks up the dependency requirement and |
| 33 |
installs DBI-1.628 or newer before tests start |
| 34 |
|
| 35 |
MSG |
| 36 |
sleep 10; |
| 37 |
} |
| 38 |
eval { require DBD::CSV; }; |
| 39 |
if (!$@ && $DBD::CSV::VERSION < 0.1010) { |
| 40 |
print <<'MSG'; |
| 41 |
|
| 42 |
WARNING! You seem to have installed a recent version of the DBD::CSV module. |
| 43 |
Note that the API (in particular attribute names) has changed, to conform to |
| 44 |
the DBI specifications. For example $dbh->{directory} has been renamed to |
| 45 |
$dbh->{f_dir} and $dbh->{eol}, $dbh->{quote_char}, ... are gone in favour of |
| 46 |
$dbh->{tables}{$table}{csv}, which is used for storing meta information. You |
| 47 |
might need to modify existing sources before doing a "make install". See the |
| 48 |
README for details. |
| 49 |
|
| 50 |
MSG |
| 51 |
sleep 5; |
| 52 |
} |
| 53 |
|
| 54 |
{ my $tmp_dir = File::Spec->tmpdir (); |
| 55 |
if (!$ENV{AUTOMATED_TESTING} && |
| 56 |
prompt ("Enable the use of $tmp_dir for tests?", "y") =~ m/[Yy]/) { |
| 57 |
unlink "tests.skip"; |
| 58 |
} |
| 59 |
else { |
| 60 |
open my $fh, ">", "tests.skip"; |
| 61 |
print $fh "tmpdir\n"; |
| 62 |
close $fh; |
| 63 |
} |
| 64 |
} |
| 65 |
my %wm = ( |
| 66 |
NAME => "DBD::CSV", |
| 67 |
DISTNAME => "DBD-CSV", |
| 68 |
ABSTRACT => "DBI driver for CSV and similar structured files", |
| 69 |
AUTHOR => "H.Merijn Brand <h.m.brand\@xs4all.nl>", |
| 70 |
VERSION_FROM => "lib/DBD/CSV.pm", |
| 71 |
PREREQ_PM => { |
| 72 |
"DBI" => 1.628, |
| 73 |
"DBD::File" => 0.42, |
| 74 |
"Text::CSV_XS" => 1.01, |
| 75 |
"SQL::Statement" => 1.405, |
| 76 |
"Test::More" => 0.90, |
| 77 |
"Encode" => 0, |
| 78 |
"charnames" => 0, |
| 79 |
}, |
| 80 |
clean => { |
| 81 |
FILES => join " ", qw( |
| 82 |
output |
| 83 |
cover_db |
| 84 |
valgrind.log |
| 85 |
) |
| 86 |
}, |
| 87 |
macro => { |
| 88 |
TARFLAGS => "--format=ustar -c -v -f", |
| 89 |
}, |
| 90 |
); |
| 91 |
$ExtUtils::MakeMaker::VERSION > 6.30 and $wm{LICENSE} = "perl"; |
| 92 |
|
| 93 |
# Windows is case-insensitive! Do not remove lib.pl and tmp.csv |
| 94 |
$File::Path::VERSION > 2.06 and File::Path::remove_tree (glob "t/[bA-KM-SU-Z]*"); |
| 95 |
|
| 96 |
eval "use DBI::Test::Conf ();"; |
| 97 |
if ($@) { |
| 98 |
# warn "******\n", |
| 99 |
# "******\tDBI::Test is not installed.\n", |
| 100 |
# "******\tIt will be required in one of the upcoming releases.\n", |
| 101 |
# "******\n"; |
| 102 |
} |
| 103 |
else { |
| 104 |
use lib "lib"; |
| 105 |
|
| 106 |
local $" = " "; |
| 107 |
$wm{PREREQ_PM}{"DBI::Test"} = "0.001"; |
| 108 |
my @nt = DBI::Test::Conf->setup (CONTAINED_DBDS => [qw( CSV )]); |
| 109 |
$wm{test} = { TESTS => join " " => (sort glob "t/*.t"), @nt }; |
| 110 |
$wm{clean}{FILES} .= " @nt"; |
| 111 |
} |
| 112 |
|
| 113 |
my $rv = WriteMakefile (%wm); |
| 114 |
|
| 115 |
# perlcriticrc uses Config::Tiny, which does not support nesting |
| 116 |
if (-f ".perlcriticrc" && -s "$ENV{HOME}/.perlcriticrc") { |
| 117 |
open my $fh, ">", ".perlcriticrc"; |
| 118 |
print $fh do { |
| 119 |
local (@ARGV, $/) = ("$ENV{HOME}/.perlcriticrc"); <> }; |
| 120 |
print $fh join "\n" => "", |
| 121 |
"[-Modules::ProhibitMultiplePackages]", |
| 122 |
"[-Subroutines::ProhibitBuiltinHomonyms]", # connect |
| 123 |
"[-ValuesAndExpressions::RestrictLongStrings]", # error message |
| 124 |
"[-Variables::ProhibitPackageVars]", # very deliberate for compatability |
| 125 |
"[-Variables::ProhibitReusedNames]", # @ISA |
| 126 |
""; |
| 127 |
close $fh; |
| 128 |
} |
| 129 |
|
| 130 |
1; |
| 131 |
|
| 132 |
package MY; |
| 133 |
|
| 134 |
sub postamble { |
| 135 |
my $min_vsn = ($] >= 5.010 && -d "xt" && ($ENV{AUTOMATED_TESTING} || 0) != 1) |
| 136 |
? join "\n" => |
| 137 |
'test ::', |
| 138 |
' -@env DBI_SQL_NANO=1 make -e test_dynamic TEST_FILES=t/[1-9]*.t', |
| 139 |
'', |
| 140 |
'test ::', |
| 141 |
' -@env TEST_FILES="xt/*.t" make -e test_dynamic', |
| 142 |
'' |
| 143 |
: ""; |
| 144 |
join "\n" => |
| 145 |
'cover test_cover:', |
| 146 |
' cover -test', |
| 147 |
'', |
| 148 |
'spellcheck:', |
| 149 |
' pod-spell-check --aspell --ispell', |
| 150 |
'', |
| 151 |
'checkmeta: spellcheck', |
| 152 |
' perl sandbox/genMETA.pl -c', |
| 153 |
'', |
| 154 |
'fixmeta: distmeta', |
| 155 |
' perl sandbox/genMETA.pl', |
| 156 |
'', |
| 157 |
'tgzdist: checkmeta fixmeta $(DISTVNAME).tar.gz distcheck', |
| 158 |
' -@mv -f $(DISTVNAME).tar.gz $(DISTVNAME).tgz', |
| 159 |
' -@cpants_lint.pl $(DISTVNAME).tgz', |
| 160 |
' -@rm -f Debian_CPANTS.txt', |
| 161 |
'', |
| 162 |
'doc docs: doc/DBD-CSV.md doc/DBD-CSV.html doc/DBD-CSV.man', |
| 163 |
' -@rm -f pod2html.tmp', |
| 164 |
'doc/DBD-CSV.md: lib/DBD/CSV.pm', |
| 165 |
' perl doc/make-doc.pl', |
| 166 |
$min_vsn; |
| 167 |
} # postamble |