autoconf: portability fixes
[openwrt/openwrt.git] / tools / autoconf / patches / 000-relocatable.patch
1 --- a/bin/autoheader.in
2 +++ b/bin/autoheader.in
3 @@ -28,7 +28,8 @@ eval 'case $# in 0) exec @PERL@ -S "$0";
4
5 BEGIN
6 {
7 - my $pkgdatadir = $ENV{'autom4te_perllibdir'} || '@pkgdatadir@';
8 + my $pkgdatadir = $ENV{'autom4te_perllibdir'} ||
9 + ($ENV{'STAGING_DIR'} ? $ENV{'STAGING_DIR'} . '/../host/share/autoconf' : '@pkgdatadir@');
10 unshift @INC, "$pkgdatadir";
11
12 # Override SHELL. On DJGPP SHELL may not be set to a shell
13 @@ -50,7 +51,7 @@ use strict;
14 use vars qw ($config_h %verbatim %symbol);
15
16 # Lib files.
17 -my $autom4te = $ENV{'AUTOM4TE'} || '@bindir@/@autom4te-name@';
18 +my $autom4te = $ENV{'AUTOM4TE'} || ($ENV{'STAGING_DIR'} ? $ENV{'STAGING_DIR'} . '/../host/bin/@autom4te-name@' : '@bindir@/@autom4te-name@');
19 local $config_h;
20 my $config_h_in;
21 my @prepend_include;
22 --- a/bin/autom4te.in
23 +++ b/bin/autom4te.in
24 @@ -1,10 +1,12 @@
25 -#! @PERL@ -w
26 +#! @PERL@
27 # -*- perl -*-
28 # @configure_input@
29
30 eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'
31 if 0;
32
33 +$^W = 1;
34 +
35 # autom4te - Wrapper around M4 libraries.
36 # Copyright (C) 2001-2003, 2005-2012 Free Software Foundation, Inc.
37
38 @@ -24,7 +26,8 @@ eval 'case $# in 0) exec @PERL@ -S "$0";
39
40 BEGIN
41 {
42 - my $pkgdatadir = $ENV{'autom4te_perllibdir'} || '@pkgdatadir@';
43 + my $pkgdatadir = $ENV{'autom4te_perllibdir'} ||
44 + ($ENV{'STAGING_DIR'} ? $ENV{'STAGING_DIR'} . '/../host/share/autoconf' : '@pkgdatadir@');
45 unshift @INC, $pkgdatadir;
46
47 # Override SHELL. On DJGPP SHELL may not be set to a shell
48 @@ -44,7 +47,8 @@ use File::Basename;
49 use strict;
50
51 # Data directory.
52 -my $pkgdatadir = $ENV{'AC_MACRODIR'} || '@pkgdatadir@';
53 +my $pkgdatadir = $ENV{'AC_MACRODIR'} ||
54 + ($ENV{'STAGING_DIR'} ? $ENV{'STAGING_DIR'} . '/../host/share/autoconf' : '@pkgdatadir@');
55
56 # $LANGUAGE{LANGUAGE} -- Automatic options for LANGUAGE.
57 my %language;
58 @@ -87,7 +91,7 @@ my @include;
59 my $freeze = 0;
60
61 # $M4.
62 -my $m4 = $ENV{"M4"} || '@M4@';
63 +my $m4 = $ENV{"M4"} || ($ENV{'STAGING_DIR'} ? $ENV{'STAGING_DIR'} . '/../host/bin/m4' : '@M4@');
64 # Some non-GNU m4's don't reject the --help option, so give them /dev/null.
65 fatal "need GNU m4 1.4 or later: $m4"
66 if system "$m4 --help </dev/null 2>&1 | grep reload-state >/dev/null";
67 @@ -269,6 +273,12 @@ sub load_configuration ($)
68
69 my @words = shellwords ($_);
70 my $type = shift @words;
71 +
72 + if ($ENV{'STAGING_DIR'})
73 + {
74 + @words = map { s!^@pkgdatadir@!$ENV{'STAGING_DIR'}/../host/share/autoconf!; $_ } @words;
75 + }
76 +
77 if ($type eq 'begin-language:')
78 {
79 fatal "$file:$.: end-language missing for: $lang"
80 --- a/bin/autoreconf.in
81 +++ b/bin/autoreconf.in
82 @@ -1,10 +1,12 @@
83 -#! @PERL@ -w
84 +#! @PERL@
85 # -*- perl -*-
86 # @configure_input@
87
88 eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'
89 if 0;
90
91 +$^W = 1;
92 +
93 # autoreconf - install the GNU Build System in a directory tree
94 # Copyright (C) 1994, 1999-2012 Free Software Foundation, Inc.
95
96 @@ -26,7 +28,8 @@ eval 'case $# in 0) exec @PERL@ -S "$0";
97
98 BEGIN
99 {
100 - my $pkgdatadir = $ENV{'autom4te_perllibdir'} || '@pkgdatadir@';
101 + my $pkgdatadir = $ENV{'autom4te_perllibdir'} ||
102 + ($ENV{'STAGING_DIR'} ? $ENV{'STAGING_DIR'} . '/../host/share/autoconf' : '@pkgdatadir@');
103 unshift @INC, $pkgdatadir;
104
105 # Override SHELL. On DJGPP SHELL may not be set to a shell
106 @@ -106,9 +109,9 @@ Written by David J. MacKenzie and Akim D
107 ";
108
109 # Lib files.
110 -my $autoconf = $ENV{'AUTOCONF'} || '@bindir@/@autoconf-name@';
111 -my $autoheader = $ENV{'AUTOHEADER'} || '@bindir@/@autoheader-name@';
112 -my $autom4te = $ENV{'AUTOM4TE'} || '@bindir@/@autom4te-name@';
113 +my $autoconf = $ENV{'AUTOCONF'} || ($ENV{'STAGING_DIR'} ? $ENV{'STAGING_DIR'} . '/../host/bin/@autoconf-name@' : '@bindir@/@autoconf-name@');
114 +my $autoheader = $ENV{'AUTOHEADER'} || ($ENV{'STAGING_DIR'} ? $ENV{'STAGING_DIR'} . '/../host/bin/@autoheader-name@' : '@bindir@/@autoheader-name@');
115 +my $autom4te = $ENV{'AUTOM4TE'} || ($ENV{'STAGING_DIR'} ? $ENV{'STAGING_DIR'} . '/../host/bin/@autom4te-name@' : '@bindir@/@autom4te-name@');
116 my $automake = $ENV{'AUTOMAKE'} || 'automake';
117 my $aclocal = $ENV{'ACLOCAL'} || 'aclocal';
118 my $libtoolize = $ENV{'LIBTOOLIZE'} || 'libtoolize';
119 --- a/bin/autoscan.in
120 +++ b/bin/autoscan.in
121 @@ -1,4 +1,4 @@
122 -#! @PERL@ -w
123 +#! @PERL@
124 # -*- perl -*-
125 # @configure_input@
126
127 @@ -23,9 +23,12 @@
128 eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'
129 if 0;
130
131 +$^W = 1;
132 +
133 BEGIN
134 {
135 - my $pkgdatadir = $ENV{'autom4te_perllibdir'} || '@pkgdatadir@';
136 + my $pkgdatadir = $ENV{'autom4te_perllibdir'} ||
137 + ($ENV{'STAGING_DIR'} ? $ENV{'STAGING_DIR'} . '/../host/share/autoconf' : '@pkgdatadir@');
138 unshift @INC, $pkgdatadir;
139
140 # Override SHELL. On DJGPP SHELL may not be set to a shell
141 @@ -91,10 +94,10 @@ my $configure_scan = 'configure.scan';
142 my $log;
143
144 # Autoconf and lib files.
145 -my $autom4te = $ENV{'AUTOM4TE'} || '@bindir@/@autom4te-name@';
146 +my $autom4te = $ENV{'AUTOM4TE'} || ($ENV{'STAGING_DIR'} ? $ENV{'STAGING_DIR'} . '/../host/bin/@autom4te-name@' : '@bindir@/@autom4te-name@');
147 my $autoconf = "$autom4te --language=autoconf";
148 my @prepend_include;
149 -my @include = ('@pkgdatadir@');
150 +my @include = ($ENV{'STAGING_DIR'} ? $ENV{'STAGING_DIR'} . '/../host/share/autoconf' : '@pkgdatadir@');
151
152 # $help
153 # -----
154 --- a/bin/autoupdate.in
155 +++ b/bin/autoupdate.in
156 @@ -1,4 +1,4 @@
157 -#! @PERL@ -w
158 +#! @PERL@
159 # -*- perl -*-
160 # @configure_input@
161
162 @@ -24,9 +24,12 @@
163 eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'
164 if 0;
165
166 +$^W = 1;
167 +
168 BEGIN
169 {
170 - my $pkgdatadir = $ENV{'autom4te_perllibdir'} || '@pkgdatadir@';
171 + my $pkgdatadir = $ENV{'autom4te_perllibdir'} ||
172 + ($ENV{'STAGING_DIR'} ? $ENV{'STAGING_DIR'} . '/../host/share/autoconf' : '@pkgdatadir@');
173 unshift @INC, $pkgdatadir;
174
175 # Override SHELL. On DJGPP SHELL may not be set to a shell
176 @@ -50,10 +53,10 @@ my $autom4te = $ENV{'AUTOM4TE'} || '@bin
177 my $autoconf = "$autom4te --language=autoconf";
178 # We need to find m4sugar.
179 my @prepend_include;
180 -my @include = ('@pkgdatadir@');
181 +my @include = ($ENV{'STAGING_DIR'} ? $ENV{'STAGING_DIR'} . '/../host/share/autoconf' : '@pkgdatadir@');
182 my $force = 0;
183 # m4.
184 -my $m4 = $ENV{"M4"} || '@M4@';
185 +my $m4 = $ENV{"M4"} || ($ENV{'STAGING_DIR'} ? $ENV{'STAGING_DIR'} . '/../host/bin/m4' : '@M4@');
186
187
188 # $HELP
189 --- a/bin/ifnames.in
190 +++ b/bin/ifnames.in
191 @@ -1,10 +1,12 @@
192 -#! @PERL@ -w
193 +#! @PERL@
194 # -*- perl -*-
195 # @configure_input@
196
197 eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'
198 if 0;
199
200 +$^W = 1;
201 +
202 # ifnames - print the identifiers used in C preprocessor conditionals
203
204 # Copyright (C) 1994-1995, 1999-2003, 2005-2012 Free Software
205 @@ -31,7 +33,8 @@ eval 'case $# in 0) exec @PERL@ -S "$0";
206
207 BEGIN
208 {
209 - my $pkgdatadir = $ENV{'autom4te_perllibdir'} || '@pkgdatadir@';
210 + my $pkgdatadir = $ENV{'autom4te_perllibdir'} ||
211 + ($ENV{'STAGING_DIR'} ? $ENV{'STAGING_DIR'} . '/../host/share/autoconf' : '@pkgdatadir@');
212 unshift @INC, $pkgdatadir;
213
214 # Override SHELL. On DJGPP SHELL may not be set to a shell
215 --- a/bin/autoconf.as
216 +++ b/bin/autoconf.as
217 @@ -84,7 +84,11 @@ exit_missing_arg='
218 # restore font-lock: '
219
220 # Variables.
221 -: ${AUTOM4TE='@bindir@/@autom4te-name@'}
222 +if test -n "$STAGING_DIR"; then
223 + : ${AUTOM4TE="$STAGING_DIR/../host/bin/@autom4te-name@"}
224 +else
225 + : ${AUTOM4TE='@bindir@/@autom4te-name@'}
226 +fi
227 autom4te_options=
228 outfile=
229 verbose=false