The platform with the compiler is an x86 PC running GNU/Linux. My target is a board with a PPC860 CPU on it. The board also runs linux with glibc. So running configure on the x86 would get me a configuration "somewhat close" to what I need.
There are other approaches, for instance there are a bunch of SED scripts included in the distribution which mangle Makefiles to make them suitable for for cross compiling to various VxWorks-based systems, including erts/autoconf/vxworks/sed.vxworks_ppc860. I chose not to use these as a starting point because they contained a lot of VxWorks-specific options.
export ac_cv_c_bigendian=yes
./configure --prefix=/export/root/gth/opt/erlang --without-ssl
If you use 'csh' you probably want to write something like
"setenv ac_cv_c_bigendian yes". Without this endianness fix,
you get interesting problems with several things, including
the binary syntax:
(mml@antilipe)3> <<19.0:32/float>>. (antilipe is an x86 box)
<<65,152,0,0>>
...
(gth@gth)11> <<19.0:32/float>>. (gth is a PPC860)
<<0,0,152,65>>
#!/bin/sh
mv $1 $1.orig_mml
sed -e 's/^CC[ \t]*=.*$/CC = ppc_8xx-gcc/' $1.orig_mml | \
sed -e 's/^SHLIB_LD[ \t]*=.*$/SHLIB_LD = ppc_8xx-gcc/' | \
sed -e 's/^CXX[ \t]*=.*$/CXX = ppc_8xx-g++/' | \
sed -e 's/^LD[ \t]*=.*$/LD = ppc_8xx-gcc/' | \
sed -e 's/^LDFLAGS[ \t]*=[ \t]*$/LDFLAGS = -L\/export\/root\/gth\/lib /' \
> $1
You'll need to edit the compiler name and library location of your compiler and the
location of your libraries. I saved it as 'mung' and ran it:
find . -name Makefile -exec ../mung \{\} \;
../mung make/i686-pc-linux-gnu/otp.mk
make noboot
We use 'noboot' because we don't want the system to use the
erlang it just built to then create the boot files. From there,
all you need to do is 'make install' and then possibly fix a
few symlinks and edit the 'erl' shell script to have the right
root directory.
By default, the Erlang library .beam files contain debugging information. On an embedded system space might be critical. One way to get rid of the debugging code is to edit the Makefiles at the top of each directory in lib to include the +no_debug_info switch. This cuts the size of the libraries by about 40%.
You can also throw out a whole bunch of libraries which aren't very useful on an embedded system, e.g. gs, the debugger and perhaps everything to do with CORBA and COM.
If you strip the emulator, you save another few megabytes.
Finally, you can go around and delete man pages, notes.html, header files, the emacs mode, etc. etc.