1#*********************************************************************
2#*** Makefile.PL
3#*** Copyright (c) 2002,2009 by Markus Winand <mws@fatalmind.com>
4#*** $Id: Makefile.PL,v 1.22 2013-04-16 10:14:43 mws Exp $
5#*********************************************************************
6
7use ExtUtils::MakeMaker qw(prompt WriteMakefile);
8use Data::Dumper;
9# See lib/ExtUtils/MakeMaker.pm for details of how to influence
10# the contents of the Makefile that is written.
11
12my %opts;
13
14$opts{NAME}	= 'ResourcePool',
15$opts{VERSION} = '1.0107';
16
17if ($ExtUtils::MakeMaker::VERSION >= 5.43) {
18    $opts{ABSTRACT} = 'A connection caching and pooling class.';
19    $opts{AUTHOR} = 'Markus Winand <mws@fatalmind.com>';
20}
21
22if (0) { # interactive testing not finished yet
23eval("use Net::LDAP;");
24if (exists $INC{"Net/LDAP.pm"}) {
25	printf("Great, you have Net::LDAP installed....\n\n");
26	eval("use Net::LDAP::Constant qw(:all)");
27	printf("If you have a ldap server which can be used for testing,\n");
28	printf("please enter the data below, if not just press enter\n");
29	my ($ldaph, $newparam);
30	do {
31		print("Hostname of your ldap server " .
32			"(use 'host:port' to use non std. port)\n");
33		$ldap_host = prompt("LDAP host:", "");
34		if ($ldap_host ne "") {
35			printf("Trying to connect via Net::LDAP....");
36			my ($host, $port) = split(':', $ldap_host);
37			if (defined $port) {
38				$newparam = [$host, port => $port];
39				print Dumper($newparam);
40			} else {
41				$newparam = [$host];
42			}
43			$ldaph = Net::LDAP->new(@{$newparam});
44			if (defined $ldaph) {
45				printf("looks good\n");
46			} else {
47				printf("failed\n\nYou can change the hostname or just ".
48					"press enter to skipp testing\n");
49			}
50		}
51	} while ($ldap_host ne "" && ! defined $ldaph);
52	if (defined $ldap_host && $ldap_host eq "") {
53		undef $ldap_host;
54	}
55	printf("\n\n");
56	if (defined $ldap_host) {
57		printf("tying to anonymously bind against %s...", $ldap_host);
58		my $rc = $ldaph->bind();
59		if ($rc->code == LDAP_SUCCESS) {
60			printf("looks good\n");
61		} else {
62			printf("failed\n");
63		}
64	}
65
66	if (defined $ldap_host) {
67		$Data::Dumper::Indent = 0;
68		$Data::Dumper::Terse = 1;
69		printf("Test configuration\n");
70		printf("==================\n");
71		printf("new() parameters: %s\n", Dumper($newparam));
72	}
73}
74
75} # disabled
76WriteMakefile(%opts);
77
78eval("use ResourcePool;");
79eval("use DBI;");
80eval("use Net::LDAP;");
81
82if (exists $INC{"ResourcePool.pm"}) {
83	my @suggestion;
84	if ($ResourcePool::VERSION < 1.0000) {
85		print("\n=================================================================================\n");
86		printf("\n\nYou are upgrading from ResourcePool %s to %s!\n\n",
87			$ResourcePool::VERSION, $opts{VERSION});
88		print( <<PLAIN_TEXT );
89The bindings for DBI and Net::LDAP which were previously included
90in the ResourcePool core package have been removed from this distribution.
91
92Anyway, they are available as separate distributions on CPAN.
93
94PLAIN_TEXT
95
96		if (exists $INC{"DBI.pm"}) {
97			push @suggestion, "ResourcePool::Resource::DBI";
98		}
99		if (exists $INC{"Net/LDAP.pm"}) {
100			push @suggestion, "ResourcePool::Resource::Net::LDAP";
101		}
102		if (scalar(@suggestion) > 0) {
103			print("For this system it looks like you need to install those packages:\n");
104			foreach $pack (@suggestion) {
105				printf("   -> %s\n", $pack);
106			}
107		}
108		print("\n=================================================================================\n");
109	}
110}
111