Commit | Line | Data |
---|---|---|
33a01fd2 | 1 | ?RCS: $Id$ |
d8875586 MBT |
2 | ?RCS: |
3 | ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi | |
4 | ?RCS: | |
33a01fd2 | 5 | ?RCS: You may redistribute only under the terms of the Artistic License, |
d8875586 MBT |
6 | ?RCS: as specified in the README file that comes with the distribution. |
7 | ?RCS: You may reuse parts of this distribution only within the terms of | |
33a01fd2 | 8 | ?RCS: that same Artistic License; a copy of which may be found at the root |
d8875586 MBT |
9 | ?RCS: of the source tree for dist 4.0. |
10 | ?RCS: | |
11 | ?RCS: Copyright (c) 2001 Jarkko Hietaniemi | |
12 | ?RCS: | |
13 | ?MAKE:run to from targetarch usecrosscompile: src awk cat grep test rm \ | |
14 | echo sed mkdir cp touch chmod | |
15 | ?MAKE: -pick add $@ %< | |
16 | ?Y:TOP | |
17 | ?S:usecrosscompile: | |
18 | ?S: This variable conditionally defines the USE_CROSS_COMPILE symbol, | |
19 | ?S: and indicates that our package has been cross-compiled. | |
20 | ?S:. | |
21 | ?S:run: | |
22 | ?S: This variable contains the command used by Configure | |
23 | ?S: to copy and execute a cross-compiled executable in the | |
24 | ?S: target host. Useful and available only during the build. | |
25 | ?S: Empty string '' if not cross-compiling. | |
26 | ?S:. | |
27 | ?S:from: | |
28 | ?S: This variable contains the command used by Configure | |
29 | ?S: to copy files from the target host. Useful and available | |
30 | ?S: only during the build. | |
31 | ?S: The string ':' if not cross-compiling. | |
32 | ?S:. | |
33 | ?S:to: | |
34 | ?S: This variable contains the command used by Configure | |
35 | ?S: to copy to from the target host. Useful and available | |
36 | ?S: only during the build. | |
37 | ?S: The string ':' if not cross-compiling. | |
38 | ?S:. | |
39 | ?S:targetarch: | |
40 | ?S: If cross-compiling, this variable contains the target architecture. | |
41 | ?S: If not, this will be empty. | |
42 | ?S:. | |
43 | ?C:USE_CROSS_COMPILE: | |
44 | ?C: This symbol, if defined, indicates that the package is being | |
45 | ?C: cross-compiled. | |
46 | ?C:. | |
47 | ?C:CROSS_TARGET_ARCH: | |
48 | ?C: This symbol, if defined, indicates the target architecture | |
49 | ?C: the package has been cross-compiled to. | |
50 | ?C: Undefined if not a cross-compile. | |
51 | ?C:. | |
52 | ?H:?usecrosscompile:#ifndef USE_CROSS_COMPILE | |
53 | ?H:?usecrosscompile:#$usecrosscompile USE_CROSS_COMPILE /**/ | |
54 | ?H:?usecrosscompile:#define CROSS_TARGET_ARCH "$targetarch" /**/ | |
55 | ?H:?usecrosscompile:#endif | |
56 | ?H:. | |
57 | ?T:croak pwd exe f q i j cwd | |
58 | ?LINT:extern usecrosscompile | |
59 | ?LINT:extern cc | |
60 | ?LINT:extern usrinc | |
61 | ?LINT:change usrinc | |
62 | ?LINT:change ar | |
63 | ?LINT:change nm | |
64 | ?LINT:change ranlib | |
65 | ?LINT:extern targethost | |
66 | ?LINT:extern targetdir | |
67 | ?LINT:change targetdir | |
68 | ?LINT:extern targetuser | |
69 | ?LINT:change targetuser | |
70 | ?LINT:extern targetrun | |
71 | ?LINT:extern targetfrom | |
72 | ?LINT:extern targetto | |
73 | ?LINT:extern targetmkdir | |
74 | ?LINT:change targetrun | |
75 | ?LINT:change targetfrom | |
76 | ?LINT:change targetto | |
77 | ?LINT:change targetmkdir | |
78 | ?LINT:extern incpth | |
79 | ?LINT:extern libpth | |
80 | ?LINT:change incpth | |
81 | ?LINT:change libpth | |
82 | ?LINT:extern locincpth | |
83 | ?LINT:extern loclibpth | |
84 | ?LINT:change locincpth | |
85 | ?LINT:change loclibpth | |
86 | : setup for possible cross-compilation | |
87 | run='' | |
88 | to=: | |
89 | from=: | |
90 | usecrosscompile='undef' | |
91 | targetarch='' | |
92 | case "$usecrosscompile" in | |
93 | $define|true|[yY]*) | |
94 | @if { test -d ../Cross } | |
95 | ?X: | |
96 | ?X: Cross-compilation is enabled when there is a 'Cross' directory found | |
97 | ?X: at the root of the package. This directory must contain the following | |
98 | ?X: entries for defining the cross-compilation process: | |
99 | ?X: | |
100 | ?X: FIXME FIXME | |
101 | ?X: WE MUST DISTINGUISH BETWEEN LOCAL cross-compiling AND REMOTE ONE | |
102 | ?X: ACTUALLY, REMOTE COMPILATION SHOULD BE CONFIGURED INTERACTIVELY | |
103 | ?X: IT WILL COPY ALL THE FILES FROM THE MANIFEST DOWN TO THE REMOTE DIR... | |
104 | ?X: (and copy things like 'mkdep', etc...) | |
105 | ?X: | |
106 | $echo "Cross-compiling..." | |
107 | croak='' | |
108 | case "$cc" in | |
109 | *-*-gcc) | |
110 | ?X: A cross-compiling gcc, probably. | |
111 | targetarch=`$echo $cc|$sed 's/-gcc$//'` | |
112 | ar=$targetarch-ar | |
113 | ?X: leave out ld, choosing it is more complex | |
114 | nm=$targetarch-nm | |
115 | ranlib=$targetarch-ranlib | |
116 | $echo 'extern int foo;' > try.c | |
117 | set X `$cc -v -E try.c 2>&1 | \ | |
118 | $awk '/^#include </,/^End of search /'|$grep '/include'` | |
119 | shift | |
120 | if $test $# -gt 0; then | |
121 | incpth="$incpth $*" | |
122 | incpth="`$echo $incpth|$sed 's/^ //'`" | |
123 | echo "Guessing incpth '$incpth'." >&4 | |
124 | for i in $*; do | |
125 | j="`$echo $i|$sed 's,/include$,/lib,'`" | |
126 | if $test -d $j; then | |
127 | libpth="$libpth $j" | |
128 | fi | |
129 | done | |
130 | libpth="`$echo $libpth|$sed 's/^ //'`" | |
131 | echo "Guessing libpth '$libpth'." >&4 | |
132 | fi | |
133 | $rm -f try.c | |
134 | ;; | |
135 | esac | |
136 | case "$targetarch" in | |
137 | '') echo "Targetarch not defined." >&4; croak=y ;; | |
138 | *) echo "Using targetarch $targetarch." >&4 ;; | |
139 | esac | |
140 | case "$incpth" in | |
141 | '') echo "Incpth not defined." >&4; croak=y ;; | |
142 | *) echo "Using incpth '$incpth'." >&4 ;; | |
143 | esac | |
144 | case "$libpth" in | |
145 | '') echo "Libpth not defined." >&4; croak=y ;; | |
146 | *) echo "Using libpth '$libpth'." >&4 ;; | |
147 | esac | |
148 | case "$usrinc" in | |
149 | '') | |
150 | for i in $incpth; do | |
151 | if $test -f $i/errno.h -a -f $i/stdio.h -a -f $i/time.h; then | |
152 | usrinc=$i | |
153 | echo "Guessing usrinc $usrinc." >&4 | |
154 | break | |
155 | fi | |
156 | done | |
157 | case "$usrinc" in | |
158 | '') echo "Usrinc not defined." >&4; croak=y ;; | |
159 | esac | |
160 | ;; | |
161 | *) echo "Using usrinc $usrinc." >&4 ;; | |
162 | esac | |
163 | case "$targethost" in | |
164 | '') echo "Targethost not defined." >&4; croak=y ;; | |
165 | *) echo "Using targethost $targethost." >&4 | |
166 | esac | |
167 | locincpth=' ' | |
168 | loclibpth=' ' | |
169 | case "$croak" in | |
170 | y) echo "Cannot continue, aborting." >&4; exit 1 ;; | |
171 | esac | |
172 | case "$src" in | |
173 | /*) run=$src/Cross/run | |
174 | targetmkdir=$src/Cross/mkdir | |
175 | to=$src/Cross/to | |
176 | from=$src/Cross/from | |
177 | ;; | |
178 | *) pwd=`$test -f ../Configure & cd ..; pwd` | |
179 | run=$pwd/Cross/run | |
180 | targetmkdir=$pwd/Cross/mkdir | |
181 | to=$pwd/Cross/to | |
182 | from=$pwd/Cross/from | |
183 | ;; | |
184 | esac | |
185 | case "$targetrun" in | |
186 | '') targetrun=ssh ;; | |
187 | esac | |
188 | case "$targetto" in | |
189 | '') targetto=scp ;; | |
190 | esac | |
191 | case "$targetfrom" in | |
192 | '') targetfrom=scp ;; | |
193 | esac | |
194 | run=$run-$targetrun | |
195 | to=$to-$targetto | |
196 | from=$from-$targetfrom | |
197 | case "$targetdir" in | |
198 | '') | |
199 | targetdir=/tmp | |
200 | echo "Guessing targetdir $targetdir." >&4 | |
201 | ;; | |
202 | esac | |
203 | case "$targetuser" in | |
204 | '') | |
205 | targetuser=root | |
206 | echo "Guessing targetuser $targetuser." >&4 | |
207 | ;; | |
208 | esac | |
209 | case "$targetfrom" in | |
210 | scp) q=-q ;; | |
211 | *) q='' ;; | |
212 | esac | |
213 | case "$targetrun" in | |
214 | ssh|rsh) | |
215 | $cat >$run <<EOF | |
216 | #!/bin/sh | |
217 | case "\$1" in | |
218 | -cwd) | |
219 | shift | |
220 | cwd=\$1 | |
221 | shift | |
222 | ;; | |
223 | esac | |
224 | case "\$cwd" in | |
225 | '') cwd=$targetdir ;; | |
226 | esac | |
227 | exe=\$1 | |
228 | shift | |
229 | if $test ! -f \$exe.xok; then | |
230 | $to \$exe | |
231 | $touch \$exe.xok | |
232 | fi | |
233 | $targetrun -l $targetuser $targethost "cd \$cwd && ./\$exe \$@" | |
234 | EOF | |
235 | ;; | |
236 | *) echo "Unknown targetrun '$targetrun'" >&4 | |
237 | exit 1 | |
238 | ;; | |
239 | esac | |
240 | case "$targetmkdir" in | |
241 | */Cross/mkdir) | |
242 | $cat >$targetmkdir <<EOF | |
243 | #!/bin/sh | |
244 | $targetrun -l $targetuser $targethost "mkdir -p \$@" | |
245 | EOF | |
246 | $chmod a+rx $targetmkdir | |
247 | ;; | |
248 | *) echo "Unknown targetmkdir '$targetmkdir'" >&4 | |
249 | exit 1 | |
250 | ;; | |
251 | esac | |
252 | case "$targetto" in | |
253 | scp|rcp) | |
254 | $cat >$to <<EOF | |
255 | #!/bin/sh | |
256 | for f in \$@ | |
257 | do | |
258 | case "\$f" in | |
259 | /*) | |
260 | $targetmkdir \`dirname \$f\` | |
261 | $targetto $q \$f $targetuser@$targethost:\$f || exit 1 | |
262 | ;; | |
263 | *) | |
264 | $targetmkdir $targetdir/\`dirname \$f\` | |
265 | $targetto $q \$f $targetuser@$targethost:$targetdir/\$f || exit 1 | |
266 | ;; | |
267 | esac | |
268 | done | |
269 | exit 0 | |
270 | EOF | |
271 | ;; | |
272 | cp) $cat >$to <<EOF | |
273 | #!/bin/sh | |
274 | for f in \$@ | |
275 | do | |
276 | case "\$f" in | |
277 | /*) | |
278 | $mkdir -p $targetdir/\`dirname \$f\` | |
279 | $cp \$f $targetdir/\$f || exit 1 | |
280 | ;; | |
281 | *) | |
282 | $targetmkdir $targetdir/\`dirname \$f\` | |
283 | $cp \$f $targetdir/\$f || exit 1 | |
284 | ;; | |
285 | esac | |
286 | done | |
287 | exit 0 | |
288 | EOF | |
289 | ;; | |
290 | *) echo "Unknown targetto '$targetto'" >&4 | |
291 | exit 1 | |
292 | ;; | |
293 | esac | |
294 | case "$targetfrom" in | |
295 | scp|rcp) | |
296 | $cat >$from <<EOF | |
297 | #!/bin/sh | |
298 | for f in \$@ | |
299 | do | |
300 | $rm -f \$f | |
301 | $targetfrom $q $targetuser@$targethost:$targetdir/\$f . || exit 1 | |
302 | done | |
303 | exit 0 | |
304 | EOF | |
305 | ;; | |
306 | cp) $cat >$from <<EOF | |
307 | #!/bin/sh | |
308 | for f in \$@ | |
309 | do | |
310 | $rm -f \$f | |
311 | cp $targetdir/\$f . || exit 1 | |
312 | done | |
313 | exit 0 | |
314 | EOF | |
315 | ;; | |
316 | *) echo "Unknown targetfrom '$targetfrom'" >&4 | |
317 | exit 1 | |
318 | ;; | |
319 | esac | |
320 | if $test ! -f $run; then | |
321 | echo "Target 'run' script '$run' not found." >&4 | |
322 | else | |
323 | $chmod a+rx $run | |
324 | fi | |
325 | if $test ! -f $to; then | |
326 | echo "Target 'to' script '$to' not found." >&4 | |
327 | else | |
328 | $chmod a+rx $to | |
329 | fi | |
330 | if $test ! -f $from; then | |
331 | echo "Target 'from' script '$from' not found." >&4 | |
332 | else | |
333 | $chmod a+rx $from | |
334 | fi | |
335 | if $test ! -f $run -o ! -f $to -o ! -f $from; then | |
336 | exit 1 | |
337 | fi | |
338 | $cat >&4 <<EOF | |
339 | Using '$run' for remote execution, | |
340 | and '$from' and '$to' | |
341 | for remote file transfer. | |
342 | EOF | |
343 | @else | |
344 | echo "Cross-compilation is not supported for this package." >&4 | |
345 | exit 1 | |
346 | @end | |
347 | ;; | |
348 | esac | |
349 |