123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476 |
- package Automake::Options;
- use 5.006;
- use strict;
- use Exporter;
- use Automake::Config;
- use Automake::ChannelDefs;
- use Automake::Channels;
- use Automake::Version;
- use vars qw (@ISA @EXPORT);
- @ISA = qw (Exporter);
- @EXPORT = qw (option global_option
- set_option set_global_option
- unset_option unset_global_option
- process_option_list process_global_option_list
- set_strictness $strictness $strictness_name
- &FOREIGN &GNU &GNITS);
- use vars '%_options';
- use vars '%_global_options';
- use vars '$_options_processed';
- use vars '$_global_options_processed';
- use constant FOREIGN => 0;
- use constant GNU => 1;
- use constant GNITS => 2;
- use vars qw ($strictness $strictness_name);
- use vars qw ($_default_strictness $_default_strictness_name);
- sub reset ()
- {
- $_options_processed = 0;
- %_options = %_global_options;
-
-
- if (defined $_default_strictness)
- {
- $strictness = $_default_strictness;
- $strictness_name = $_default_strictness_name;
- }
- else
- {
- $_default_strictness = $strictness;
- $_default_strictness_name = $strictness_name;
- }
- }
- sub option ($)
- {
- my ($name) = @_;
- return () unless defined $_options{$name};
- return $_options{$name};
- }
- sub global_option ($)
- {
- my ($name) = @_;
- return () unless defined $_global_options{$name};
- return $_global_options{$name};
- }
- sub set_option ($$)
- {
- my ($name, $value) = @_;
- $_options{$name} = $value;
- }
- sub set_global_option ($$)
- {
- my ($name, $value) = @_;
- $_global_options{$name} = $value;
- }
- sub unset_option ($)
- {
- my ($name) = @_;
- delete $_options{$name};
- }
- sub unset_global_option ($)
- {
- my ($name) = @_;
- delete $_global_options{$name};
- }
- sub _option_is_from_configure ($$)
- {
- my ($opt, $where)= @_;
- return 1
- if $where->get =~ /^configure\./;
- error $where,
- "option '$opt' can only be used as argument to AM_INIT_AUTOMAKE\n" .
- "but not in AUTOMAKE_OPTIONS makefile statements";
- return 0;
- }
- sub _is_valid_easy_option ($)
- {
- my $opt = shift;
- return scalar grep { $opt eq $_ } qw(
- check-news
- color-tests
- dejagnu
- dist-bzip2
- dist-lzip
- dist-xz
- dist-zip
- info-in-builddir
- no-define
- no-dependencies
- no-dist
- no-dist-gzip
- no-exeext
- no-installinfo
- no-installman
- no-texinfo.tex
- nostdinc
- readme-alpha
- serial-tests
- parallel-tests
- silent-rules
- std-options
- subdir-objects
- );
- }
- sub _process_option_list (\%@)
- {
- my ($options, @list) = @_;
- my @warnings = ();
- my $ret = 1;
- foreach my $h (@list)
- {
- local $_ = $h->{'option'};
- my $where = $h->{'where'};
- $options->{$_} = $where;
- if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
- {
- set_strictness ($_);
- }
-
- elsif (/^(.*\/)?ansi2knr$/)
- {
-
- error ($where,
- "automatic de-ANSI-fication support has been removed");
- $ret = 0;
- }
-
- elsif ($_ eq 'cygnus')
- {
- error $where, "support for Cygnus-style trees has been removed";
- $ret = 0;
- }
-
- elsif ($_ eq 'dist-lzma')
- {
- error ($where, "support for lzma-compressed distribution " .
- "archives has been removed");
- $ret = 0;
- }
-
- elsif ($_ eq 'dist-shar')
- {
- msg ('obsolete', $where,
- "support for shar distribution archives is deprecated.\n" .
- " It will be removed in Automake 2.0");
- }
-
- elsif ($_ eq 'dist-tarZ')
- {
- msg ('obsolete', $where,
- "support for distribution archives compressed with " .
- "legacy program 'compress' is deprecated.\n" .
- " It will be removed in Automake 2.0");
- }
- elsif (/^filename-length-max=(\d+)$/)
- {
- delete $options->{$_};
- $options->{'filename-length-max'} = [$_, $1];
- }
- elsif ($_ eq 'tar-v7' || $_ eq 'tar-ustar' || $_ eq 'tar-pax')
- {
- if (not _option_is_from_configure ($_, $where))
- {
- $ret = 0;
- }
- for my $opt ('tar-v7', 'tar-ustar', 'tar-pax')
- {
- next
- if $opt eq $_ or ! exists $options->{$opt};
- error ($where,
- "options '$_' and '$opt' are mutually exclusive");
- $ret = 0;
- }
- }
- elsif (/^\d+\.\d+(?:\.\d+)?[a-z]?(?:-[A-Za-z0-9]+)?$/)
- {
-
- if (Automake::Version::check ($VERSION, $&))
- {
- error ($where, "require Automake $_, but have $VERSION");
- $ret = 0;
- }
- }
- elsif (/^(?:--warnings=|-W)(.*)$/)
- {
- my @w = map { { cat => $_, loc => $where} } split (',', $1);
- push @warnings, @w;
- }
- elsif (! _is_valid_easy_option $_)
- {
- error ($where, "option '$_' not recognized");
- $ret = 0;
- }
- }
-
-
-
- foreach my $w (@warnings)
- {
- msg 'unsupported', $w->{'loc'},
- "unknown warning category '$w->{'cat'}'"
- if switch_warning $w->{cat};
- }
- return $ret;
- }
- sub process_option_list (@)
- {
- prog_error "local options already processed"
- if $_options_processed;
- $_options_processed = 1;
- _process_option_list (%_options, @_);
- }
- sub process_global_option_list (@)
- {
- prog_error "global options already processed"
- if $_global_options_processed;
- $_global_options_processed = 1;
- _process_option_list (%_global_options, @_);
- }
- sub set_strictness ($)
- {
- $strictness_name = $_[0];
- Automake::ChannelDefs::set_strictness ($strictness_name);
- if ($strictness_name eq 'gnu')
- {
- $strictness = GNU;
- }
- elsif ($strictness_name eq 'gnits')
- {
- $strictness = GNITS;
- }
- elsif ($strictness_name eq 'foreign')
- {
- $strictness = FOREIGN;
- }
- else
- {
- prog_error "level '$strictness_name' not recognized";
- }
- }
- 1;
|