Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 183 lines (152 sloc) 5.775 kb
a23fcb7 @coke [perl6] add a Configure.pl for perl6; use this to regenerate the Makefil...
coke authored
1 #! perl
7d7f1af Update Configure.pl with some help messages and options.
Patrick R. Michaud authored
2 # Copyright (C) 2009 The Perl Foundation
a23fcb7 @coke [perl6] add a Configure.pl for perl6; use this to regenerate the Makefil...
coke authored
3
0bb68ee @japhb Configure improvements
japhb authored
4 use 5.008;
a23fcb7 @coke [perl6] add a Configure.pl for perl6; use this to regenerate the Makefil...
coke authored
5 use strict;
6 use warnings;
0579b56 @pmichaud Add support for "config.default" file to hold default arguments to Confi...
pmichaud authored
7 use Text::ParseWords;
0bb68ee @japhb Configure improvements
japhb authored
8 use Getopt::Long;
607f531 @pmichaud Initial re-attempt at building/running Rakudo from installed Parrot.
pmichaud authored
9 use Cwd;
7ec8cf2 @pmichaud New Configure/build system, part 1.
pmichaud authored
10 use lib "tools/lib";
bcc0773 @pmichaud Search for nqp executable if not specified. Check NQP revision requirem...
pmichaud authored
11 use NQP::Configure qw(sorry slurp cmp_rev gen_nqp read_config
39737ca @pmichaud Clean up verify_install handling.
pmichaud authored
12 fill_template_text fill_template_file
79c1c9f @moritz [Configure.pl] fix import list, not_gerd++
moritz authored
13 system_or_die verify_install);
a23fcb7 @coke [perl6] add a Configure.pl for perl6; use this to regenerate the Makefil...
coke authored
14
05e5fab @pmichaud Parameterize Configure.pl so it can potentially be used by languages oth...
pmichaud authored
15 my $lang = 'Rakudo';
16 my $lclang = lc $lang;
17 my $uclang = uc $lang;
18
688f9a2 @pmichaud Modernizing some code. Eliminated globals from Configure.pl. Error chec...
pmichaud authored
19 MAIN: {
0579b56 @pmichaud Add support for "config.default" file to hold default arguments to Confi...
pmichaud authored
20 if (-r "config.default") {
21 unshift @ARGV, shellwords(slurp('config.default'));
22 }
23
7ec8cf2 @pmichaud New Configure/build system, part 1.
pmichaud authored
24 my %config;
05e5fab @pmichaud Parameterize Configure.pl so it can potentially be used by languages oth...
pmichaud authored
25 my $config_status = "${lclang}_config_status";
26 $config{$config_status} = join(' ', map { "\"$_\""} @ARGV);
7ec8cf2 @pmichaud New Configure/build system, part 1.
pmichaud authored
27
bcc0773 @pmichaud Search for nqp executable if not specified. Check NQP revision requirem...
pmichaud authored
28 my $exe = $NQP::Configure::exe;
29
0bb68ee @japhb Configure improvements
japhb authored
30 my %options;
7ec8cf2 @pmichaud New Configure/build system, part 1.
pmichaud authored
31 GetOptions(\%options, 'help!', 'prefix=s',
32 'with-nqp=s', 'gen-nqp:s',
6dcae2e @pmichaud Add --parrot-option to Configure.pl.
pmichaud authored
33 'with-parrot=s', 'gen-parrot:s', 'parrot-option=s@',
ced04f7 @felher enable Configure.pl to pass options to Parrot's make
felher authored
34 'parrot-make-option=s@',
7ec8cf2 @pmichaud New Configure/build system, part 1.
pmichaud authored
35 'make-install!', 'makefile-timing!',
36 );
688f9a2 @pmichaud Modernizing some code. Eliminated globals from Configure.pl. Error chec...
pmichaud authored
37
38 # Print help if it's requested
39 if ($options{'help'}) {
40 print_help();
41 exit(0);
42 }
7d7f1af Update Configure.pl with some help messages and options.
Patrick R. Michaud authored
43
bcc0773 @pmichaud Search for nqp executable if not specified. Check NQP revision requirem...
pmichaud authored
44 my $prefix = $options{'prefix'} || cwd().'/install';
6c9783d @pmichaud Add some better error message support and option handling.
pmichaud authored
45 my $with_nqp = $options{'with-nqp'};
46 my $gen_nqp = $options{'gen-nqp'};
47 my $with_parrot = $options{'with-parrot'};
48 my $gen_parrot = $options{'gen-parrot'};
7d7f1af Update Configure.pl with some help messages and options.
Patrick R. Michaud authored
49
7ec8cf2 @pmichaud New Configure/build system, part 1.
pmichaud authored
50 # Save options in config.status
51 unlink('config.status');
52 if (open(my $CONFIG_STATUS, '>', 'config.status')) {
53 print $CONFIG_STATUS
05e5fab @pmichaud Parameterize Configure.pl so it can potentially be used by languages oth...
pmichaud authored
54 "$^X Configure.pl $config{$config_status} \$*\n";
7ec8cf2 @pmichaud New Configure/build system, part 1.
pmichaud authored
55 close($CONFIG_STATUS);
924ea54 @moritz detect missing nqp executable at Configure.pl time
moritz authored
56 }
57
6c9783d @pmichaud Add some better error message support and option handling.
pmichaud authored
58 # --with-parrot and --gen-parrot imply --gen-nqp
75c0e9c @moritz [Configure] do not gen-nqp when --with-nqp is provided
moritz authored
59 if (!defined $gen_nqp && !defined $with_nqp && (defined $with_parrot || defined $gen_parrot)) {
6c9783d @pmichaud Add some better error message support and option handling.
pmichaud authored
60 $gen_nqp = '';
61 }
62
63 # determine the version of NQP we want
7ec8cf2 @pmichaud New Configure/build system, part 1.
pmichaud authored
64 my ($nqp_want) = split(' ', slurp('tools/build/NQP_REVISION'));
6c9783d @pmichaud Add some better error message support and option handling.
pmichaud authored
65
66 if (defined $gen_nqp) {
7ec8cf2 @pmichaud New Configure/build system, part 1.
pmichaud authored
67 $with_nqp = gen_nqp($nqp_want, %options);
bd7533f @pmichaud Improve the error diagnostics when someone tries to build Rakudo
pmichaud authored
68 }
688f9a2 @pmichaud Modernizing some code. Eliminated globals from Configure.pl. Error chec...
pmichaud authored
69
6c9783d @pmichaud Add some better error message support and option handling.
pmichaud authored
70 my @errors;
bcc0773 @pmichaud Search for nqp executable if not specified. Check NQP revision requirem...
pmichaud authored
71
72 my %nqp_config;
73 if ($with_nqp) {
74 %nqp_config = read_config($with_nqp)
75 or push @errors, "Unable to read configuration from $with_nqp.";
6c9783d @pmichaud Add some better error message support and option handling.
pmichaud authored
76 }
bcc0773 @pmichaud Search for nqp executable if not specified. Check NQP revision requirem...
pmichaud authored
77 else {
78 %nqp_config = read_config("$prefix/bin/nqp$exe", "nqp$exe")
79 or push @errors, "Unable to find an NQP executable.";
80 $with_nqp = fill_template_text('@bindir@/nqp@exe@', %nqp_config)
6c9783d @pmichaud Add some better error message support and option handling.
pmichaud authored
81 }
82
83 %config = (%config, %nqp_config);
bcc0773 @pmichaud Search for nqp executable if not specified. Check NQP revision requirem...
pmichaud authored
84 my $nqp_have = $config{'nqp::version'} || '';
85 if ($nqp_have && cmp_rev($nqp_have, $nqp_want) < 0) {
86 push @errors, "NQP revision $nqp_want required (currently $nqp_have).";
87 }
6c9783d @pmichaud Add some better error message support and option handling.
pmichaud authored
88
39737ca @pmichaud Clean up verify_install handling.
pmichaud authored
89 if (!@errors) {
90 push @errors, verify_install([ @NQP::Configure::required_parrot_files,
91 @NQP::Configure::required_nqp_files ],
92 %config);
93 push @errors,
94 "(Perhaps you need to 'make install', 'make install-dev',",
95 "or install the 'devel' package for NQP or Parrot?)"
96 if @errors;
97 }
98
6c9783d @pmichaud Add some better error message support and option handling.
pmichaud authored
99 if (@errors && !defined $gen_nqp) {
100 push @errors,
39737ca @pmichaud Clean up verify_install handling.
pmichaud authored
101 "\nTo automatically clone (git) and build a copy of NQP $nqp_want,",
6c9783d @pmichaud Add some better error message support and option handling.
pmichaud authored
102 "try re-running Configure.pl with the '--gen-nqp' or '--gen-parrot'",
103 "options. Or, use '--with-nqp=' or '--with-parrot=' to explicitly",
05e5fab @pmichaud Parameterize Configure.pl so it can potentially be used by languages oth...
pmichaud authored
104 "specify the NQP or Parrot executable to use to build $lang.";
6c9783d @pmichaud Add some better error message support and option handling.
pmichaud authored
105 }
106
107 sorry(@errors) if @errors;
108
109 print "Using $with_nqp (version $config{'nqp::version'}).\n";
110
7ec8cf2 @pmichaud New Configure/build system, part 1.
pmichaud authored
111 $config{'makefile-timing'} = $options{'makefile-timing'};
112 $config{'stagestats'} = '--stagestats' if $options{'makefile-timing'};
25967be @jnthn Fix build on Cygwin; patch courtesy of not_gerd++.
jnthn authored
113 $config{'shell'} = $^O eq 'MSWin32' ? 'cmd' : 'sh';
114 if ($^O eq 'MSWin32' or $^O eq 'cygwin') {
115 $config{'dll'} = '$(PARROT_BIN_DIR)/$(PARROT_LIB_SHARED)';
116 $config{'dllcopy'} = '$(PARROT_LIB_SHARED)';
117 $config{'make_dllcopy'} =
118 '$(PARROT_DLL_COPY): $(PARROT_DLL)'."\n\t".'$(CP) $(PARROT_DLL) .';
7247277 @moritz [Configure] experimental timing option for Makefile
moritz authored
119 }
120
424a6df @pmichaud Force a "make clean" after running Configure, output a better 'we are do...
pmichaud authored
121 my $make = fill_template_text('@make@', %config);
7ec8cf2 @pmichaud New Configure/build system, part 1.
pmichaud authored
122 fill_template_file('tools/build/Makefile.in', 'Makefile', %config);
7d7f1af Update Configure.pl with some help messages and options.
Patrick R. Michaud authored
123
424a6df @pmichaud Force a "make clean" after running Configure, output a better 'we are do...
pmichaud authored
124 {
125 no warnings;
126 print "Cleaning up ...\n";
127 if (open my $CLEAN, '-|', "$make clean") {
128 my @slurp = <$CLEAN>;
129 close($CLEAN);
130 }
131 }
132
133 if ($options{'make-install'}) {
134 system_or_die($make);
135 system_or_die($make, 'install');
05e5fab @pmichaud Parameterize Configure.pl so it can potentially be used by languages oth...
pmichaud authored
136 print "\n$lang has been built and installed.\n";
424a6df @pmichaud Force a "make clean" after running Configure, output a better 'we are do...
pmichaud authored
137 }
138 else {
05e5fab @pmichaud Parameterize Configure.pl so it can potentially be used by languages oth...
pmichaud authored
139 print "\nYou can now use '$make' to build $lang.\n";
424a6df @pmichaud Force a "make clean" after running Configure, output a better 'we are do...
pmichaud authored
140 print "After that, '$make test' will run some tests and\n";
05e5fab @pmichaud Parameterize Configure.pl so it can potentially be used by languages oth...
pmichaud authored
141 print "'$make install' will install $lang.\n";
424a6df @pmichaud Force a "make clean" after running Configure, output a better 'we are do...
pmichaud authored
142 }
143
7ec8cf2 @pmichaud New Configure/build system, part 1.
pmichaud authored
144 exit 0;
5948c11 @pmichaud Allow Parrot VERSION to be used in cases when the svn revision
pmichaud authored
145 }
146
7d7f1af Update Configure.pl with some help messages and options.
Patrick R. Michaud authored
147
148 # Print some help text.
149 sub print_help {
05e5fab @pmichaud Parameterize Configure.pl so it can potentially be used by languages oth...
pmichaud authored
150 print <<"END";
151 Configure.pl - $lang Configure
7d7f1af Update Configure.pl with some help messages and options.
Patrick R. Michaud authored
152
153 General Options:
154 --help Show this text
7ec8cf2 @pmichaud New Configure/build system, part 1.
pmichaud authored
155 --prefix=dir Install files in dir
412a42e @pmichaud Update Configure.pl --help text.
pmichaud authored
156 --with-nqp=path/to/bin/nqp
05e5fab @pmichaud Parameterize Configure.pl so it can potentially be used by languages oth...
pmichaud authored
157 NQP executable to use to build $lang
412a42e @pmichaud Update Configure.pl --help text.
pmichaud authored
158 --gen-nqp[=branch]
159 Download and build a copy of NQP
160 --with-parrot=path/to/bin/parrot
7ec8cf2 @pmichaud New Configure/build system, part 1.
pmichaud authored
161 Parrot executable to use to build NQP
412a42e @pmichaud Update Configure.pl --help text.
pmichaud authored
162 --gen-parrot[=branch]
163 Download and build a copy of Parrot
6dcae2e @pmichaud Add --parrot-option to Configure.pl.
pmichaud authored
164 --parrot-option='--option'
165 Options to pass to Parrot's Configure.pl
ced04f7 @felher enable Configure.pl to pass options to Parrot's make
felher authored
166 --parrot-make-option='--option'
167 Options to pass to Parrot's make, for example:
168 --parrot-make-option='--jobs=4'
412a42e @pmichaud Update Configure.pl --help text.
pmichaud authored
169 --makefile-timing Enable timing of individual makefile commands
d5237b9 @pmichaud Update --help text to tell about config.default.
pmichaud authored
170
171 Configure.pl also reads options from 'config.default' in the current directory.
7d7f1af Update Configure.pl with some help messages and options.
Patrick R. Michaud authored
172 END
f9cb35e @petdance modernize some code, and add error checking
petdance authored
173
174 return;
7d7f1af Update Configure.pl with some help messages and options.
Patrick R. Michaud authored
175 }
46f5a49 @moritz Apply coding style fix by François Perrad, fperrad++
moritz authored
176
177 # Local Variables:
178 # mode: cperl
179 # cperl-indent-level: 4
180 # fill-column: 100
181 # End:
182 # vim: expandtab shiftwidth=4:
Something went wrong with that request. Please try again.