1dnl @synopsis AC_JNI_INCLUDE_DIR 2dnl 3dnl AC_JNI_INCLUDE_DIR finds include directories needed 4dnl for compiling programs using the JNI interface. 5dnl 6dnl JNI include directories are usually in the java distribution 7dnl This is deduced from the value of JAVAC. When this macro 8dnl completes, a list of directories is left in the variable 9dnl JNI_INCLUDE_DIRS. 10dnl 11dnl Example usage follows: 12dnl 13dnl AC_JNI_INCLUDE_DIR 14dnl 15dnl for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS 16dnl do 17dnl CPPFLAGS="$CPPFLAGS -I$JNI_INCLUDE_DIR" 18dnl done 19dnl 20dnl If you want to force a specific compiler: 21dnl 22dnl - at the configure.in level, set JAVAC=yourcompiler before calling 23dnl AC_JNI_INCLUDE_DIR 24dnl 25dnl - at the configure level, setenv JAVAC 26dnl 27dnl Note: This macro can work with the autoconf M4 macros for Java programs. 28dnl This particular macro is not part of the original set of macros. 29dnl 30dnl @author Don Anderson 31dnl @version $Id: ac_jni_include_dirs.m4,v 12.2 2007/11/16 15:48:09 bschmeck Exp $ 32dnl 33AC_DEFUN(AC_JNI_INCLUDE_DIR,[ 34 35JNI_INCLUDE_DIRS="" 36 37test "x$JAVAC" = x && AC_MSG_ERROR(['$JAVAC' undefined]) 38AC_PATH_PROG(_ACJNI_JAVAC, $JAVAC, $JAVAC) 39test ! -x "$_ACJNI_JAVAC" && AC_MSG_ERROR([$JAVAC could not be found in path]) 40AC_MSG_CHECKING(absolute path of $JAVAC) 41case "$_ACJNI_JAVAC" in 42/*) AC_MSG_RESULT($_ACJNI_JAVAC);; 43*) AC_MSG_ERROR([$_ACJNI_JAVAC is not an absolute path name]);; 44esac 45 46_ACJNI_FOLLOW_SYMLINKS("$_ACJNI_JAVAC") 47_JTOPDIR=`echo "$_ACJNI_FOLLOWED" | sed -e 's://*:/:g' -e 's:/[[^/]]*$::'` 48case "$host_os" in 49 darwin*) _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'` 50 _JINC="$_JTOPDIR/Headers";; 51 *) _JINC="$_JTOPDIR/include";; 52esac 53 54# If we find jni.h in /usr/include, then it's not a java-only tree, so 55# don't add /usr/include or subdirectories to the list of includes. 56# An extra -I/usr/include can foul things up with newer gcc's. 57# 58# If we don't find jni.h, just keep going. Hopefully javac knows where 59# to find its include files, even if we can't. 60if test -r "$_JINC/jni.h"; then 61 if test "$_JINC" != "/usr/include"; then 62 JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JINC" 63 fi 64else 65 _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'` 66 if test -r "$_JTOPDIR/include/jni.h"; then 67 if test "$_JTOPDIR" != "/usr"; then 68 JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include" 69 fi 70 fi 71fi 72 73# get the likely subdirectories for system specific java includes 74if test "$_JTOPDIR" != "/usr"; then 75 case "$host_os" in 76 aix*) _JNI_INC_SUBDIRS="aix";; 77 bsdi*) _JNI_INC_SUBDIRS="bsdos";; 78 cygwin*) _JNI_INC_SUBDIRS="win32";; 79 freebsd*) _JNI_INC_SUBDIRS="freebsd";; 80 hp*) _JNI_INC_SUBDIRS="hp-ux";; 81 linux*) _JNI_INC_SUBDIRS="linux genunix";; 82 osf*) _JNI_INC_SUBDIRS="alpha";; 83 solaris*) _JNI_INC_SUBDIRS="solaris";; 84 *) _JNI_INC_SUBDIRS="genunix";; 85 esac 86fi 87 88# add any subdirectories that are present 89for _JINCSUBDIR in $_JNI_INC_SUBDIRS 90do 91 if test -d "$_JTOPDIR/include/$_JINCSUBDIR"; then 92 JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include/$_JINCSUBDIR" 93 fi 94done 95]) 96 97# _ACJNI_FOLLOW_SYMLINKS <path> 98# Follows symbolic links on <path>, 99# finally setting variable _ACJNI_FOLLOWED 100# -------------------- 101AC_DEFUN(_ACJNI_FOLLOW_SYMLINKS,[ 102# find the include directory relative to the javac executable 103_cur="$1" 104while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do 105 AC_MSG_CHECKING(symlink for $_cur) 106 _slink=`ls -ld "$_cur" | sed 's/.* -> //'` 107 case "$_slink" in 108 /*) _cur="$_slink";; 109 # 'X' avoids triggering unwanted echo options. 110 *) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";; 111 esac 112 AC_MSG_RESULT($_cur) 113done 114_ACJNI_FOLLOWED="$_cur" 115])# _ACJNI 116