GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / toolchains / hndtools-arm-linux-2.6.36-uclibc-4.5.3 / share / automake-1.11 / Automake / ChannelDefs.pm
bloba740603c53d31213996b5fb8589075a1b98f93ea
1 # Copyright (C) 2002, 2003, 2006, 2008, 2009 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2, or (at your option)
6 # any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 package Automake::ChannelDefs;
18 use Automake::Config;
19 BEGIN
21 if ($perl_threads)
23 require threads;
24 import threads;
27 use Automake::Channels;
29 =head1 NAME
31 Automake::ChannelDefs - channel definitions for Automake and helper functions
33 =head1 SYNOPSIS
35 use Automake::ChannelDefs;
37 Automake::ChannelDefs::usage ();
38 prog_error ($MESSAGE, [%OPTIONS]);
39 error ($WHERE, $MESSAGE, [%OPTIONS]);
40 error ($MESSAGE);
41 fatal ($WHERE, $MESSAGE, [%OPTIONS]);
42 fatal ($MESSAGE);
43 verb ($MESSAGE, [%OPTIONS]);
44 switch_warning ($CATEGORY);
45 parse_WARNINGS ();
46 parse_warning ($OPTION, $ARGUMENT);
47 Automake::ChannelDefs::set_strictness ($STRICTNESS_NAME);
49 =head1 DESCRIPTION
51 This packages defines channels that can be used in Automake to
52 output diagnostics and other messages (via C<msg()>). It also defines
53 some helper function to enable or disable these channels, and some
54 shorthand function to output on specific channels.
56 =cut
58 use 5.005;
59 use strict;
60 use Exporter;
62 use vars qw (@ISA @EXPORT);
64 @ISA = qw (Exporter);
65 @EXPORT = qw (&prog_error &error &fatal &verb
66 &switch_warning &parse_WARNINGS &parse_warnings);
68 =head2 CHANNELS
70 The following channels can be used as the first argument of
71 C<Automake::Channel::msg>. For some of them we list a shorthand
72 function that makes the code more readable.
74 =over 4
76 =item C<fatal>
78 Fatal errors. Use C<&fatal> to send messages over this channel.
80 =item C<error>
82 Common errors. Use C<&error> to send messages over this channel.
84 =item C<error-gnu>
86 Errors related to GNU Standards.
88 =item C<error-gnu/warn>
90 Errors related to GNU Standards that should be warnings in `foreign' mode.
92 =item C<error-gnits>
94 Errors related to GNITS Standards (silent by default).
96 =item C<automake>
98 Internal errors. Use C<&prog_error> to send messages over this channel.
100 =item C<gnu>
102 Warnings related to GNU Coding Standards.
104 =item C<obsolete>
106 Warnings about obsolete features (silent by default).
108 =item C<override>
110 Warnings about user redefinitions of Automake rules or
111 variables (silent by default).
113 =item C<portability>
115 Warnings about non-portable constructs.
117 =item C<syntax>
119 Warnings about weird syntax, unused variables, typos...
121 =item C<unsupported>
123 Warnings about unsupported (or mis-supported) features.
125 =item C<verb>
127 Messages output in C<--verbose> mode. Use C<&verb> to send such messages.
129 =item C<note>
131 Informative messages.
133 =back
135 =cut
137 # Initialize our list of error/warning channels.
138 # Do not forget to update &usage and the manual
139 # if you add or change a warning channel.
141 register_channel 'fatal', type => 'fatal', uniq_part => UP_NONE, ordered => 0;
142 register_channel 'error', type => 'error';
143 register_channel 'error-gnu', type => 'error';
144 register_channel 'error-gnu/warn', type => 'error';
145 register_channel 'error-gnits', type => 'error', silent => 1;
146 register_channel 'automake', type => 'fatal', backtrace => 1,
147 header => ("####################\n" .
148 "## Internal Error ##\n" .
149 "####################\n"),
150 footer => "\nPlease contact <bug-automake\@gnu.org>.",
151 uniq_part => UP_NONE, ordered => 0;
153 register_channel 'gnu', type => 'warning';
154 register_channel 'obsolete', type => 'warning', silent => 1;
155 register_channel 'override', type => 'warning', silent => 1;
156 register_channel 'portability', type => 'warning', silent => 1;
157 register_channel 'portability-recursive', type => 'warning', silent => 1;
158 register_channel 'syntax', type => 'warning';
159 register_channel 'unsupported', type => 'warning';
161 register_channel 'verb', type => 'debug', silent => 1, uniq_part => UP_NONE,
162 ordered => 0;
163 register_channel 'note', type => 'debug', silent => 0;
165 =head2 FUNCTIONS
167 =over 4
169 =item C<usage ()>
171 Display warning categories.
173 =cut
175 sub usage ()
177 print "Warning categories include:
178 `gnu' GNU coding standards (default in gnu and gnits modes)
179 `obsolete' obsolete features or constructions
180 `override' user redefinitions of Automake rules or variables
181 `portability' portability issues (default in gnu and gnits modes)
182 `syntax' dubious syntactic constructs (default)
183 `unsupported' unsupported or incomplete features (default)
184 `all' all the warnings
185 `no-CATEGORY' turn off warnings in CATEGORY
186 `none' turn off all the warnings
187 `error' treat warnings as errors
191 =item C<prog_error ($MESSAGE, [%OPTIONS])>
193 Signal a programming error (on channel C<automake>),
194 display C<$MESSAGE>, and exit 1.
196 =cut
198 sub prog_error ($;%)
200 my ($msg, %opts) = @_;
201 msg 'automake', '', $msg, %opts;
204 =item C<error ($WHERE, $MESSAGE, [%OPTIONS])>
206 =item C<error ($MESSAGE)>
208 Uncategorized errors.
210 =cut
212 sub error ($;$%)
214 my ($where, $msg, %opts) = @_;
215 msg ('error', $where, $msg, %opts);
218 =item C<fatal ($WHERE, $MESSAGE, [%OPTIONS])>
220 =item C<fatal ($MESSAGE)>
222 Fatal errors.
224 =cut
226 sub fatal ($;$%)
228 my ($where, $msg, %opts) = @_;
229 msg ('fatal', $where, $msg, %opts);
232 =item C<verb ($MESSAGE, [%OPTIONS])>
234 C<--verbose> messages.
236 =cut
238 sub verb ($;%)
240 my ($msg, %opts) = @_;
241 $msg = "thread " . threads->tid . ": " . $msg
242 if $perl_threads;
243 msg 'verb', '', $msg, %opts;
246 =item C<switch_warning ($CATEGORY)>
248 If C<$CATEGORY> is C<mumble>, turn on channel C<mumble>.
249 If it's C<no-mumble>, turn C<mumble> off.
250 Else handle C<all> and C<none> for completeness.
252 =cut
254 sub switch_warning ($)
256 my ($cat) = @_;
257 my $has_no = 0;
259 if ($cat =~ /^no-(.*)$/)
261 $cat = $1;
262 $has_no = 1;
265 if ($cat eq 'all')
267 setup_channel_type 'warning', silent => $has_no;
269 elsif ($cat eq 'none')
271 setup_channel_type 'warning', silent => ! $has_no;
273 elsif ($cat eq 'error')
275 $warnings_are_errors = ! $has_no;
276 # Set exit code if Perl warns about something
277 # (like uninitialized variables).
278 $SIG{"__WARN__"} =
279 $has_no ? 'DEFAULT' : sub { print STDERR @_; $exit_code = 1; };
281 elsif (channel_type ($cat) eq 'warning')
283 setup_channel $cat, silent => $has_no;
284 setup_channel 'portability-recursive', silent => $has_no
285 if $cat eq 'portability';
287 else
289 return 1;
291 return 0;
294 =item C<parse_WARNINGS ()>
296 Parse the WARNINGS environment variable.
298 =cut
300 sub parse_WARNINGS ()
302 if (exists $ENV{'WARNINGS'})
304 # Ignore unknown categories. This is required because WARNINGS
305 # should be honored by many tools.
306 switch_warning $_ foreach (split (',', $ENV{'WARNINGS'}));
310 =item C<parse_warning ($OPTION, $ARGUMENT)>
312 Parse the argument of C<--warning=CATEGORY> or C<-WCATEGORY>.
314 C<$OPTIONS> is C<"--warning"> or C<"-W">, C<$ARGUMENT> is C<CATEGORY>.
316 This is meant to be used as an argument to C<Getopt>.
318 =cut
320 sub parse_warnings ($$)
322 my ($opt, $categories) = @_;
324 foreach my $cat (split (',', $categories))
326 msg 'unsupported', "unknown warning category `$cat'"
327 if switch_warning $cat;
331 =item C<set_strictness ($STRICTNESS_NAME)>
333 Configure channels for strictness C<$STRICTNESS_NAME>.
335 =cut
337 sub set_strictness ($)
339 my ($name) = @_;
341 if ($name eq 'gnu')
343 setup_channel 'error-gnu', silent => 0;
344 setup_channel 'error-gnu/warn', silent => 0, type => 'error';
345 setup_channel 'error-gnits', silent => 1;
346 setup_channel 'portability', silent => 0;
347 setup_channel 'gnu', silent => 0;
349 elsif ($name eq 'gnits')
351 setup_channel 'error-gnu', silent => 0;
352 setup_channel 'error-gnu/warn', silent => 0, type => 'error';
353 setup_channel 'error-gnits', silent => 0;
354 setup_channel 'portability', silent => 0;
355 setup_channel 'gnu', silent => 0;
357 elsif ($name eq 'foreign')
359 setup_channel 'error-gnu', silent => 1;
360 setup_channel 'error-gnu/warn', silent => 0, type => 'warning';
361 setup_channel 'error-gnits', silent => 1;
362 setup_channel 'portability', silent => 1;
363 setup_channel 'gnu', silent => 1;
365 else
367 prog_error "level `$name' not recognized\n";
371 =back
373 =head1 SEE ALSO
375 L<Automake::Channels>
377 =head1 HISTORY
379 Written by Alexandre Duret-Lutz E<lt>F<adl@gnu.org>E<gt>.
381 =cut
383 ### Setup "GNU" style for perl-mode and cperl-mode.
384 ## Local Variables:
385 ## perl-indent-level: 2
386 ## perl-continued-statement-offset: 2
387 ## perl-continued-brace-offset: 0
388 ## perl-brace-offset: 0
389 ## perl-brace-imaginary-offset: 0
390 ## perl-label-offset: -2
391 ## cperl-indent-level: 2
392 ## cperl-brace-offset: 0
393 ## cperl-continued-brace-offset: 0
394 ## cperl-label-offset: -2
395 ## cperl-extra-newline-before-brace: t
396 ## cperl-merge-trailing-else: nil
397 ## cperl-continued-statement-offset: 2
398 ## End: