Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
4.6KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_jni_include_dir.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_JNI_INCLUDE_DIR
  8. #
  9. # DESCRIPTION
  10. #
  11. # AX_JNI_INCLUDE_DIR finds include directories needed for compiling
  12. # programs using the JNI interface.
  13. #
  14. # JNI include directories are usually in the Java distribution. This is
  15. # deduced from the value of $JAVA_HOME, $JAVAC, or the path to "javac", in
  16. # that order. When this macro completes, a list of directories is left in
  17. # the variable JNI_INCLUDE_DIRS.
  18. #
  19. # Example usage follows:
  20. #
  21. # AX_JNI_INCLUDE_DIR
  22. #
  23. # for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS
  24. # do
  25. # CPPFLAGS="$CPPFLAGS -I$JNI_INCLUDE_DIR"
  26. # done
  27. #
  28. # If you want to force a specific compiler:
  29. #
  30. # - at the configure.in level, set JAVAC=yourcompiler before calling
  31. # AX_JNI_INCLUDE_DIR
  32. #
  33. # - at the configure level, setenv JAVAC
  34. #
  35. # Note: This macro can work with the autoconf M4 macros for Java programs.
  36. # This particular macro is not part of the original set of macros.
  37. #
  38. # LICENSE
  39. #
  40. # Copyright (c) 2008 Don Anderson <dda@sleepycat.com>
  41. #
  42. # Copying and distribution of this file, with or without modification, are
  43. # permitted in any medium without royalty provided the copyright notice
  44. # and this notice are preserved. This file is offered as-is, without any
  45. # warranty.
  46. #serial 14
  47. AU_ALIAS([AC_JNI_INCLUDE_DIR], [AX_JNI_INCLUDE_DIR])
  48. AC_DEFUN([AX_JNI_INCLUDE_DIR],[
  49. JNI_INCLUDE_DIRS=""
  50. if test "x$JAVA_HOME" != x; then
  51. _JTOPDIR="$JAVA_HOME"
  52. else
  53. if test "x$JAVAC" = x; then
  54. JAVAC=javac
  55. fi
  56. AC_PATH_PROG([_ACJNI_JAVAC], [$JAVAC], [no])
  57. if test "x$_ACJNI_JAVAC" = xno; then
  58. AC_MSG_ERROR([cannot find JDK; try setting \$JAVAC or \$JAVA_HOME])
  59. fi
  60. _ACJNI_FOLLOW_SYMLINKS("$_ACJNI_JAVAC")
  61. _JTOPDIR=`echo "$_ACJNI_FOLLOWED" | sed -e 's://*:/:g' -e 's:/[[^/]]*$::'`
  62. fi
  63. case "$host_os" in
  64. darwin*) # Apple Java headers are inside the Xcode bundle.
  65. macos_version=$(sw_vers -productVersion | sed -n -e 's/^@<:@0-9@:>@*.\(@<:@0-9@:>@*\).@<:@0-9@:>@*/\1/p')
  66. if @<:@ "$macos_version" -gt "7" @:>@; then
  67. _JTOPDIR="$(xcrun --show-sdk-path)/System/Library/Frameworks/JavaVM.framework"
  68. _JINC="$_JTOPDIR/Headers"
  69. else
  70. _JTOPDIR="/System/Library/Frameworks/JavaVM.framework"
  71. _JINC="$_JTOPDIR/Headers"
  72. fi
  73. ;;
  74. *) _JINC="$_JTOPDIR/include";;
  75. esac
  76. _AS_ECHO_LOG([_JTOPDIR=$_JTOPDIR])
  77. _AS_ECHO_LOG([_JINC=$_JINC])
  78. # On Mac OS X 10.6.4, jni.h is a symlink:
  79. # /System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/jni.h
  80. # -> ../../CurrentJDK/Headers/jni.h.
  81. AC_CACHE_CHECK(jni headers, ac_cv_jni_header_path,
  82. [
  83. if test -f "$_JINC/jni.h"; then
  84. ac_cv_jni_header_path="$_JINC"
  85. JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $ac_cv_jni_header_path"
  86. else
  87. _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'`
  88. if test -f "$_JTOPDIR/include/jni.h"; then
  89. ac_cv_jni_header_path="$_JTOPDIR/include"
  90. JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $ac_cv_jni_header_path"
  91. else
  92. ac_cv_jni_header_path=none
  93. fi
  94. fi
  95. ])
  96. # get the likely subdirectories for system specific java includes
  97. case "$host_os" in
  98. bsdi*) _JNI_INC_SUBDIRS="bsdos";;
  99. freebsd*) _JNI_INC_SUBDIRS="freebsd";;
  100. darwin*) _JNI_INC_SUBDIRS="darwin";;
  101. linux*) _JNI_INC_SUBDIRS="linux genunix";;
  102. osf*) _JNI_INC_SUBDIRS="alpha";;
  103. solaris*) _JNI_INC_SUBDIRS="solaris";;
  104. mingw*) _JNI_INC_SUBDIRS="win32";;
  105. cygwin*) _JNI_INC_SUBDIRS="win32";;
  106. *) _JNI_INC_SUBDIRS="genunix";;
  107. esac
  108. if test "x$ac_cv_jni_header_path" != "xnone"; then
  109. # add any subdirectories that are present
  110. for JINCSUBDIR in $_JNI_INC_SUBDIRS
  111. do
  112. if test -d "$_JTOPDIR/include/$JINCSUBDIR"; then
  113. JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include/$JINCSUBDIR"
  114. fi
  115. done
  116. fi
  117. ])
  118. # _ACJNI_FOLLOW_SYMLINKS <path>
  119. # Follows symbolic links on <path>,
  120. # finally setting variable _ACJNI_FOLLOWED
  121. # ----------------------------------------
  122. AC_DEFUN([_ACJNI_FOLLOW_SYMLINKS],[
  123. # find the include directory relative to the javac executable
  124. _cur="$1"
  125. while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do
  126. AC_MSG_CHECKING([symlink for $_cur])
  127. _slink=`ls -ld "$_cur" | sed 's/.* -> //'`
  128. case "$_slink" in
  129. /*) _cur="$_slink";;
  130. # 'X' avoids triggering unwanted echo options.
  131. *) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";;
  132. esac
  133. AC_MSG_RESULT([$_cur])
  134. done
  135. _ACJNI_FOLLOWED="$_cur"
  136. ])# _ACJNI