fix includes
[presencevnc] / libvnc / configure.ac
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT(LibVNCServer, 0.9.7, http://sourceforge.net/projects/libvncserver)
3 AM_INIT_AUTOMAKE(LibVNCServer, 0.9.7)
4 AM_CONFIG_HEADER(rfbconfig.h)
5 AX_PREFIX_CONFIG_H([rfb/rfbconfig.h])
6
7 # Checks for programs.
8 AC_PROG_CC
9 if test -z "$CC"; then
10         CCLD="\$(CC)"
11 else
12         CCLD="$CC"
13 fi
14 AC_PROG_MAKE_SET
15 AC_PROG_LIBTOOL
16 AC_PATH_PROG([AR], [ar], [/usr/bin/ar],
17                   [$PATH:/usr/ccs/bin])
18
19 # Options
20 AH_TEMPLATE(WITH_TIGHTVNC_FILETRANSFER, [Disable TightVNCFileTransfer protocol])
21 AC_ARG_WITH(tightvnc-filetransfer,
22         [  --without-filetransfer  disable TightVNC file transfer protocol],
23         , [ with_tightvnc_filetransfer=yes ])
24 # AC_DEFINE moved to after libpthread check.
25
26 AH_TEMPLATE(ALLOW24BPP, [Enable 24 bit per pixel in native framebuffer])
27 AC_ARG_WITH(24bpp,
28         [  --without-24bpp         disable 24 bpp framebuffers],
29         , [ with_24bpp=yes ])
30 if test "x$with_24bpp" = "xyes"; then
31         AC_DEFINE(ALLOW24BPP)
32 fi
33 AH_TEMPLATE(FFMPEG, [Use ffmpeg (for vnc2mpg)])
34 AC_ARG_WITH(ffmpeg,
35         [  --with-ffmpeg=dir       set ffmpeg home directory],,)
36 AC_SUBST(with_ffmpeg)
37 AM_CONDITIONAL(WITH_FFMPEG, test ! -z "$with_ffmpeg")
38 if test ! -z "$with_ffmpeg"; then
39         AC_CHECK_LIB(mp3lame, lame_init, HAVE_MP3LAME="true", HAVE_MP3LAME="false" )
40 fi
41 AM_CONDITIONAL(HAVE_MP3LAME, test "$HAVE_MP3LAME" = "true")
42
43 # Seem to need this dummy here to induce the 'checking for egrep... grep -E', etc.
44 # before it seemed to be inside the with_jpeg conditional. 
45 AC_CHECK_HEADER(thenonexistentheader.h, HAVE_THENONEXISTENTHEADER_H="true")
46
47 # Checks for X libraries
48 HAVE_X="false"
49 AC_PATH_XTRA
50 AH_TEMPLATE(HAVE_X11, [X11 build environment present])
51
52 # See if we are to build x11vnc:
53 AH_TEMPLATE(HAVE_SYSTEM_LIBVNCSERVER, [Use the system libvncserver build environment for x11vnc.])
54 AC_ARG_WITH(system-libvncserver,
55 [  --with-system-libvncserver     use installed libvncserver for x11vnc]
56 [  --with-system-libvncserver=DIR use libvncserver installed in DIR for x11vnc],,)
57 AC_ARG_WITH(x11vnc,
58 [  --with-x11vnc           configure for building the x11vnc subdir (if present)]
59 [                          you will need to cd to x11vnc and run 'make' etc.],,)
60
61 if test ! -z "$with_x11vnc" -a "$with_x11vnc" = "yes"; then
62         build_x11vnc="yes"
63 elif test "$PACKAGE_NAME" = "x11vnc"; then
64         build_x11vnc="yes"
65 else
66         build_x11vnc="no"
67 fi
68         
69 # x11vnc only:
70 if test "$build_x11vnc" = "yes"; then
71
72 AH_TEMPLATE(HAVE_XSHM, [MIT-SHM extension build environment present])
73 AH_TEMPLATE(HAVE_XTEST, [XTEST extension build environment present])
74 AH_TEMPLATE(HAVE_XTESTGRABCONTROL, [XTEST extension has XTestGrabControl])
75 AH_TEMPLATE(HAVE_XKEYBOARD, [XKEYBOARD extension build environment present])
76 AH_TEMPLATE(HAVE_LIBXINERAMA, [XINERAMA extension build environment present])
77 AH_TEMPLATE(HAVE_LIBXRANDR, [XRANDR extension build environment present])
78 AH_TEMPLATE(HAVE_LIBXFIXES, [XFIXES extension build environment present])
79 AH_TEMPLATE(HAVE_LIBXDAMAGE, [XDAMAGE extension build environment present])
80 AH_TEMPLATE(HAVE_LIBXTRAP, [DEC-XTRAP extension build environment present])
81 AH_TEMPLATE(HAVE_RECORD, [RECORD extension build environment present])
82 AH_TEMPLATE(HAVE_SOLARIS_XREADSCREEN, [Solaris XReadScreen available])
83 AH_TEMPLATE(HAVE_IRIX_XREADDISPLAY, [IRIX XReadDisplay available])
84 AH_TEMPLATE(HAVE_FBPM, [FBPM extension build environment present])
85 AH_TEMPLATE(HAVE_DPMS, [DPMS extension build environment present])
86 AH_TEMPLATE(HAVE_LINUX_VIDEODEV_H, [video4linux build environment present])
87 AH_TEMPLATE(HAVE_LINUX_FB_H, [linux fb device build environment present])
88 AH_TEMPLATE(HAVE_LINUX_INPUT_H, [linux/input.h present])
89 AH_TEMPLATE(HAVE_LINUX_UINPUT_H, [linux uinput device build environment present])
90 AH_TEMPLATE(HAVE_MACOSX_NATIVE_DISPLAY, [build MacOS X native display support])
91
92 AC_ARG_WITH(xkeyboard,
93 [  --without-xkeyboard     disable xkeyboard extension support],,)
94 AC_ARG_WITH(xinerama,
95 [  --without-xinerama      disable xinerama extension support],,)
96 AC_ARG_WITH(xrandr,
97 [  --without-xrandr        disable xrandr extension support],,)
98 AC_ARG_WITH(xfixes,
99 [  --without-xfixes        disable xfixes extension support],,)
100 AC_ARG_WITH(xdamage,
101 [  --without-xdamage       disable xdamage extension support],,)
102 AC_ARG_WITH(xtrap,
103 [  --without-xtrap         disable xtrap extension support],,)
104 AC_ARG_WITH(xrecord,
105 [  --without-xrecord       disable xrecord extension support],,)
106 AC_ARG_WITH(fbpm,
107 [  --without-fbpm          disable fbpm extension support],,)
108 AC_ARG_WITH(dpms,
109 [  --without-dpms          disable dpms extension support],,)
110 AC_ARG_WITH(v4l,
111 [  --without-v4l           disable video4linux support],,)
112 AC_ARG_WITH(fbdev,
113 [  --without-fbdev         disable linux fb device support],,)
114 AC_ARG_WITH(uinput,
115 [  --without-uinput        disable linux uinput device support],,)
116 AC_ARG_WITH(macosx-native,
117 [  --without-macosx-native disable MacOS X native display support],,)
118
119 fi
120 # end x11vnc only.
121
122 if test "x$with_x" = "xno"; then
123         HAVE_X="false"
124 elif test "$X_CFLAGS" != "-DX_DISPLAY_MISSING"; then
125         AC_CHECK_LIB(X11, XGetImage, [AC_DEFINE(HAVE_X11) HAVE_X="true"],
126                 HAVE_X="false",
127                 $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
128
129         # x11vnc only:
130         if test $HAVE_X = "true" -a "$build_x11vnc" = "yes"; then
131                 X_PRELIBS="$X_PRELIBS -lXext"
132
133                 AC_CHECK_LIB(Xext, XShmGetImage, 
134                         [AC_DEFINE(HAVE_XSHM)], ,
135                         $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
136
137                 AC_CHECK_LIB(Xext, XReadScreen, 
138                         [AC_DEFINE(HAVE_SOLARIS_XREADSCREEN)], ,
139                         $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
140
141                 AC_CHECK_HEADER(X11/extensions/readdisplay.h,
142                         [AC_DEFINE(HAVE_IRIX_XREADDISPLAY)], ,
143                         [#include <X11/Xlib.h>])
144
145                 if test "x$with_fbpm" != "xno"; then
146                         AC_CHECK_LIB(Xext, FBPMForceLevel, 
147                                 [AC_DEFINE(HAVE_FBPM)], ,
148                                 $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
149                 fi
150
151                 if test "x$with_dpms" != "xno"; then
152                         AC_CHECK_LIB(Xext, DPMSForceLevel, 
153                                 [AC_DEFINE(HAVE_DPMS)], ,
154                                 $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
155                 fi
156
157                 AC_CHECK_LIB(Xtst, XTestGrabControl, 
158                         X_PRELIBS="-lXtst $X_PRELIBS"
159                         [AC_DEFINE(HAVE_XTESTGRABCONTROL) HAVE_XTESTGRABCONTROL="true"], ,
160                         $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
161
162                 AC_CHECK_LIB(Xtst, XTestFakeKeyEvent, 
163                         X_PRELIBS="-lXtst $X_PRELIBS"
164                         [AC_DEFINE(HAVE_XTEST) HAVE_XTEST="true"], ,
165                         $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
166
167                 if test "x$with_xrecord" != "xno"; then
168                         AC_CHECK_LIB(Xtst, XRecordEnableContextAsync, 
169                                 X_PRELIBS="-lXtst $X_PRELIBS"
170                                 [AC_DEFINE(HAVE_RECORD)], ,
171                                 $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
172                 fi
173
174                 # we use XTRAP on X11R5, or user can set X11VNC_USE_XTRAP
175                 if test "x$with_xtrap" != "xno"; then
176                     if test ! -z "$X11VNC_USE_XTRAP" -o -z "$HAVE_XTESTGRABCONTROL"; then
177                         AC_CHECK_LIB(XTrap, XETrapSetGrabServer, 
178                                 X_PRELIBS="$X_PRELIBS -lXTrap"
179                                 [AC_DEFINE(HAVE_LIBXTRAP)], ,
180                                 $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
181                         # tru64 uses libXETrap.so
182                         AC_CHECK_LIB(XETrap, XETrapSetGrabServer, 
183                                 X_PRELIBS="$X_PRELIBS -lXETrap"
184                                 [AC_DEFINE(HAVE_LIBXTRAP)], ,
185                                 $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
186                     fi
187                 fi
188
189                 if test "x$with_xkeyboard" != "xno"; then
190                         saved_CPPFLAGS="$CPPFLAGS"
191                         CPPFLAGS="$CPPFLAGS $X_CFLAGS"
192                         AC_CHECK_HEADER(X11/XKBlib.h, HAVE_XKBLIB_H="true",
193                                 HAVE_XKBLIB_H="false", [#include <X11/Xlib.h>])
194                         CPPFLAGS="$saved_CPPFLAGS"
195                         if test $HAVE_XKBLIB_H = "true"; then
196                                 AC_CHECK_LIB(X11, XkbSelectEvents,
197                                         [AC_DEFINE(HAVE_XKEYBOARD)], ,
198                                         $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
199                         fi
200                 fi
201
202                 if test "x$with_xinerama" != "xno"; then
203                         AC_CHECK_LIB(Xinerama, XineramaQueryScreens,
204                                 X_PRELIBS="$X_PRELIBS -lXinerama"
205                                 [AC_DEFINE(HAVE_LIBXINERAMA)], ,
206                                 $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
207                 fi
208
209                 if test "x$with_xrandr" != "xno"; then
210                         AC_CHECK_LIB(Xrandr, XRRSelectInput,
211                                 X_PRELIBS="$X_PRELIBS -lXrandr"
212                                 [AC_DEFINE(HAVE_LIBXRANDR) HAVE_LIBXRANDR="true"], ,
213                                 $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
214                 fi
215
216                 if test "x$with_xfixes" != "xno"; then
217                         AC_CHECK_LIB(Xfixes, XFixesGetCursorImage,
218                                 X_PRELIBS="$X_PRELIBS -lXfixes"
219                                 [AC_DEFINE(HAVE_LIBXFIXES) HAVE_LIBXFIXES="true"], ,
220                                 $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
221                 fi
222
223                 if test "x$with_xdamage" != "xno"; then
224                         AC_CHECK_LIB(Xdamage, XDamageQueryExtension,
225                                 X_PRELIBS="$X_PRELIBS -lXdamage"
226                                 [AC_DEFINE(HAVE_LIBXDAMAGE) HAVE_LIBXDAMAGE="true"], ,
227                                 $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
228                 fi
229
230                 if test ! -z "$HAVE_LIBXFIXES" -o ! -z "$HAVE_LIBXDAMAGE"; then
231                         # need /usr/sfw/lib in RPATH for Solaris 10 and later
232                         case `(uname -sr) 2>/dev/null` in
233                         "SunOS 5"*) X_EXTRA_LIBS="$X_EXTRA_LIBS -R/usr/sfw/lib" ;;
234                         esac
235                 fi
236                 if test ! -z "$HAVE_LIBXRANDR"; then
237                         # also need /usr/X11/include for Solaris 10 10/08 and later
238                         case `(uname -sr) 2>/dev/null` in
239                         "SunOS 5"*) CPPFLAGS="$CPPFLAGS -I/usr/X11/include" ;;
240                         esac
241                 fi
242
243                 X_LIBS="$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS"
244         fi
245         # end x11vnc only.
246 fi
247
248 AC_SUBST(X_LIBS)
249 AM_CONDITIONAL(HAVE_X, test $HAVE_X != "false")
250
251 # x11vnc only:
252 if test "$build_x11vnc" = "yes"; then
253
254 if test "x$HAVE_X" = "xfalse" -a "x$with_x" != "xno"; then
255         AC_MSG_ERROR([
256 ==========================================================================
257 *** A working X window system build environment is required to build ***
258 x11vnc.  Make sure any required X development packages are installed.
259 If they are installed in non-standard locations, one can use the
260 --x-includes=DIR and --x-libraries=DIR configure options or set the
261 CPPFLAGS and LDFLAGS environment variables to indicate where the X
262 window system header files and libraries may be found.  On 64+32 bit
263 machines you may need to point to lib64 or lib32 directories to pick up
264 the correct word size.
265
266 If you want to build x11vnc without X support (e.g. for -rawfb use only
267 or for native Mac OS X), specify the --without-x configure option.
268 ==========================================================================
269 ])
270 fi
271
272 if test "x$HAVE_X" = "xtrue" -a "x$HAVE_XTEST" != "xtrue"; then
273         AC_MSG_WARN([
274 ==========================================================================
275 *** A working build environment for the XTEST extension was not found ***
276 (libXtst).  An x11vnc built this way will be *ONLY BARELY USABLE*.
277 You will be able to move the mouse but not click or type.  There can
278 also be deadlocks if an application grabs the X server.
279
280 It is recommended that you install the necessary development packages
281 for XTEST (perhaps it is named something like libxtst-dev) and run
282 configure again.
283 ==========================================================================
284 ])
285         sleep 5
286 fi
287
288 # set some ld -R nonsense
289 #
290 uname_s=`(uname -s) 2>/dev/null`
291 ld_minus_R="yes"
292 if test "x$uname_s" = "xHP-UX"; then
293         ld_minus_R="no"
294 elif test "x$uname_s" = "xOSF1"; then
295         ld_minus_R="no"
296 elif test "x$uname_s" = "xDarwin"; then
297         ld_minus_R="no"
298 fi
299
300
301 AH_TEMPLATE(HAVE_LIBCRYPT, [libcrypt library present])
302 AC_ARG_WITH(crypt,
303 [  --without-crypt         disable support for libcrypt],,)
304 if test "x$with_crypt" != "xno"; then
305         AC_CHECK_FUNCS([crypt], HAVE_LIBC_CRYPT="true")
306         if test -z "$HAVE_LIBC_CRYPT"; then
307                 AC_CHECK_LIB(crypt, crypt,
308                         CRYPT_LIBS="-lcrypt"
309                         [AC_DEFINE(HAVE_LIBCRYPT)], ,)
310         fi
311 fi
312 AC_SUBST(CRYPT_LIBS)
313
314 # some OS's need both -lssl and -lcrypto on link line:
315 AH_TEMPLATE(HAVE_LIBCRYPTO, [openssl libcrypto library present])
316 AC_ARG_WITH(crypto,
317 [  --without-crypto        disable support for openssl libcrypto],,)
318
319 AH_TEMPLATE(HAVE_LIBSSL, [openssl libssl library present])
320 AC_ARG_WITH(ssl,
321 [  --without-ssl           disable support for openssl libssl]
322 [  --with-ssl=DIR          use openssl include/library files in DIR],,)
323
324 if test "x$with_crypto" != "xno" -a "x$with_ssl" != "xno"; then
325         if test ! -z "$with_ssl" -a "x$with_ssl" != "xyes"; then
326                 saved_CPPFLAGS="$CPPFLAGS"
327                 saved_LDFLAGS="$LDFLAGS"
328                 CPPFLAGS="$CPPFLAGS -I$with_ssl/include"
329                 LDFLAGS="$LDFLAGS -L$with_ssl/lib"
330                 if test "x$ld_minus_R" = "xno"; then
331                         :
332                 elif test "x$GCC" = "xyes"; then
333                         LDFLAGS="$LDFLAGS -Xlinker -R$with_ssl/lib"
334                 else
335                         LDFLAGS="$LDFLAGS -R$with_ssl/lib"
336                 fi
337         fi
338         AC_CHECK_LIB(crypto, RAND_file_name,
339                 [AC_DEFINE(HAVE_LIBCRYPTO) HAVE_LIBCRYPTO="true"], ,)
340         if test ! -z "$with_ssl" -a "x$with_ssl" != "xyes"; then
341                 if test "x$HAVE_LIBCRYPTO" != "xtrue"; then
342                         CPPFLAGS="$saved_CPPFLAGS"
343                         LDFLAGS="$saved_LDFLAGS"
344                 fi
345         fi
346 fi
347
348 AH_TEMPLATE(HAVE_X509_PRINT_EX_FP, [open ssl X509_print_ex_fp available])
349 if test "x$with_ssl" != "xno"; then
350         if test "x$HAVE_LIBCRYPTO" = "xtrue"; then
351                 AC_CHECK_LIB(ssl, SSL_library_init,
352                         SSL_LIBS="-lssl -lcrypto"
353                         [AC_DEFINE(HAVE_LIBSSL) HAVE_LIBSSL="true"], ,
354                         -lcrypto)
355         else
356                 AC_CHECK_LIB(ssl, SSL_library_init,
357                         SSL_LIBS="-lssl"
358                         [AC_DEFINE(HAVE_LIBSSL) HAVE_LIBSSL="true"], ,)
359         fi
360 fi
361 AC_SUBST(SSL_LIBS)
362
363         if test "x$HAVE_LIBSSL" != "xtrue" -a "x$with_ssl" != "xno"; then
364                 AC_MSG_WARN([
365 ==========================================================================
366 *** The openssl encryption library libssl.so was not found. ***
367 An x11vnc built this way will not support SSL encryption.  To enable
368 SSL install the necessary development packages (perhaps it is named
369 something like libssl-dev) and run configure again.
370 ==========================================================================
371 ])
372                 sleep 5
373         elif test "x$with_ssl" != "xno"; then
374                 AC_CHECK_LIB(ssl, X509_print_ex_fp, 
375                         [AC_DEFINE(HAVE_X509_PRINT_EX_FP) HAVE_X509_PRINT_EX_FP="true"], , $SSL_LIBS
376                         )
377         fi
378
379 if test "x$with_v4l" != "xno"; then
380         AC_CHECK_HEADER(linux/videodev.h,
381                 [AC_DEFINE(HAVE_LINUX_VIDEODEV_H)],,)
382 fi
383 if test "x$with_fbdev" != "xno"; then
384         AC_CHECK_HEADER(linux/fb.h,
385                 [AC_DEFINE(HAVE_LINUX_FB_H)],,)
386 fi
387 if test "x$with_uinput" != "xno"; then
388         AC_CHECK_HEADER(linux/input.h,
389                 [AC_DEFINE(HAVE_LINUX_INPUT_H) HAVE_LINUX_INPUT_H="true"],,)
390         if test "x$HAVE_LINUX_INPUT_H" = "xtrue"; then
391                 AC_CHECK_HEADER(linux/uinput.h,
392                         [AC_DEFINE(HAVE_LINUX_UINPUT_H)],, [#include <linux/input.h>])
393         fi
394 fi
395
396 if test "x$with_macosx_native" != "xno"; then
397         AC_DEFINE(HAVE_MACOSX_NATIVE_DISPLAY)
398 fi
399
400 AH_TEMPLATE(HAVE_AVAHI, [Avahi/mDNS client build environment present])
401 AC_ARG_WITH(avahi,
402 [  --without-avahi         disable support for Avahi/mDNS]
403 [  --with-avahi=DIR        use avahi include/library files in DIR],,)
404 if test "x$with_avahi" != "xno"; then
405         printf "checking for avahi... "
406         if test ! -z "$with_avahi" -a "x$with_avahi" != "xyes"; then
407                 AVAHI_CFLAGS="-I$with_avahi/include"
408                 AVAHI_LIBS="-L$with_avahi/lib -lavahi-common -lavahi-client"
409                 echo "using $with_avahi"
410                 with_avahi=yes
411         elif pkg-config --atleast-version=0.6.4 avahi-client >/dev/null 2>&1; then
412                 AVAHI_CFLAGS=`pkg-config --cflags avahi-client`
413                 AVAHI_LIBS=`pkg-config --libs avahi-client`
414                 with_avahi=yes
415                 echo yes
416         else
417                 with_avahi=no
418                 echo no
419         fi
420 fi
421 if test "x$with_avahi" = "xyes"; then
422         AC_DEFINE(HAVE_AVAHI)
423         AC_SUBST(AVAHI_CFLAGS)
424         AC_SUBST(AVAHI_LIBS)
425 fi
426
427 fi
428 # end x11vnc only.
429
430 # Checks for libraries.
431
432 if test ! -z "$with_system_libvncserver" -a "x$with_system_libvncserver" != "xno"; then
433         printf "checking for system libvncserver... "
434         vneed="0.9.1"
435         if test "X$VNEED" != "X"; then
436                 vneed=$VNEED
437         fi
438         if test "x$with_system_libvncserver" != "xyes"; then
439                 rflag=""
440                 if test "x$ld_minus_R" = "xno"; then
441                         :
442                 elif test "x$GCC" = "xyes"; then
443                         rflag="-Xlinker -R$with_system_libvncserver/lib"
444                 else
445                         rflag="-R$with_system_libvncserver/lib"
446                 fi
447                 cmd="$with_system_libvncserver/bin/libvncserver-config"
448                 if $cmd --version 1>/dev/null 2>&1; then
449                         cvers=`$cmd --version 2>/dev/null`
450                         cscore=`echo "$cvers" | tr '.' ' ' | awk '{print 10000 * $1 + 100 * $2 + $3}'`
451                         nscore=`echo "$vneed" | tr '.' ' ' | awk '{print 10000 * $1 + 100 * $2 + $3}'`
452
453                         if test $cscore -lt $nscore; then
454                                 echo "no"
455                                 with_system_libvncserver=no
456                                 AC_MSG_ERROR([
457 ==========================================================================
458 *** Need libvncserver version $vneed, have version $cvers ***
459 You are building with a system installed libvncserver and it is not
460 new enough.
461 ==========================================================================
462 ])
463                         else
464                                 SYSTEM_LIBVNCSERVER_CFLAGS="-I$with_system_libvncserver/include"
465                                 SYSTEM_LIBVNCSERVER_LIBS="-L$with_system_libvncserver/lib $rflag -lvncserver -lvncclient"
466                                 echo "using $with_system_libvncserver"
467                                 with_system_libvncserver=yes
468                         fi
469                 else
470                         echo " *** cannot run $cmd *** " 1>&2
471                         with_system_libvncserver=no
472                         echo no
473                 fi
474         elif libvncserver-config --version 1>/dev/null 2>&1; then
475                 rflag=""
476                 rprefix=`libvncserver-config --prefix`
477                 if test "x$ld_minus_R" = "xno"; then
478                         :
479                 elif test "x$GCC" = "xyes"; then
480                         rflag=" -Xlinker -R$rprefix/lib "
481                 else
482                         rflag=" -R$rprefix/lib "
483                 fi
484                 cvers=`libvncserver-config --version 2>/dev/null`
485                 cscore=`echo "$cvers" | tr '.' ' ' | awk '{print 10000 * $1 + 100 * $2 + $3}'`
486                 nscore=`echo "$vneed" | tr '.' ' ' | awk '{print 10000 * $1 + 100 * $2 + $3}'`
487
488                 if test $cscore -lt $nscore; then
489                         echo "no"
490                                 AC_MSG_ERROR([
491 ==========================================================================
492 *** Need libvncserver version $vneed, have version $cvers ***
493 You are building with a system installed libvncserver and it is not
494 new enough.
495 ==========================================================================
496 ])
497                 else
498                         SYSTEM_LIBVNCSERVER_CFLAGS=`libvncserver-config --cflags`
499                         SYSTEM_LIBVNCSERVER_LIBS="$rflag"`libvncserver-config --libs`
500                         with_system_libvncserver=yes
501                         echo yes
502                 fi
503         else
504                 with_system_libvncserver=no
505                 echo no
506         fi
507 fi
508
509 if test "x$with_system_libvncserver" = "xyes"; then
510         AC_DEFINE(HAVE_SYSTEM_LIBVNCSERVER)
511         AC_SUBST(SYSTEM_LIBVNCSERVER_CFLAGS)
512         AC_SUBST(SYSTEM_LIBVNCSERVER_LIBS)
513 fi
514 AM_CONDITIONAL(HAVE_SYSTEM_LIBVNCSERVER, test "x$with_system_libvncserver" = "xyes")
515
516
517 AC_ARG_WITH(jpeg,
518 [  --without-jpeg          disable support for jpeg]
519 [  --with-jpeg=DIR         use jpeg include/library files in DIR],,)
520
521 # At this point:
522 #       no jpeg on command line   with_jpeg=""
523 #       -with-jpeg                with_jpeg="yes"
524 #       -without-jpeg             with_jpeg="no"
525 #       -with-jpeg=/foo/dir       with_jpeg="/foo/dir"
526
527 if test "x$with_jpeg" != "xno"; then
528         if test ! -z "$with_jpeg" -a "x$with_jpeg" != "xyes"; then
529                 # add user supplied directory to flags:
530                 saved_CPPFLAGS="$CPPFLAGS"
531                 saved_LDFLAGS="$LDFLAGS"
532                 CPPFLAGS="$CPPFLAGS -I$with_jpeg/include"
533                 LDFLAGS="$LDFLAGS -L$with_jpeg/lib"
534                 if test "x$ld_minus_R" = "xno"; then
535                         :
536                 elif test "x$GCC" = "xyes"; then
537                         # this is not complete... in general a rat's nest.
538                         LDFLAGS="$LDFLAGS -Xlinker -R$with_jpeg/lib"
539                 else
540                         LDFLAGS="$LDFLAGS -R$with_jpeg/lib"
541                 fi
542         fi
543         AC_CHECK_HEADER(jpeglib.h, HAVE_JPEGLIB_H="true")
544         if test "x$HAVE_JPEGLIB_H" = "xtrue"; then
545                 AC_CHECK_LIB(jpeg, jpeg_CreateCompress, , HAVE_JPEGLIB_H="")
546         fi
547         if test ! -z "$with_jpeg" -a "x$with_jpeg" != "xyes"; then
548                 if test "x$HAVE_JPEGLIB_H" != "xtrue"; then
549                         # restore old flags on failure:
550                         CPPFLAGS="$saved_CPPFLAGS"
551                         LDFLAGS="$saved_LDFLAGS"
552                 fi
553         fi
554         if test "$build_x11vnc" = "yes"; then
555                 if test "x$HAVE_JPEGLIB_H" != "xtrue"; then
556                         AC_MSG_WARN([
557 ==========================================================================
558 *** The libjpeg compression library was not found. ***
559 This may lead to reduced performance, especially over slow links.
560 If libjpeg is in a non-standard location use --with-jpeg=DIR to
561 indicate the header file is in DIR/include/jpeglib.h and the library
562 in DIR/lib/libjpeg.a.  A copy of libjpeg may be obtained from:
563 ftp://ftp.uu.net/graphics/jpeg/
564 ==========================================================================
565 ])
566                         sleep 5
567                 fi
568         fi
569 fi
570
571 AC_ARG_WITH(libz,
572 [  --without-libz          disable support for deflate],,)
573 AC_ARG_WITH(zlib,
574 [  --without-zlib          disable support for deflate]
575 [  --with-zlib=DIR         use zlib include/library files in DIR],,)
576
577 if test "x$with_zlib" != "xno" -a "x$with_libz" != "xno"; then
578         if test ! -z "$with_zlib" -a "x$with_zlib" != "xyes"; then
579                 saved_CPPFLAGS="$CPPFLAGS"
580                 saved_LDFLAGS="$LDFLAGS"
581                 CPPFLAGS="$CPPFLAGS -I$with_zlib/include"
582                 LDFLAGS="$LDFLAGS -L$with_zlib/lib"
583                 if test "x$ld_minus_R" = "xno"; then
584                         :
585                 elif test "x$GCC" = "xyes"; then
586                         LDFLAGS="$LDFLAGS -Xlinker -R$with_zlib/lib"
587                 else
588                         LDFLAGS="$LDFLAGS -R$with_zlib/lib"
589                 fi
590         fi
591         AC_CHECK_HEADER(zlib.h, HAVE_ZLIB_H="true")
592         if test "x$HAVE_ZLIB_H" = "xtrue"; then
593                 AC_CHECK_LIB(z, deflate, , HAVE_ZLIB_H="")
594         fi
595         if test ! -z "$with_zlib" -a "x$with_zlib" != "xyes"; then
596                 if test "x$HAVE_ZLIB_H" != "xtrue"; then
597                         CPPFLAGS="$saved_CPPFLAGS"
598                         LDFLAGS="$saved_LDFLAGS"
599                 fi
600         fi
601         if test "$build_x11vnc" = "yes"; then
602                 if test "x$HAVE_ZLIB_H" != "xtrue"; then
603                         AC_MSG_WARN([
604 ==========================================================================
605 *** The libz compression library was not found. ***
606 This may lead to reduced performance, especially over slow links.
607 If libz is in a non-standard location use --with-zlib=DIR to indicate the
608 header file is in DIR/include/zlib.h and the library in DIR/lib/libz.a.
609 A copy of libz may be obtained from: http://www.gzip.org/zlib/
610 ==========================================================================
611 ])
612                         sleep 5
613                 fi
614         fi
615 fi
616
617 AC_ARG_WITH(pthread,
618 [  --without-pthread       disable support for libpthread],,)
619
620 if test "x$with_pthread" != "xno"; then
621         AC_CHECK_HEADER(pthread.h, HAVE_PTHREAD_H="true")
622         if test ! -z "$HAVE_PTHREAD_H"; then
623                 AC_CHECK_LIB(pthread, pthread_mutex_lock)
624                 AC_CHECK_LIB(pthread, pthread_mutex_lock, HAVE_LIBPTHREAD="true")
625         fi
626 fi
627 AM_CONDITIONAL(HAVE_LIBPTHREAD, test ! -z "$HAVE_LIBPTHREAD")
628
629 # tightvnc-filetransfer implemented using threads:
630 if test -z "$HAVE_LIBPTHREAD"; then
631         with_tightvnc_filetransfer=""
632 fi
633 if test "x$with_tightvnc_filetransfer" = "xyes"; then
634         AC_DEFINE(WITH_TIGHTVNC_FILETRANSFER)
635 fi
636 AM_CONDITIONAL(WITH_TIGHTVNC_FILETRANSFER, test "$with_tightvnc_filetransfer" = "yes")
637
638 AM_CONDITIONAL(HAVE_LIBZ, test ! -z "$HAVE_ZLIB_H")
639 AM_CONDITIONAL(HAVE_LIBJPEG, test ! -z "$HAVE_JPEGLIB_H")
640
641 if test -z "$with_sdl"; then
642         if sdl-config --version >/dev/null 2>&1; then
643                 with_sdl=yes
644                 SDL_CFLAGS=`sdl-config --cflags`
645                 SDL_LIBS=`sdl-config --libs`
646         else
647                 with_sdl=no
648         fi
649 fi
650 AM_CONDITIONAL(HAVE_LIBSDL, test "x$with_sdl" = "xyes")
651 AC_SUBST(SDL_CFLAGS)
652 AC_SUBST(SDL_LIBS)
653
654 MINGW=`uname -s | grep MINGW 2>/dev/null`
655 AM_CONDITIONAL(MINGW, test ! -z "$MINGW" )
656 if test ! -z "$MINGW"; then
657         WSOCKLIB="-lws2_32"
658 fi
659 AC_SUBST(WSOCKLIB)
660
661 # Checks for header files.
662 AC_HEADER_STDC
663 AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h sys/timeb.h syslog.h unistd.h])
664
665 # x11vnc only:
666 if test "$build_x11vnc" = "yes"; then
667         AC_CHECK_HEADERS([pwd.h sys/wait.h utmpx.h termios.h sys/ioctl.h sys/stropts.h])
668 fi
669
670 # Checks for typedefs, structures, and compiler characteristics.
671 AC_C_CONST
672 AC_C_INLINE
673 AC_C_BIGENDIAN
674 AC_TYPE_SIZE_T
675 AC_HEADER_TIME
676 AC_HEADER_SYS_WAIT
677 AC_TYPE_SOCKLEN_T
678 if test ! -d ./rfb; then
679         echo "creating subdir ./rfb for rfbint.h"
680         mkdir ./rfb 
681 fi
682 AC_CREATE_STDINT_H(rfb/rfbint.h)
683 AC_CACHE_CHECK([for in_addr_t],
684         inaddrt, [
685                 AC_TRY_COMPILE([#include <sys/types.h>
686 #include <netinet/in.h>],
687                         [in_addr_t foo; return 0;],
688                                         [inaddrt=yes],
689                                         [inaddrt=no]),
690         ])
691 AH_TEMPLATE(NEED_INADDR_T, [Need a typedef for in_addr_t])
692 if test $inaddrt = no ; then
693   AC_DEFINE(NEED_INADDR_T)
694 fi
695
696 # Checks for library functions.
697 AC_FUNC_MEMCMP
698 AC_FUNC_STAT
699 AC_FUNC_STRFTIME
700 AC_FUNC_VPRINTF
701 AC_FUNC_FORK
702 AC_CHECK_LIB(nsl,gethostbyname)
703 AC_CHECK_LIB(socket,socket)
704
705 uname_s=`(uname -s) 2>/dev/null`
706 if test "x$uname_s" = "xHP-UX"; then
707         # need -lsec for getspnam()
708         LDFLAGS="$LDFLAGS -lsec"
709 fi
710
711 AC_CHECK_FUNCS([ftime gethostbyname gethostname gettimeofday inet_ntoa memmove memset mmap mkfifo select socket strchr strcspn strdup strerror strstr])
712 # x11vnc only:
713 if test "$build_x11vnc" = "yes"; then
714         AC_CHECK_FUNCS([setsid setpgrp getpwuid getpwnam getspnam getuid geteuid setuid setgid seteuid setegid initgroups waitpid setutxent grantpt shmat])
715 fi
716
717 # check, if shmget is in cygipc.a
718 AC_CHECK_LIB(cygipc,shmget)
719 AM_CONDITIONAL(CYGIPC, test "$HAVE_CYGIPC" = "true")
720
721 # Check if /dev/vcsa1 exists, if so, define LINUX
722 AM_CONDITIONAL(LINUX, test -c /dev/vcsa1)
723
724 # Check for OS X specific header
725 AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h, HAVE_OSX="true")
726 AM_CONDITIONAL(OSX, test "$HAVE_OSX" = "true")
727
728 # On Solaris 2.7, write() returns ENOENT when it really means EAGAIN
729 AH_TEMPLATE(ENOENT_WORKAROUND, [work around when write() returns ENOENT but does not mean it])
730 case `(uname -sr) 2>/dev/null` in
731     "SunOS 5.7")
732         AC_DEFINE(ENOENT_WORKAROUND)
733     ;;
734 esac
735
736 # Check for rpm SOURCES path
737 printf "checking for rpm sources path... "
738 RPMSOURCEDIR="NOT-FOUND"
739 for directory in packages OpenLinux redhat RedHat rpm RPM "" ; do
740         if test -d /usr/src/${directory}/SOURCES; then
741                 RPMSOURCEDIR="/usr/src/${directory}/SOURCES/"
742         fi
743 done
744 echo "$RPMSOURCEDIR"
745 AM_CONDITIONAL(HAVE_RPM, test "$RPMSOURCEDIR" != "NOT-FOUND")
746 AM_CONDITIONAL(WITH_X11VNC,  test "$build_x11vnc" = "yes")
747 AC_SUBST(RPMSOURCEDIR)
748
749 AC_CONFIG_FILES([Makefile
750         libvncserver/Makefile
751         contrib/Makefile
752         examples/Makefile
753         vncterm/Makefile
754         classes/Makefile
755         classes/ssl/Makefile
756         libvncclient/Makefile
757         client_examples/Makefile
758         test/Makefile
759         libvncserver-config
760         LibVNCServer.spec])
761 #
762 # x11vnc only:
763 #
764 if test "$build_x11vnc" = "yes"; then
765         #
766         # NOTE: if you are using the LibVNCServer-X.Y.Z.tar.gz source
767         # tarball and nevertheless want to run autoconf (i.e. aclocal,
768         # autoheader, automake, autoconf) AGAIN (perhaps you have a
769         # special target system, e.g. embedded) then you will need to
770         # comment out the following 'AC_CONFIG_FILES' line to avoid
771         # automake error messages like:
772         #
773         # configure.ac:690: required file `x11vnc/Makefile.in' not found
774         #
775         AC_CONFIG_FILES([x11vnc/Makefile x11vnc/misc/Makefile])
776 fi
777
778 AC_CONFIG_COMMANDS([chmod-libvncserver-config],[chmod a+x libvncserver-config])
779 AC_OUTPUT
780 chmod a+x ./libvncserver-config
781