1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Getopt::Long qw(:config no_ignore_case);
7use Module::Build::Convert;
8
9my $params = parse_switches() if @ARGV;
10convert($params);
11
12sub parse_switches {
13    my %opts;
14    GetOptions(\%opts,'c','d','e','h','l=i','n','p','rc','v','vv','V') or usage();
15
16    if ($opts{c} && $opts{p}) {
17        print "Can't process code while in PPI mode\n";
18        usage();
19    }
20    if ($opts{d} && $opts{e}) {
21        print "Can't debug while in executing Makefile.PL mode\n";
22        usage();
23    }
24    if ($opts{d} && $opts{p}) {
25        print "Can't debug while parsing in PPI mode\n";
26        usage();
27    }
28    if ($opts{v} && $opts{vv}) {
29        print "Can't use both -v and -vv switches\n";
30        usage();
31    }
32
33    usage()   if $opts{h};
34    version() if $opts{V};
35
36    return { Path             => $ARGV[0],
37             Process_Code     => $opts{c},
38             Debug            => $opts{d},
39             Exec_Makefile    => $opts{e},
40             Len_Indent       => $opts{l},
41             Use_Native_Order => $opts{n},
42             Parse_PPI        => $opts{p},
43             Create_RC        => $opts{rc},
44             Verbose          => $opts{v} ? 1 : $opts{vv} ? 2 : undef };
45}
46
47sub usage {
48    print <<USAGE;
49Usage: $0 [switches] [path-to-distribution]
50  -c           process code (within the arguments list)
51  -d           debug the parsing process
52  -e           execute Makefile.PL
53  -h           help screen
54  -l length    indentation length
55  -n           native ordering of build arguments
56  -p           PPI parse mode
57  -rc          create RC-file in homedir
58  -v(v)        verbosity level
59  -V           print version
60USAGE
61    exit;
62}
63
64sub version {
65    print "  Module::Build::Convert $Module::Build::Convert::VERSION\n";
66    exit;
67}
68
69sub convert {
70    my $make = Module::Build::Convert->new(%{$_[0]});
71    $make->convert;
72}
73
74=head1 NAME
75
76make2build - frontend to Module::Build::Convert
77
78=head1 SYNOPSIS
79
80 make2build         # In the root directory of an
81                    # ExtUtils::MakeMaker based distribution
82
83 Usage: make2build [switches] [path-to-distribution]
84   -c           process code (within the arguments list)
85   -d           debug the parsing process
86   -e           execute Makefile.PL
87   -h           help screen
88   -l length    indentation length
89   -n           native ordering of build arguments
90   -p           PPI parse mode
91   -rc          create RC-file in homedir
92   -v(v)        verbosity level
93   -V           version
94
95=head1 AUTHOR
96
97Steven Schubiger <schubiger@cpan.org>
98
99=head1 LICENSE
100
101This program is free software; you may redistribute it and/or
102modify it under the same terms as Perl itself.
103
104See L<http://www.perl.com/perl/misc/Artistic.html>
105
106=cut
107