1#  Copyright 2008 Red Hat, Inc.
2#
3#  Permission is hereby granted, free of charge, to any person obtaining a
4#  copy of this software and associated documentation files (the "Software"),
5#  to deal in the Software without restriction, including without limitation
6#  on the rights to use, copy, modify, merge, publish, distribute, sub
7#  license, and/or sell copies of the Software, and to permit persons to whom
8#  the Software is furnished to do so, subject to the following conditions:
9#
10#  The above copyright notice and this permission notice (including the next
11#  paragraph) shall be included in all copies or substantial portions of the
12#  Software.
13#
14#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16#  FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
17#  THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18#  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19#  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20#
21# Process this file with autoconf to produce a configure script
22
23# Initialize Autoconf
24AC_PREREQ([2.60])
25AC_INIT([xf86-video-qxl],
26        [0.1.6],
27        [https://gitlab.freedesktop.org/xorg/driver/xf86-video-qxl/issues],
28        [xf86-video-qxl])
29AC_CONFIG_SRCDIR([Makefile.am])
30AC_CANONICAL_HOST
31
32# Initialize Automake
33AM_INIT_AUTOMAKE([foreign dist-xz])
34AM_MAINTAINER_MODE
35AC_CONFIG_HEADERS([config.h])
36AC_SYS_LARGEFILE
37
38# Require xorg-macros: XORG_DEFAULT_OPTIONS
39m4_ifndef([XORG_MACROS_VERSION],
40          [m4_fatal([you must install X.Org util-macros 1.4 or later (or the corresponding package from your distribution) before running autoconf/autogen])])
41XORG_MACROS_VERSION(1.4)
42XORG_DEFAULT_OPTIONS
43
44# Initialize libtool
45AC_DISABLE_STATIC
46AC_PROG_INSTALL
47AC_PROG_LIBTOOL
48
49AH_TOP([#include "xorg-server.h"])
50
51# Define a configure option for an alternate module directory
52AC_ARG_WITH(xorg-module-dir, [  --with-xorg-module-dir=DIR ],
53                             [ moduledir="$withval" ],
54                             [ moduledir="$libdir/xorg/modules" ])
55AC_SUBST(moduledir)
56
57# Store the list of server defined optional extensions in REQUIRED_MODULES
58XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
59XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
60XORG_DRIVER_CHECK_EXT(XV, videoproto)
61XORG_DRIVER_CHECK_EXT(XFreeXDGA, xf86dgaproto)
62
63# We can use either version 1 or version 2 of libXfont
64PKG_CHECK_EXISTS(xfont2,
65                 [xfont_pc=xfont2
66                  AC_DEFINE(HAVE_XFONT2,1,[Version 2 of the libXfont library])],
67                 [xfont_pc=xfont])
68
69# Obtain compiler/linker options for the driver dependencies
70PKG_CHECK_MODULES(XORG, [xorg-server >= 1.0.99.901] xproto fontsproto $xfont_pc $REQUIRED_MODULES)
71
72save_CFLAGS="$CFLAGS"
73CFLAGS="$XORG_CFLAGS"
74AC_CHECK_DECL(XSERVER_LIBPCIACCESS,
75	      [XSERVER_LIBPCIACCESS=yes], [XSERVER_LIBPCIACCESS=no],
76	      [#include "xorg-server.h"])
77CFLAGS="$save_CFLAGS"
78
79AC_ARG_ENABLE(kms,
80	      AS_HELP_STRING([--disable-kms],
81	                     [Disable KMS support [[default=enabled]]]),
82	     [DRM_MODE="$enableval"],
83	     [DRM_MODE=yes])
84
85# Checks for libraries.
86if test "x$DRM_MODE" = xyes; then
87	# require support for kms cursor hotspot
88	PKG_CHECK_MODULES(DRM, [libdrm >= 2.4.46])
89else
90	DRM_MODE=no
91fi
92
93if test "x$XSERVER_LIBPCIACCESS" = xyes; then
94    PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.10])
95fi
96AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)
97save_CFLAGS="$CFLAGS"
98CFLAGS="$DRM_CFLAGS $CFLAGS"
99if test "x$DRM_MODE" = xyes; then
100   	AC_CHECK_HEADER(xf86drmMode.h,[DRM_MODE=yes],[DRM_MODE=no],[#include <stdint.h>
101#include <stdlib.h>])
102	if test "x$DRM_MODE" = xyes; then
103	   	AC_DEFINE(XF86DRM_MODE,1,[DRM kernel modesetting])
104        else
105                DRM_MODE=no
106        fi
107fi
108CFLAGS="$save_CFLAGS"
109AM_CONDITIONAL(DRM_MODE, test x$DRM_MODE = xyes)
110
111enable_qxl=yes
112AC_ARG_ENABLE(xspice,
113[  --enable-xspice[[=(no|yes|only)]]  Build the xspice driver
114                   no      (default) Do not build
115                   yes     Build in addition to qxl
116                   only    Only build xspice],
117[  if test "x$enableval" = "xyes"; then
118        enable_xspice=yes
119   elif test "x$enableval" = "xonly"; then
120        enable_xspice=yes
121        enable_qxl=no
122   else
123        enable_xspice=no
124   fi
125])
126
127if test "x$enable_xspice" = "xyes"; then
128    AC_CHECK_HEADERS(sys/inotify.h)
129    AC_CHECK_FUNCS(inotify_init1)
130    PKG_CHECK_MODULES([SPICE], [spice-server >= 0.6.3],
131    [
132        AC_SUBST(SPICE_CFLAGS)
133        AC_SUBST(SPICE_LIBS)
134    ],
135    )
136else
137    enable_xspice=no
138fi
139
140AC_ARG_ENABLE([ccid],
141            [AS_HELP_STRING([--enable-ccid],
142            [Build the spiceccid SmartCard driver (default is no)])],
143            [enable_ccid=$enableval],
144            [enable_ccid=no])
145AC_ARG_WITH(ccid-module-dir,
146            [AS_HELP_STRING([--with-ccid-module-dir=DIR ],
147            [Specify the install path for spiceccid driver (default is $libdir/pcsc/drivers/serial)])],
148            [ cciddir="$withval" ],
149            [ cciddir="$libdir/pcsc/drivers/serial" ])
150AC_SUBST(cciddir)
151if test "x$enable_ccid" != "xno"; then
152    PKG_CHECK_MODULES(LIBPCSCLITE, [libpcsclite])
153    PKG_CHECK_MODULES(LIBCACARD, [libcacard])
154
155    if test "x$enable_xspice" = "xno"; then
156        AC_MSG_ERROR([Building with ccid requires xspice, but xspice is not enabled])
157    fi
158fi
159
160
161AM_CONDITIONAL(BUILD_XSPICE, test "x$enable_xspice" = "xyes")
162AM_CONDITIONAL(BUILD_QXL, test "x$enable_qxl" = "xyes")
163AM_CONDITIONAL(BUILD_SPICECCID, test "x$enable_ccid" = "xyes")
164
165AC_ARG_ENABLE([udev],
166		AS_HELP_STRING([--disable-udev], [Disable libudev support [default=auto]]),
167		[enable_udev="$enableval"],
168		[enable_udev=auto])
169if test "x$enable_udev" != "xno"; then
170	PKG_CHECK_MODULES(LIBUDEV, [libudev], [LIBUDEV=yes], [LIBUDEV=no])
171	if test "x$LIBUDEV" = xyes; then
172		AC_DEFINE(HAVE_LIBUDEV, 1,[libudev support])
173	elif test "x$enable_udev" != "xauto"; then
174		AC_MSG_ERROR([Building with udev requested but libudev not found])
175	fi
176fi
177AM_CONDITIONAL(LIBUDEV, test x$LIBUDEV = xyes)
178
179PKG_CHECK_MODULES([SPICE_PROTOCOL], [spice-protocol >= 0.12.0])
180
181# AC_CHECK_FILE is not supported when cross compiling
182if test "$cross_compiling" = "no" ; then
183    AC_CHECK_FILE(.git, [
184        GIT_VERSION=`git log -1 --format=%h`
185        AC_DEFINE_UNQUOTED([GIT_VERSION], ["$GIT_VERSION"], [Defined if building from git])
186        ]
187    )
188fi
189
190AC_CONFIG_FILES([
191                Makefile
192                src/Makefile
193                src/spiceccid/Makefile
194                src/uxa/Makefile
195                scripts/Makefile
196                examples/Makefile
197])
198AC_OUTPUT
199
200dnl ==========================================================================
201echo "
202
203        xf86-video-qxl $VERSION
204        =====================
205
206        prefix:                   ${prefix}
207        c compiler:               ${CC}
208
209        drm:                      ${DRM_CFLAGS}
210        KMS:                      ${DRM_MODE}
211        Build qxl:                ${enable_qxl}
212        Build xspice:             ${enable_xspice}
213        Build spiceccid:          ${enable_ccid}
214"
215