fixed 64bit build error on dibs
[sdk/emulator/libs/spice-server.git] / configure.ac
1 AC_PREREQ([2.57])
2
3 # Making releases:
4 # 1. The version is SPICE_MAJOR.SPICE_MINOR.SPICE_MICRO
5 # 2. It is generated via a two stage process:
6 #   1. Create a tag
7 #   2. run configure which calls git-version-gen.
8 # 3. Follow these rules for setting the next tag (aka tarball version):
9 #   1. SPICE_MAJOR remains 0 until a major change is done.
10 #   2. Increment SPICE_MINOR to next even value on a significant release,
11 #      updating the release schedule: http://www.spice-space.org/page/Releases
12 #   3. Increment SPICE_MINOR otherwise.
13 # 4. Follow the libtool manual for the so version:
14 #  http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
15
16 m4_define([SPICE_CURRENT], [9])
17 m4_define([SPICE_REVISION], [0])
18 m4_define([SPICE_AGE], [8])
19
20 # Note on the library name on linux (SONAME) produced by libtool (for reference, gleaned
21 # from looking at libtool 2.4.2)
22 #
23 #  libspice-servver.so.current-age.age.revision
24
25 AC_INIT(spice, [m4_esyscmd(build-aux/git-version-gen .tarball-version)],
26         [spice-devel@lists.freedesktop.org], spice)
27
28 AC_CONFIG_MACRO_DIR([m4])
29 AM_CONFIG_HEADER([config.h])
30 AC_CONFIG_AUX_DIR(.)
31
32 # For automake >= 1.12
33 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
34
35 AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip subdir-objects])
36 AM_MAINTAINER_MODE
37
38 AC_PROG_CC
39 AC_PROG_CC_C99
40 if test x"$ac_cv_prog_cc_c99" = xno; then
41     AC_MSG_ERROR([C99 compiler is required.])
42 fi
43 AC_PROG_CXX
44 AC_PROG_INSTALL
45 AC_CANONICAL_HOST
46 AC_PROG_LIBTOOL
47 AM_PROG_CC_C_O
48 AC_C_BIGENDIAN
49 AC_PATH_PROGS(PYTHON, python2 python)
50 PKG_PROG_PKG_CONFIG
51
52 AC_CHECK_HEADERS([sys/time.h])
53 AC_CHECK_HEADERS([execinfo.h])
54 AC_FUNC_ALLOCA
55
56 AC_DEFINE([__STDC_FORMAT_MACROS],[],[Force definition of format macros for C++])
57
58 SPICE_LT_VERSION=m4_format("%d:%d:%d", SPICE_CURRENT, SPICE_REVISION, SPICE_AGE)
59 AC_SUBST(SPICE_LT_VERSION)
60
61 # Check for the CPU we are using
62 #
63 AC_MSG_CHECKING(for x86, x86-64 or armv6+ platform)
64 case $host_cpu in
65   i386|i486|i586|i686|i786|k6|k7|armv6|armv6l|armv6hl|armv7|armv7l|armv7hl)
66         variant=32
67         ;;
68   x86_64)
69         variant=64
70         ;;
71   *)
72         AC_MSG_RESULT(no)
73         echo Only x86 and x86-64 are supported
74         exit 1
75 esac
76 AC_MSG_RESULT($variant bit)
77 AM_CONDITIONAL([X86_64], [test "$variant" = 64])
78
79 AC_MSG_CHECKING([for native Win32])
80 case "$host" in
81   *-*-mingw*)
82     os_win32=yes
83     ;;
84   *)
85     os_win32=no
86     ;;
87 esac
88 AC_MSG_RESULT([$os_win32])
89
90 case $host in
91   *-*-linux*)
92     os_linux=yes
93     ;;
94 esac
95
96 dnl =========================================================================
97 dnl Check OS target
98
99 AC_MSG_CHECKING([for some Win32 platform])
100 case "$host" in
101   *-*-mingw*|*-*-cygwin*)
102     platform_win32=yes
103     ;;
104   *)
105     platform_win32=no
106     ;;
107 esac
108 AC_MSG_RESULT([$platform_win32])
109 if test "$platform_win32" = yes; then
110   red_target=windows
111 else
112   red_target=x11
113 fi
114
115 AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes")
116 AM_CONDITIONAL(OS_UNIX, test "$os_win32" != "yes")
117 AM_CONDITIONAL(OS_LINUX, test "$os_linux" = "yes")
118
119 dnl =========================================================================
120 dnl Chek optional features
121 AC_ARG_ENABLE(tunnel,
122 [  --enable-tunnel         Enable network redirection],,
123 [enable_tunnel="no"])
124 AS_IF([test x"$enable_tunnel" != "xno"], [enable_tunnel="yes"])
125 AM_CONDITIONAL(SUPPORT_TUNNEL, test "x$enable_tunnel" != "xno")
126 if test "x$enable_tunnel" != "xno"; then
127    AC_DEFINE([USE_TUNNEL], [1], [Define if supporting tunnel proxying])
128 fi
129
130 AC_ARG_ENABLE(gui,
131 [  --enable-gui         Enable start dialog with CEGUI],,
132 [enable_gui="no"])
133 AS_IF([test x"$enable_gui" != "xno"], [enable_gui="yes"])
134 AM_CONDITIONAL(SUPPORT_GUI, test "x$enable_gui" != "xno")
135
136 AC_ARG_ENABLE(opengl,
137 [  --enable-opengl         Enable opengl requirement / support (not recommended)],,
138 [enable_opengl="no"])
139 AS_IF([test x"$enable_opengl" != "xno"], [enable_opengl="yes"])
140 AM_CONDITIONAL(SUPPORT_GL, test "x$enable_opengl" = "xyes")
141
142 AC_ARG_ENABLE(smartcard,
143 [  --enable-smartcard         Enable network redirection],,
144 [enable_smartcard="no"])
145 AS_IF([test x"$enable_smartcard" != "xno"], [enable_smartcard="yes"])
146 AM_CONDITIONAL(SUPPORT_SMARTCARD, test "x$enable_smartcard" != "xno")
147 if test "x$enable_smartcard" = "xyes"; then
148    AC_DEFINE([USE_SMARTCARD], [1], [Define if supporting smartcard proxying])
149 fi
150
151 AC_ARG_ENABLE(client,
152 [  --enable-client         Enable spice client],,
153 [enable_client="no"])
154 AS_IF([test x"$enable_client" != "xno"], [enable_client="yes"])
155 AM_CONDITIONAL(SUPPORT_CLIENT, test "x$enable_client" = "xyes")
156
157 AC_ARG_ENABLE(automated_tests,
158 [  --enable-automated-tests     Enable automated tests using snappy (part of spice--gtk)],,
159 [enable_automated_tests="no"])
160 AS_IF([test x"$enable_automated_tests" != "xno"], [enable_automated_tests="yes"])
161 AM_CONDITIONAL(SUPPORT_AUTOMATED_TESTS, test "x$enable_automated_tests" != "xno")
162
163
164 dnl =========================================================================
165 dnl Check deps
166
167 AC_CONFIG_SUBDIRS([spice-common])
168 COMMON_CFLAGS='-I ${top_srcdir}/spice-common/ -I ${top_srcdir}/spice-common/spice-protocol/'
169 AC_SUBST(COMMON_CFLAGS)
170
171 AC_CHECK_LIBM
172 AC_SUBST(LIBM)
173
174 AC_CHECK_LIB(rt, clock_gettime,
175    AC_DEFINE([HAVE_CLOCK_GETTIME], 1, [Defined if we have clock_gettime()])
176    LIBRT=-lrt
177    )
178 AC_SUBST(LIBRT)
179
180 if test "$red_target" = "windows"; then
181         SPICE_NONPKGCONFIG_LIBS+=" -lpthreadGC2 -lversion -lmsimg32 $LIBM"
182 else
183         SPICE_NONPKGCONFIG_LIBS+=" -pthread $LIBM $LIBRT"
184 fi
185
186 dnl The client needs a yield function
187 AC_MSG_CHECKING(for posix yield function)
188 for yield_func in pthread_yield pthread_yield_np sched_yield \
189                                         thr_yield; do
190     spice_save_CPPFLAGS="$CPPFLAGS"
191     CPPFLAGS="$CPPFLAGS $SPICE_NONPKGCONFIG_LIBS"
192     AC_TRY_LINK([#include <pthread.h>],
193                 [$yield_func()],
194                 [posix_yield_func="$yield_func"
195                 break])
196     CPPFLAGS="$spice_save_CPPFLAGS"
197 done
198 if test x"$posix_yield_func" = xnone; then
199     AC_MSG_ERROR([No posix yield function found])
200 else
201     AC_MSG_RESULT($posix_yield_func)
202     posix_yield_func="$posix_yield_func()"
203 fi
204 AC_DEFINE_UNQUOTED([POSIX_YIELD_FUNC],$posix_yield_func,[The POSIX RT yield function])
205
206 SPICE_REQUIRES=""
207
208 if test "x$enable_gui" = "xyes" && test "x$enable_client" = "xyes" ; then
209     PKG_CHECK_MODULES(CEGUI06, CEGUI-0.6 >= 0.6.0 CEGUI-0.6 < 0.7.0,
210     [
211         AC_SUBST(CEGUI06_CFLAGS)
212         AC_SUBST(CEGUI06_LIBS)
213         AC_DEFINE([USE_GUI], [1], [Define to build with CEGUI support])
214     ],
215     [
216         PKG_CHECK_MODULES(CEGUI, CEGUI >= 0.6.0 CEGUI < 0.7.0)
217         AC_SUBST(CEGUI_CFLAGS)
218         AC_SUBST(CEGUI_LIBS)
219         AC_DEFINE([USE_GUI], [1], [Define to build with CEGUI support])
220     ])
221 fi
222
223 if test "x$enable_tunnel" = "xyes"; then
224         PKG_CHECK_MODULES(SLIRP, slirp)
225         AC_SUBST(SLIRP_CFLAGS)
226         AC_SUBST(SLIRP_LIBS)
227         SPICE_REQUIRES+=" slirp"
228         AC_DEFINE([HAVE_SLIRP], [], [Define if we have slirp])
229 fi
230
231 if test "x$enable_smartcard" = "xyes"; then
232     PKG_CHECK_MODULES(CAC_CARD, libcacard >= 0.1.2)
233     SMARTCARD_LIBS="$CAC_CARD_LIBS"
234     SMARTCARD_CFLAGS="$CAC_CARD_CFLAGS"
235     AC_SUBST(SMARTCARD_LIBS)
236     AC_SUBST(SMARTCARD_CFLAGS)
237     SPICE_REQUIRES+=" libcacard >= 0.1.2"
238 fi
239
240
241 PKG_CHECK_MODULES([GLIB2], [glib-2.0 >= 2.22])
242 SPICE_REQUIRES+=" glib-2.0 >= 2.22"
243
244 PKG_CHECK_MODULES(PIXMAN, pixman-1 >= 0.17.7)
245 AC_SUBST(PIXMAN_CFLAGS)
246 AC_SUBST(PIXMAN_LIBS)
247 SPICE_REQUIRES+=" pixman-1 >= 0.17.7"
248
249 PKG_CHECK_MODULES(CELT051, celt051 >= 0.5.1.1)
250 AC_SUBST(CELT051_CFLAGS)
251 AC_SUBST(CELT051_LIBS)
252 AC_SUBST(CELT051_LIBDIR)
253 SPICE_REQUIRES+=" celt051 >= 0.5.1.1"
254
255 if test ! -e client/generated_marshallers.cpp; then
256 AC_MSG_CHECKING([for pyparsing python module])
257 echo "import pyparsing" | ${PYTHON} - >/dev/null 2>&1
258 if test $? -ne 0 ; then
259     AC_MSG_RESULT([not found])
260     AC_MSG_ERROR([pyparsing python module is required to compile this package])
261 fi
262 AC_MSG_RESULT([found])
263 fi
264
265 if test "$os_linux" = yes; then
266         PKG_CHECK_MODULES(ALSA, alsa)
267         AC_SUBST(ALSA_CFLAGS)
268         AC_SUBST(ALSA_LIBS)
269 fi
270
271 PKG_CHECK_MODULES(SSL, openssl)
272 AC_SUBST(SSL_CFLAGS)
273 AC_SUBST(SSL_LIBS)
274 SPICE_REQUIRES+=" openssl"
275
276 # These are commented out because the gl libraries on RHEL 5 do not have pkgconfig files
277 #
278 # PKG_CHECK_MODULES(GL, gl glu)
279 # AC_SUBST(GL_CFLAGS)
280 # AC_SUBST(GL_LIBS)
281 # SPICE_REQUIRES+=" gl glu"
282
283 if test "x$enable_opengl" = "xyes"; then
284    AC_CHECK_LIB(GL, glBlendFunc, GL_LIBS="$GL_LIBS -lGL", enable_opengl=no)
285    AC_CHECK_LIB(GLU, gluSphere, GL_LIBS="$GL_LIBS -lGLU", enable_opengl=no)
286    AC_DEFINE([USE_OPENGL], [1], [Define to build with OpenGL support])
287    AC_DEFINE([GL_GLEXT_PROTOTYPES], [], [Enable GLExt prototypes])
288
289    if test "x$enable_opengl" = "xno"; then
290       AC_MSG_ERROR([GL libraries not available])
291    fi
292 fi
293
294 AC_SUBST(GL_CFLAGS)
295 AC_SUBST(GL_LIBS)
296 SPICE_NONPKGCONFIG_LIBS+=" $GL_LIBS"
297
298 if test "x$red_target" = "xx11" && test "x$enable_client" = "xyes" ; then
299         PKG_CHECK_MODULES(XRANDR, xrandr)
300         PKG_CHECK_MODULES(XFIXES, xfixes)
301         PKG_CHECK_MODULES(MISC_X, x11 xext xrender)
302         AC_SUBST(XRANDR_CFLAGS)
303         AC_SUBST(XRANDR_LIBS)
304         AC_SUBST(MISC_X_CFLAGS)
305         AC_SUBST(MISC_X_LIBS)
306
307         PKG_CHECK_MODULES(XRANDR12,
308                 xrandr >= 1.2,
309                 have_xrandr12=yes,
310                 have_xrandr12=no)
311 else
312         have_xrandr12=no
313 fi
314
315 AM_CONDITIONAL([HAVE_XRANDR12], [test "x$have_xrandr12" = "xyes"])
316 if test "x$have_xrandr12" = "xyes" ; then
317   AC_DEFINE([HAVE_XRANDR12], [], [Define if we have XRANDR 12])
318 fi
319
320 # Add parameter for libXinerama
321 AC_ARG_ENABLE([xinerama],
322     [AS_HELP_STRING([--disable-xinerama],
323         [disable Xinerama library @<:@default=no@:>@])])
324
325 if test "x$enable_xinerama" != "xno"; then
326     PKG_CHECK_MODULES(XINERAMA,
327         xinerama >= 1.0,
328         have_xinerama=yes,
329         have_xinerama=no)
330 else
331     have_xinerama=no
332 fi
333
334 if test "x$enable_xinerama" = "xyes" && test "x$have_xinerama" = "xno"; then
335     AC_MSG_ERROR([Requested Xinerama library was not found])
336 fi
337
338 AM_CONDITIONAL([HAVE_XINERAMA], [test "x$have_xinerama" = "xyes"])
339 if test "x$have_xinerama" = "xyes" ; then
340   AC_DEFINE([HAVE_XINERAMA], [], [Define if we have Xinerama])
341   AC_SUBST(XINERAMA_CFLAGS)
342   AC_SUBST(XINERAMA_LIBS)
343   SPICE_REQUIRES+=" xinerama"
344 fi
345
346 # Add parameter for (partial) static linkage of spice client.
347 # this is used to achive single binary package for all (?) distros.
348 AC_ARG_ENABLE(static-linkage,
349 [  --enable-static-linkage will generate spice client binary with static linkage to external libraries ],,
350 [enable_static_linkage="no"])
351 AS_IF([test x"$enable_static_linkage" != "xno"],
352 [SPICEC_STATIC_LINKAGE_BSTATIC=["-Wl,-Bstatic"]])
353
354 AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
355     AC_MSG_CHECKING([for jpeglib.h])
356     AC_TRY_CPP(
357 [#include <stdio.h>
358 #undef PACKAGE
359 #undef VERSION
360 #undef HAVE_STDLIB_H
361 #include <jpeglib.h>],
362         JPEG_LIBS='-ljpeg'
363         AC_MSG_RESULT($jpeg_ok),
364         AC_MSG_ERROR([jpeglib.h not found])),
365     AC_MSG_ERROR([libjpeg not found]))
366 AC_SUBST(JPEG_LIBS)
367
368 AC_CHECK_LIB(z, deflate, Z_LIBS='-lz', AC_MSG_ERROR([zlib not found]))
369 AC_SUBST(Z_LIBS)
370
371 dnl Cyrus SASL, check from gtk-vnc
372 AC_ARG_WITH([sasl],
373   [AS_HELP_STRING([--with-sasl],
374     [use cyrus SASL for authentication @<:@default=check@:>@])],
375   [],
376   [with_sasl=check])
377
378 SASL_CFLAGS=
379 SASL_LIBS=
380 enable_sasl=no
381 if test "x$with_sasl" != "xno"; then
382   if test "x$with_sasl" != "xyes" && test "x$with_sasl" != "xcheck"; then
383     SASL_CFLAGS="-I$with_sasl"
384     SASL_LIBS="-L$with_sasl"
385   fi
386   fail=0
387   old_cflags="$CFLAGS"
388   old_libs="$LIBS"
389   CFLAGS="$CFLAGS $SASL_CFLAGS"
390   LIBS="$LIBS $SASL_LIBS"
391   AC_CHECK_HEADER([sasl/sasl.h],[],[
392     if test "x$with_sasl" != "xcheck" ; then
393         with_sasl=no
394     else
395         fail=1
396     fi])
397   if test "x$with_sasl" != "xno" ; then
398     AC_CHECK_LIB([sasl2], [sasl_client_init],[with_sasl2=yes],[with_sasl2=no])
399   fi
400   if test "x$with_sasl2" = "xno" && test "x$with_sasl" != "xno" ; then
401     AC_CHECK_LIB([sasl], [sasl_client_init],[with_sasl=yes],[with_sasl=no])
402   fi
403   if test "x$with_sasl2" = "xyes"; then
404     SASL_LIBS="$SASL_LIBS -lsasl2"
405   elif test "x$with_sasl" = "xyes"; then
406     SASL_LIBS="$SASL_LIBS -lsasl"
407   else
408     AC_MSG_ERROR([Missing required Cyrus SASL development package])
409   fi
410   CFLAGS="$old_cflags"
411   LIBS="$old_libs"
412   if test "x$with_sasl2" = "xyes" || test "x$with_sasl" = "xyes" ; then
413     AC_DEFINE_UNQUOTED([HAVE_SASL], 1,
414       [whether Cyrus SASL is available for authentication])
415     enable_sasl=yes
416   fi
417 fi
418 AM_CONDITIONAL([HAVE_SASL], [test "x$with_sasl2" = "xyes" || test "x$with_sasl" = "xyes"])
419 AC_SUBST([SASL_CFLAGS])
420 AC_SUBST([SASL_LIBS])
421
422 if test "x$enable_automated_tests" = "xyes"; then
423     AC_MSG_CHECKING([for snappy])
424     snappy --help >/dev/null 2>&1
425     if test $? -ne 0 ; then
426         AC_MSG_RESULT([not found])
427         AC_MSG_ERROR([snappy was not found, this module is part of spice-gtk andis required to compile this package])
428     fi
429     AC_MSG_RESULT([found])
430 fi
431
432 dnl ===========================================================================
433 dnl check compiler flags
434
435 SPICE_COMPILE_WARNINGS
436
437 # use ximage.h for win32 build if it is found (no package for mingw32 atm)
438 if test $os_win32 == "yes" ; then
439     AC_MSG_CHECKING([for cximage])
440     AC_TRY_CPP(
441 [#include <ximage.h>
442 int main()
443 {
444  return CXIMAGE_FORMAT_RAW;
445 )}
446 ],[
447  AC_MSG_RESULT([found])
448  have_cximage="yes"
449 ]
450 ,[AC_MSG_RESULT([missing])
451  CXIMAGE_CFLAGS='-DDISABLE_CXIMAGE'
452  have_cximage="no"
453  ]
454 )
455 fi
456 AC_SUBST(CXIMAGE_CFLAGS)
457
458 # check for windres for mingw32 builds
459 if test $os_win32 == "yes" ; then
460     AC_CHECK_PROGS(WINDRES,i686-pc-mingw32-windres mingw-windres mingw32-windres,false)
461     AC_SUBST(WINDRES)
462 fi
463
464 AC_SUBST(WARN_CFLAGS)
465 AC_SUBST(CFLAGS_CFLAGS)
466
467 dnl =========================================================================
468 dnl -fvisibility stuff
469
470 have_gcc4=no
471 AC_MSG_CHECKING(for -fvisibility)
472 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
473 #if defined(__GNUC__) && (__GNUC__ >= 4)
474 #else
475 error Need GCC 4.0 for visibility
476 #endif
477 int main () { return 0; }
478 ])], have_gcc4=yes)
479
480 if test "x$have_gcc4" = "xyes" && test ! "$os_win32" = "yes" ; then
481    VISIBILITY_HIDDEN_CFLAGS="-fvisibility=hidden"
482 fi
483 AC_MSG_RESULT($have_gcc4)
484 AC_SUBST(VISIBILITY_HIDDEN_CFLAGS)
485
486 dnl ensure linker supports ---version-script option before using it
487 AC_CACHE_CHECK([if -Wl,--version-script works], [spice_cv_ld_version_script],
488     [save_LDFLAGS="$LDFLAGS"
489      LDFLAGS="$LDFLAGS -Wl,--version-script=$srcdir/server/spice-server.syms"
490      AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
491         [spice_cv_ld_version_script=yes], [spice_cv_ld_version_script=no])
492      LDFLAGS="$save_LDFLAGS"])
493 AM_CONDITIONAL([HAVE_LD_VERSION_SCRIPT],
494     [test x"$spice_cv_ld_version_script" = xyes])
495
496 AC_SUBST(SPICE_REQUIRES)
497 AC_SUBST(SPICE_NONPKGCONFIG_CFLAGS)
498 AC_SUBST(SPICE_NONPKGCONFIG_LIBS)
499
500 AC_SUBST([SPICEC_STATIC_LINKAGE_BSTATIC])
501
502 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
503
504 AC_OUTPUT([
505 Makefile
506 spice-server.pc
507 server/Makefile
508 server/tests/Makefile
509 client/Makefile
510 ])
511
512 dnl ==========================================================================
513 echo "
514
515         Spice $VERSION
516         ==============
517
518         prefix:                   ${prefix}
519         c compiler:               ${CC}
520         c++ compiler:             ${CXX}
521         python:                   ${PYTHON}
522
523         Build Spice client:       ${enable_client}
524 " ; if test "x$enable_client" == "xyes"; then echo "\
525         Have XRANDR 1.2:          ${have_xrandr12}
526
527         Have Xinerama:            ${have_xinerama}
528
529         Red target:               ${red_target}
530
531         OpenGL:                   ${enable_opengl}
532
533         GUI:                      ${enable_gui}
534 " ; fi ; echo "\
535         Support tunneling:        ${enable_tunnel}
536
537         Smartcard:                ${enable_smartcard}
538
539         SASL support:             ${enable_sasl}
540
541         Automated tests:          ${enable_automated_tests}
542 "
543
544 if test $os_win32 == "yes" ; then
545 echo \
546 "        Copy & Paste Images:     ${have_cximage}
547 "
548 fi
549
550 echo \
551 "        Now type 'make' to build $PACKAGE
552 "