File: Makefile.PL

package info (click to toggle)
libdbix-dbstag-perl 0.12-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 1,424 kB
  • ctags: 826
  • sloc: perl: 6,152; sql: 588; xml: 221; lisp: 59; makefile: 20
file content (289 lines) | stat: -rw-r--r-- 7,828 bytes parent folder | download | duplicates (2)
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#$Id: Makefile.PL,v 1.14 2007/08/29 09:33:45 cmungall Exp $


# This Makefile.PL was cut-n-pasted from the DBIx::Abstract
# Nakefile.PL, by Andrew Turner <turnera@cpan.org>

use strict;
BEGIN { $^W = 1 } # use warnings in Perl 5.6 parlance
use ExtUtils::MakeMaker qw( prompt WriteMakefile );
use Config ();
use Getopt::Long();
use Data::Dumper ();
use lib '.';
use lib 't';

use vars qw($opt);
$opt =
  { "help" => \&Usage,
  };
Getopt::Long::GetOptions($opt, "help", 
                         "testdsn=s", 
                         "testdriver=s", 
#                         "testdb=s", 
                         "testhost=s",
# 			 "testport=s", 
#                         "testdriver=s",
			 "testuser=s", 
                         "testpassword=s",
			 "testrecreate=s",
			 );

my $hostflag = $ENV{TESTHOST} || $opt->{testhost};
my $hostdsn = $hostflag ? ";host=$hostflag" : '';
$hostflag = $hostflag ? "-h $hostflag" : '';

my $TESTDB  = $ENV{TESTDB} || "test";
my $TESTDRIVER = "Pg";
#my $TESTDSN  = $ENV{TESTDSN} || "dbi:Pg:dbname=test$hostdsn";
my $TESTDSN  = $ENV{TESTDSN} || "dbi:Pg:dbname=test$hostdsn";
my $TESTRECREATE  = $ENV{TESTRECREATE} || "dropdb $hostflag test; createdb $hostflag test";
if ($opt->{testdriver}) {
    if ($opt->{testdriver} eq 'mysql') {
        $TESTRECREATE = $ENV{TESTRECREATE} ||
          "mysqladmin --force $hostflag drop test; mysqladmin --force $hostflag create test";
    }
    if ($opt->{testdriver} ne 'Pg') {
        $TESTDSN = "$opt->{testdriver}:test$hostdsn";
        print <<MSG;

**** NOTE ****
Some of the tests in the testsuite rely on postgresql CREATE TABLE syntax

This means that the test suite will not work for your driver

DBStag is known to work on mysql
**************

MSG

    }
    
}


my $source = {};

foreach my $key (qw/testdsn testdriver testuser testhost testpassword testrecreate/) {
  Configure($opt, $source, $key);
}

print <<"MSG";
I will use the following settings for compiling and testing:

MSG

delete $opt->{'help'};
my $keylen = 0;
foreach my $key (keys %$opt) {
  $keylen = length($key) if length($key) > $keylen;
}
my $slen = 0;
foreach my $val (values %$source) {
  $slen = length($val) if length($val) > $slen;
}
foreach my $key (sort { $a cmp $b} keys %$opt) {
    printf("  %-" . $keylen . "s (%-" . $slen . "s) = %s\n",
	 $key, $source->{$key}, $opt->{$key})
}

print <<"MSG";

To change these settings, see 'perl Makefile.PL --help'.

MSG

#sleep 5;

eval { require File::Spec };
my $fileName = $@ ?
  "t/db.config" : File::Spec->catfile("t", "db.config");
#die "Failed to determine location of $fileName" unless -f $fileName;
if (open(FILE, ">$fileName")) {
    print FILE "{ my " . Data::Dumper->Dump([$opt], ["opt"]) .
               "  sub connect_args { return (\n".
               "      \$opt->{'testdsn'},\n" .
               "      \$opt->{'testuser'},\n" .
               "      \$opt->{'testpassword'},\n" .
               "      ) }\n".
               "  sub recreate_cmd { return (\n".
               "      \$opt->{'testrecreate'},\n" .
               "      ) }\n".
               "} 1;\n";
    close(FILE) or die "Failed to create $fileName: $!";
}

