Added fronted for setting user roles.
[accounts-service-plus:accounts-service-plus.git] / configure.ac
1 AC_INIT([AccountsService],[0.6.22])
2 AM_INIT_AUTOMAKE(no-dist-gzip dist-xz tar-ustar foreign)
3
4 GETTEXT_PACKAGE=accounts-service
5 AC_SUBST(GETTEXT_PACKAGE)
6 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",
7                    [the gettext translation domain])
8
9 # Support silent build rules, requires at least automake-1.11. Enable
10 # by either passing --enable-silent-rules to configure or passing V=0
11 # to make
12 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
13
14 AC_USE_SYSTEM_EXTENSIONS
15 AC_PROG_CC
16 PKG_PROG_PKG_CONFIG
17 AM_GLIB_GNU_GETTEXT
18 IT_PROG_INTLTOOL([0.40.0])
19
20 LT_INIT
21 LT_CURRENT=0
22 LT_REVISION=0
23 LT_AGE=0
24 AC_SUBST(LT_CURRENT)
25 AC_SUBST(LT_REVISION)
26 AC_SUBST(LT_AGE)
27
28 PKG_CHECK_MODULES(GLIB, glib-2.0)
29 PKG_CHECK_MODULES(GIO, gio-2.0 gio-unix-2.0)
30 PKG_CHECK_MODULES(POLKIT, polkit-gobject-1)
31
32 AM_MAINTAINER_MODE([enable])
33
34 # client library dependencies
35 LIBACCOUNTSSERVICE_LIBS="$GLIB_LIBS $GIO_LIBS"
36 AC_SUBST(LIBACCOUNTSSERVICE_LIBS)
37 LIBACCOUNTSSERVICE_CFLAGS="$GLIB_CFLAGS $GIO_CFLAGS"
38 AC_SUBST(LIBACCOUNTSSERVICE_CFLAGS)
39
40 GOBJECT_INTROSPECTION_CHECK([0.9.12])
41 LIBACCOUNTSSERVICE_GIR_INCLUDES="GLib-2.0 GObject-2.0"
42 AC_SUBST(LIBACCOUNTSSERVICE_GIR_INCLUDES)
43
44 VAPIGEN_CHECK
45
46 AC_ARG_ENABLE(more-warnings,
47               AS_HELP_STRING([--enable-more-warnings],
48                              [Maximum compiler warnings]),
49               set_more_warnings="$enableval",[
50               if test -d $srcdir/.git; then
51                 set_more_warnings=yes
52               else
53                 set_more_warnings=no
54               fi])
55
56 AC_MSG_CHECKING(for more warnings)
57 if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
58   AC_MSG_RESULT(yes)
59   MAYBE_WARN="\
60    -Wall -Wextra  \
61    -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes \
62    -Wwrite-strings -Wnested-externs -Wpointer-arith \
63    -Wswitch-enum -Wstrict-aliasing=2 -Winit-self -Wunsafe-loop-optimizations \
64    -Wno-missing-field-initializers -Wno-unused-parameter \
65    -Wcast-align -Wsign-compare"
66 elif test "$GCC" = "yes"; then
67   AC_MSG_RESULT(no)
68   MAYBE_WARN="-Wall -Wno-sign-compare -Wno-deprecated-declarations"
69 else
70   AC_MSG_RESULT(no)
71 fi
72
73 # invalidate cached value if MAYBE_WARN has changed
74 if test "x$accountsservice_cv_warn_maybe" != "x$MAYBE_WARN"; then
75   unset accountsservice_cv_warn_cflags
76 fi
77
78 AC_DEFUN([ACCOUNTSSERVICE_CC_TRY_FLAG], [
79   AC_MSG_CHECKING([whether $CC supports $1])
80
81   accountsservice_save_CFLAGS="$CFLAGS"
82   CFLAGS="$CFLAGS $1"
83
84   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
85                     [accountsservice_cc_flag=yes],
86                     [accountsservice_cc_flag=no])
87   CFLAGS="$accountsservice_save_CFLAGS"
88
89   if test "x$accountsservice_cc_flag" = "xyes"; then
90     ifelse([$2], , :, [$2])
91   else
92     ifelse([$3], , :, [$3])
93   fi
94   AC_MSG_RESULT([$accountsservice_cc_flag])
95 ])
96
97 AC_CACHE_CHECK([for supported warning flags], accountsservice_cv_warn_cflags, [
98   echo
99   WARN_CFLAGS=""
100
101   # Some warning options are not supported by all versions of
102   # gcc, so test all desired options against the current
103   # compiler.
104   #
105   # Note that there are some order dependencies
106   # here. Specifically, an option that disables a warning will
107   # have no net effect if a later option then enables that
108   # warnings, (perhaps implicitly). So we put some grouped
109   # options (-Wall and -Wextra) up front and the -Wno options
110   # last.
111
112   for W in $MAYBE_WARN; do
113     ACCOUNTSSERVICE_CC_TRY_FLAG([$W], [WARN_CFLAGS="$WARN_CFLAGS $W"])
114   done
115
116   accountsservice_cv_warn_cflags=$WARN_CFLAGS
117   accountsservice_cv_warn_maybe=$MAYBE_WARN
118
119   AC_MSG_CHECKING([which warning flags were supported])
120 ])
121
122 WARN_CFLAGS="$accountsservice_cv_warn_cflags"
123
124 if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
125   # Only add this when optimizing is enabled (default)
126   AC_MSG_CHECKING([whether optimization is enabled])
127   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if __OPTIMIZE__ == 0
128                                        #error No optimization
129                                        #endif
130                                      ]], [[]])],
131                     [has_optimization=yes],
132                     [has_optimization=no])
133   if test $has_optimization = yes; then
134     WARN_CFLAGS="$WARN_CFLAGS -Wp,-D_FORTIFY_SOURCE=2"
135   fi
136   AC_MSG_RESULT($has_optimization)
137 fi
138
139 AC_SUBST(WARN_CFLAGS)
140
141 AC_CHECK_HEADERS([shadow.h utmpx.h])
142
143 dnl ---------------------------------------------------------------------------
144 dnl - DocBook Documentation
145 dnl ---------------------------------------------------------------------------
146
147 AC_ARG_ENABLE(docbook-docs,
148         [AS_HELP_STRING([--enable-docbook-docs],[build documentation (requires xmlto)])],
149         enable_docbook_docs=$enableval,enable_docbook_docs=no)
150 AC_PATH_PROG(XMLTO, xmlto, no)
151 AC_MSG_CHECKING([whether to build DocBook documentation])
152 if test x$XMLTO = xno ; then
153         have_docbook=no
154 else
155         have_docbook=yes
156 fi
157 if test x$enable_docbook_docs = xauto ; then
158         if test x$have_docbook = xno ; then
159                 enable_docbook_docs=no
160         else
161                 enable_docbook_docs=yes
162         fi
163 fi
164 if test x$enable_docbook_docs = xyes; then
165         if test x$have_docbook = xno; then
166                 AC_MSG_ERROR([Building DocBook docs explicitly required, but DocBook not found])
167         fi
168 fi
169 AM_CONDITIONAL(DOCBOOK_DOCS_ENABLED, test x$enable_docbook_docs = xyes)
170 AC_MSG_RESULT(yes)
171 AC_ARG_VAR([XMLTO],[Define/override the 'xmlto' location.])
172 AC_ARG_VAR([XMLTO_FLAGS],[Define/override 'xmlto' options, like '--skip-validation'.])
173
174 dnl ---------------------------------------------------------------------------
175 dnl Check for xsltproc
176 dnl ---------------------------------------------------------------------------
177 AC_PATH_PROG([XSLTPROC], [xsltproc])
178
179 # systemd
180
181 AC_ARG_ENABLE([systemd],
182               AS_HELP_STRING([--enable-systemd], [Use systemd]),
183               [enable_systemd=$enableval],
184               [enable_systemd=auto])
185
186 if test x$enable_systemd != xno; then
187    PKG_CHECK_MODULES(SYSTEMD, [libsystemd-login >= 43 libsystemd-daemon],
188                                              [have_systemd=yes], [have_systemd=no])
189 else
190    have_systemd=no
191 fi
192
193 AC_MSG_CHECKING([whether to use systemd])
194
195 if test x$enable_systemd = xauto ; then
196         if test x$have_systemd = xno ; then
197                 enable_systemd=no
198         else
199                 enable_systemd=yes
200         fi
201 fi
202
203 AC_MSG_RESULT($enable_systemd)
204
205 if test x$enable_systemd = xyes; then
206         if test x$have_systemd = xno; then
207                 AC_MSG_ERROR([Systemd support explicitly required, but systemd not found])
208         fi
209         AC_DEFINE(HAVE_SYSTEMD, 1, [Define if systemd is used])
210 fi
211 AC_SUBST(SYSTEMD_CFLAGS)
212 AC_SUBST(SYSTEMD_LIBS)
213
214 LIBACCOUNTSSERVICE_LIBS="$LIBACCOUNTSSERVICE_LIBS $SYSTEMD_LIBS"
215 LIBACCOUNTSSERVICE_CFLAGS="$LIBACCOUNTSSERVICE_CFLAGS $SYSTEMD_CFLAGS"
216
217 if test "x$have_systemd" != "xno" ; then
218         AC_DEFINE(WITH_SYSTEMD, 1, [Define to enable systemd support])
219 fi
220
221 AC_ARG_WITH([systemdsystemunitdir],
222         AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
223         [],
224         [with_systemdsystemunitdir=$have_systemd])
225 if test "x$with_systemdsystemunitdir" = "xyes"; then
226     with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
227 fi
228 if test "x$with_systemdsystemunitdir" != "xno"; then
229     AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
230 fi
231 AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != "xno" ])
232
233 AC_CONFIG_HEADERS([config.h])
234 AC_CONFIG_FILES([
235 Makefile
236 po/Makefile.in
237 data/Makefile
238 src/Makefile
239 src/libaccountsservice/Makefile
240 src/libaccountsservice/accountsservice.pc
241 doc/Makefile
242 doc/dbus/Makefile
243 doc/dbus/AccountsService.xml
244 ])
245 AC_OUTPUT
246
247 echo
248 AC_MSG_NOTICE([accountsservice was configured with the following options:])
249 if test "x$enable_docbook_docs" = "xyes"; then
250         AC_MSG_NOTICE([** DocBook documentation build enabled])
251 else
252         AC_MSG_NOTICE([** DocBook documentation build disabled])
253 fi
254 echo
255
256