Skip to content
Newer
Older
100644 189 lines (155 sloc) 5.95 KB
e1a4735 @pmichaud Initial files for regex implementations.
pmichaud authored Oct 6, 2009
1 #! perl
2 # Copyright (C) 2009 The Perl Foundation
3
4 use 5.008;
5 use strict;
6 use warnings;
335b8f6 @pmichaud Add support for "config.default" file to hold default arguments to Co…
pmichaud authored Jun 8, 2011
7 use Text::ParseWords;
e1a4735 @pmichaud Initial files for regex implementations.
pmichaud authored Oct 6, 2009
8 use Getopt::Long;
9 use Cwd;
290d603 @pmichaud Refactor build/gen_how_pm.pl and build/gen_setting.pl into tools/buil…
pmichaud authored May 31, 2011
10 use lib "tools/lib";
4319fd2 @jnthn Cygwin build fixes. Patch courtesy of not_gerd++.
jnthn authored Jan 20, 2012
11 use NQP::Configure qw(cmp_rev read_parrot_config
878e8ff @pmichaud Major refactor of build/Configure system (based on new tools/lib/NQP/…
pmichaud authored Jun 8, 2011
12 fill_template_file fill_template_text
13 slurp system_or_die verify_install sorry gen_parrot);
e1a4735 @pmichaud Initial files for regex implementations.
pmichaud authored Oct 6, 2009
14
15 MAIN: {
335b8f6 @pmichaud Add support for "config.default" file to hold default arguments to Co…
pmichaud authored Jun 9, 2011
16 if (-r "config.default") {
17 unshift @ARGV, shellwords(slurp('config.default'));
18 }
19
290d603 @pmichaud Refactor build/gen_how_pm.pl and build/gen_setting.pl into tools/buil…
pmichaud authored May 31, 2011
20 my %config;
21 $config{'nqp_config_status'} = join(' ', map { "\"$_\""} @ARGV);
22
878e8ff @pmichaud Major refactor of build/Configure system (based on new tools/lib/NQP/…
pmichaud authored Jun 8, 2011
23 my $exe = $NQP::Configure::exe;
24
e1a4735 @pmichaud Initial files for regex implementations.
pmichaud authored Oct 6, 2009
25 my %options;
70da0c1 @pmichaud Obtain parrot configuration from 'parrot' executable instead of
pmichaud authored Jun 4, 2011
26 GetOptions(\%options, 'help!', 'prefix=s',
878e8ff @pmichaud Major refactor of build/Configure system (based on new tools/lib/NQP/…
pmichaud authored Jun 8, 2011
27 'with-parrot=s', 'gen-parrot:s',
547c431 @pmichaud Update --makefile-timing flag from nom (based on mberends++ patch in …
pmichaud authored Jun 9, 2011
28 'make-install!', 'makefile-timing!',
05b65e9 @pmichaud Add --parrot-option flags to Configure.pl.
pmichaud authored Apr 21, 2012
29 'parrot-config=s', 'parrot-option=s@');
e1a4735 @pmichaud Initial files for regex implementations.
pmichaud authored Oct 6, 2009
30
31 # Print help if it's requested
32 if ($options{'help'}) {
33 print_help();
34 exit(0);
35 }
36
70da0c1 @pmichaud Obtain parrot configuration from 'parrot' executable instead of
pmichaud authored Jun 4, 2011
37 # Deprecated --parrot-config option
38 if ($options{'parrot-config'}) {
878e8ff @pmichaud Major refactor of build/Configure system (based on new tools/lib/NQP/…
pmichaud authored Jun 8, 2011
39 sorry "The --parrot-config option has been removed.",
40 "Use --with-parrot to specify the parrot executable to use."
70da0c1 @pmichaud Obtain parrot configuration from 'parrot' executable instead of
pmichaud authored Jun 4, 2011
41 }
42
878e8ff @pmichaud Major refactor of build/Configure system (based on new tools/lib/NQP/…
pmichaud authored Jun 8, 2011
43 my $prefix = $options{'prefix'} || cwd().'/install';
44 my $with_parrot = $options{'with-parrot'};
45 my $gen_parrot = $options{'gen-parrot'};
46
290d603 @pmichaud Refactor build/gen_how_pm.pl and build/gen_setting.pl into tools/buil…
pmichaud authored May 31, 2011
47 # Save options in config.status
878e8ff @pmichaud Major refactor of build/Configure system (based on new tools/lib/NQP/…
pmichaud authored Jun 8, 2011
48 unlink('config.status');
290d603 @pmichaud Refactor build/gen_how_pm.pl and build/gen_setting.pl into tools/buil…
pmichaud authored May 31, 2011
49 if (open(my $CONFIG_STATUS, '>', 'config.status')) {
50 print $CONFIG_STATUS
51 "$^X Configure.pl $config{'nqp_config_status'} \$*\n";
52 close($CONFIG_STATUS);
53 }
e1a4735 @pmichaud Initial files for regex implementations.
pmichaud authored Oct 6, 2009
54
878e8ff @pmichaud Major refactor of build/Configure system (based on new tools/lib/NQP/…
pmichaud authored Jun 8, 2011
55 my ($par_want) = split(' ', slurp('tools/build/PARROT_REVISION'));
56
57 if (defined $gen_parrot) {
58 $with_parrot = gen_parrot($par_want, %options, prefix => $prefix);
e1a4735 @pmichaud Initial files for regex implementations.
pmichaud authored Oct 6, 2009
59 }
60
878e8ff @pmichaud Major refactor of build/Configure system (based on new tools/lib/NQP/…
pmichaud authored Jun 8, 2011
61 my @errors;
62
63 my %par_config;
64 if ($with_parrot) {
65 %par_config = read_parrot_config($with_parrot)
66 or push @errors, "Unable to read configuration from $with_parrot.";
e1a4735 @pmichaud Initial files for regex implementations.
pmichaud authored Oct 6, 2009
67 }
290d603 @pmichaud Refactor build/gen_how_pm.pl and build/gen_setting.pl into tools/buil…
pmichaud authored May 31, 2011
68 else {
9ec488d @pmichaud Also look for any parrot in the search patch (tadzik++).
pmichaud authored Jun 8, 2011
69 %par_config = read_parrot_config("$prefix/bin/parrot$exe", "parrot$exe")
878e8ff @pmichaud Major refactor of build/Configure system (based on new tools/lib/NQP/…
pmichaud authored Jun 8, 2011
70 or push @errors, "Unable to find parrot.";
71 $with_parrot = fill_template_text('@bindir@/parrot@exe@', %par_config);
e1a4735 @pmichaud Initial files for regex implementations.
pmichaud authored Oct 6, 2009
72 }
73
878e8ff @pmichaud Major refactor of build/Configure system (based on new tools/lib/NQP/…
pmichaud authored Jun 8, 2011
74 %config = (%config, %par_config);
75 my $par_have = $config{'parrot::git_describe'} || '';
76 if ($par_have && cmp_rev($par_have, $par_want) < 0) {
77 push @errors, "Parrot revision $par_want required (currently $par_have).";
e1a4735 @pmichaud Initial files for regex implementations.
pmichaud authored Oct 6, 2009
78 }
79
878e8ff @pmichaud Major refactor of build/Configure system (based on new tools/lib/NQP/…
pmichaud authored Jun 8, 2011
80 if (!@errors) {
81 push @errors, verify_install([@NQP::Configure::required_parrot_files],
82 %config);
83 push @errors,
84 "(Perhaps you need to 'make install', 'make install-dev',",
85 "or install the 'devel' package for Parrot?)"
86 if @errors;
87 }
e1a4735 @pmichaud Initial files for regex implementations.
pmichaud authored Oct 6, 2009
88
878e8ff @pmichaud Major refactor of build/Configure system (based on new tools/lib/NQP/…
pmichaud authored Jun 8, 2011
89 if (@errors && !defined $gen_parrot) {
90 push @errors,
91 "\nTo automatically clone (git) and build a copy of Parrot $par_want,",
92 "try re-running Configure.pl with the '--gen-parrot' option.",
93 "Or, use '--with-parrot=' to explicitly specify the Parrot",
94 "executable to use to build NQP.";
e1a4735 @pmichaud Initial files for regex implementations.
pmichaud authored Oct 6, 2009
95 }
96
878e8ff @pmichaud Major refactor of build/Configure system (based on new tools/lib/NQP/…
pmichaud authored Jun 8, 2011
97 sorry(@errors) if @errors;
13eb661 @pmichaud Refactor --gen-parrot and Configure.pl a bit more, move git repo
pmichaud authored Jun 4, 2011
98
878e8ff @pmichaud Major refactor of build/Configure system (based on new tools/lib/NQP/…
pmichaud authored Jun 8, 2011
99 print "Using $with_parrot (version $config{'parrot::git_describe'}).\n";
e1a4735 @pmichaud Initial files for regex implementations.
pmichaud authored Oct 6, 2009
100
878e8ff @pmichaud Major refactor of build/Configure system (based on new tools/lib/NQP/…
pmichaud authored Jun 8, 2011
101 $config{'makefile-timing'} = $options{'makefile-timing'};
102 $config{'stagestats'} = '--stagestats' if $options{'makefile-timing'};
4319fd2 @jnthn Cygwin build fixes. Patch courtesy of not_gerd++.
jnthn authored Jan 20, 2012
103 $config{'shell'} = $^O eq 'MSWin32' ? 'cmd' : 'sh';
104 if ($^O eq 'MSWin32' or $^O eq 'cygwin') {
105 $config{'dll'} = '$(PARROT_BIN_DIR)/$(PARROT_LIB_SHARED)';
106 $config{'dllcopy'} = '$(PARROT_LIB_SHARED)';
107 $config{'make_dllcopy'} =
108 '$(PARROT_DLL_COPY) : $(PARROT_DLL)'."\n\t".'$(CP) $(PARROT_DLL) .';
878e8ff @pmichaud Major refactor of build/Configure system (based on new tools/lib/NQP/…
pmichaud authored Jun 8, 2011
109 }
290d603 @pmichaud Refactor build/gen_how_pm.pl and build/gen_setting.pl into tools/buil…
pmichaud authored May 31, 2011
110
878e8ff @pmichaud Major refactor of build/Configure system (based on new tools/lib/NQP/…
pmichaud authored Jun 8, 2011
111 my $make = fill_template_text('@make@', %config);
4319fd2 @jnthn Cygwin build fixes. Patch courtesy of not_gerd++.
jnthn authored Jan 20, 2012
112
d2ec8c9 @jnthn First cut at getting dyncall configuration and build integrated, and …
jnthn authored Nov 22, 2011
113 if ($make eq 'nmake') {
c9d6b20 @jnthn Don't include version number in directory holding dyncall; it'll just…
jnthn authored Nov 27, 2011
114 system_or_die('cd 3rdparty\dyncall && Configure.bat' .
d2ec8c9 @jnthn First cut at getting dyncall configuration and build integrated, and …
jnthn authored Nov 22, 2011
115 ($config{'parrot::archname'} =~ /x64/ ? ' /target-x64' : ''));
c9d6b20 @jnthn Don't include version number in directory holding dyncall; it'll just…
jnthn authored Nov 27, 2011
116 $config{'dyncall_build'} = 'cd 3rdparty\dyncall && nmake Nmakefile';
d2ec8c9 @jnthn First cut at getting dyncall configuration and build integrated, and …
jnthn authored Nov 22, 2011
117 }
118 else {
c2068c6 tweak Configure.pl, so dyncall builds with strawberry perl
Jimmy Zhuo authored Feb 22, 2012
119 if ($^O eq 'MSWin32') {
120 my $configure_args =
121 $config{'parrot::archname'} =~ /x86/ ? ' /target-x86' : ' /target-x64';
122
123 $configure_args .= $config{'parrot::cc'} eq 'gcc' ? ' /tool-gcc' : '';
124
125 system_or_die('cd 3rdparty\dyncall && Configure.bat' . $configure_args);
126 $config{'dyncall_build'} = "cd 3rdparty/dyncall && $make BUILD_DIR=. -f GNUmakefile";
127 } else {
128 system_or_die('cd 3rdparty/dyncall && sh configure');
7e65c6f @thirdm Fix build problem in NetBSD. NetBSD's make doesn't look for BSDmakefi…
thirdm authored Feb 28, 2012
129 if ($^O eq 'netbsd') {
130 $config{'dyncall_build'} = "cd 3rdparty/dyncall && BUILD_DIR=. $make -f BSDmakefile";
131 } else {
132 $config{'dyncall_build'} = "cd 3rdparty/dyncall && BUILD_DIR=. $make";
133 }
c2068c6 tweak Configure.pl, so dyncall builds with strawberry perl
Jimmy Zhuo authored Feb 22, 2012
134 }
d2ec8c9 @jnthn First cut at getting dyncall configuration and build integrated, and …
jnthn authored Nov 22, 2011
135 }
4319fd2 @jnthn Cygwin build fixes. Patch courtesy of not_gerd++.
jnthn authored Jan 20, 2012
136
878e8ff @pmichaud Major refactor of build/Configure system (based on new tools/lib/NQP/…
pmichaud authored Jun 8, 2011
137 fill_template_file('tools/build/Makefile.in', 'Makefile', %config);
e1a4735 @pmichaud Initial files for regex implementations.
pmichaud authored Oct 6, 2009
138
139 {
140 no warnings;
141 print "Cleaning up ...\n";
0b3c754 @pmichaud Remove trailing spaces from a lot of files, to make Parrot happier.
pmichaud authored Nov 12, 2009
142 if (open my $CLEAN, '-|', "$make clean") {
e1a4735 @pmichaud Initial files for regex implementations.
pmichaud authored Oct 6, 2009
143 my @slurp = <$CLEAN>;
290d603 @pmichaud Refactor build/gen_how_pm.pl and build/gen_setting.pl into tools/buil…
pmichaud authored May 31, 2011
144 close($CLEAN);
e1a4735 @pmichaud Initial files for regex implementations.
pmichaud authored Oct 6, 2009
145 }
146 }
147
a4f80df @pmichaud Add a --make-install option to Configure.pl, to automatically build
pmichaud authored May 31, 2011
148 if ($options{'make-install'}) {
149 system_or_die($make);
150 system_or_die($make, 'install');
151 print "\nNQP has been built and installed.\n";
152 }
153 else {
154 print "You can now use '$make' to build NQP.\n";
155 print "After that, '$make test' will run some tests and\n";
156 print "'$make install' will install NQP.\n";
157 }
e1a4735 @pmichaud Initial files for regex implementations.
pmichaud authored Oct 6, 2009
158
159 exit 0;
160 }
161
162
163 # Print some help text.
164 sub print_help {
165 print <<'END';
166 Configure.pl - NQP Configure
167
168 General Options:
169 --help Show this text
290d603 @pmichaud Refactor build/gen_how_pm.pl and build/gen_setting.pl into tools/buil…
pmichaud authored May 31, 2011
170 --prefix=dir Install files in dir
70da0c1 @pmichaud Obtain parrot configuration from 'parrot' executable instead of
pmichaud authored Jun 4, 2011
171 --with-parrot=path/to/bin/parrot
172 Parrot executable to use to build NQP
173 --gen-parrot Download and build a copy of Parrot to use
174 --parrot-option='--option=value'
175 Options to pass to parrot configuration for --gen-parrot
57c3ba2 @pmichaud Update --help text to tell about config.default.
pmichaud authored Jun 8, 2011
176
177 Configure.pl also reads options from 'config.default' in the current directory.
e1a4735 @pmichaud Initial files for regex implementations.
pmichaud authored Oct 6, 2009
178 END
179
180 return;
181 }
182
183 # Local Variables:
184 # mode: cperl
185 # cperl-indent-level: 4
186 # fill-column: 100
187 # End:
188 # vim: expandtab shiftwidth=4:
Something went wrong with that request. Please try again.