Cross-Compiling Perl

Joe Ciccone jciccone at gmail.com
Wed Dec 28 12:35:36 PST 2005


In my current build x86 -> x86_64 multilib the instructions that the
book provide do not correctly cross-compile perl, After playin with it
for a bit i ended up with the script below. I would like some opinions
and ideas on how i can change or improve these instructions before I put
them in the book.

#!/bin/bash

tar xf perl-5.8.7.tar.bz2 &&
cd perl-5.8.7 &&

patch -Np1 -i ../perl-5.8.7-libc-1.patch &&

chmod 755 ext/util/make_ext &&
cp ext/util/make_ext{,.orig} &&
sed -e 's/miniperl/miniperl-cross/g' ext/util/make_ext.orig >
ext/util/make_ext &&
chmod 755 x2p/Makefile.SH &&
cp x2p/Makefile.SH{,.orig} &&
sed -e 's/miniperl/miniperl-cross/g' x2p/Makefile.SH.orig >
x2p/Makefile.SH &&
chmod 755 utils/Makefile &&
cp utils/Makefile{,.orig} &&
sed -e 's/miniperl/miniperl-cross/g' utils/Makefile.orig > utils/Makefile &&

sh Configure -des -Dprefix=/tools -Dstatic_ext='Data/Dumper IO Fcntl
POSIX' &&

make miniperl &&
mv miniperl miniperl-cross &&
make clean &&

cp config.sh{,.orig} &&
sed -e "s@\(^ar=\).*@\1'${AR}'@g" \
    -e "s@\(^ranlib=\).*@\1'${RANLIB}'@g" \
    -e "s@\(^cc=\).*@\1'${CC} ${BUILD64}'@g" \
    -e "s@\(^ld=\).*@\1'${CC} ${BUILD64}'@g" config.sh.orig > config.sh &&

cp Makefile{,.orig} &&
sed -e 's|(LDLIBPTH) ./miniperl|(LDLIBPTH) ./miniperl-cross|g' \
    -e "s at CC = cc at CC = ${LFS_TARGET}-gcc@" \
    -e "s at LD = cc at LD = ${LFS_TARGET}-gcc@" \
    -e "s at AR = /usr/bin/ar at AR = ${LFS_TARGET}-ar@" Makefile.orig >
Makefile &&

make perl utilitites &&

cp perl pod/pod2man /tools/bin &&
install -d /tools/lib/perl5/5.8.7 &&
cp -R lib/* /tools/lib/perl5/5.8.7

# End of script

perl:           ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV),
for GNU/Linux 2.6.0, dynamically linked (uses shared libs), for
GNU/Linux 2.6.0, not stripped
miniperl:       ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV),
for GNU/Linux 2.6.0, dynamically linked (uses shared libs), for
GNU/Linux 2.6.0, not stripped
miniperl-cross: ELF 32-bit LSB executable, Intel 80386, version 1
(SYSV), for GNU/Linux 2.6.0, dynamically linked (uses shared libs), for
GNU/Linux 2.6.0, not stripped



More information about the cross-lfs mailing list