comparison acinclude.m4 @ 2540:1fd4d8e5aad2

Various new helper macros added for simplifying and sanitizing configure.ac.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 21 Apr 2008 16:39:18 +0300
parents 13389e613d67
children dc12b0d4d33e
comparison
equal deleted inserted replaced
2531:f0ade2681644 2540:1fd4d8e5aad2
1 dnl ADD_PKG_REQUIRES([requirement])
2 1
3 AC_DEFUN([ADD_PC_REQUIRES], 2 dnl ** ADD_PKG_REQUIRES([requirement])
4 [ 3 AC_DEFUN([ADD_PC_REQUIRES], [
5 test -z "$PC_REQUIRES" && PC_REQUIRES="$1" || PC_REQUIRES="$PC_REQUIRES, $1" 4 if test "x$PC_REQUIRES" = "x"; then
6 AC_SUBST(PC_REQUIRES) 5 PC_REQUIRES="$1"
7 ] 6 else
8 ) 7 PC_REQUIRES="$PC_REQUIRES, $1"
8 fi
9 AC_SUBST([PC_REQUIRES])
10 ])
9 11
12
13 dnl ** Like PKG_CHECK_MODULES, but provides an informative error message.
14 dnl ** AUD_CHECK_MODULE([define name], [module], [version required],
15 dnl ** [informational name], [additional error message])
16 dnl **
17 dnl ** AUD_CHECK_MODULE([GLIB], [gtk+-2.0], [>= 2.10.0], [Gtk+2], [See http://www.gtk.org/])
18 AC_DEFUN([AUD_CHECK_MODULE], [
19 PKG_CHECK_MODULES([$1], [$2 $3], [
20 ADD_PC_REQUIRES([$2 $3])
21 ],[
22 PKG_CHECK_EXISTS([$2], [
23 cv_pkg_version=`$PKG_CONFIG --modversion "$2" 2>/dev/null`
24 AC_MSG_ERROR([[
25 $4 version $cv_pkg_version was found, but $2 $3 is required.
26 $5]])
27 ],[
28 AC_MSG_ERROR([[
29 Cannot find $4! If you are using binary packages based system, check that you
30 have the corresponding -dev/devel packages installed.
31 $5]])
32 ])
33 ])
34 ])
35
36
37 dnl ** Simplifying wrapper
38 AC_DEFUN([AUD_CONDITIONAL],
39 dnl [AM_CONDITIONAL([$1],[test "x${$2}" = m4_ifval([$3], ["x$3"],["xyes"])])
40 [if test "x${$2}" = m4_ifval([$3], ["x$3"],["xyes"]) ; then
41 $1="yes"
42 else
43 $1="no"
44 fi
45 AC_SUBST([$1])dnl
46 ])
47
48
49 dnl ** Simple wrapper for AC_ARG_ENABLE
50 dnl ** AUD_ARG_ENABLE([name], [default value], [help string], [if enabled], [if disabled])
51 AC_DEFUN([AUD_ARG_ENABLE], [dnl
52 define([Name], [translit([$1], [./-], [___])])
53 AC_ARG_ENABLE([$1], [$3],, [enable_[]Name=$2])
54 if test "x${enable_[]Name}" = "xyes"; then
55 m4_ifvaln([$4], [$4], [:])dnl
56 m4_ifvaln([$5], [else $5])dnl
57 fi
58 ])
59
60
61 AC_DEFUN([AUD_ARG_SIMPLE], [dnl
62 define([Name], [translit([$1], [./-], [___])])
63 AC_ARG_ENABLE([$1], [$3],, [enable_[]Name=$2])
64 if test "x${enable_[]Name}" = "xyes"; then
65 AC_DEFINE([$4], [$5], [$6])
66 fi
67 AUD_CONDITIONAL([$4], [enable_$1])
68 AC_SUBST([$4])
69 ])
70
71
72 dnl ** Wrapper for cached compilation check
73 dnl ** AUD_TRY_COMPILE([message], [result variable], [includes], [body], [if ok], [if not ok])
74 AC_DEFUN([AUD_TRY_COMPILE], [dnl
75 AC_CACHE_CHECK([$1], [$2],
76 [AC_TRY_COMPILE([$3], [$4], [$2="yes"], [$2="no"])])
77 if test "x${$2}" = "xyes"; then
78 m4_ifvaln([$5], [$5], [:])dnl
79 m4_ifvaln([$6], [else $6])dnl
80 fi
81 ])
82
83
84 dnl ** Check for GNU make
85 AC_DEFUN([AUD_CHECK_GNU_MAKE],[
86 AC_CACHE_CHECK([for GNU make],aud_gnu_make_command,[
87 aud_gnu_make_command=""
88 for a in "$MAKE" make gmake gnumake; do
89 test "x$a" = "x" && continue
90 if ( sh -c "$a --version" 2>/dev/null | grep "GNU Make" >/dev/null ) ; then
91 aud_gnu_make_command="$a"
92 break
93 fi
94 done
95 ])
96 if test "x$aud_gnu_make_command" != "x" ; then
97 MAKE="$aud_gnu_make_command"
98 else
99 AC_MSG_ERROR([** GNU make not found. If it is installed, try setting MAKE environment variable. **])
100 fi
101 AC_SUBST([MAKE])
102 ])
103
104
105 dnl *** Define plugin directories
106 AC_DEFUN([AUD_DEFINE_PLUGIN_DIR],[
107 define([Name], [translit([$1], [a-z], [A-Z])])dnl
108 if test "x$enable_one_plugin_dir" = "xyes"; then
109 ifdef([aud_plugin_dirs_defined],[],
110 [ pluginsubs="\\\"Plugins\\\""
111 ])dnl
112 Name[]_PLUGIN_DIR="Plugins"
113 else
114 ifdef([aud_plugin_dirs_defined],
115 [pluginsubs="$pluginsubs,\\\"$1\\\""],
116 [pluginsubs="\\\"$1\\\""])
117 Name[]_PLUGIN_DIR="$1"
118 fi
119 AC_SUBST(Name[]_PLUGIN_DIR)dnl
120 define([aud_plugin_dirs_defined],[1])dnl
121 ])dnl