3 ?RCS: Copyright (c) 2001 Jarkko Hietaniemi
5 ?RCS: You may distribute under the terms of either the GNU General Public
6 ?RCS: License or the Artistic License, as specified in the README file.
8 ?MAKE:run to from targetarch targetdir targetmkdir targethost targetport \
9 usecrosscompile hostperl hostgenerate hostosname targetenv: \
10 src test rm echo sed mkdir cp chmod make touch
11 ?MAKE: -pick add $@ %<
14 ?S: This variable conditionally defines the USE_CROSS_COMPILE symbol,
15 ?S: and indicates that Perl has been cross-compiled.
18 ?S: This variable contains the command used by Configure
19 ?S: to copy and execute a cross-compiled executable in the
20 ?S: target host. Useful and available only during Perl build.
21 ?S: Empty string '' if not cross-compiling.
24 ?S: This variable contains the command used by Configure
25 ?S: to copy files from the target host. Useful and available
26 ?S: only during Perl build.
27 ?S: The string ':' if not cross-compiling.
30 ?S: This variable contains the command used by Configure
31 ?S: to copy to from the target host. Useful and available
32 ?S: only during Perl build.
33 ?S: The string ':' if not cross-compiling.
36 ?S: If cross-compiling, this variable contains the target architecture.
37 ?S: If not, this will be empty.
40 ?S: This variable contains a path that will be created on the target
41 ?S: host using targetmkdir, and then used to copy the cross-compiled
42 ?S: executables to. Defaults to '/tmp' if not set.
45 ?S: This variable contains the command used by Configure to create a
46 ?S: new directory on the target host.
49 ?S: This variable contains the name of a separate host machine that
50 ?S: can be used to run compiled test programs and perl tests on.
51 ?S: Set to empty string if not in use.
54 ?S: This variable contains the number of a network port to be used to
55 ?S: connect to the host in targethost, if unset defaults to 22 for ssh.
58 ?S: This variable contains the path to a miniperl binary that can be
59 ?S: run on the host OS when cross-compiling. Useful and available only
60 ?S: during Perl build.
61 ?S: Empty string '' if not cross-compiling.
64 ?S: This variable contains the path to a generate_uudmap binary that
65 ?S: can be run on the host OS when cross-compiling. Useful and
66 ?S: available only during Perl build.
67 ?S: Empty string '' if not cross-compiling.
70 ?S: This variable contains the original value of '$^O' for hostperl
71 ?S: when cross-compiling. This is useful to pick the proper tools
72 ?S: when running build code in the host.
73 ?S: Empty string '' if not cross-compiling.
76 ?S: If cross-compiling, this variable can be used to modify the
77 ?S: environment on the target system.
78 ?S: However, how and where it's used, and even if it's used at all, is
79 ?S: entirely dependent on both the transport mechanism (targetrun) and
80 ?S: what the target system is. Unless the relevant documentation says
81 ?S: otherwise, it is genereally not useful.
84 ?C: This symbol, if defined, indicates that Perl is being cross-compiled.
87 ?C: This symbol, if defined, indicates the target architecture
88 ?C: Perl has been cross-compiled to. Undefined if not a cross-compile.
90 ?H:?%<:#ifndef USE_CROSS_COMPILE
91 ?H:?%<:#$usecrosscompile USE_CROSS_COMPILE /**/
92 ?H:?%<:#define PERL_TARGETARCH "$targetarch" /**/
98 ?T:croak pwd exe f q cwd file xxx env
99 ?LINT:extern usecrosscompile
106 ?LINT:extern targetenv
107 ?LINT:extern targetport
108 ?LINT:extern targetdir
109 ?LINT:extern targetuser
110 ?LINT:change targetuser
111 ?LINT:extern targetrun
112 ?LINT:extern targetfrom
113 ?LINT:extern targetto
114 ?LINT:change targetrun
115 ?LINT:change targetfrom
116 ?LINT:change targetto
119 ?LINT:extern locincpth
120 ?LINT:extern loclibpth
121 ?LINT:change locincpth
122 ?LINT:change loclibpth
123 ?LINT:extern hostperl
124 ?LINT:extern hostgenerate
125 ?LINT:extern before_host
126 ?LINT:change before_host
127 ?LINT:extern hostosname
128 ?LINT:extern multiarch
129 : Check for Cross-Compilation
130 ?X: targethost and targetenv mainly set to allow ?S: documentation
131 ?X:otherwise it could have been declared extern
132 if $test "X$targethost" = "X"; then
135 if $test "X$targetenv" = "X"; then
138 case "$usecrosscompile" in
140 $echo "Cross-compiling..."
143 *-gcc*|*-g++*) # A cross-compiling gcc, probably.
144 # arm-linux-androideabi-gcc -> arm-linux-androideabi
145 # x86_64-w64-mingw32-gcc.exe -> x86_64-w64-mingw32
146 targetarch=`$echo $cc|$sed 's/-g[c\+][c\+].*$//'`
147 ar=`$echo $cc|$sed 's/-g[c\+][c\+]/-ar/'`
148 # leave out ld, choosing it is more complex
149 nm=`$echo $cc|$sed 's/-g[c\+][c\+]/-nm/'`
150 ranlib=`$echo $cc|$sed 's/-g[c\+][c\+]/-ranlib/'`
151 # We are in a weird spot. Just before us, some values
152 # were 'saved', to be restored after the hints are
153 # run. This means that the changes we made to ar,
154 # nm and ranlib will get reverted.
155 # To avoid that, we hijack the saving mechanism and
156 # have it save our new values.
157 for file in ar nm ranlib; do
164 case "$targetarch" in
165 '') echo "Targetarch not defined." >&4; croak=y ;;
166 *) echo "Using targetarch $targetarch." >&4 ;;
168 case "$targethost" in
169 '') echo "Targethost not defined." >&4; croak=n ;;
170 *) echo "Using targethost $targethost." >&4
175 y) echo "Cannot continue, aborting." >&4; exit 1 ;;
177 : compile a host miniperl and generate_uudmap, unless we got passed them
178 if $test "X$hostperl" = X; then
179 echo "Building host miniperl and generate_uudmap binaries" >&4
187 $src/Configure -des -Dusedevel -Dmksymlinks
189 case "$hostgenerate" in
190 '') $make generate_uudmap
191 hostgenerate=$src/host/generate_uudmap
193 "$undef") hostgenerate=''
196 hostperl=$src/host/miniperl
199 hostosname=`$hostperl -le 'print $^O'`
202 usecrosscompile="$undef"
206 : Define -Dtargethost=somecomputer to run compiled tests on another machine
207 case "$targethost" in
208 '') echo "Checking for cross-compile" >&4
209 case "$usecrosscompile$multiarch" in
210 *$define*) echo "Skipping the try tests in the rest of Configure as no targethost was defined when cross-compiling" >&4
211 if [ -f Makefile ]; then
213 echo "Now you must ensure config.sh, config.h and the generated headers exist and run a $make."
215 echo "Configure done."
219 *) echo "No targethost for running compiler tests against defined, running locally" >&4
226 *) echo "Using targethost $targethost." >&4
228 /*) run=$src/Cross/run
229 targetmkdir=$src/Cross/mkdir
233 *) pwd=`$test -f ../Configure & cd ..; pwd`
235 targetmkdir=$pwd/Cross/mkdir
246 case "$targetfrom" in
247 '') targetfrom=scp ;;
251 from=$from-$targetfrom
254 echo "Guessing targetdir $targetdir." >&4
257 case "$targetuser" in
259 echo "Guessing targetuser $targetuser." >&4
262 case "$targetport" in
264 echo "Guessing targetport $targetport." >&4
267 case "$targetfrom" in
291 '') cwd=$targetdir ;;
296 $targetrun -p $targetport -l $targetuser $targethost "cd \$cwd && \$env \$exe \$@"
302 *) echo "Unknown targetrun '$targetrun'" >&4
306 case "$targetmkdir" in
308 cat >$targetmkdir <<EOF
310 $targetrun -p $targetport -l $targetuser $targethost "mkdir -p \$@"
312 $chmod a+rx $targetmkdir
314 *) echo "Unknown targetmkdir '$targetmkdir'" >&4
326 $targetmkdir \`dirname \$f\`
327 $targetto -P $targetport -r $q \$f $targetuser@$targethost:\$f 2>/dev/null || exit 1
330 $targetmkdir $targetdir/\`dirname \$f\`
331 $targetto -P $targetport -r $q \$f $targetuser@$targethost:$targetdir/\$f 2>/dev/null || exit 1
344 $mkdir -p $targetdir/\`dirname \$f\`
345 $cp \$f $targetdir/\$f || exit 1
348 $targetmkdir $targetdir/\`dirname \$f\`
349 $cp \$f $targetdir/\$f || exit 1
356 *) echo "Unknown targetto '$targetto'" >&4
360 case "$targetfrom" in
367 $targetfrom -P $targetport $q $targetuser@$targethost:$targetdir/\$f . || exit 1
377 cp $targetdir/\$f . || exit 1
382 *) echo "Unknown targetfrom '$targetfrom'" >&4
386 if $test ! -f $run; then
387 echo "Target 'run' script '$run' not found." >&4
391 if $test ! -f $to; then
392 echo "Target 'to' script '$to' not found." >&4
396 if $test ! -f $from; then
397 echo "Target 'from' script '$from' not found." >&4
401 if $test ! -f $run -o ! -f $to -o ! -f $from; then
405 Using '$run' for remote execution,
406 and '$from' and '$to'
407 for remote file transfer.
413 usecrosscompile="$undef"