-
Notifications
You must be signed in to change notification settings - Fork 138
/
make.pm
129 lines (101 loc) · 3.21 KB
/
make.pm
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
# Copyright (C) 2001-2007, Parrot Foundation.
=head1 NAME
config/inter/make.pm - make utility
=head1 DESCRIPTION
Determines whether C<make> is installed and if it's actually GNU C<make>.
=cut
package inter::make;
use strict;
use warnings;
use base qw(Parrot::Configure::Step);
use Parrot::Configure::Utils qw( :inter capture_output check_progs );
sub _init {
my $self = shift;
my %data;
$data{description} = q{Is make installed};
$data{result} = q{};
return \%data;
}
sub runstep {
my ( $self, $conf ) = @_;
my $util = 'make';
my $prompt = "Do you have a make utility like 'gmake' or 'make'?";
my $verbose = $conf->options->get('verbose');
# undef means we don't have GNU make... default to not having it
$conf->data->set( gmake_version => undef );
my $candidates;
if ( $^O eq 'cygwin') {
# On Cygwin prefer make over nmake.
$candidates = ['gmake', 'make'];
}
elsif ($conf->option_or_data('cc') =~ /cl(\.exe)?$/i) {
# Windows, Visual C++, prefer nmake
# This test should use something more stable than the compiler
# executable name. 'msvcversion' might be good, but is determined
# after this check.
$candidates = [ 'nmake', 'mingw32-make', 'gmake', 'make' ];
}
else {
# Default
$candidates = ['gmake', 'mingw32-make', 'nmake', 'make'];
}
my $prog;
# check the candidates for a 'make' program in this order:
# environment ; option ; probe ; ask ; default
# first pick wins.
$prog ||= $ENV{ uc($util) };
$prog ||= $conf->options->get($util);
$prog ||= check_progs( $candidates, $verbose );
if ( !$prog ) {
$prog = ( $conf->options->get('ask') )
? prompt( $prompt, $prog ? $prog : $conf->data->get($util) )
: $conf->data->get($util);
}
# never override the user. If a non-existent program is specified then
# the user is responsible for the consequences.
if ( defined $prog ) {
$conf->data->set( $util => $prog );
$self->set_result('yes');
}
else {
$prog = check_progs( $candidates, $verbose );
unless ($prog) {
# fall back to default
$self->set_result('no');
return 1;
}
}
my ( $stdout, $stderr, $ret ) = capture_output( $prog, '--version' );
# don't override the user even if the program they provided appears to be
# broken
if ( $ret == -1 and !$conf->options->get('ask') ) {
# fall back to default
$self->set_result('no');
return 1;
}
# if '--version' returns a string assume that this is gmake.
if ( $stdout =~ /GNU \s+ Make \s+ (\d+) \. (\d+)/x ) {
$conf->data->set( gmake_version => "$1.$2" );
}
$conf->data->set( $util => $prog );
$self->set_result('yes');
# setup make_C
_set_make_c($conf, $prog);
return 1;
}
sub _set_make_c {
my ($conf, $prog) = @_;
if ( $conf->data->get('gmake_version') ) {
$conf->data->set( make_c => "+$prog -C" );
}
else {
# The default value is fine.
}
}
1;
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4: