summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2014-09-04 16:43:12 +0200
committerCedric BAIL <cedric@osg.samsung.com>2014-09-04 17:33:05 +0200
commit4664b183e3babe46917f48870069cb5958df2f76 (patch)
tree173aa412027e5633b52f874db948bb61ecc3a462 /m4
parentad9aa4a41697c9ea1ef394b5315f983a74bee34f (diff)
autotools: add m4 macro to check for options
This simplify autotools in elementary by recycling the same m4 and also compilation flags. Less code to read and maintain.
Diffstat (limited to 'm4')
-rw-r--r--m4/elm_check_option.m4118
1 files changed, 118 insertions, 0 deletions
diff --git a/m4/elm_check_option.m4 b/m4/elm_check_option.m4
new file mode 100644
index 000000000..abad0f167
--- /dev/null
+++ b/m4/elm_check_option.m4
@@ -0,0 +1,118 @@
1
2dnl use: ELM_CHECK_OPTION_DEP(option, pkgver)
3AC_DEFUN([ELM_CHECK_OPTION_DEP],
4[dnl
5
6m4_pushdef([UP], m4_translit([$1], [-a-z], [_A-Z]))dnl
7m4_pushdef([DOWN], m4_translit([$1], [-A-Z], [_a-z]))dnl
8
9ELM_[]UP[]_DEF="#undef"
10have_elementary_[]DOWN="no"
11
12AC_ARG_ENABLE(DOWN,
13 [AS_HELP_STRING([--disable-]DOWN, [disable ]DOWN[ support. @<:@default=detect@:>@])],
14 [want_option=$enableval],
15 [want_option="auto"])
16
17AC_MSG_CHECKING([whether to enable $1 option])
18AC_MSG_RESULT([${want_option}])
19
20if test "x${want_option}" != "xno"; then
21 PKG_CHECK_EXISTS(DOWN[ >= $2],
22 [
23 AC_DEFINE([HAVE_ELEMENTARY_]UP, [1], [$1 support for Elementary])
24 have_elementary_[]DOWN="yes"
25 ELM_[]UP[]_DEF="#define"
26 requirement_elm="[]DOWN >= $2 ${requirement_elm}"
27 ],
28 [have_elementary_]DOWN[="no"]
29 )
30fi
31
32AC_MSG_CHECKING([whether to build $1 option])
33AC_MSG_RESULT([${have_elementary_[]DOWN}])
34
35if test "x${want_elementary_[]DOWN}" = "xyes" && test "x${have_elementary_[]DOWN}" = "xno"; then
36 AC_MSG_ERROR([$1 support requested, but $1 was not found by pkg-config.])
37fi
38
39AC_SUBST([ELM_]UP[_DEF])
40
41m4_popdef([UP])dnl
42m4_popdef([DOWN])dnl
43])
44
45dnl use: ELM_CHECK_OPTION_DEP_EWK2()
46AC_DEFUN([ELM_CHECK_OPTION_DEP_EWK2],
47[dnl
48
49ELM_WEB2_DEF="#undef"
50elementary_web="no"
51
52AC_ARG_WITH([elementary-web-backend],
53 [AS_HELP_STRING(
54 [--with-elementary-web-backend=@<:@ewebkit2/detect/none@:>@],
55 [Select the WebKit backend for Elementary to support web @<:@default=detect@:>@])],
56 [elementary_web_backend=${withval}],
57 [elementary_web_backend="detect"])
58
59case "${elementary_web_backend}" in
60 ewebkit2|detect|none)
61 ;;
62 *)
63 AC_MSG_ERROR([Invalid web backend: must be ewebkit2, detect or none])
64 ;;
65esac
66
67if test "x${elementary_web_backend}" = "xdetect"; then
68 want_elementary_web="ewebkit2"
69else
70 want_elementary_web=${elementary_web_backend}
71fi
72
73AC_MSG_CHECKING([which web option to use])
74AC_MSG_RESULT([${want_elementary_web}])
75
76if test "x${want_elementary_web}" != "xnone"; then
77 PKG_CHECK_EXISTS([$want_elementary_web],
78 [
79 AC_DEFINE([HAVE_ELEMENTARY_WEB], [1], [Web support for Elementary])
80 webkit_datadir=$(${PKG_CONFIG} ${want_elementary_web} --variable=datadir)
81 AC_DEFINE_UNQUOTED([WEBKIT_DATADIR],
82 [${webkit_datadir}],
83 ["WebKit's data dir"])
84 ELM_WEB2_DEF="#define"
85 elementary_web=${want_elementary_web}
86 requirement_elm="${want_elementary_web} ${requirement_elm}"
87 ],
88 [elementary_web="no"]
89 )
90fi
91
92AC_MSG_CHECKING([whether to build web option])
93AC_MSG_RESULT([${elementary_web}])
94
95if test "x${elementary_web_backend}" = "xewebkit2" && test "x${elementary_web}" = "xnone"; then
96 AC_MSG_ERROR([Web support requested, but no ${elementary_web_backend} found by pkg-config.])
97fi
98
99AC_SUBST([ELM_WEB2_DEF])
100])
101
102
103dnl use: ELM_CHECK_OPTION(option, pkgver)
104AC_DEFUN([ELM_CHECK_OPTION],
105[dnl
106
107m4_pushdef([UP], m4_translit([$1], [-a-z], [_A-Z]))dnl
108m4_pushdef([DOWN], m4_translit([$1], [-A-Z], [_a-z]))dnl
109
110if test "x$1" = "xeweb" ; then
111 ELM_CHECK_OPTION_DEP_EWK2
112else
113 ELM_CHECK_OPTION_DEP($1, $2)
114fi
115
116m4_popdef([UP])dnl
117m4_popdef([DOWN])dnl
118])