summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 107e5d332f1f2cf155bb3ea0da8ee8fd63d0aba1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
AC_PREREQ(2.59)
AC_INIT([spice-vdagent], [0.22.1])
AC_CONFIG_SRCDIR([configure.ac])

AM_CONFIG_HEADER([src/config.h])

AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip subdir-objects])
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])

AC_PROG_CC
AM_PROG_CC_C_O
AC_HEADER_STDC
AC_SYS_LARGEFILE
AC_PROG_INSTALL
AC_PROG_LN_S
AC_DEFINE(_GNU_SOURCE, [1], [Enable GNU extensions])
PKG_PROG_PKG_CONFIG

AC_ARG_WITH([session-info],
  [AS_HELP_STRING([--with-session-info=@<:@auto/console-kit/systemd/none@:>@],
                  [Session-info source to use @<:@default=auto@:>@])],
  [case "$with_session_info" in
     auto|console-kit|systemd|none) ;;
     *) AC_MSG_ERROR([invalid session-info type specified]) ;;
   esac],
  [with_session_info="auto"])

dnl based on libvirt configure --init-script
AC_MSG_CHECKING([for init script flavor])
AC_ARG_WITH([init-script],
  [AC_HELP_STRING(
     [--with-init-script=@<:@redhat/systemd/systemd+redhat/check@:>@],
     [Style of init script to install @<:@default=check@:>@])],
     [],[with_init_script=check])
init_redhat=no
init_systemd=no
case "$with_init_script" in
    systemd+redhat)
       init_redhat=yes
       init_systemd=yes
       ;;
    systemd)
       init_systemd=yes
       ;;
    redhat)
       init_redhat=yes
       ;;
    none)
       ;;
    check)
       with_init_script=none
       if test "$cross_compiling" != yes && test -f /etc/redhat-release; then
          init_redhat=yes
          with_init_script=redhat
       fi
       ;;
    *)
       AC_MSG_ERROR([Unknown initscript flavour $with_init_script])
    ;;
esac
AM_CONDITIONAL([INIT_SCRIPT_RED_HAT], test "$init_redhat" = "yes")
AM_CONDITIONAL([INIT_SCRIPT_SYSTEMD], test "$init_systemd" = "yes")
AC_MSG_RESULT($with_init_script)

if test "x$init_systemd" = "xyes"; then
  SYSTEMDSYSTEMUNITDIR=`${PKG_CONFIG} systemd --variable=systemdsystemunitdir`
  SYSTEMDUSERUNITDIR=`${PKG_CONFIG} systemd --variable=systemduserunitdir`
  AC_SUBST(SYSTEMDSYSTEMUNITDIR)
  AC_SUBST(SYSTEMDUSERUNITDIR)
  # earlier versions of systemd require a separate libsystemd-daemon library
  PKG_CHECK_MODULES([LIBSYSTEMD_DAEMON],
                    [libsystemd >= 209],
                    [have_libsystemd_daemon="yes"],
                    [have_libsystemd_daemon="no"])
  if test "$have_libsystemd_daemon" = "yes"; then
      AC_DEFINE([WITH_SYSTEMD_SOCKET_ACTIVATION], [1], [If defined, vdagentd will support socket activation with systemd] )
  fi
fi

AC_ARG_WITH([gtk],
            [AS_HELP_STRING(
               [--with-gtk=@<:@auto/yes/no@:>@],
               [Use GTK+ instead of Xlib @<:@default=auto@:>@])],
            [],
            [with_gtk="auto"])
AC_ARG_WITH([gtk4],
            [AS_HELP_STRING(
               [--with-gtk4=@<:@yes/no@:>@],
               [Use GTK4 instead of Xlib @<:@default=no@:>@])],
            [],
            [with_gtk4="no"])
if test "x$with_gtk4" = "xyes"; then
    PKG_CHECK_MODULES([GTK], [gtk4 >= 3.98], [
                     AC_DEFINE([WITH_GTK], [1], [If defined, load GTK+ libraries])
                     AC_DEFINE([USE_GTK_FOR_MONITORS], [1], [If defined, use GTK for monitor resolution instead of XRandr])
                     with_gtk="yes"
                 ], [
                     AC_MSG_ERROR([GTK4 requested but not found])
                     with_gtk="no"])
else
    if test "x$with_gtk" != "xno"; then
        PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= 3.22], [
                     AC_DEFINE([WITH_GTK], [1], [If defined, load GTK+ libraries])
                     AC_DEFINE([USE_GTK_FOR_CLIPBOARD], [1], [If defined, use GTK for clipboard features])
                     with_gtk="yes"
                 ], [
                     AS_IF([test "x$with_gtk" = "xyes"], [AC_MSG_ERROR([GTK+ requested but not found])])
                     with_gtk="no"])
    fi
fi

AC_ARG_ENABLE([pciaccess],
              [AS_HELP_STRING([--enable-pciaccess], [Enable libpciaccess use for auto generation of Xinerama xorg.conf (default: yes)])],
              [enable_pciaccess="$enableval"],
              [enable_pciaccess="yes"])

AC_ARG_ENABLE([static-uinput],
              [AS_HELP_STRING([--enable-static-uinput], [Enable use of a fixed, static uinput device for X-servers without hotplug support (default: no)])],
              [enable_static_uinput="$enableval"],
              [enable_static_uinput="no"])

PKG_CHECK_MODULES([GIO2], [gio-unix-2.0 >= 2.50])
PKG_CHECK_MODULES(X, [xfixes xrandr >= 1.3 xinerama x11])
PKG_CHECK_MODULES(SPICE, [spice-protocol >= 0.14.3])
PKG_CHECK_MODULES(ALSA, [alsa >= 1.0.22])
PKG_CHECK_MODULES([DBUS], [dbus-1])
PKG_CHECK_MODULES([DRM], [libdrm])

PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.68], [], [
    AC_DEFINE(g_memdup2, g_memdup, [GLib2 < 2.68 compatibility])
])

if test "$with_session_info" = "auto" || test "$with_session_info" = "systemd"; then
    PKG_CHECK_MODULES([LIBSYSTEMD_LOGIN],
                      [libsystemd >= 209],
                      [have_libsystemd_login="yes"],
                      [have_libsystemd_login="no"])
    if test "$have_libsystemd_login" = "no"; then
        # for backward compatibility with older systemd versions
        PKG_CHECK_MODULES([LIBSYSTEMD_LOGIN],
                          [libsystemd-login >= 42],
                          [have_libsystemd_login="yes"],
                          [have_libsystemd_login="no"])
    fi
    if test x"$have_libsystemd_login" = "xno" && test "$with_session_info" = "systemd"; then
        AC_MSG_ERROR([libsystemd-login support explicitly requested, but some required packages are not available])
    fi
    if test x"$have_libsystemd_login" = "xyes"; then
        AC_DEFINE(HAVE_LIBSYSTEMD_LOGIN, [1], [If defined, vdagentd will be compiled with libsystemd-login support])
        with_session_info="systemd"
    fi
else
    have_libsystemd_login="no"
fi
AM_CONDITIONAL(HAVE_LIBSYSTEMD_LOGIN, test x"$have_libsystemd_login" = "xyes")

#udevdir
udevdir=$($PKG_CONFIG --variable=udevdir udev)
AC_SUBST(udevdir)

if test "$with_session_info" = "auto" || test "$with_session_info" = "console-kit"; then
    AC_DEFINE([HAVE_CONSOLE_KIT], [1], [If defined, vdagentd will be compiled with ConsoleKit support])
    have_console_kit="yes"
    with_session_info="console-kit"
else
    have_console_kit="no"
fi
AM_CONDITIONAL(HAVE_CONSOLE_KIT, test x"$have_console_kit" = "xyes")

if test x"$enable_pciaccess" = "xyes" ; then
    PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10])
    AC_DEFINE([HAVE_PCIACCESS], [1], [If defined, vdagentd will be compiled with pciaccess support] )
fi
AM_CONDITIONAL(HAVE_PCIACCESS, test x"$enable_pciaccess" = "xyes")

if test x"$enable_static_uinput" = "xyes" ; then
    AC_DEFINE([WITH_STATIC_UINPUT], [1], [If defined, vdagentd will use a static uinput device] )
fi

# If no CFLAGS are set, set some sane default CFLAGS
if test -z "$ac_test_CFLAGS"; then
  DEFAULT_CFLAGS="-Wall -Werror -Wp,-D_FORTIFY_SOURCE=2 -fno-strict-aliasing -fstack-protector --param=ssp-buffer-size=4"
  for F in $DEFAULT_CFLAGS; do
    AC_MSG_CHECKING([whether $CC supports $F])
    save_CFLAGS="$CFLAGS"
    CFLAGS="$CFLAGS $F"
    AC_COMPILE_IFELSE([AC_LANG_SOURCE([ ])], [cc_flag=yes], [cc_flag=no])
    if test "x$cc_flag" != "xyes"; then
      CFLAGS="$save_CFLAGS"
    fi
    AC_MSG_RESULT([$cc_flag])
  done
fi

AC_ARG_ENABLE([pie],
  AS_HELP_STRING([--enable-pie=@<:@auto/yes/no@:>@],
                 [Enable position-independent-executable support (for spice-vdagentd)@<:@default=auto@:>@]),
  [],
  [enable_pie="auto"])

if test "x$enable_pie" != "xno"; then
  save_CFLAGS="$CFLAGS"
  save_LDFLAGS="$LDFLAGS"
  CFLAGS="$CFLAGS -fPIE"
  LDFLAGS="$LDFLAGS -pie -Wl,-z,relro -Wl,-z,now"
  AC_MSG_CHECKING([for PIE support])
  AC_LINK_IFELSE([AC_LANG_SOURCE([int main () { return 0; }])],
                 [have_pie=yes],
                 [have_pie=no])
  AC_MSG_RESULT([$have_pie])
  if test "x$have_pie" = "xno" && test "x$enable_pie" = "xyes"; then
    AC_MSG_ERROR([pie support explicitly requested, but your toolchain does not support it])
  fi
  if test "x$have_pie" = "xyes"; then
    PIE_CFLAGS="-fPIE"
    PIE_LDFLAGS="-pie -Wl,-z,relro -Wl,-z,now"
    AC_SUBST(PIE_CFLAGS)
    AC_SUBST(PIE_LDFLAGS)
  fi
  CFLAGS="$save_CFLAGS"
  LDFLAGS="$save_LDFLAGS"
else
  have_pie=no
fi

AC_CONFIG_FILES([
Makefile
data/spice-vdagent.1
data/spice-vdagentd.1
])
AC_OUTPUT

dnl ==========================================================================
AC_MSG_NOTICE([

        spice-vdagent $VERSION
        ====================

        prefix:                   ${prefix}
        c compiler:               ${CC}

        session-info:             ${with_session_info}
        pciaccess:                ${enable_pciaccess}
        static uinput:            ${enable_static_uinput}
        vdagentd pie + relro:     ${have_pie}

        install RH initscript:    ${init_redhat}
        install systemd service:  ${init_systemd}
        udevdir:                  ${udevdir}

        use GTK+:                 ${with_gtk}

        Now type 'make' to build $PACKAGE

])