Subject: Re: Creating a Cross Compile package
To: David Price <dprice@cs.nmsu.edu>
From: Frederick Bruckman <fredb@immanent.net>
List: tech-pkg
Date: 08/13/2004 14:09:09
In article <Pine.LNX.4.60.0408111041300.17989@mustang>,
	dprice@cs.nmsu.edu (David Price) writes:
>
>          Im working on creating a package which uses the i386-linux package 
> in cross to make a linux compatible library that the sun-java jni interface
> can load and work with.  The library comes with a configure script, which I
> pass the following options to:
> 
> CONF_ARGS+=     --with-java=${PKG_JAVA_HOME}/include
> CONF_ARGS+=     --with-javaos=${PKG_JAVA_HOME}/include/linux
> CONF_ARGS+=     --bindir=${PREFIX}/bin
> CONF_ARGS+=     --libdir=${PREFIX}/lib
> CONF_ARGS+=     --x-libraries=${PREFIX}/emul/linux/usr/X11R6/lib/
> CONF_ARGS+=     --host=i386-linux
> CONF_ARGS+=     --build=i386-netbsd
> CONF_ARGS+=     --prefix=${PREFIX}/cross/i386-linux/ (also tried 
> ${PREFIX}/cross/)

I think it's not a good idea to embed ${PREFIX} and ${PREFIX}/cross
into the binary. I would install to "/usr/local", but with ${DESTDIR}
set to "${PREFIX}/emul/linux", so it will *install* to
"${PREFIX}/emul/linux/usr/local", but the program will think it's
in "/usr/local", just as a native linux binary does. You shouldn't
have to tell the build system about "${PREFIX}/cross, either;
the cross compiler should do that transparently.
 
> and then execute the command (CROSS_PKG is set to i386-linux):
> cd ${WRKSRC} && ${PREFIX}/bin/cross-env ./configure ${CONF_ARGS}
> 
> The configure script excutes successfully and detects i386-linux-gcc.  So 
> I execute the makefile with: cd ${WRKSRC} && ${PREFIX}/bin/cross-env make
> 
> The library builds successfully, but when I go to do a make install, I 
> get:
> /home/dprice/pkg/lib/libajaxj.so:       -lc.6 => not found
> *** The above programs/libs will not find the listed shared libraries
>      at runtime. Please fix the package (add -Wl,-R.../lib in the right
> places)!
> 
> To fix this, I added -Wl,-R/${PREFIX}/cross/i386-linux/lib/ to CFLAGS.
> This fixed the error, but I got a new one:
> 
> /home/dprice/pkg/lib/libajaxj.so:        ld-linux.so.2 => not found
> *** The above programs/libs will not find the listed shared libraries
>      at runtime. Please fix the package (add -Wl,-R.../lib in the right
> places)!
> *** Error code 1
> 
> ld-linux.so.2 exists in the same directory that libc does
> (${PREFIX}/cross/i386-linux/lib/).
> ld-linux.so.2 exists as a symlink to ld-2.0.7.so (which exists in
> ${PREFIX}/cross/i386-linux/lib/ as well).

The ".so" files in ".../cross" are for use by the linker. You don't really
want a run-time dependency upon anything in cross. The run-time dependency
should be on the base linux libraries: the linux run-time interpreter will
think to find "ld-linux.so.2" in "/lib", but the kernel emulation and
symlinks will conspire to present it "/usr/pkg/emul/linux/lib" (again,
just like a pre-built native linux binary).

In any case...

linux binaries don't really need RPATH. You can just set ${CHECK_SHLIBS}
to "NO" in the package "Makefile" to avoid the error.

-- 
Frederick