sdl

FORK: Simple Directmedia Layer
git clone https://git.neptards.moe/neptards/sdl.git
Log | Files | Refs

pkg_config.m4 (4290B)


      1 # PKG_PROG_PKG_CONFIG([MIN-VERSION])
      2 # ----------------------------------
      3 AC_DEFUN([PKG_PROG_PKG_CONFIG],
      4 [m4_pattern_forbid([^_?PKG_[A-Z_]+$])
      5 m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
      6 AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
      7 AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
      8 AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
      9 
     10 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
     11 	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
     12 fi
     13 if test -n "$PKG_CONFIG"; then
     14 	_pkg_min_version=m4_default([$1], [0.9.0])
     15 	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
     16 	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
     17 		AC_MSG_RESULT([yes])
     18 	else
     19 		AC_MSG_RESULT([no])
     20 		PKG_CONFIG=""
     21 	fi
     22 fi[]dnl
     23 ])# PKG_PROG_PKG_CONFIG
     24 
     25 # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
     26 #
     27 # Check to see whether a particular set of modules exists.  Similar
     28 # to PKG_CHECK_MODULES(), but does not set variables or print errors.
     29 #
     30 # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
     31 # only at the first occurence in configure.ac, so if the first place
     32 # it's called might be skipped (such as if it is within an "if", you
     33 # have to call PKG_CHECK_EXISTS manually
     34 # --------------------------------------------------------------
     35 AC_DEFUN([PKG_CHECK_EXISTS],
     36 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
     37 if test -n "$PKG_CONFIG" && \
     38     AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
     39   m4_default([$2], [:])
     40 m4_ifvaln([$3], [else
     41   $3])dnl
     42 fi])
     43 
     44 # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
     45 # ---------------------------------------------
     46 m4_define([_PKG_CONFIG],
     47 [if test -n "$$1"; then
     48     pkg_cv_[]$1="$$1"
     49  elif test -n "$PKG_CONFIG"; then
     50     PKG_CHECK_EXISTS([$3],
     51                      [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
     52 		     [pkg_failed=yes])
     53  else
     54     pkg_failed=untried
     55 fi[]dnl
     56 ])# _PKG_CONFIG
     57 
     58 # _PKG_SHORT_ERRORS_SUPPORTED
     59 # -----------------------------
     60 AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
     61 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])
     62 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
     63         _pkg_short_errors_supported=yes
     64 else
     65         _pkg_short_errors_supported=no
     66 fi[]dnl
     67 ])# _PKG_SHORT_ERRORS_SUPPORTED
     68 
     69 
     70 # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
     71 # [ACTION-IF-NOT-FOUND])
     72 #
     73 #
     74 # Note that if there is a possibility the first call to
     75 # PKG_CHECK_MODULES might not happen, you should be sure to include an
     76 # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
     77 #
     78 #
     79 # --------------------------------------------------------------
     80 AC_DEFUN([PKG_CHECK_MODULES],
     81 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
     82 AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
     83 AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
     84 
     85 pkg_failed=no
     86 AC_MSG_CHECKING([for $1])
     87 
     88 _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
     89 _PKG_CONFIG([$1][_LIBS], [libs], [$2])
     90 
     91 m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
     92 and $1[]_LIBS to avoid the need to call pkg-config.
     93 See the pkg-config man page for more details.])
     94 
     95 if test $pkg_failed = yes; then
     96    	AC_MSG_RESULT([no])
     97         _PKG_SHORT_ERRORS_SUPPORTED
     98         if test $_pkg_short_errors_supported = yes; then
     99 	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
    100         else 
    101 	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
    102         fi
    103 	# Put the nasty error message in config.log where it belongs
    104 	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
    105 
    106 	m4_default([$4], [AC_MSG_ERROR(
    107 [Package requirements ($2) were not met:
    108 
    109 $$1_PKG_ERRORS
    110 
    111 Consider adjusting the PKG_CONFIG_PATH environment variable if you
    112 installed software in a non-standard prefix.
    113 
    114 _PKG_TEXT])dnl
    115         ])
    116 elif test $pkg_failed = untried; then
    117      	AC_MSG_RESULT([no])
    118 	m4_default([$4], [AC_MSG_FAILURE(
    119 [The pkg-config script could not be found or is too old.  Make sure it
    120 is in your PATH or set the PKG_CONFIG environment variable to the full
    121 path to pkg-config.
    122 
    123 _PKG_TEXT
    124 
    125 To get pkg-config, see <http://pkg-config.freedesktop.org/>.])dnl
    126         ])
    127 else
    128 	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
    129 	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
    130         AC_MSG_RESULT([yes])
    131 	$3
    132 fi[]dnl
    133 ])# PKG_CHECK_MODULES