1use 5.006002;
2
3use strict;
4use warnings;
5
6use lib qw{ inc };
7
8use My::Module::Build;
9use My::Module::Meta;
10use My::Module::Recommend;
11use Module::Build;
12use Config;
13use FileHandle;
14
15(my $mbv = Module::Build->VERSION) =~ s/_//g;
16
17my $meta = My::Module::Meta->new();
18
19my %args = (
20    add_to_cleanup	=> [],
21    build_requires	=> $meta->build_requires(),
22    configure_requires	=> $meta->configure_requires(),
23    dist_abstract	=> $meta->abstract(),
24    dist_author	=> $meta->author(),
25    dist_name	=> $meta->dist_name(),
26    license	=> $meta->license(),
27    module_name	=> $meta->module_name(),
28    requires	=> $meta->requires(
29	perl	=> $meta->requires_perl(),
30    ),
31    script_files	=> [],
32);
33
34$mbv >= 0.26
35    and $args{get_options} = {
36	n	=> { type => '!' },
37	y	=> { type => '!' },
38    };
39
40if ( $mbv >= 0.28 ) {
41    $args{meta_merge} = $meta->meta_merge();
42    $args{no_index} = $meta->no_index();
43    $args{meta_add} = {
44	$meta->provides(),
45    },
46}
47
48# Don't require Module::Build if we are making a distribution, since the
49# user may choose to use ExtUtils::MakeMaker.
50$mbv >= 0.34
51    and $args{auto_configure_requires} = !$meta->distribution();
52
53My::Module::Recommend->recommend();
54
55my $bldr = My::Module::Build->new( %args );
56
57my %opt = $bldr->args();
58
59my @exe_files;
60my @clean_files;
61
62print <<"EOD";
63
64The following executable can be installed:
65
66  satpass is a scriptable program to predict satellite passes
67    over a given observer.
68
69If you do not want this, run Makefile.PL with the -n option. If you want
70to install without being asked, run Makefile.PL with the -y option.
71
72>>>> NOTICE <<<<\a\a\a
73
74As of release 0.066, this script no longer asks whether
75the satpass script should be installed, since it is being deprecated
76(slowly) in favor of Astro::App::Satpass2. If you want the satpass
77script installed, you should run this script with the -y option. You can
78make this the default in your CPAN client by installing the preferences
79file eg/Astro-Coord-ECI.yml in .cpan/prefs.
80
81EOD
82
83my @possible_exes = qw{satpass};
84if ( $opt{n} ) {
85    print "Because you have asserted -n, the executables will not be installed.\n\n";
86} elsif ( $opt{y} ) {
87    print "Because you have asserted -y, the executables will be installed.\n\n";
88    @exe_files = @possible_exes;
89}
90
91if (@exe_files) {
92    if ($^O eq 'MSWin32') {
93	@exe_files = map {"script/$_"} @exe_files;
94	foreach (@exe_files) {`pl2bat $_`}
95	@clean_files = @exe_files =
96	    grep {-e $_} map {"$_.bat"} @exe_files;
97    } elsif ($^O eq 'VMS') {
98	foreach my $fni (map {"[.script]$_"} @exe_files) {
99	    my $fno = "$fni.com";
100	    my $fhi = FileHandle->new ("<$fni") or die <<eod;
101Error - Unable to open $fni
102        $!
103eod
104	    my $fho = FileHandle->new (">$fno") or die <<eod;
105Error - Unable to open $fno
106        $!
107eod
108	    print $fho "$Config{startperl}\n";
109	    while (<$fhi>) {print $fho $_}
110	    }
111	@clean_files = @exe_files = map {"[.script]$_.com"} @exe_files;
112    } else {
113	@exe_files = map {"script/$_"} @exe_files;
114    }
115}
116
117$bldr->add_to_cleanup( @{ $meta->add_to_cleanup() }, @clean_files );
118$bldr->script_files( \@exe_files );
119
120$bldr->create_build_script ();
121
122# ex: set textwidth=72 :
123