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.

81 lines
3.0KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_check_java_home.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_CHECK_JAVA_HOME
  8. #
  9. # DESCRIPTION
  10. #
  11. # Check for Sun Java (JDK / JRE) installation, where the 'java' VM is in.
  12. # If found, set environment variable JAVA_HOME = Java installation home,
  13. # else left JAVA_HOME untouch, which in most case means JAVA_HOME is
  14. # empty.
  15. #
  16. # LICENSE
  17. #
  18. # Copyright (c) 2008 Gleen Salmon <gleensalmon@yahoo.com>
  19. #
  20. # This program is free software; you can redistribute it and/or modify it
  21. # under the terms of the GNU General Public License as published by the
  22. # Free Software Foundation; either version 2 of the License, or (at your
  23. # option) any later version.
  24. #
  25. # This program is distributed in the hope that it will be useful, but
  26. # WITHOUT ANY WARRANTY; without even the implied warranty of
  27. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  28. # Public License for more details.
  29. #
  30. # You should have received a copy of the GNU General Public License along
  31. # with this program. If not, see <https://www.gnu.org/licenses/>.
  32. #
  33. # As a special exception, the respective Autoconf Macro's copyright owner
  34. # gives unlimited permission to copy, distribute and modify the configure
  35. # scripts that are the output of Autoconf when processing the Macro. You
  36. # need not follow the terms of the GNU General Public License when using
  37. # or distributing such scripts, even though portions of the text of the
  38. # Macro appear in them. The GNU General Public License (GPL) does govern
  39. # all other use of the material that constitutes the Autoconf Macro.
  40. #
  41. # This special exception to the GPL applies to versions of the Autoconf
  42. # Macro released by the Autoconf Archive. When you make and distribute a
  43. # modified version of the Autoconf Macro, you may extend this special
  44. # exception to the GPL to apply to your modified version as well.
  45. #serial 7
  46. AU_ALIAS([AC_CHECK_JAVA_HOME], [AX_CHECK_JAVA_HOME])
  47. AC_DEFUN([AX_CHECK_JAVA_HOME],
  48. [AC_MSG_CHECKING([for JAVA_HOME])
  49. # We used a fake loop so that we can use "break" to exit when the result
  50. # is found.
  51. while true
  52. do
  53. # If the user defined JAVA_HOME, don't touch it.
  54. test "${JAVA_HOME+set}" = set && break
  55. # On Mac OS X 10.5 and following, run /usr/libexec/java_home to get
  56. # the value of JAVA_HOME to use.
  57. # (http://developer.apple.com/library/mac/#qa/qa2001/qa1170.html).
  58. JAVA_HOME=`/usr/libexec/java_home 2>/dev/null`
  59. test x"$JAVA_HOME" != x && break
  60. # See if we can find the java executable, and compute from there.
  61. TRY_JAVA_HOME=`ls -dr /usr/java/* 2> /dev/null | head -n 1`
  62. if test x$TRY_JAVA_HOME != x; then
  63. PATH=$PATH:$TRY_JAVA_HOME/bin
  64. fi
  65. AC_PATH_PROG([JAVA_PATH_NAME], [java])
  66. if test "x$JAVA_PATH_NAME" != x; then
  67. JAVA_HOME=`echo $JAVA_PATH_NAME | sed "s/\(.*\)[[/]]bin[[/]]java.*/\1/"`
  68. break
  69. fi
  70. AC_MSG_NOTICE([Could not compute JAVA_HOME])
  71. break
  72. done
  73. AC_MSG_RESULT([$JAVA_HOME])
  74. ])