Cross-compiling perl

Unpack perl-X.Y.Z-cross-W.Q.tar.gz over perl-X.Y.Z distribution.
Perl-cross package should overwrite top-level Makefile and some other files in the perl source tree.

The build process is similar to that of most autoconf-based packages. For a native build, use something like

	./configure --prefix=/usr
	make DESTDIR=/some/tmp/dir install

For a cross-build, specify your target:

	./configure --prefix=/usr --target=i586-pc-linux-uclibc
	make DESTDIR=/some/tmp/dir install

Check below for other possible make targets.

Target-specific notes

Android. Tested with NDK 24.0.8215888, Perl 5.36.0, and perl-cross 1.4. Installed on a Pixel 6 in /data/local/tmp/perl.

	export AR=$TOOLCHAIN/bin/llvm-ar
	export CC=$TOOLCHAIN/bin/aarch64-linux-android21-clang
	export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
	export STRIP=$TOOLCHAIN/bin/llvm-strip
	export NM=$TOOLCHAIN/bin/llvm-nm
	export READELF=$TOOLCHAIN/bin/llvm-readelf
	export OBJDUMP=$TOOLCHAIN/bin/llvm-objdump
	./configure --target=aarch64-linux-android --sysroot=$SYSROOT --prefix=/data/local/tmp/perl
        make DESTDIR=<local install dir> install

Then, to install:

        cd <local install dir>/data/local/tmp
        find perl -type d -exec adb shell mkdir /data/local/tmp/\{\} \;
        adb push perl /data/local/tmp
	adb shell '/data/local/tmp/perl/bin/perl -e "print qq{Hello, world!\n}";'

Adjust platform and compiler version to match your particular NDK.

arm-linux-uclibc: successful build is highly likely.
Check target tools prefix, it may be useful here, especially if --sysroot is used.

	./configure --target=arm-linux-uclibc --target-tools-prefix=arm-linux-

ix86-* with Intel cc, native build: use -Dcc=icc. Configure will not supply any optimization options to the compiler, consider -Doptimize if necessary.

MinGW32: cannot be built yet. Configure will produce, but current perl-cross Makefiles can't handle win32 build.

	./configure --target=i486-mingw32 --no-dynaloader

Complete configure options list

Overall call order:

	configure [options]

Perl-cross configure adheres to common GNU autoconf style, but also accepts most of the original Configure options. Both short and long options are supported (-D, --define).

Valid ways to supply arguments for the options:

Whenever necessary, dashes in "key" are converted to underscores; use --set-d-something instead of --set-d_something.

The only essential thing configure does is writing (and possibly Most options are meant to alter the values written there. Refer to Porting/Glossary for description of variables found in This page only decribes how to modify them, not which values to use.

General configure control options:

dump a short help message on stdout and exit
set configure mode; used internally
Append to config.log instead of truncating it; used internally.
Re-generates config.h, xconfig.h and Makefile.config from and Does not change or

General installation setup:

Installation prefix (on the target).
Installation prefix for HTML documentation (not used)
Installation prefix for manual pages
Target description (e.g. i586-pc-linux-uclibc); machine-gcc, machine-ld, machine-ar will be used for target build unless explicitly overriden, and perl archname will be set to machine. Hints will be choosen based on this value.
Use prefix-gcc, prefix-ld without overriding archname.
Same as --target but for host executables (miniperl)
Suggest specified hint files (cnf/hints/h1 and so on). The hints are processed after other options, see Workflow below.
Comma-separated list of libraries to check
(basenames only, use "dl" to have -ldl passed to the linker).
(target) C compiler.
(target) C preprocessor.
(target) ranlib; set to 'true' or 'echo' to disable.
(target) objdump; not used during the build, but crucial for some configure test.
Same, for host executables. Only useful when cross-compiling.
Passed directly to target compiler, linker and preprocessor. See gcc(1) on how to use this option.

Options from the original Configure which are not supported or make no sense for this version of configure:

go on without questioning past the production of
(ignored, you'll have to run make manually)
stop at the end of questions, after having produced (ignored, that's the only way perl-cross works)
reuse C symbols value if possible, skips costly nm extraction (ignored, configure uses completely different method of checking function availability)
silent mode (ignored, perl-cross has no other modes)
(not supported)
perform variable substitutions on all .SH files (ignored, configure can't do that)
show version number (not supported)
use defaults for all answers (ignored, default mode)
show help (ignored, use --help instead)

The following options are used to manipulate the values configure will write to Check Porting/Glossary for the list of possible symbols.

load configuration from a file.
See Workflow below.
-D symbol[=value]
set value for symbol; default value is "define".
Common examples (see INSTALL for more info):
-U symbol
set symbol to "undef"; -U symbol= set empty value.
let -D and -U override definitions from loaded configuration files; without -O, configuration files specified with -f will overwrite anything that was set using configure options. See Workflow below.
-A [a:]symbol=value
append value to symbol; some other forms are supported for compatibility with Configure but their use is discouraged.
--set symbol=value
Set symbol to value (default "").
Same as --set usesomething=define
Same as --set d_function=define
Same as --set something=define
Set i_header to 'define' or 'undef'; e.g. to disable <sys/time.h> use --include-sys-time-h=no.

When configuring for a cross-build, -D/--set and other similar options affect target perl configuration ( only. Use --host-option[=value] to pass --option[=value over to miniperl configure.

Configure tries to build all modules it can find in the source tree. Use the following options to alter modules list:

Build specified modules statically
Do not build specified modules.
Build listed modules only
Build all XS modules as static. Does not imply --no-dynaloader.
Do not build DynaLoader. Implies --all-static. Resulting perl won't be able to load any XS modules. Same as -Uusedl.

modX should be something like cpan/Archive-Extract; static only applies to XS modules and will not affect non-XS modules.

make targets

Warning: run "make crosspatch" BEFORE making other targets manually.

Default make target is building perl and all configured modules. Other targets:

Apply all patches from cnf/diffs. Files are only patched once, cnf/diffs/path/file.applied locks are created to track that.
Build miniperl only.
Re-build resp. files from [x], may be needed after editing [x] manually. Note that make may try updating Makefile.config as a dependency for something else, but it won't re-read it immediately.
Build DynaLoader module. This is the first big target after miniperl, and the first that requires target compiler. If you can't get past dynaloder, something's really wrong. May be used to check target compiler viability.
Build the main perl executable. Implies dynaloader and any static modules, but does not build dynamic or non-XS ones.
Build all non-XS / dynamic XS / static XS modules listed in Makefile.config. Check Modules page for details.
Build all modules at once.
Build Some-Module. Only works for modules listed in Makefile.config.
Remove all pm_to_blib locks. See Modules page for more info.
Create/update Makefiles for all configured modules.
Run make clean for all modules. May cause unexpected side effects, see Modules page.
Build everything in utils/.
Same as make install.perl
Install perl and all the modules.
Install manual pages.
Run perl test suite from t/
Build testpack for on-target testing. See Testing page.
Try to clean up the source tree. Does not always work as expected.

For most generated files, make file should be enough to rebuild file.