Since nobody responded, I had to figure it out myself :-)

The solution is to keep the apr source tree after the apr build and, when cross compiling apr-util, set the --with-apr option NOT to the directory where the apr-1-config was installed BUT to the apr source tree so it finds the apr-1-config located there.

The apr-1-config in the apr source tree contains line:  
location=source
while the installed apr-1-config has this options set to:
location=installed

The apr-util build recognizes that option and takes all information it needs from the apr source tree. The cross-compile process then works OK.

Mira

P.S.
Similar approach should be used when cross-compiling activemq-cpp which needs options to be set for config files of both apr and apr-util.



To:        dev@apr.apache.org
cc:        
Subject:        How to cross compile apr & apr-util ?

Hi,

I have problem to correctly setup cross compile for APR and APR-util for
Linux ARM (big endian) target. After some experiments to bypass tests that
need to execute code on the targt platform I suceeded to cross compile
APR. Lets say the APR is built using these commands

./configure --prefix=/usr \
           --host=armv5teb-softfloat-linux-gnueabi \
           ac_cv_file__dev_zero="yes" \
           ac_cv_func_setpgrp_void="yes" \
           apr_cv_process_shared_works="yes" \
           apr_cv_mutex_robust_shared="no" \
           apr_cv_tcp_nodelay_with_cork="yes" \
           ac_cv_sizeof_struct_iovec="8" \
           apr_cv_mutex_recursive="yes" \
           CPPFLAGS=-I/tmp/usr/include \
           LDFLAGS=-L/tmp/usr/lib

make all
make DESTDIR=/tmp install

i.e. the cross compiled APR is installed in /tmp/usr/bin ,
/tmp/usr/build-1, /tmp/usr/include ...

Now if I want to build apr-utils the configure script fails to find the
correct build-1 directory:

./configure --prefix=/usr \
           --host=armv5teb-softfloat-linux-gnueabi \
           --with-apr=/tmp/usr \
           CPPFLAGS=-I/tmp/usr/include \
           LDFLAGS=-L/tmp/usr/lib

configure: WARNING: If you wanted to set the --build type, don't use
--host.
   If a cross compiler is detected then cross compile mode will be used.
checking build system type... i686-pc-linux-gnu
checking host system type... armv5teb-softfloat-linux-gnueabi
checking target system type... armv5teb-softfloat-linux-gnueabi
checking for a BSD-compatible install... /usr/bin/install -c
checking for working mkdir -p... yes
APR-util Version: 1.3.4
checking for chosen layout... apr-util
checking for armv5teb-softfloat-linux-gnueabi-gcc...
armv5teb-softfloat-linux-gnueabi-gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... yes
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether armv5teb-softfloat-linux-gnueabi-gcc accepts -g... yes
checking for armv5teb-softfloat-linux-gnueabi-gcc option to accept ISO
C89... none needed
Applying apr-util hints file rules for armv5teb-softfloat-linux-gnueabi
checking for APR... yes
./configure: line 3761: cd: /usr/build-1: No such file or directory

The reason is that the ./configure script finds the
/tmp/usr/bin/apr-1-config but querying the apr-1-config for the APR
configuration it points to /usr which is correct from the target
filesystem point of view but incorrect from the build process point of
view.

How should setup the cross compile environment to get aroud this problem?

Thanks

Mira Kes