File: Makefile.PL

package info (click to toggle)
eekboek 2.03.01-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 2,956 kB
  • sloc: perl: 19,547; sql: 371; lisp: 26; makefile: 22
file content (210 lines) | stat: -rwxr-xr-x 4,544 bytes parent folder | download
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
# Makefile.PL -- Build file for EekBoek
# Author          : Johan Vromans
# Created On      : Fri Sep  2 14:25:11 2005
# Last Modified By: Johan Vromans
# Last Modified On: Tue Aug 29 16:22:07 2017
# Update Count    : 119
# Status          : Unknown, Use with caution!

# Ease the life of the CPAN testers.
exit 0 if $ENV{AUTOMATED_TESTING} && $] < 5.008006;

use 5.008006;

use strict;

# EU::MM 6.5503 is the first version to understand *_REQUIRES.
use ExtUtils::MakeMaker 6.5503;

my $distname = 'EekBoek';
my $version = MM->parse_version('lib/EB/Version.pm');

my @bins = qw( ebshell ebwxshell );

# Warn on non-standard install locations.
checkbin(<<EOD);
Please consult section "Determination of Perl Library and Installation
Locations" of the ExtUtils::MakeMaker documentation section if you
want to change this location.
EOD

# Write Makefile.
WriteMakefile
(
 NAME             => $distname,
 AUTHOR	          => 'Johan Vromans (jvromans@squirrel.nl)',
 ABSTRACT_FROM    => 'lib/EekBoek.pm',
 PL_FILES         => {'script/ebpp.PL' => [ map { "script/$_" } @bins ]},
 INSTALLDIRS      => 'site',
 DISTNAME         => $distname,
 EXE_FILES        => [ map { "script/$_" } @bins ],
 VERSION          => $version,
 MIN_PERL_VERSION => 5.008006,

 PREREQ_PM   => {
     'Getopt::Long'     => '2.13',
     'Term::ReadLine'   => 0,
     $^O eq "linux" ? ('Term::ReadLine::Gnu' => 0) : (),
     'DBI'              => '1.40',
     'Archive::Zip'	=> '1.16',
     'DBD::SQLite'      => '1.13',
 },

 CONFIGURE_REQUIRES => {
    'ExtUtils::MakeMaker' => 6.5503,
 },

# BUILD_REQUIRES => {
# },

 TEST_REQUIRES  => {
    'Test::More'  => 0,
    'IPC::Run3' => 0.034,
 },

 PM          => filelist("lib", '$(INST_LIBDIR)/'),

 META_MERGE => {
     license   => "perl",
     resources => {
	 license    => "https://dev.perl.org/licenses/",
	 homepage   => "https://www.eekboek.nl",
	 repository => {
	     web  => "https://sourceforge.net/p/eekboek/code/",
	     url  => "git://git.code.sf.net/p/eekboek/code",
	     type => "git",
	 },
     },
     recommends => {
         'DBD::Pg'        => 1.41,
	 'Getopt::Long'   => 2.32,
         'HTML::Entities' => 1.35,
     },
     provides => {
	 'EekBoek' => { file => "lib/EekBoek.pm",
			version => $version },
     },
     no_index => {
         directory => [
	    "lib/EB",
	 ],
     },
 },


);

# Write .spec file, Debian control, ...
ProcessTemplates($distname, $version);

################ Subroutines ################

use Config;

sub checkbin {
    my ($msg) = @_;
    my $installscript = $Config{installscript};

    return if $installscript eq "/usr/bin";
    print STDERR <<EOD;

WARNING: This build process will install user accessible scripts.
The default location for user accessible scripts is
$installscript.
EOD
    print STDERR ($msg);
}

sub filelist {
    my ($dir, $pfx) = @_;
    $pfx ||= "";
    my $dirp = quotemeta($dir . "/");
    my $pm;

    open(my $mf, "MANIFEST") or die("Missing MANIFEST file.\n");
    while ( <$mf> ) {
	chomp;
	next unless /$dirp(.*)/;
	$pm->{$_} = $pfx ? $pfx . $1 : $_;
    }
    close($mf);
    $pm;
}

sub ProcessTemplates {
    my $name    = shift;
    my $version = shift;

    my ($mv) = $version =~ /^\d+\.(\d+)/;
    my %vars =
      ( PkgName	   => $name,
	pkgname	   => lc($name),
	version	   => $version,
	stable	   => $mv % 2 ? "-unstable" : "\%nil",
	stability  => $mv % 2 ? "unstable" : "stable",
      );

    vcopy( _tag	    => "XAF ref file",
	   _dst	    => "t/ivp/ref/export.xaf",
	   %vars);

=begin Fedora

    vcopy( _tag	    => "RPM spec file",
	   _dst	    => "$name.spec",
	   %vars);

=cut

=begin Debian

    vcopy( _tag	    => "Debian control file",
	   _dst	    => "debian/control",
	   %vars);

    vcopy( _tag	    => "Debian rules file",
	   _dst	    => "debian/rules",
	   %vars);
	 );
    chmod((((stat("debian/rules"))[2] & 0777) | 0111), "debian/rules");

    vcopy( _tag	    => "Debian changelog file",
	   _dst	    => "debian/changelog",
	   %vars);

=end

=cut

}

sub vcopy {
    my (%ctrl) = @_;

    $ctrl{_src} ||= $ctrl{_dst} . ".in";

    return unless open(my $fh, "<", $ctrl{_src});

    print("Writing ", $ctrl{_tag}, "...\n") if $ctrl{_tag};

    my $newfh;
    open ($newfh, ">", $ctrl{_dst})
      or die($ctrl{_dst}, ": $!\n");

    my $pat = "(";
    foreach ( grep { ! /^_/ } keys(%ctrl) ) {
	$pat .= quotemeta($_) . "|";
    }
    chop($pat);
    $pat .= ")";

    $pat = qr/\[\%\s+$pat\s+\%\]/;

    while ( <$fh> ) {
	s/$pat/$ctrl{$1}/ge;
	print { $newfh } $_;
    }
    close($newfh);
}

1;