jamie@89
|
1 ##### http://autoconf-archive.cryp.to/ac_jni_include_dir.html
|
jamie@89
|
2 #
|
jamie@89
|
3 # SYNOPSIS
|
jamie@89
|
4 #
|
jamie@89
|
5 # AC_JNI_INCLUDE_DIR
|
jamie@89
|
6 #
|
jamie@89
|
7 # DESCRIPTION
|
jamie@89
|
8 #
|
jamie@89
|
9 # AC_JNI_INCLUDE_DIR finds include directories needed for compiling
|
jamie@89
|
10 # programs using the JNI interface.
|
jamie@89
|
11 #
|
jamie@89
|
12 # JNI include directories are usually in the java distribution This
|
jamie@89
|
13 # is deduced from the value of JAVAC. When this macro completes, a
|
jamie@89
|
14 # list of directories is left in the variable JNI_INCLUDE_DIRS.
|
jamie@89
|
15 #
|
jamie@89
|
16 # Example usage follows:
|
jamie@89
|
17 #
|
jamie@89
|
18 # AC_JNI_INCLUDE_DIR
|
jamie@89
|
19 #
|
jamie@89
|
20 # for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS
|
jamie@89
|
21 # do
|
jamie@89
|
22 # CPPFLAGS="$CPPFLAGS -I$JNI_INCLUDE_DIR"
|
jamie@89
|
23 # done
|
jamie@89
|
24 #
|
jamie@89
|
25 # If you want to force a specific compiler:
|
jamie@89
|
26 #
|
jamie@89
|
27 # - at the configure.in level, set JAVAC=yourcompiler before calling
|
jamie@89
|
28 # AC_JNI_INCLUDE_DIR
|
jamie@89
|
29 #
|
jamie@89
|
30 # - at the configure level, setenv JAVAC
|
jamie@89
|
31 #
|
jamie@89
|
32 # Note: This macro can work with the autoconf M4 macros for Java
|
jamie@89
|
33 # programs. This particular macro is not part of the original set of
|
jamie@89
|
34 # macros.
|
jamie@89
|
35 #
|
jamie@89
|
36 # LAST MODIFICATION
|
jamie@89
|
37 #
|
jamie@89
|
38 # 2006-05-27
|
jamie@89
|
39 #
|
jamie@89
|
40 # COPYLEFT
|
jamie@89
|
41 #
|
jamie@89
|
42 # Copyright (c) 2006 Don Anderson <dda@sleepycat.com>
|
jamie@89
|
43 #
|
jamie@89
|
44 # Copying and distribution of this file, with or without
|
jamie@89
|
45 # modification, are permitted in any medium without royalty provided
|
jamie@89
|
46 # the copyright notice and this notice are preserved.
|
jamie@89
|
47
|
jamie@89
|
48 AC_DEFUN([AC_JNI_INCLUDE_DIR],[
|
jamie@89
|
49
|
jamie@89
|
50 JNI_INCLUDE_DIRS=""
|
jamie@89
|
51
|
jamie@89
|
52 test "x$JAVAC" = x && AC_MSG_ERROR(['\$JAVAC' undefined])
|
jamie@89
|
53 AC_PATH_PROG(_ACJNI_JAVAC, $JAVAC, no)
|
jamie@89
|
54 test "x$_ACJNI_JAVAC" = xno && AC_MSG_ERROR([$JAVAC could not be found in path])
|
jamie@89
|
55
|
jamie@89
|
56 _ACJNI_FOLLOW_SYMLINKS("$_ACJNI_JAVAC")
|
jamie@89
|
57 _JTOPDIR=`echo "$_ACJNI_FOLLOWED" | sed -e 's://*:/:g' -e 's:/[[^/]]*$::'`
|
jamie@89
|
58 case "$host_os" in
|
jamie@89
|
59 darwin*) _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'`
|
jamie@89
|
60 _JINC="$_JTOPDIR/Headers";;
|
jamie@89
|
61 *) _JINC="$_JTOPDIR/include";;
|
jamie@89
|
62 esac
|
jamie@89
|
63 if test -f "$_JINC/jni.h"; then
|
jamie@89
|
64 JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JINC"
|
jamie@89
|
65 else
|
jamie@89
|
66 _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'`
|
jamie@89
|
67 if test -f "$_JTOPDIR/include/jni.h"; then
|
jamie@89
|
68 JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include"
|
jamie@89
|
69 else
|
jamie@89
|
70 AC_MSG_ERROR([cannot find java include files])
|
jamie@89
|
71 fi
|
jamie@89
|
72 fi
|
jamie@89
|
73
|
jamie@89
|
74 # get the likely subdirectories for system specific java includes
|
jamie@89
|
75 case "$host_os" in
|
jamie@89
|
76 bsdi*) _JNI_INC_SUBDIRS="bsdos";;
|
jamie@89
|
77 linux*) _JNI_INC_SUBDIRS="linux genunix";;
|
jamie@89
|
78 osf*) _JNI_INC_SUBDIRS="alpha";;
|
jamie@89
|
79 solaris*) _JNI_INC_SUBDIRS="solaris";;
|
jamie@89
|
80 mingw*) _JNI_INC_SUBDIRS="win32";;
|
jamie@89
|
81 cygwin*) _JNI_INC_SUBDIRS="win32";;
|
jamie@89
|
82 *) _JNI_INC_SUBDIRS="genunix";;
|
jamie@89
|
83 esac
|
jamie@89
|
84
|
jamie@89
|
85 # add any subdirectories that are present
|
jamie@89
|
86 for JINCSUBDIR in $_JNI_INC_SUBDIRS
|
jamie@89
|
87 do
|
jamie@89
|
88 if test -d "$_JTOPDIR/include/$JINCSUBDIR"; then
|
jamie@89
|
89 JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include/$JINCSUBDIR"
|
jamie@89
|
90 fi
|
jamie@89
|
91 done
|
jamie@89
|
92 ])
|
jamie@89
|
93
|
jamie@89
|
94 # _ACJNI_FOLLOW_SYMLINKS <path>
|
jamie@89
|
95 # Follows symbolic links on <path>,
|
jamie@89
|
96 # finally setting variable _ACJNI_FOLLOWED
|
jamie@89
|
97 # --------------------
|
jamie@89
|
98 AC_DEFUN([_ACJNI_FOLLOW_SYMLINKS],[
|
jamie@89
|
99 # find the include directory relative to the javac executable
|
jamie@89
|
100 _cur="$1"
|
jamie@89
|
101 while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do
|
jamie@89
|
102 AC_MSG_CHECKING(symlink for $_cur)
|
jamie@89
|
103 _slink=`ls -ld "$_cur" | sed 's/.* -> //'`
|
jamie@89
|
104 case "$_slink" in
|
jamie@89
|
105 /*) _cur="$_slink";;
|
jamie@89
|
106 # 'X' avoids triggering unwanted echo options.
|
jamie@89
|
107 *) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";;
|
jamie@89
|
108 esac
|
jamie@89
|
109 AC_MSG_RESULT($_cur)
|
jamie@89
|
110 done
|
jamie@89
|
111 _ACJNI_FOLLOWED="$_cur"
|
jamie@89
|
112 ])# _ACJNI
|