summaryrefslogtreecommitdiff
path: root/m4/ac-plugins.m4
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2008-12-08 02:04:20 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2008-12-08 02:04:20 +0000
commit926522f7d6d4c6238b5c316ef9efc89967a370a9 (patch)
tree32faff6aa612e9d4f3138ba41efab920dc2d17a1 /m4/ac-plugins.m4
parentebcb9f85a745a4ccd0cf441601da6e2900128b64 (diff)
missing file!
SVN revision: 38010
Diffstat (limited to 'm4/ac-plugins.m4')
-rw-r--r--m4/ac-plugins.m4169
1 files changed, 169 insertions, 0 deletions
diff --git a/m4/ac-plugins.m4 b/m4/ac-plugins.m4
new file mode 100644
index 000000000..8ff745bcd
--- /dev/null
+++ b/m4/ac-plugins.m4
@@ -0,0 +1,169 @@
1dnl _XTERM_COLORS
2define([_XTERM_COLORS],
3[
4 # Check for XTerm and define some colors
5 if test "x$TERM" = "xxterm" -o "x$TERM" = "xscreen"; then
6 COLOR_PREF="\0033\0133"
7 COLOR_H="${COLOR_PREF}1m"
8 COLOR_HGREEN="${COLOR_PREF}1;32m"
9 COLOR_HRED="${COLOR_PREF}1;31m"
10 COLOR_GREEN="${COLOR_PREF}32m"
11 COLOR_RED="${COLOR_PREF}31m"
12 COLOR_YELLOW="${COLOR_PREF}1;33m"
13 COLOR_END="${COLOR_PREF}0m"
14 else
15 COLOR_H=""
16 COLOR_HGREEN=""
17 COLOR_HRED=""
18 COLOR_GREEN=""
19 COLOR_RED=""
20 COLOR_YELLOW=""
21 COLOR_END=""
22 fi
23])
24
25dnl AC_E_CHECK_PKG(name, lib [>= version], [action-if, [action-not]])
26dnl improved version of PKG_CHECK_MODULES, it does the same checking
27dnl and defines HAVE_[name]=yes/no and also exports
28dnl [name]_CFLAGS and [name]_LIBS.
29dnl
30dnl if action-not isn't provided, AC_MSG_ERROR will be used.
31dnl
32dnl Checks:
33dnl lib >= version
34dnl
35dnl Provides:
36dnl - HAVE_[name]=yes|no
37dnl - [name]_CFLAGS: if HAVE_[name]=yes
38dnl - [name]_LIBS: if HAVE_[name]=yes
39dnl - [name]_VERSION: if HAVE_[name]=yes
40dnl
41AC_DEFUN([AC_E_CHECK_PKG],
42[
43# ----------------------------------------------------------------------
44# BEGIN: Check library with pkg-config: $1 (pkg-config=$2)
45#
46
47 PKG_CHECK_MODULES([$1], [$2],
48 [
49 HAVE_[$1]=yes
50 [pkg_name]=$(echo "[$2]" | cut -d\ -f1)
51 [$1]_VERSION=$($PKG_CONFIG --modversion $pkg_name)
52 AC_SUBST([$1]_VERSION)
53 AC_SUBST([$1]_CFLAGS)
54 AC_SUBST([$1]_LIBS)
55 ifelse([$3], , :, [$3])
56 ],
57 [
58 HAVE_[$1]=no
59 ifelse([$4], , AC_MSG_ERROR(you need [$2] development installed!), AC_MSG_RESULT(no); [$4])
60 ])
61 AM_CONDITIONAL(HAVE_[$1], test x$HAVE_[$1] = xyes)
62 AC_SUBST(HAVE_[$1])
63 if test x$HAVE_[$1] = xyes; then
64 AC_DEFINE_UNQUOTED(HAVE_[$1], 1, Package [$1] ($2) found.)
65 fi
66
67#
68# END: Check library with pkg-config: $1 (pkg-config=$2)
69# ----------------------------------------------------------------------
70])
71
72dnl AC_E_OPTIONAL_MODULE(name, [initial-status, [check-if-enabled]])
73dnl Defines configure argument --<enable|disable>-[name] to enable an
74dnl optional module called 'name'.
75dnl
76dnl If initial-status is true, then it's enabled by default and option
77dnl will be called --disable-[name], otherwise it's disabled and option
78dnl is --enable-[name].
79dnl
80dnl If module is enabled, then check-if-enabled will be executed. This
81dnl may change the contents of shell variable NAME (uppercase version of
82dnl name, with underscores instead of dashed) to something different than
83dnl "true" to disable module.
84dnl
85dnl Parameters:
86dnl - name: module name to use. It will be converted to have dashes (-)
87dnl instead of underscores, and will be in lowercase.
88dnl - initial-status: true or false, states if module is enabled or
89dnl disabled by default.
90dnl - check-if-enabled: macro to be expanded inside check for enabled
91dnl module.
92dnl
93dnl Provides:
94dnl - USE_MODULE_[name]=true|false [make, shell]
95dnl - USE_MODULE_[name]=1 if enabled [config.h]
96dnl
97AC_DEFUN([AC_E_OPTIONAL_MODULE],
98[
99# ----------------------------------------------------------------------
100# BEGIN: Check for optional module: $1 (default: $2)
101#
102 m4_pushdef([MODNAME], [m4_bpatsubst(m4_toupper([$1]), -, _)])dnl
103 m4_pushdef([modname_opt], [m4_bpatsubst(m4_tolower([$1]), _, -)])
104 m4_pushdef([INITVAL], [m4_default([$2], [false])])dnl
105 m4_pushdef([ENABLE_HELP], AS_HELP_STRING([--enable-modname_opt],
106 [enable optional module modname_opt. Default is disabled.])
107 )dnl
108 m4_pushdef([DISABLE_HELP], AS_HELP_STRING([--disable-modname_opt],
109 [disable optional module modname_opt. Default is enabled.])
110 )dnl
111 m4_pushdef([HELP_STR], m4_if(INITVAL, [true], [DISABLE_HELP], [ENABLE_HELP]))dnl
112 m4_pushdef([NOT_INITVAL], m4_if(INITVAL, [true], [false], [true]))dnl
113
114 USING_MODULES=1
115
116 MODNAME=INITVAL
117 AC_ARG_ENABLE(modname_opt, HELP_STR, [MODNAME=${enableval:-NOT_INITVAL}])
118 if test x[$]MODNAME = xyes || test x[$]MODNAME = x1; then
119 MODNAME=true
120 fi
121 if test x[$]MODNAME = xno || test x[$]MODNAME = x0; then
122 MODNAME=false
123 fi
124
125 USE_MODULE_[]MODNAME=[$]MODNAME
126
127 _XTERM_COLORS
128
129 # Check list for optional module $1
130 if test x[$]MODNAME = xtrue; then
131 ifelse([$3], , , [
132echo
133echo "checking optional module modname_opt:"
134# BEGIN: User checks
135$3
136# END: User checks
137if test x[$]MODNAME = xfalse; then
138 echo -e "optional module modname_opt ${COLOR_HRED}failed${COLOR_END} checks."
139else
140 echo -e "optional module modname_opt passed checks."
141fi
142echo
143])
144
145 if test x[$]MODNAME = xfalse; then
146 echo -e "${COLOR_YELLOW}Warning:${COLOR_END} optional module ${COLOR_H}modname_opt${COLOR_END} disabled by extra checks."
147 fi
148 fi
149
150 # Check if user checks succeeded
151 if test x[$]MODNAME = xtrue; then
152 [OPTIONAL_MODULES]="$[OPTIONAL_MODULES] modname_opt"
153 AC_DEFINE_UNQUOTED(USE_MODULE_[]MODNAME, 1, Use module modname_opt)
154 else
155 [UNUSED_OPTIONAL_MODULES]="$[UNUSED_OPTIONAL_MODULES] modname_opt"
156 fi
157
158 AM_CONDITIONAL(USE_MODULE_[]MODNAME, test x[$]MODNAME = xtrue)
159 AC_SUBST(USE_MODULE_[]MODNAME)
160
161 m4_popdef([HELP_STR])dnl
162 m4_popdef([DISABLE_HELP])dnl
163 m4_popdef([ENABLE_HELP])dnl
164 m4_popdef([INITVAL])dnl
165 m4_popdef([MODNAME])
166#
167# END: Check for optional module: $1 ($2)
168# ----------------------------------------------------------------------
169])