File: Makefile.PL

package info (click to toggle)
libdbix-recordset-perl 0.26-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,836 kB
  • sloc: perl: 6,970; makefile: 11
file content (228 lines) | stat: -rw-r--r-- 5,221 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#
# Building Makefile for DBIx::Recordset
#
# (C) 1997-1998 G.Richter (richter@dev.ecos.de) / ECOS
#
#


use ExtUtils::MakeMaker;

# Ignore the following DBD Drivers

%ignore = ('ExampleP' => 1,
           'NullP'    => 1,
           'Sponge'   => 1,
           'Proxy'   => 1,
	   'File'     => 1) ;

%datasource = (
	       'Pg'       => 'dbi:Pg:dbname=test',
	       'SQLite'   => 'dbi:SQLite:test.db',
               'Solid'    => 'dbi:Solid:'
	      ) ;

$configfile = 'test/Config.pl' ;

mkdir 'test', 0755 ;

if (-e $configfile)
    {
    do $configfile ;
    }

## ----------------------------------------------------------------------------

sub MY::test_via_script 
	{
	my ($txt) = shift -> MM::test_via_script (@_) ;

	$txt =~ s/\$\(TEST_FILE\)/\$(TEST_FILE) \$(TESTARGS)/g ;

	return $txt ;
	}
	

## ----------------------------------------------------------------------------

sub GetString
	{
	my ($prompt, $default) = @_ ;

	printf ("%s [%s]", $prompt, $default) ;
	chop ($_ = <STDIN>) ;
	if (!/^\s*$/)
	    {return $_ ;}
	else
    	{
        if ($_ eq "")
	        {return $default ;}
	    else
            { return "" ; }
    
        }
    }

## ----------------------------------------------------------------------------

sub GetYesNo
	{
	my ($prompt, $default) = @_ ;
	my ($value) ;

	do
	    {
	    $value = lc (GetString ($prompt . "(y/n)", ($default?"y":"n"))) ;
	    }
	until (($value cmp "j") == 0 || ($value cmp "y") == 0 || ($value cmp "n" ) == 0) ;

	return ($value cmp "n") != 0 ;
	}

## ----------------------------------------------------------------------------

print "\n" ;

eval 'use DBI' ;

if ($@ ne '')
    {
    print "\nPlease install DBI before installing DBIx::Recordset\n" ;
    exit (1) ;
    }

print "Found DBI version $DBI::VERSION\n" ;

$skip = 0 ;
if (-e $configfile)
    {
    $skip = GetYesNo ("Use previous configuration for tests", 1) ;
    }
	
if (!$skip)
    {
@drvs = DBI::available_drivers () ;

$driversinstalled = 0 ;
foreach $drv (@drvs)
    {
    next if (exists ($ignore{$drv})) ;
    
    if (exists $Drivers{$drv})
        { $drivers{$drv} = $Drivers{$drv} ; }
    else
        { $drivers{$drv}{dsn} = $datasource{$drv} || "dbi:$drv:test" ; }

    $driversinstalled = 1 ;
    }

if ($driversinstalled == 0)
    {
    print "\nAt least one DBD driver must be installed before installing DBIx::Recordset\n" ;
    exit (1) ;
    }

print "Found the following DBD drivers:\n" ;

@drivers = sort keys %drivers ;
$i = 1 ;

foreach $drv (@drivers)
    {
    print "$i.) $drv\n" ;
    $i++ ;
    }
print "\n" ;
print "For running tests it's necessary to have an existing datasource for each\n" ;
print "DBD driver against which DBIx::Recordset should be tested.\n" ;
print '
For most drivers, 

   DROP DATABASE TEST; CREATE DATABASE TEST 

is adequate. For SQLite, it is recommended to do the following:

   cd $DIST; cat > test.db <control-d>

to create an empty database. $DIST is the root directory of the Recordset
distribution.
';

print "Please enter a valid datasource (or accept the default) for each DBD driver\n" ;
print "or enter a '.' if you do not want to test DBIx::Recordset against this driver\n" ;
print "\n" ;

$i = 1 ;
foreach $drv (@drivers)
    {
    $dsn = GetString ("$i.) $drv",  $drivers{$drv}{dsn}) ;
    if ($dsn eq '.')
        { delete $drivers{$drv} ; }
    else
        {
        $drivers{$drv}{dsn} = $dsn ;
        $user = GetString ("\tUsername", defined ($drivers{$drv}{user})?$drivers{$drv}{user}:"undef") ;
        if ($user ne 'undef') 
            {
            $drivers{$drv}{user} = $user ;        
            $pass = GetString ("\tPassword", defined ($drivers{$drv}{pass})?$drivers{$drv}{pass}:"undef") ;
            $drivers{$drv}{pass} = $pass if ($pass ne 'undef') ;        
            }
        }
    $i++ ;
    }

print "\n" ;
print "The tests will performed with the following parameters\n" ;

@drivers = sort keys %drivers ;
foreach $drv (@drivers)
    {
    print "$drv \t-> $drivers{$drv}{dsn}\t" ;
    print "user: $drivers{$drv}{user}\t" if (defined ($drivers{$drv}{user})) ;
    print "password: $drivers{$drv}{pass}"  if (defined ($drivers{$drv}{pass})) ;
    print "\n" ;
    }

print "\n" ;
print "In every of the above datasources the tables\n" ;
print "\n" ;
print "   dbixrs1, dbixrs2, dbixrs3, dbixrs4\n" ;
print "\n" ;
print "will be created and dropped afterwards. 
Please make sure the datasources
exist *before* you run make test.


" ;



open FH, ">$configfile" or die "Cannot open $configfile for writing ($!)" ;

print FH "%Drivers = (\n" ;

foreach $drv (@drivers)
    {
    print FH "\t$drv => {\n" ;
    print FH "\t\tdsn  => \"$drivers{$drv}{dsn}\",\n" ;
    print FH "\t\tuser => \"$drivers{$drv}{user}\",\n" if (defined ($drivers{$drv}{user})) ;
    print FH "\t\tpass => \"$drivers{$drv}{pass}\",\n" if (defined ($drivers{$drv}{pass}));
    print FH "\t},\n" ;
    }

print FH ");\n" ;

close FH ;
    } 


WriteMakefile
    (
    'NAME'	=> 'DBIx::Recordset',
    'VERSION_FROM' => 'Recordset.pm', # finds $VERSION
    'dist'         => { COMPRESS => 'gzip', SUFFIX => 'gz'},
    'clean'        => { FILES => 'test.log' },
    'realclean'    => { FILES => './test test.log' },

    );