1 |
# autoconf -- create `configure' using m4 macros |
# autoconf -- create `configure' using m4 macros |
2 |
# Copyright (C) 2001, 2002 Free Software Foundation, Inc. |
# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. |
3 |
|
|
4 |
# This program is free software; you can redistribute it and/or modify |
# This program is free software; you can redistribute it and/or modify |
5 |
# it under the terms of the GNU General Public License as published by |
# it under the terms of the GNU General Public License as published by |
89 |
|
|
90 |
# END |
# END |
91 |
# --- |
# --- |
92 |
# Exit nonzero whenever closing STDOUT fails. |
# Filter Perl's exit codes, delete any temporary directory, and exit |
93 |
# Ideally we should `exit ($? >> 8)', unfortunately, for some reason |
# nonzero whenever closing STDOUT fails. |
|
# I don't understand, whenever we `exit (1)' somewhere in the code, |
|
|
# we arrive here with `$? = 29'. I suspect some low level END routine |
|
|
# might be responsible. In this case, be sure to exit 1, not 29. |
|
94 |
sub END |
sub END |
95 |
{ |
{ |
96 |
my $exit_status = $? ? 1 : 0; |
# $? contains the exit status we will return. |
97 |
|
# It was set using one of the following ways: |
98 |
use POSIX qw (_exit); |
# |
99 |
|
# 1) normal termination |
100 |
|
# this sets $? = 0 |
101 |
|
# 2) calling `exit (n)' |
102 |
|
# this sets $? = n |
103 |
|
# 3) calling die or friends (croak, confess...): |
104 |
|
# a) when $! is non-0 |
105 |
|
# this set $? = $! |
106 |
|
# b) when $! is 0 but $? is not |
107 |
|
# this sets $? = ($? >> 8) (i.e., the exit code of the |
108 |
|
# last program executed) |
109 |
|
# c) when both $! and $? are 0 |
110 |
|
# this sets $? = 255 |
111 |
|
# |
112 |
|
# Cases 1), 2), and 3b) are fine, but we prefer $? = 1 for 3a) and 3c). |
113 |
|
$? = 1 if ($! && $! == $?) || $? == 255; |
114 |
|
# (Note that we cannot safely distinguish calls to `exit (n)' |
115 |
|
# from calls to die when `$! = n'. It's not big deal because |
116 |
|
# we only call `exit (0)' or `exit (1)'.) |
117 |
|
|
118 |
if (!$debug && defined $tmp && -d $tmp) |
if (!$debug && defined $tmp && -d $tmp) |
119 |
{ |
{ |
120 |
if (<$tmp/*>) |
if (<$tmp/*>) |
121 |
{ |
{ |
122 |
unlink <$tmp/*> |
if (! unlink <$tmp/*>) |
123 |
or carp ("$me: cannot empty $tmp: $!\n"), _exit (1); |
{ |
124 |
|
print "$me: cannot empty $tmp: $!\n"; |
125 |
|
$? = 1; |
126 |
|
return; |
127 |
|
} |
128 |
|
} |
129 |
|
if (! rmdir $tmp) |
130 |
|
{ |
131 |
|
print "$me: cannot remove $tmp: $!\n"; |
132 |
|
$? = 1; |
133 |
|
return; |
134 |
} |
} |
|
rmdir $tmp |
|
|
or carp ("$me: cannot remove $tmp: $!\n"), _exit (1); |
|
135 |
} |
} |
136 |
|
|
137 |
# This is required if the code might send any output to stdout |
# This is required if the code might send any output to stdout |
138 |
# E.g., even --version or --help. So it's best to do it unconditionally. |
# E.g., even --version or --help. So it's best to do it unconditionally. |
139 |
close STDOUT |
if (! close STDOUT) |
140 |
or (carp "$me: closing standard output: $!\n"), _exit (1); |
{ |
141 |
|
print "$me: closing standard output: $!\n"; |
142 |
_exit ($exit_status); |
$? = 1; |
143 |
|
return; |
144 |
|
} |
145 |
} |
} |
146 |
|
|
147 |
|
|
520 |
|
|
521 |
verbose "running: $command"; |
verbose "running: $command"; |
522 |
|
|
523 |
(system $command) == 0 |
$! = 0; |
524 |
or error ((split (' ', $command))[0] |
|
525 |
. " failed with exit status: " |
if (system $command) |
526 |
. WEXITSTATUS ($?)); |
{ |
527 |
|
$command = (split (' ', $command))[0]; |
528 |
|
if ($!) |
529 |
|
{ |
530 |
|
error "failed to run $command: $!"; |
531 |
|
} |
532 |
|
else |
533 |
|
{ |
534 |
|
error "$command failed with exit status: " . WEXITSTATUS ($?); |
535 |
|
} |
536 |
|
} |
537 |
} |
} |
538 |
|
|
539 |
|
|