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.