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