tags:

views:

46

answers:

1

I have a shared C library, libfoo.so, for which I'm creating a JNI interface. In order to compile the JNI interface library, libfoojni.so, compiler include search paths must be specified. For example, on Linux (using GCC) the following compiler flags are required: -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux.

Unfortunately, the latter path includes the platform. On SunOS the latter path is -I${JAVA_HOME}/include/solaris, on AIX it is -I${JAVA_HOME}/include/aix, and on HP-UX it's -I${JAVA_HOME}/include/hp-ux. This is a nuisance in the build files.

Is there a way to obtain the include paths portably? For example, with perl, you can use perl -MExtUtils::Embed -e ccopts to obtain the compiler flags and -e ldopts the linker flags, respectively. I'm looking for something similar to this, but haven't found anything.

A: 

This is really not a Java or JNI question at all.

The normal way to address this is to use something like the autoconf / automake tool chain which create Make files and 'configure' scripts that run on a wide range of platforms.

Stephen C
I've removed the java tag but kept the jni one, since people doing JNI have probably bumped into this issue.
okun