WriteMakefile(
	      'NAME'         => "DBIx",
	      'DISTNAME'         => "DBIx-DBStag",
	      'ABSTRACT'     => 'DBStag',
	      'AUTHOR'       => 'Chris Mungall <cjm@fruitfly.org>',
	      'dist'  => {
				 'SUFFIX'       => ".gz",
				 'DIST_DEFAULT' => 'all tardist',
				 'COMPRESS'     => "gzip -9f" 
                         },
	      'VERSION_FROM' => "DBIx/DBStag.pm",
	      'PREREQ_PM'    => {
				 'Parse::RecDescent'  => 0,
				 'Text::Balanced'     => 0,
				 'Data::Stag'         => '0.07',
                                 'XML::Parser::PerlSAX' => 0,
				 'DBIx::DBSchema'     => '0.34',
				 'DBI'                => 0,
				},
	      'EXE_FILES'    => [
                                 'scripts/selectall_xml.pl',
                                 'scripts/selectall_html.pl',
                                 'scripts/stag-autoddl.pl',
                                 'scripts/stag-autotemplate.pl',
                                 'scripts/stag-template2bin.pl',
                                 'scripts/stag-storenode.pl',
                                 'scripts/stag-ir.pl',
                                 'scripts/stag-qsh',
                                 'cgi-bin/ubiq.cgi',
				],
	      
	      clean => {
			FILES => 'DBIx-DBStag-$(VERSION).tar.gz',
		       },
	     );

eval {
    require "DBStagTest.pm";
};
if ($@) {
    print "You are missing a required module!\n";
    print $@;
    print "Exiting!\n";
    exit 1;
}
eval {
    DBStagTest::dbh()->disconnect;
};
if ($@) {
    print STDERR <<EOM
===================================
** WARNING **

Could not connect using these parameters; test suite will probably fail

$@
EOM
}

{

package MY;

sub processPL {
    my($self) = shift;
    my @output;
    foreach (keys(%{$self->{'PL_FILES'}})) {
        my $from = $_;
        my $to = $self->{'PL_FILES'}{$_};
        my $cfg = 'config.pl';
        push(@output, qq|
pm_to_blib: $to

$to: $from
	\$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) \\
			-I\$(PERL_LIB) -Ilib -MExtUtils::PerlPP \\
			-e ppp "$from" "$to" "$cfg"

|);
    }
    join('', @output);
}

}

sub Configure {
    my($opt, $source, $param) = @_;

    if (exists($opt->{$param})) {
        $source->{$param} = "Users choice";
        return;
    }

    if ($param eq "testdriver") {
        $source->{$param} = "default";
        $opt->{$param} = $TESTDRIVER;
    } elsif ($param eq "testdb") {
        $source->{$param} = "default";
        $opt->{$param} = $TESTDB;
    } elsif ($param eq "testdriver") {
        $source->{$param} = "default";
        $opt->{$param} = $TESTDRIVER;
    } elsif ($param eq "testdsn") {
        $source->{$param} = "default";
        $opt->{$param} = $TESTDSN;
    } elsif ($param eq "testrecreate") {
        $source->{$param} = "default";
        $opt->{$param} = $TESTRECREATE;
    } elsif ($param eq "testuser"  || $param eq "testpassword" || 
             $param eq "testdsn" || $param eq "testhost" ||
             $param eq "testport") {
        $source->{$param} = "default";
        $opt->{$param} = "";
    } else {
        die "Unknown configuration parameter: $param";
    }
}


sub Usage {
  print STDERR <<"USAGE";
Usage: perl $0 [options]

Possible options are:


  --testhost=<host>      Use the DBMS on <host> for testing
                         defaults to empty (localhost)

  --testdsn=<db>         Use the DBI datasource <dsn> for running the test suite
                         defaults to $TESTDSN

  --testdriver=<dbms>    Use the DBD driver <db> for running the test suite
                         defaults to $TESTDRIVER
                         (you may also need to change testrecreate)

  --testuser=<user>      Use the username <user> for running the test suite;
                         defaults to no username

  --testpassword=<pwd>   Use the password <pwd> for running the test suite;
                         defaults to no password

  --testrecreate=<cmd>   Unix command string for dropping and creating the db

  --help                 Print this message and exit

Examples:

perl Makefile.PL

  uses the postgresql database 'test' on localhost

perl Makefile.PL --testhost mydbserver

  uses the postgresql database 'test' on host mydbserver

perl Makefile.PL -testdsn 'dbi:Pg:dbname=mytestdb;host=mydbserver' -mytestdbrecreate 'dropdb -h mydbserver mytestdb; createdb -h mydbserver mytestdb'

  uses the postgresql database 'mytestdb' on host mydbserver

Note: the options are only important for running the test suite - if
you are willing to risk an install without running the test suite,
just do this:

perl Makefile.PL
make install

USAGE
  exit 1;
}


__END__