Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • m4/pkg.m4

    r8073852 r13a39ae8  
    11# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
     2# serial 1 (pkg-config-0.24)
    23#
    34# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
     
    2627AC_DEFUN([PKG_PROG_PKG_CONFIG],
    2728[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
    28 m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
    29 AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
     29m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
     30m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
     31AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
     32AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
     33AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
     34
    3035if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
    3136        AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
     
    4045                PKG_CONFIG=""
    4146        fi
    42                
    4347fi[]dnl
    4448])# PKG_PROG_PKG_CONFIG
     
    4953# to PKG_CHECK_MODULES(), but does not set variables or print errors.
    5054#
    51 #
    52 # Similar to PKG_CHECK_MODULES, make sure that the first instance of
    53 # this or PKG_CHECK_MODULES is called, or make sure to call
    54 # PKG_CHECK_EXISTS manually
     55# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
     56# only at the first occurence in configure.ac, so if the first place
     57# it's called might be skipped (such as if it is within an "if", you
     58# have to call PKG_CHECK_EXISTS manually
    5559# --------------------------------------------------------------
    5660AC_DEFUN([PKG_CHECK_EXISTS],
     
    5862if test -n "$PKG_CONFIG" && \
    5963    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
    60   m4_ifval([$2], [$2], [:])
     64  m4_default([$2], [:])
    6165m4_ifvaln([$3], [else
    6266  $3])dnl
    6367fi])
    6468
    65 
    6669# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
    6770# ---------------------------------------------
    6871m4_define([_PKG_CONFIG],
    69 [if test -n "$PKG_CONFIG"; then
    70     if test -n "$$1"; then
    71         pkg_cv_[]$1="$$1"
    72     else
    73         PKG_CHECK_EXISTS([$3],
    74                          [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
    75                          [pkg_failed=yes])
    76     fi
    77 else
    78         pkg_failed=untried
     72[if test -n "$$1"; then
     73    pkg_cv_[]$1="$$1"
     74 elif test -n "$PKG_CONFIG"; then
     75    PKG_CHECK_EXISTS([$3],
     76                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
     77                      test "x$?" != "x0" && pkg_failed=yes ],
     78                     [pkg_failed=yes])
     79 else
     80    pkg_failed=untried
    7981fi[]dnl
    8082])# _PKG_CONFIG
     
    118120
    119121if test $pkg_failed = yes; then
     122        AC_MSG_RESULT([no])
    120123        _PKG_SHORT_ERRORS_SUPPORTED
    121124        if test $_pkg_short_errors_supported = yes; then
    122                 $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
     125                $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
    123126        else
    124                 $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
     127                $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
    125128        fi
    126129        # Put the nasty error message in config.log where it belongs
    127130        echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
    128131
    129         ifelse([$4], , [AC_MSG_ERROR(dnl
     132        m4_default([$4], [AC_MSG_ERROR(
    130133[Package requirements ($2) were not met:
    131134
     
    135138installed software in a non-standard prefix.
    136139
    137 _PKG_TEXT
    138 ])],
    139                 [AC_MSG_RESULT([no])
    140                 $4])
     140_PKG_TEXT])[]dnl
     141        ])
    141142elif test $pkg_failed = untried; then
    142         ifelse([$4], , [AC_MSG_FAILURE(dnl
     143        AC_MSG_RESULT([no])
     144        m4_default([$4], [AC_MSG_FAILURE(
    143145[The pkg-config script could not be found or is too old.  Make sure it
    144146is in your PATH or set the PKG_CONFIG environment variable to the full
     
    147149_PKG_TEXT
    148150
    149 To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
    150                 [$4])
     151To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
     152        ])
    151153else
    152154        $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
    153155        $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
    154156        AC_MSG_RESULT([yes])
    155         ifelse([$3], , :, [$3])
     157        $3
    156158fi[]dnl
    157159])# PKG_CHECK_MODULES
     160
     161
     162# PKG_INSTALLDIR(DIRECTORY)
     163# -------------------------
     164# Substitutes the variable pkgconfigdir as the location where a module
     165# should install pkg-config .pc files. By default the directory is
     166# $libdir/pkgconfig, but the default can be changed by passing
     167# DIRECTORY. The user can override through the --with-pkgconfigdir
     168# parameter.
     169AC_DEFUN([PKG_INSTALLDIR],
     170[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
     171m4_pushdef([pkg_description],
     172    [pkg-config installation directory @<:@]pkg_default[@:>@])
     173AC_ARG_WITH([pkgconfigdir],
     174    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
     175    [with_pkgconfigdir=]pkg_default)
     176AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
     177m4_popdef([pkg_default])
     178m4_popdef([pkg_description])
     179]) dnl PKG_INSTALLDIR
     180
     181
     182# PKG_NOARCH_INSTALLDIR(DIRECTORY)
     183# -------------------------
     184# Substitutes the variable noarch_pkgconfigdir as the location where a
     185# module should install arch-independent pkg-config .pc files. By
     186# default the directory is $datadir/pkgconfig, but the default can be
     187# changed by passing DIRECTORY. The user can override through the
     188# --with-noarch-pkgconfigdir parameter.
     189AC_DEFUN([PKG_NOARCH_INSTALLDIR],
     190[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
     191m4_pushdef([pkg_description],
     192    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
     193AC_ARG_WITH([noarch-pkgconfigdir],
     194    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
     195    [with_noarch_pkgconfigdir=]pkg_default)
     196AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
     197m4_popdef([pkg_default])
     198m4_popdef([pkg_description])
     199]) dnl PKG_NOARCH_INSTALLDIR
     200
     201
     202# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
     203# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
     204# -------------------------------------------
     205# Retrieves the value of the pkg-config variable for the given module.
     206AC_DEFUN([PKG_CHECK_VAR],
     207[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
     208AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
     209
     210_PKG_CONFIG([$1], [variable="][$3]["], [$2])
     211AS_VAR_COPY([$1], [pkg_cv_][$1])
     212
     213AS_VAR_IF([$1], [""], [$5], [$4])dnl
     214])# PKG_CHECK_VAR
Note: See TracChangeset for help on using the changeset viewer.