[src] Tidied PIC file to make the code somewhat easier to follow; no functional
[parrot.git] / Configure.pl
blob937bf44cc82487d0915f708af63e648805d2f9d7
1 #! perl
3 # Copyright (C) 2001-2008, The Perl Foundation.
4 # $Id$
6 use 5.008;
7 use strict;
8 use warnings;
9 use lib 'lib';
10 use Data::Dumper;$Data::Dumper::Indent = 1;
12 use Parrot::Configure;
13 use Parrot::Configure::Options qw( process_options );
14 use Parrot::Configure::Options::Test;
15 use Parrot::Configure::Options::Test::Prepare qw(
16 get_preconfiguration_tests
17 get_postconfiguration_tests
19 use Parrot::Configure::Messages qw(
20 print_introduction
21 print_conclusion
23 use Parrot::Revision;
25 $| = 1; # $OUTPUT_AUTOFLUSH = 1;
27 # Install Option text was taken from:
29 # autoconf (GNU Autoconf) 2.59
30 # Written by David J. MacKenzie and Akim Demaille.
32 # Copyright (C) 2003 Free Software Foundation, Inc.
33 # This is free software; see the source for copying conditions. There is NO
34 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
36 # from Parrot::Configure::Options
37 my ($args, $steps_list_ref) = process_options(
39 mode => (defined $ARGV[0] and $ARGV[0] =~ /^--file=/)
40 ? 'file'
41 : 'configure',
42 argv => [@ARGV],
45 #print STDERR Dumper ($args, $steps_list_ref);
46 exit(1) unless defined $args;
48 my $opttest = Parrot::Configure::Options::Test->new($args);
50 # configuration tests will only be run if you requested them
51 # as command-line option
52 $opttest->run_configure_tests( get_preconfiguration_tests() );
54 my $parrot_version = $Parrot::Configure::Options::Conf::parrot_version;
56 # from Parrot::Configure::Messages
57 print_introduction($parrot_version);
59 # Update revision number if needed
60 Parrot::Revision::update();
62 my $conf = Parrot::Configure->new();
64 $conf->add_steps( @{ $steps_list_ref } );
66 # from Parrot::Configure::Data
67 $conf->options->set( %{$args} );
69 # Log files created by Configure.pl in MANIFEST.configure.generated
70 $conf->{active_configuration} = 1;
71 unlink 'MANIFEST.configure.generated';
73 # Run the actual steps from Parrot::Configure
74 $conf->runsteps or exit(1);
76 # build tests will only be run if you requested them
77 # as command-line option
78 $opttest->run_build_tests( get_postconfiguration_tests() );
80 my $make = $conf->data->get('make');
81 # from Parrot::Configure::Messages
82 ( print_conclusion( $conf, $make ) ) ? exit 0 : exit 1;
84 ################### DOCUMENTATION ###################
86 =head1 NAME
88 Configure.pl - Parrot's configuration script
90 =head1 SYNOPSIS
92 % perl Configure.pl [options]
94 or:
96 % perl Configure.pl --file=/path/to/configuration/directives
98 =head1 DESCRIPTION
100 This is Parrot's configuration program. It should be run to create
101 the necessary system-specific files before building Parrot.
103 We now offer two interfaces to configuration:
105 =over 4
107 =item * Command-Line Interface
109 All configuration options are placed on the command-line. You may request
110 interactive configuration with the C<--ask> option. You may not use the
111 C<--file> option, as that is reserved for the Configuration-File interface.
113 =item * Configuration-File Interface
115 All configuration options are placed in a special configuration file whose
116 full path is invoked on the command-line as
117 C<--file=/path/to/configuration/directives> as the sole command-line option.
118 You may not request interactive configuration. For specific instructions, see
119 L</"CONFIGURATION-FILE INTERFACE"> below.
121 =back
123 =head2 General Options
125 =over 4
127 =item C<--help>
129 Prints out a description of the options and exits.
131 =item C<--version>
133 Prints out the version number of Configure.pl and exits.
135 =item C<--verbose>
137 Tells Configure.pl to output extra information about the configuration data it
138 is setting.
140 =item C<--verbose=2>
142 Tells Configure.pl to output information about i<every> setting added or
143 changed.
145 =item C<--verbose-step={N|regex}>
147 Run C<--verbose=2> for step number C<N> or matching description.
149 =item C<--fatal>
151 Tells Configure.pl to halt completely if any configuration step fails.
153 =item C<--fatal-step={init::alpha,inter::beta,auto::gamma}>
155 Tells Configure.pl to halt completely if any configuration step in
156 comma-delimited string individually fails.
158 =item C<--nomanicheck>
160 Tells Configure.pl not to run the MANIFEST check.
162 =item C<--prefix>
164 Sets the location where parrot will be installed.
166 =item C<--languages="list of languages">
168 Specify a list of languages to process (space separated.)
169 Used in combination with C<--step=gen::languages> to regenerate makefiles.
171 =item C<--ask>
173 This turns on the user prompts during configuraion. Available only in
174 Command-Line interface. Not available in Configuration-File interface.
176 =item C<--test>
178 Run certain tests along with F<Configure.pl>:
180 =over 4
182 =item C<--test=configure>
184 Run tests found in F<t/configure/> I<before> beginning configuration. These
185 tests demonstrate that Parrot's configuration tools will work properly once
186 configuration has begun.
188 =item C<--test=build>
190 Run tests found in F<t/postconfigure/>, F<t/tools/pmc2cutils/>,
191 F<t/tools/ops2cutils/> and F<t/tools/ops2pmutils/> I<after> configuration has
192 completed. These tests demonstrate (a) that certain of Parrot's configuration
193 tools are working properly post-configuration; and (b) that certain of
194 Parrot's build tools will work properly once you call F<make>.
196 =item C<--test>
198 Run the tests described in C<--test=configure>, conduct configuration, then
199 run the tests described in C<--test=build>.
201 =back
203 =back
205 =head2 Compile Options
207 =over 4
209 =item C<--debugging=0>
211 Debugging is turned on by default. Use this to disable it.
213 =item C<--parrot_is_shared>
215 Link parrot dynamically.
217 =item C<--m=32>
219 Create a 32-bit executable on 64-architectures like x86_64. This
220 option appends -m32 to compiler and linker programs and does
221 s/lib64/lib/g on link flags.
223 This option is experimental. See F<config/init/defaults.pm> for more.
225 =item C<--profile>
227 Turn on profiled compile (gcc only for now)
229 =item C<--cage>
231 [CAGE] compile includes many additional warnings
233 =item C<--optimize>
235 Add perl5's $Config{optimize} to the compiler flags.
237 =item C<--optimize=flags>
239 Add C<flags> to the compiler flags.
241 =item C<--inline>
243 Tell Configure that the compiler supports C<inline>.
245 =item C<--cc=(compiler)>
247 Specify which compiler to use.
249 =item C<--ccflags=(flags)>
251 Use the given compiler flags.
253 =item C<--ccwarn=(flags)>
255 Use the given compiler warning flags.
257 =item C<--cxx=(compiler)>
259 Specify which C++ compiler to use (for ICU).
261 =item C<--libs=(libs)>
263 Use the given libraries.
265 =item C<--link=(linker)>
267 Specify which linker to use.
269 =item C<--linkflags=(flags)>
271 Use the given linker flags
273 =item C<--ld=(linker)>
275 Specify which loader to use for shared libraries.
277 =item C<--ldflags=(flags)>
279 Use the given loader flags for shared libraries
281 =item C<--lex=(lexer)>
283 Specify which lexer to use.
285 =item C<--yacc=(parser)>
287 Specify which parser to use.
289 =item C<--define=val1[,val2]>
291 Generate "#define PARROT_DEF_VAL1 1" ... entries in has_header.h. Currently
292 needed to use inet_aton for systems that lack inet_pton:
294 --define=inet_aton
296 =back
298 =head2 Parrot Options
300 =over 4
302 =item C<--intval=(type)>
304 Use the given type for C<INTVAL>.
306 =item C<--floatval=(type)>
308 Use the given type for C<FLOATVAL>.
310 =item C<--opcode=(type)>
312 Use the given type for opcodes.
314 =item C<--ops=(files)>
316 Use the given ops files.
318 =item C<--pmc=(files)>
320 Use the given PMC files.
322 =item C<--cgoto=0>
324 Don't build cgoto core. This is recommended when you are short of memory.
326 =item C<--jitcapable>
328 Use JIT system.
330 =item C<--execcapable>
332 Use JIT to emit a native executable.
334 =item C<--gc=(type)>
336 Determine the type of garbage collection. The value for C<type> should be one
337 of: C<gc>, C<libc>, C<malloc> or C<malloc-trace>. The default is C<gc>.
339 =back
341 =head2 International Components For Unicode (ICU) Options
343 =over 4
345 =item C<--icu-config=/path/to/icu-config>
347 Use the specified icu-config script to determine the necessary ICU options.
349 Use --icu-config=none to disable the autodetect feature. Parrot will then be
350 build without ICU.
352 B<Note:> If you specify another ICU option than --icu-config, the autodetection
353 functionality will be disabled.
355 =item C<--icushared=(linkeroption)>
357 Linker command to link against ICU library.
359 E.g.
361 --icushared='-L /opt/openoffice/program -licudata -licuuc'
363 (The libs in openoffice are actually version 2.2 and do not work)
365 =item C<--icuheaders=(header_dir)>
367 Location of ICU header files without the /unicode suffix.
369 E.g.
371 --icuheaders='/home/lt/icu/'
373 =back
375 =head2 Other Options
377 =over 4
379 =item C<--maintainer>
381 Use this option if you want imcc's parser and lexer files to be generated.
382 Needs a working parser and lexer.
384 =item C<--miniparrot>
386 Build parrot assuming only pure ANSI C is available.
388 =back
390 =head1 CONFIGURATION-FILE INTERFACE
392 In the Configuration-File interface, unlike the Command-Line interface, you
393 may delete configuration steps or run them in an order different from that
394 listed in Parrot::Configure::Step::List.
396 A configuration file is a plain-text file located somewhere in or under your
397 top-level Parrot directory. Unless indicated otherwise, all lines in this
398 file must have no leading whitespace. As in Perl 5, lines beginning with C<#>
399 marks are comments and are ignored during parsing of the file. Unlike Perl 5,
400 you may not begin comments in the middle of a line.
402 The configuration file must contain these three sections:
404 =over 4
406 =item * variables
408 =over 4
410 =item *
412 Section begins with line C<=variables> and must be followed by at least one
413 blank line. All other content in this section is optional.
415 =item *
417 Section may contain one or more I<key=value> pairs which assign strings to
418 variables much in the way that you would do in a shell script wrapping around
419 F<Configure.pl>.
421 =variables
423 CC=/usr/bin/gcc
424 CX=/usr/bin/g++
426 So if you typically invoked F<Configure.pl> by wrapping it in a shell script
427 for the purpose of setting environmental variables used in options, like this:
429 CC="/usr/bin/gcc"
430 CX="/usr/bin/g++"
431 /usr/local/bin/perl Configure.pl \
432 --cc="$CC" \
433 --cxx="$CX" \
434 --link="$CX" \
435 --ld="$CX"
437 ... you would now place the assignments to C<CC> and C<CX> in the
438 I<=variables> section of the configuration file (as above).
440 =back
442 =item * general
444 =over 4
446 =item *
448 Section begins with line C<=general> and must be followed by at least one
449 blank line. All other content in this section is optional.
451 =item *
453 This section is the location recommended for listing options whose impact is
454 not conceptually limited to a single step. It is also the location where the
455 variables defined in the I<=variables> section are assigned to particular
456 Parrot configuration options. Entries in this section must be either
457 I<option=value> pairs or be options which will be assigned a true value.
459 cc=$CC
460 cxx=$CX
461 link=$CX
462 ld=/usr/bin/g++
463 verbose
465 Note that when the value is a variable defined in the I<=variables> section,
466 it must be preceded by a C<$> sign.
468 =item *
470 You I<may> list options here which are I<conceptually> limited to a single
471 configuration step. For example, if you wished to skip validation of the
472 F<MANIFEST> during configuration and to configure without ICU, you I<could>,
473 in this section, say:
475 nomanicheck
476 without-icu
478 However, as we shall quickly see, it's conceptually clearer to place these
479 values next to those configuration steps that actually use them.
481 =back
483 =item * steps
485 =over 4
487 =item *
489 Section begins with line C<=steps> and must be followed by at least one
490 blank line, in turn followed by the list of configuration steps, followed by
491 another blank line followed by a line C<=cut> (just like POD).
493 =item *
495 The order in which you list the steps is the order in which they will be
496 executed. If you delete a step from the canonical list or comment a step out,
497 it will not be executed.
500 auto::snprintf
501 # auto::perldoc
502 auto::ctags
505 In the above example, step C<auto::perldoc> will be completely skipped. You
506 will not see it listed as C<....skipped> in F<Configure.pl>'s output; it will
507 simply not be there at all.
509 =item *
511 This is the recommended location to call options whose impact is
512 I<conceptually> limited to a single configuration step. Type the
513 configuration step's name, type a whitespace, type the option (with no leading
514 C<-->) and repeat as needed for additional step-specific options.
516 init::manifest nomanicheck
519 =item *
521 This is also the location to call options whose impact is limited to one step
522 at a time but which may be applied to more than one configuration step. The
523 C<fatal-step> and C<verbose-step> options are the best examples of this case.
524 Rather than requesting verbose output from all configuration steps, you may,
525 for example, wish to designate only a few steps for verbose output:
528 init::hints verbose-step
529 init::headers
530 inter::progs fatal-step
532 auto::gcc verbose-step
535 In the above example, F<Configure.pl> will grind to a halt if C<inter::progs>
536 does not complete successfully. You will get verbose output only from
537 C<init::hints> and C<auto::gcc>; the other 60+ steps will be terse.
539 =item *
541 Nothing prevents you from listing general options anywhere in this section.
543 init::manifest nomanicheck cc=$CC ld=/usr/bin/g++ verbose
544 init::defaults
547 That will work -- but why would you want to do something that messy?
549 =back
551 =back
553 =head2 Example
555 Ignoring leading whitespace, this is an example of a correctly formed
556 configuration file.
558 =variables
560 CC=/usr/bin/gcc
561 CX=/usr/bin/g++
563 =general
565 cc=$CC
566 cxx=$CX
567 link=$CX
568 ld=/usr/bin/g++
570 =steps
572 init::manifest nomanicheck
573 init::defaults
574 init::install
575 init::miniparrot
576 init::hints verbose-step
577 init::headers
578 inter::progs
579 inter::make
580 inter::lex
581 inter::yacc
582 auto::gcc
583 auto::glibc
584 auto::backtrace
585 auto::fink
586 auto::macports
587 auto::msvc
588 auto::attributes
589 auto::warnings
590 init::optimize
591 inter::shlibs
592 inter::libparrot
593 inter::charset
594 inter::encoding
595 inter::types
596 auto::ops
597 auto::pmc
598 auto::alignptrs
599 auto::headers
600 auto::sizes
601 auto::byteorder
602 auto::va_ptr
603 auto::format
604 auto::isreg
605 auto::arch
606 auto::jit
607 auto::cpu
608 auto::funcptr
609 auto::cgoto
610 auto::inline
611 auto::gc
612 auto::memalign
613 auto::signal
614 auto::socklen_t
615 auto::env
616 auto::aio
617 auto::gmp
618 auto::readline
619 auto::gdbm
620 auto::pcre
621 auto::opengl
622 auto::crypto
623 auto::gettext
624 auto::snprintf
625 # auto::perldoc
626 auto::ctags
627 auto::revision
628 auto::icu
629 gen::config_h
630 gen::core_pmcs
631 gen::crypto
632 gen::parrot_include
633 gen::opengl
634 gen::call_list
635 gen::languages
636 gen::makefiles
637 gen::platform
638 gen::config_pm
640 =cut
642 You may see how this works in practice by calling:
644 perl Configure.pl --file=xconf/samples/yourfoobar
648 perl Configure.pl --file=xconf/samples/testfoobar
650 =head1 SEE ALSO
652 F<config/init/data.pl>, F<lib/Parrot/Configure.pm>,
653 F<lib/Parrot/Configure/Step.pm>, F<docs/configuration.pod>
655 =cut
657 # Local Variables:
658 # mode: cperl
659 # cperl-indent-level: 4
660 # fill-column: 100
661 # End:
662 # vim: expandtab shiftwidth=4: