console-kit: use define for dbus paths
[vd_agent.git] / configure.ac
blob2fe685b6638b5121aebc5d1df6b86c7f7095d442
1 AC_PREREQ(2.59)
2 AC_INIT([spice-vdagent], [0.16.0])
3 AC_CONFIG_SRCDIR([configure.ac])
5 AM_CONFIG_HEADER([src/config.h])
7 AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip subdir-objects])
8 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
10 AC_PROG_CC
11 AM_PROG_CC_C_O
12 AC_HEADER_STDC
13 AC_SYS_LARGEFILE
14 AC_PROG_INSTALL
15 AC_PROG_LN_S
16 AC_DEFINE(_GNU_SOURCE, [1], [Enable GNU extensions])
17 PKG_PROG_PKG_CONFIG
19 AC_ARG_WITH([session-info],
20   [AS_HELP_STRING([--with-session-info=@<:@auto/console-kit/systemd/none@:>@],
21                   [Session-info source to use @<:@default=auto@:>@])],
22   [case "$with_session_info" in
23      auto|console-kit|systemd|none) ;;
24      *) AC_MSG_ERROR([invalid session-info type specified]) ;;
25    esac],
26   [with_session_info="auto"])
28 dnl based on libvirt configure --init-script
29 AC_MSG_CHECKING([for init script flavor])
30 AC_ARG_WITH([init-script],
31   [AC_HELP_STRING(
32      [--with-init-script=@<:@redhat/systemd/systemd+redhat/check@:>@],
33      [Style of init script to install @<:@default=check@:>@])],
34      [],[with_init_script=check])
35 init_redhat=no
36 init_systemd=no
37 case "$with_init_script" in
38     systemd+redhat)
39        init_redhat=yes
40        init_systemd=yes
41        ;;
42     systemd)
43        init_systemd=yes
44        ;;
45     redhat)
46        init_redhat=yes
47        ;;
48     none)
49        ;;
50     check)
51        with_init_script=none
52        if test "$cross_compiling" != yes && test -f /etc/redhat-release; then
53           init_redhat=yes
54           with_init_script=redhat
55        fi
56        ;;
57     *)
58        AC_MSG_ERROR([Unknown initscript flavour $with_init_script])
59     ;;
60 esac
61 AM_CONDITIONAL([INIT_SCRIPT_RED_HAT], test "$init_redhat" = "yes")
62 AM_CONDITIONAL([INIT_SCRIPT_SYSTEMD], test "$init_systemd" = "yes")
63 AC_MSG_RESULT($with_init_script)
65 if test "x$init_systemd" = "xyes"; then
66   SYSTEMDSYSTEMUNITDIR=`${PKG_CONFIG} systemd --variable=systemdsystemunitdir`
67   AC_SUBST(SYSTEMDSYSTEMUNITDIR)
70 AC_ARG_ENABLE([pciaccess],
71               [AS_HELP_STRING([--enable-pciaccess], [Enable libpciaccess use for auto generation of Xinerama xorg.conf (default: yes)])],
72               [enable_pciaccess="$enableval"],
73               [enable_pciaccess="yes"])
75 AC_ARG_ENABLE([static-uinput],
76               [AS_HELP_STRING([--enable-statis-uinput], [Enable use of a fixed, static uinput device for X-servers without hotplug support (default: no)])],
77               [enable_static_uinput="$enableval"],
78               [enable_static_uinput="no"])
80 PKG_CHECK_MODULES([GLIB2], [glib-2.0 >= 2.28])
81 PKG_CHECK_MODULES(X, [xfixes xrandr >= 1.3 xinerama x11])
82 PKG_CHECK_MODULES(SPICE, [spice-protocol >= 0.12.8])
83 PKG_CHECK_MODULES(ALSA, [alsa >= 1.0.22])
85 if test "$with_session_info" = "auto" || test "$with_session_info" = "systemd"; then
86     PKG_CHECK_MODULES([LIBSYSTEMD_LOGIN],
87                       [libsystemd >= 209],
88                       [have_libsystemd_login="yes"],
89                       [have_libsystemd_login="no"])
90     if test "$have_libsystemd_login" = "no"; then
91         # for backward compatibility with older systemd versions
92         PKG_CHECK_MODULES([LIBSYSTEMD_LOGIN],
93                           [libsystemd-login >= 42],
94                           [have_libsystemd_login="yes"],
95                           [have_libsystemd_login="no"])
96     fi
97     if test x"$have_libsystemd_login" = "xno" && test "$with_session_info" = "systemd"; then
98         AC_MSG_ERROR([libsystemd-login support explicitly requested, but some required packages are not available])
99     fi
100     if test x"$have_libsystemd_login" = "xyes"; then
101         AC_DEFINE(HAVE_LIBSYSTEMD_LOGIN, [1], [If defined, vdagentd will be compiled with libsystemd-login support])
102         with_session_info="systemd"
103     fi
104 else
105     have_libsystemd_login="no"
107 AM_CONDITIONAL(HAVE_LIBSYSTEMD_LOGIN, test x"$have_libsystemd_login" = "xyes")
109 if test "$with_session_info" = "auto" || test "$with_session_info" = "console-kit"; then
110     PKG_CHECK_MODULES([DBUS],
111                       [dbus-1],
112                       [have_console_kit="yes"],
113                       [have_console_kit="no"])
114     if test x"$have_console_kit" = "xno" && test "$with_session_info" = "console-kit"; then
115         AC_MSG_ERROR([console-kit support explicitly requested, but some required packages are not available])
116     fi
117     if test x"$have_console_kit" = "xyes"; then
118         AC_DEFINE([HAVE_CONSOLE_KIT], [1], [If defined, vdagentd will be compiled with ConsoleKit support])
119         with_session_info="console-kit"
120     else
121         with_session_info="none"
122     fi
123 else
124     have_console_kit="no"
126 AM_CONDITIONAL(HAVE_CONSOLE_KIT, test x"$have_console_kit" = "xyes")
128 if test x"$enable_pciaccess" = "xyes" ; then
129     PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10])
130     AC_DEFINE([HAVE_PCIACCESS], [1], [If defined, vdagentd will be compiled with pciaccess support] )
132 AM_CONDITIONAL(HAVE_PCIACCESS, test x"$enable_pciaccess" = "xyes")
134 if test x"$enable_static_uinput" = "xyes" ; then
135     AC_DEFINE([WITH_STATIC_UINPUT], [1], [If defined, vdagentd will use a static uinput device] )
138 # If no CFLAGS are set, set some sane default CFLAGS
139 if test "$ac_test_CFLAGS" != set; then
140   DEFAULT_CFLAGS="-Wall -Werror -Wp,-D_FORTIFY_SOURCE=2 -fno-strict-aliasing -fstack-protector --param=ssp-buffer-size=4"
141   for F in $DEFAULT_CFLAGS; do
142     AC_MSG_CHECKING([whether $CC supports $F])
143     save_CFLAGS="$CFLAGS"
144     CFLAGS="$CFLAGS $F"
145     AC_COMPILE_IFELSE([AC_LANG_SOURCE([ ])], [cc_flag=yes], [cc_flag=no])
146     if test "x$cc_flag" != "xyes"; then
147       CFLAGS="$save_CFLAGS"
148     fi
149     AC_MSG_RESULT([$cc_flag])
150   done
153 AC_ARG_ENABLE([pie],
154   AS_HELP_STRING([--enable-pie=@<:@auto/yes/no@:>@],
155                  [Enable position-independent-executable support (for spice-vdagentd)@<:@default=auto@:>@]),
156   [],
157   [enable_pie="auto"])
159 if test "x$enable_pie" != "xno"; then
160   save_CFLAGS="$CFLAGS"
161   save_LDFLAGS="$LDFLAGS"
162   CFLAGS="$CFLAGS -fPIE"
163   LDFLAGS="$LDFLAGS -pie -Wl,-z,relro -Wl,-z,now"
164   AC_MSG_CHECKING([for PIE support])
165   AC_LINK_IFELSE([AC_LANG_SOURCE([int main () { return 0; }])],
166                  [have_pie=yes],
167                  [have_pie=no])
168   AC_MSG_RESULT([$have_pie])
169   if test "x$have_pie" = "xno" && test "x$enable_pie" = "xyes"; then
170     AC_MSG_ERROR([pie support explicitly requested, but your toolchain does not support it])
171   fi
172   if test "x$have_pie" = "xyes"; then
173     PIE_CFLAGS="-fPIE"
174     PIE_LDFLAGS="-pie -Wl,-z,relro -Wl,-z,now"
175     AC_SUBST(PIE_CFLAGS)
176     AC_SUBST(PIE_LDFLAGS)
177   fi
178   CFLAGS="$save_CFLAGS"
179   LDFLAGS="$save_LDFLAGS"
180 else
181   have_pie=no
184 AC_CONFIG_FILES([
185 Makefile
186 data/spice-vdagent.1
187 data/spice-vdagentd.1
189 AC_OUTPUT
191 dnl ==========================================================================
192 AC_MSG_NOTICE([
194         spice-vdagent $VERSION
195         ====================
197         prefix:                   ${prefix}
198         c compiler:               ${CC}
200         session-info:             ${with_session_info}
201         pciaccess:                ${enable_pciaccess}
202         static uinput:            ${enable_static_uinput}
203         vdagentd pie + relro:     ${have_pie}
205         install RH initscript:    ${init_redhat}
206         install systemd service:  ${init_systemd}
208         Now type 'make' to build $PACKAGE