Tue, 09 Apr 2013 09:45:48 +0200
8010465: Can't enable sjavac when building in jprt.
Reviewed-by: ohair, tbell
ohair@425 | 1 | # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- |
ohair@576 | 2 | |
ohair@576 | 3 | # |
ohair@576 | 4 | # Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
ohair@576 | 5 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ohair@576 | 6 | # |
ohair@576 | 7 | # This code is free software; you can redistribute it and/or modify it |
ohair@576 | 8 | # under the terms of the GNU General Public License version 2 only, as |
ohair@576 | 9 | # published by the Free Software Foundation. Oracle designates this |
ohair@576 | 10 | # particular file as subject to the "Classpath" exception as provided |
ohair@576 | 11 | # by Oracle in the LICENSE file that accompanied this code. |
ohair@576 | 12 | # |
ohair@576 | 13 | # This code is distributed in the hope that it will be useful, but WITHOUT |
ohair@576 | 14 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ohair@576 | 15 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ohair@576 | 16 | # version 2 for more details (a copy is included in the LICENSE file that |
ohair@576 | 17 | # accompanied this code). |
ohair@576 | 18 | # |
ohair@576 | 19 | # You should have received a copy of the GNU General Public License version |
ohair@576 | 20 | # 2 along with this work; if not, write to the Free Software Foundation, |
ohair@576 | 21 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ohair@576 | 22 | # |
ohair@576 | 23 | # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@576 | 24 | # or visit www.oracle.com if you need additional information or have any |
ohair@576 | 25 | # questions. |
ohair@576 | 26 | # |
ohair@576 | 27 | |
ohair@425 | 28 | # |
ohair@425 | 29 | # Copyright © 2004 Scott James Remnant <scott@netsplit.com>. |
ohair@425 | 30 | # |
ohair@425 | 31 | # This program is free software; you can redistribute it and/or modify |
ohair@425 | 32 | # it under the terms of the GNU General Public License as published by |
ohair@425 | 33 | # the Free Software Foundation; either version 2 of the License, or |
ohair@425 | 34 | # (at your option) any later version. |
ohair@425 | 35 | # |
ohair@425 | 36 | # This program is distributed in the hope that it will be useful, but |
ohair@425 | 37 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
ohair@425 | 38 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
ohair@425 | 39 | # General Public License for more details. |
ohair@425 | 40 | # |
ohair@425 | 41 | # You should have received a copy of the GNU General Public License |
ohair@425 | 42 | # along with this program; if not, write to the Free Software |
ohair@425 | 43 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
ohair@425 | 44 | # |
ohair@425 | 45 | # As a special exception to the GNU General Public License, if you |
ohair@425 | 46 | # distribute this file as part of a program that contains a |
ohair@425 | 47 | # configuration script generated by Autoconf, you may include it under |
ohair@425 | 48 | # the same distribution terms that you use for the rest of that program. |
ohair@425 | 49 | |
ohair@425 | 50 | # PKG_PROG_PKG_CONFIG([MIN-VERSION]) |
ohair@425 | 51 | # ---------------------------------- |
ohair@425 | 52 | AC_DEFUN([PKG_PROG_PKG_CONFIG], |
ohair@425 | 53 | [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) |
ohair@425 | 54 | m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) |
ohair@425 | 55 | AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl |
ohair@425 | 56 | if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then |
ohair@425 | 57 | AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) |
ohair@425 | 58 | fi |
ohair@425 | 59 | if test -n "$PKG_CONFIG"; then |
ohair@425 | 60 | _pkg_min_version=m4_default([$1], [0.9.0]) |
ohair@425 | 61 | AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) |
ohair@425 | 62 | if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then |
ohair@425 | 63 | AC_MSG_RESULT([yes]) |
ohair@425 | 64 | else |
ohair@425 | 65 | AC_MSG_RESULT([no]) |
ohair@425 | 66 | PKG_CONFIG="" |
ohair@425 | 67 | fi |
ohair@425 | 68 | |
ohair@425 | 69 | fi[]dnl |
ohair@425 | 70 | ])# PKG_PROG_PKG_CONFIG |
ohair@425 | 71 | |
ohair@425 | 72 | # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) |
ohair@425 | 73 | # |
ohair@425 | 74 | # Check to see whether a particular set of modules exists. Similar |
ohair@425 | 75 | # to PKG_CHECK_MODULES(), but does not set variables or print errors. |
ohair@425 | 76 | # |
ohair@425 | 77 | # |
ohair@425 | 78 | # Similar to PKG_CHECK_MODULES, make sure that the first instance of |
ohair@425 | 79 | # this or PKG_CHECK_MODULES is called, or make sure to call |
ohair@425 | 80 | # PKG_CHECK_EXISTS manually |
ohair@425 | 81 | # -------------------------------------------------------------- |
ohair@425 | 82 | AC_DEFUN([PKG_CHECK_EXISTS], |
ohair@425 | 83 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl |
ohair@425 | 84 | if test -n "$PKG_CONFIG" && \ |
ohair@425 | 85 | AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then |
ohair@425 | 86 | m4_ifval([$2], [$2], [:]) |
ohair@425 | 87 | m4_ifvaln([$3], [else |
ohair@425 | 88 | $3])dnl |
ohair@425 | 89 | fi]) |
ohair@425 | 90 | |
ohair@425 | 91 | |
ohair@425 | 92 | # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) |
ohair@425 | 93 | # --------------------------------------------- |
ohair@425 | 94 | m4_define([_PKG_CONFIG], |
ohair@425 | 95 | [if test -n "$$1"; then |
ohair@425 | 96 | pkg_cv_[]$1="$$1" |
ohair@425 | 97 | elif test -n "$PKG_CONFIG"; then |
ohair@425 | 98 | PKG_CHECK_EXISTS([$3], |
ohair@425 | 99 | [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], |
ohair@425 | 100 | [pkg_failed=yes]) |
ohair@425 | 101 | else |
ohair@425 | 102 | pkg_failed=untried |
ohair@425 | 103 | fi[]dnl |
ohair@425 | 104 | ])# _PKG_CONFIG |
ohair@425 | 105 | |
ohair@425 | 106 | # _PKG_SHORT_ERRORS_SUPPORTED |
ohair@425 | 107 | # ----------------------------- |
ohair@425 | 108 | AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], |
ohair@425 | 109 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) |
ohair@425 | 110 | if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then |
ohair@425 | 111 | _pkg_short_errors_supported=yes |
ohair@425 | 112 | else |
ohair@425 | 113 | _pkg_short_errors_supported=no |
ohair@425 | 114 | fi[]dnl |
ohair@425 | 115 | ])# _PKG_SHORT_ERRORS_SUPPORTED |
ohair@425 | 116 | |
ohair@425 | 117 | |
ohair@425 | 118 | # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], |
ohair@425 | 119 | # [ACTION-IF-NOT-FOUND]) |
ohair@425 | 120 | # |
ohair@425 | 121 | # |
ohair@425 | 122 | # Note that if there is a possibility the first call to |
ohair@425 | 123 | # PKG_CHECK_MODULES might not happen, you should be sure to include an |
ohair@425 | 124 | # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac |
ohair@425 | 125 | # |
ohair@425 | 126 | # |
ohair@425 | 127 | # -------------------------------------------------------------- |
ohair@425 | 128 | AC_DEFUN([PKG_CHECK_MODULES], |
ohair@425 | 129 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl |
ohair@425 | 130 | AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl |
ohair@425 | 131 | AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl |
ohair@425 | 132 | |
ohair@425 | 133 | pkg_failed=no |
ohair@425 | 134 | AC_MSG_CHECKING([for $1]) |
ohair@425 | 135 | |
ohair@425 | 136 | _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) |
ohair@425 | 137 | _PKG_CONFIG([$1][_LIBS], [libs], [$2]) |
ohair@425 | 138 | |
ohair@425 | 139 | m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS |
ohair@425 | 140 | and $1[]_LIBS to avoid the need to call pkg-config. |
ohair@425 | 141 | See the pkg-config man page for more details.]) |
ohair@425 | 142 | |
ohair@425 | 143 | if test $pkg_failed = yes; then |
ohair@425 | 144 | _PKG_SHORT_ERRORS_SUPPORTED |
ohair@425 | 145 | if test $_pkg_short_errors_supported = yes; then |
ohair@425 | 146 | $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1` |
ohair@425 | 147 | else |
ohair@425 | 148 | $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1` |
ohair@425 | 149 | fi |
ohair@425 | 150 | # Put the nasty error message in config.log where it belongs |
ohair@425 | 151 | echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD |
ohair@425 | 152 | |
ohair@425 | 153 | ifelse([$4], , [AC_MSG_ERROR(dnl |
ohair@425 | 154 | [Package requirements ($2) were not met: |
ohair@425 | 155 | |
ohair@425 | 156 | $$1_PKG_ERRORS |
ohair@425 | 157 | |
ohair@425 | 158 | Consider adjusting the PKG_CONFIG_PATH environment variable if you |
ohair@425 | 159 | installed software in a non-standard prefix. |
ohair@425 | 160 | |
ohair@425 | 161 | _PKG_TEXT |
ohair@425 | 162 | ])], |
ohair@425 | 163 | [AC_MSG_RESULT([no]) |
ohair@425 | 164 | $4]) |
ohair@425 | 165 | elif test $pkg_failed = untried; then |
ohair@425 | 166 | ifelse([$4], , [AC_MSG_FAILURE(dnl |
ohair@425 | 167 | [The pkg-config script could not be found or is too old. Make sure it |
ohair@425 | 168 | is in your PATH or set the PKG_CONFIG environment variable to the full |
ohair@425 | 169 | path to pkg-config. |
ohair@425 | 170 | |
ohair@425 | 171 | _PKG_TEXT |
ohair@425 | 172 | |
ohair@425 | 173 | To get pkg-config, see <http://pkg-config.freedesktop.org/>.])], |
ohair@425 | 174 | [$4]) |
ohair@425 | 175 | else |
ohair@425 | 176 | $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS |
ohair@425 | 177 | $1[]_LIBS=$pkg_cv_[]$1[]_LIBS |
ohair@425 | 178 | AC_MSG_RESULT([yes]) |
ohair@425 | 179 | ifelse([$3], , :, [$3]) |
ohair@425 | 180 | fi[]dnl |
ohair@425 | 181 | ])# PKG_CHECK_MODULES |