common/autoconf/build-aux/pkg.m4

Wed, 27 Apr 2016 01:39:08 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:39:08 +0800
changeset 0
75a576e87639
child 1133
50aaf272884f
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/
changeset: 1170:d117f01bfb4f
tag: jdk8u25-b17

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

mercurial