| 1 | # Copyright (C) 2005-2008 David Carter <arm4@arm4.org> |
|---|
| 2 | # |
|---|
| 3 | # This file is free software; as a special exception the author gives |
|---|
| 4 | # unlimited permission to copy and/or distribute it, with or without |
|---|
| 5 | # modifications, as long as this notice is preserved. |
|---|
| 6 | # |
|---|
| 7 | # This program is distributed in the hope that it will be useful, but |
|---|
| 8 | # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the |
|---|
| 9 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|---|
| 10 | |
|---|
| 11 | # Macros to check the paths for the jni headers |
|---|
| 12 | |
|---|
| 13 | AC_DEFUN([__ARM4_JNI_COMPILE], |
|---|
| 14 | [ |
|---|
| 15 | JNI_INCLUDES="$1" |
|---|
| 16 | ac_save_CFLAGS="$CFLAGS" |
|---|
| 17 | CFLAGS="$CFLAGS $JNI_INCLUDES" |
|---|
| 18 | AC_COMPILE_IFELSE([ |
|---|
| 19 | #include <jni.h> |
|---|
| 20 | ], ,[JNI_INCLUDES="fail"]) |
|---|
| 21 | CFLAGS="$ac_save_CFLAGS" |
|---|
| 22 | AC_SUBST(JNI_INCLUDES) |
|---|
| 23 | ]) |
|---|
| 24 | |
|---|
| 25 | AC_DEFUN([ARM4_CHECK_JNI], |
|---|
| 26 | [ |
|---|
| 27 | AC_MSG_CHECKING(for jni.h) |
|---|
| 28 | jdkhome_prefix="/usr" |
|---|
| 29 | AC_ARG_WITH(jdkhome, |
|---|
| 30 | [ --with-jdkhome=PATH prefix for installed Java Development Kit (JDK)], |
|---|
| 31 | [ |
|---|
| 32 | if test "$withval" = "no" || test "$withval" = "yes"; then |
|---|
| 33 | AC_MSG_ERROR([--with-jdkhome requires the full path to the JDK install root]) |
|---|
| 34 | fi |
|---|
| 35 | |
|---|
| 36 | if test -d "$withval/include" || test -d "$withval/Headers" ; then |
|---|
| 37 | jdkhome_prefix="$withval" |
|---|
| 38 | else |
|---|
| 39 | AC_MSG_ERROR([--with-jdkhome requires the full path to the JDK install root]) |
|---|
| 40 | fi |
|---|
| 41 | ],jdkhome_prefix="") |
|---|
| 42 | __ARM4_JNI_COMPILE([]) |
|---|
| 43 | if test "x$JNI_INCLUDES" = "xfail" ; then |
|---|
| 44 | __ARM4_JNI_COMPILE([-I$jdkhome_prefix/include]) |
|---|
| 45 | fi |
|---|
| 46 | if test "x$JNI_INCLUDES" = "xfail" ; then |
|---|
| 47 | __ARM4_JNI_COMPILE([-I$jdkhome_prefix/Headers]) |
|---|
| 48 | fi |
|---|
| 49 | if test "x$JNI_INCLUDES" = "xfail" ; then |
|---|
| 50 | subdirs=`find $jdkhome_prefix/include -type d | \ |
|---|
| 51 | sed 's/^/ -I/' | \ |
|---|
| 52 | tr -d '\n'` |
|---|
| 53 | __ARM4_JNI_COMPILE([$subdirs]) |
|---|
| 54 | fi |
|---|
| 55 | if test "x$JNI_INCLUDES" = "xfail" ; then |
|---|
| 56 | AC_MSG_RESULT(no) |
|---|
| 57 | AC_MSG_ERROR(require jni.h. Use the --with-jdkhome option to specify where it is located.) |
|---|
| 58 | else |
|---|
| 59 | AC_MSG_RESULT($JNI_INCLUDES) |
|---|
| 60 | fi |
|---|
| 61 | ]) |
|---|