aboutsummaryrefslogtreecommitdiffstats
path: root/dists/autogen/m4/pkg_config_utils.m4
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-09-09 12:50:50 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-09-09 12:50:50 +0000
commit5e1dd23ad5ed2fe8b0a618a9f9e10eac1694fe2b (patch)
treefb59afccbff16075ac39b00fe5d81340a2612741 /dists/autogen/m4/pkg_config_utils.m4
parentf3e8cb5a09ada2c74292047f2fad4fd47a01b99a (diff)
downloadusdx-5e1dd23ad5ed2fe8b0a618a9f9e10eac1694fe2b.tar.gz
usdx-5e1dd23ad5ed2fe8b0a618a9f9e10eac1694fe2b.tar.xz
usdx-5e1dd23ad5ed2fe8b0a618a9f9e10eac1694fe2b.zip
- better conformance of Makefiles to GNU coding standards
- bindir/prefix, etc. can be changed anytime make is performed and is not hardcoded on configure time anymore - paths are written to the intermediate paths.inc file (instead of config-xyz.inc) - binary is not stripped anymore - fpc.m4 rewrite - additional options like heaptrace, range-checks - noexecstack workaround - some more changes - configure.ac helper functions moved to ax_ectract_version.m4 and pkg_config_utils.m4 - some icons moved from artwork to icons git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1351 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'dists/autogen/m4/pkg_config_utils.m4')
-rw-r--r--dists/autogen/m4/pkg_config_utils.m4190
1 files changed, 190 insertions, 0 deletions
diff --git a/dists/autogen/m4/pkg_config_utils.m4 b/dists/autogen/m4/pkg_config_utils.m4
new file mode 100644
index 00000000..903e0fc9
--- /dev/null
+++ b/dists/autogen/m4/pkg_config_utils.m4
@@ -0,0 +1,190 @@
+# This file is part of UltraStar Deluxe
+# Created by the UltraStar Deluxe Team
+
+
+# OVERVIEW
+#
+# PKG_VALUE(VARIABLE_PREFIX, POSTFIX, COMMAND, MODULE, HELP-STRING)
+# PKG_VERSION(VARIABLE_PREFIX, MODULE)
+# PKG_HAVE(VARIABLE_PREFIX, MODULE, [REQUIRED])
+# AX_TRIM(STRING)
+
+# SYNOPSIS
+#
+# PKG_VALUE(VARIABLE_PREFIX, POSTFIX, COMMAND, MODULE, HELP-STRING)
+#
+# DESCRIPTION
+#
+# Calls pkg-config with a given command and stores the result.
+# If the variable was already defined by the user or the package
+# is not present on the system ([$VARIABLE_PREFIX]_HAVE <> yes)
+# pkg-config will not be executed and the old value remains.
+# In addition the variable will be shown on "./configure --help"
+# described by a given help-string.
+#
+# Parameters:
+# - VARIABLE_PREFIX: the prefix for the variables storing
+# information about the package.
+# - POSTFIX: [$VARIABLE_PREFIX]_[$POSTFIX] will contain the value
+# - COMMAND: a pkg-config command, e.g. "variable=prefix"
+# - MODULE: the package pkg-config will retrieve info from
+# - HELP-STRING: description of the variable
+#
+# Sets:
+# [$VARIABLE_PREFIX]_[$POSTFIX] # value (AC_SUBST)
+
+AC_DEFUN([PKG_VALUE],
+[
+ AC_ARG_VAR([$1]_[$2], [$5, overriding pkg-config])
+ # check if variable was defined by the user
+ if test -z "$[$1]_[$2]"; then
+ # if not, get it from pkg-config
+ if test x$[$1][_HAVE] = xyes; then
+ PKG_CHECK_EXISTS([$4],
+ [[$1]_[$2]=`$PKG_CONFIG --[$3] --silence-errors "$4"`],
+ [# print error message and quit
+ err_msg=`$PKG_CONFIG --errors-to-stdout --print-errors "$4"`
+ AC_MSG_ERROR(
+[
+
+$err_msg
+
+If --with-[$1]=nocheck is defined the environment variable
+[$1]_[$2]
+must be set to avoid the need to call pkg-config.
+
+See the pkg-config man page for more details.
+])
+
+ ])
+ fi
+ fi
+ AC_SUBST([$1]_[$2])
+])
+
+# SYNOPSIS
+#
+# PKG_VERSION(VARIABLE_PREFIX, MODULE)
+#
+# DESCRIPTION
+#
+# Retrieves the version of a package
+#
+# Parameters:
+# - VARIABLE_PREFIX: the prefix for the variables storing
+# information about the package.
+# - MODULE: package name according to pkg-config
+#
+# Sets:
+# [$VARIABLE_PREFIX]_VERSION # full version string
+# # (format: "major.minor.release")
+#
+# [$VARIABLE_PREFIX]_VERSION_MAJOR # major version number
+# [$VARIABLE_PREFIX]_VERSION_MINOR # minor version number
+# [$VARIABLE_PREFIX]_VERSION_RELEASE # release version number
+#
+# [$VARIABLE_PREFIX]_VERSION_INT # integer representation:
+# # MMMmmmrrr (M:major,m:minor,r:release)
+
+AC_DEFUN([PKG_VERSION],
+[
+ if test x$[$1][_HAVE] = xyes; then
+ AC_MSG_CHECKING([version of $1])
+ PKG_VALUE([$1], [VERSION], [modversion], [$2], [version of $1])
+ AC_MSG_RESULT(@<:@$[$1][_VERSION]@:>@)
+ else
+ [$1][_VERSION]="0.0.0"
+ fi
+ AX_EXTRACT_VERSION([$1], $[$1][_VERSION])
+])
+
+
+# SYNOPSIS
+#
+# AX_TRIM(STRING)
+#
+# DESCRIPTION
+#
+# Removes surrounding whitespace
+
+AC_DEFUN([AX_TRIM],
+[
+ echo "[$1]" | $SED 's/^[[ \t]]*//' | $SED 's/[[ \t]]*$//'
+])
+
+# SYNOPSIS
+#
+# PKG_HAVE(VARIABLE_PREFIX, MODULE, [REQUIRED])
+#
+# DESCRIPTION
+#
+# Checks with pkg-config if a package exists and retrieves
+# information about it.
+#
+# Parameters:
+# - VARIABLE_PREFIX: the prefix for the variables storing information about the package.
+# - MODULE: package name according to pkg-config
+# - REQUIRED: if true, the configure-script is aborted if the package was not found
+#
+# Uses:
+# with_[$VARIABLE_PREFIX]: whether and how the package should be checked for
+# "check": check for the package but do not abort if it does not exist (default)
+# "no": do not check for the package (sets _HAVE to "no" and _VERSION to "0.0.0")
+# "yes": check for the package and abort if it does not exist
+# "nocheck": do not check for the package (sets _HAVE to "yes")
+#
+# Sets:
+# [$VARIABLE_PREFIX]_HAVE # package is available (values: "yes"|"no")
+# [$VARIABLE_PREFIX]_LIBS # linker flags (e.g. -Lmylibdir -lmylib)
+# [$VARIABLE_PREFIX]_LIBDIRS # library dirs (e.g. -Lmylibdir)
+
+AC_DEFUN([PKG_HAVE],
+[
+ have_lib="no"
+ AC_MSG_CHECKING([for $2])
+ if test x"$with_[$1]" = xnocheck; then
+ # do not call pkg-config, use user settings
+ have_lib="yes"
+ elif test x"$with_[$1]" != xno; then
+ # check if package exists
+ PKG_CHECK_EXISTS([$2], [
+ have_lib="yes"
+ [$1][_LIBS]=`$PKG_CONFIG --libs --silence-errors "$2"`
+ [$1][_LIBDIRS]=`$PKG_CONFIG --libs-only-L --silence-errors "$2"`
+ [$1][_LIBDIRS]=`AX_TRIM($[$1][_LIBDIRS])`
+ # add library directories to LIBS (ignore *_LIBS for now)
+ if test -n "$[$1][_LIBDIRS]"; then
+ LIBS="$LIBS $[$1][_LIBDIRS]"
+ fi
+ ])
+ fi
+ if test x$have_lib = xyes; then
+ [$1][_HAVE]="yes"
+ if test -n "$[$1][_LIBDIRS]"; then
+ # show additional lib-dirs
+ AC_MSG_RESULT(yes [(]$[$1][_LIBDIRS][)])
+ else
+ AC_MSG_RESULT(yes)
+ fi
+ else
+ [$1][_HAVE]="no"
+ AC_MSG_RESULT(no)
+
+ # check if package is required
+ if test x$3 = xyes -o x"$with_[$1]" = xyes ; then
+ # print error message and quit
+ err_msg=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
+ AC_MSG_ERROR(
+[
+
+$err_msg
+
+Alternatively, you may set --with-[$1]=nocheck and the environment
+variables [$1]_[[...]] (see configure --help)
+to appropriate values to avoid the need to call pkg-config.
+
+See the pkg-config man page for more details.
+])
+ fi
+ fi
+])