• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <dda@sleepycat.com>
31dnl @version $Id: ac_jni_include_dirs.m4,v 1.3 2004/12/24 01:16:37 guidod 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, no)
39test "x$_ACJNI_JAVAC" = xno && AC_MSG_ERROR([$JAVAC could not be found in path])
40
41_ACJNI_FOLLOW_SYMLINKS("$_ACJNI_JAVAC")
42_JTOPDIR=`echo "$_ACJNI_FOLLOWED" | sed -e 's://*:/:g' -e 's:/[[^/]]*$::'`
43case "$host_os" in
44        darwin*)        _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'`
45                        _JINC="$_JTOPDIR/Headers";;
46        *)              _JINC="$_JTOPDIR/include";;
47esac
48if test -f "$_JINC/jni.h"; then
49        JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JINC"
50else
51        _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'`
52        if test -f "$_JTOPDIR/include/jni.h"; then
53                JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include"
54        else
55                AC_MSG_ERROR([cannot find java include files])
56        fi
57fi
58
59# get the likely subdirectories for system specific java includes
60case "$host_os" in
61bsdi*)          _JNI_INC_SUBDIRS="bsdos";;
62linux*)         _JNI_INC_SUBDIRS="linux genunix";;
63osf*)           _JNI_INC_SUBDIRS="alpha";;
64solaris*)       _JNI_INC_SUBDIRS="solaris";;
65mingw*)			_JNI_INC_SUBDIRS="win32";;
66cygwin*)		_JNI_INC_SUBDIRS="win32";;
67*)              _JNI_INC_SUBDIRS="genunix";;
68esac
69
70# add any subdirectories that are present
71for JINCSUBDIR in $_JNI_INC_SUBDIRS
72do
73        if test -d "$_JTOPDIR/include/$JINCSUBDIR"; then
74                JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include/$JINCSUBDIR"
75        fi
76done
77])
78
79# _ACJNI_FOLLOW_SYMLINKS <path>
80# Follows symbolic links on <path>,
81# finally setting variable _ACJNI_FOLLOWED
82# --------------------
83AC_DEFUN([_ACJNI_FOLLOW_SYMLINKS],[
84# find the include directory relative to the javac executable
85_cur="$1"
86while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do
87        AC_MSG_CHECKING(symlink for $_cur)
88        _slink=`ls -ld "$_cur" | sed 's/.* -> //'`
89        case "$_slink" in
90        /*) _cur="$_slink";;
91        # 'X' avoids triggering unwanted echo options.
92        *) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";;
93        esac
94        AC_MSG_RESULT($_cur)
95done
96_ACJNI_FOLLOWED="$_cur"
97])# _ACJNI
98