configure.ac 25.5 KB
Newer Older
dscho's avatar
dscho committed
1
# Process this file with autoconf to produce a configure script.
2 3
AC_INIT(LibVNCServer, 0.9.7, http://sourceforge.net/projects/libvncserver)
AM_INIT_AUTOMAKE(LibVNCServer, 0.9.7)
4
AM_CONFIG_HEADER(rfbconfig.h)
5
AX_PREFIX_CONFIG_H([rfb/rfbconfig.h])
dscho's avatar
dscho committed
6 7 8

# Checks for programs.
AC_PROG_CC
dscho's avatar
dscho committed
9
AM_PROG_CC_C_O
10 11 12 13 14
if test -z "$CC"; then
	CCLD="\$(CC)"
else
	CCLD="$CC"
fi
dscho's avatar
dscho committed
15
test "x$GCC" = "xyes" && CFLAGS="$CFLAGS -Wall"
dscho's avatar
dscho committed
16
AC_PROG_MAKE_SET
17
AC_PROG_LIBTOOL
18 19
AC_PATH_PROG([AR], [ar], [/usr/bin/ar],
                  [$PATH:/usr/ccs/bin])
dscho's avatar
dscho committed
20 21

# Options
22 23
AH_TEMPLATE(WITH_TIGHTVNC_FILETRANSFER, [Disable TightVNCFileTransfer protocol])
AC_ARG_WITH(tightvnc-filetransfer,
24
	[  --without-filetransfer  disable TightVNC file transfer protocol],
25
	, [ with_tightvnc_filetransfer=yes ])
26 27
# AC_DEFINE moved to after libpthread check.

dscho's avatar
dscho committed
28 29
AH_TEMPLATE(ALLOW24BPP, [Enable 24 bit per pixel in native framebuffer])
AC_ARG_WITH(24bpp,
30
	[  --without-24bpp         disable 24 bpp framebuffers],
31 32 33 34
	, [ with_24bpp=yes ])
if test "x$with_24bpp" = "xyes"; then
	AC_DEFINE(ALLOW24BPP)
fi
35 36
AH_TEMPLATE(FFMPEG, [Use ffmpeg (for vnc2mpg)])
AC_ARG_WITH(ffmpeg,
37
	[  --with-ffmpeg=dir       set ffmpeg home directory],,)
38 39
AC_SUBST(with_ffmpeg)
AM_CONDITIONAL(WITH_FFMPEG, test ! -z "$with_ffmpeg")
40 41 42 43
if test ! -z "$with_ffmpeg"; then
	AC_CHECK_LIB(mp3lame, lame_init, HAVE_MP3LAME="true", HAVE_MP3LAME="false" )
fi
AM_CONDITIONAL(HAVE_MP3LAME, test "$HAVE_MP3LAME" = "true")
44 45 46 47 48

# Seem to need this dummy here to induce the 'checking for egrep... grep -E', etc.
# before it seemed to be inside the with_jpeg conditional. 
AC_CHECK_HEADER(thenonexistentheader.h, HAVE_THENONEXISTENTHEADER_H="true")

dscho's avatar
dscho committed
49 50 51
# Checks for X libraries
HAVE_X="false"
AC_PATH_XTRA
52
AH_TEMPLATE(HAVE_X11, [X11 build environment present])
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73

# See if we are to build x11vnc:
AH_TEMPLATE(HAVE_SYSTEM_LIBVNCSERVER, [Use the system libvncserver build environment for x11vnc.])
AC_ARG_WITH(system-libvncserver,
[  --with-system-libvncserver     use installed libvncserver for x11vnc]
[  --with-system-libvncserver=DIR use libvncserver installed in DIR for x11vnc],,)
AC_ARG_WITH(x11vnc,
[  --with-x11vnc           configure for building the x11vnc subdir (if present)]
[                          you will need to cd to x11vnc and run 'make' etc.],,)

if test ! -z "$with_x11vnc" -a "$with_x11vnc" = "yes"; then
	build_x11vnc="yes"
elif test "$PACKAGE_NAME" = "x11vnc"; then
	build_x11vnc="yes"
else
	build_x11vnc="no"
fi
	
# x11vnc only:
if test "$build_x11vnc" = "yes"; then

74 75
AH_TEMPLATE(HAVE_XSHM, [MIT-SHM extension build environment present])
AH_TEMPLATE(HAVE_XTEST, [XTEST extension build environment present])
76
AH_TEMPLATE(HAVE_XTESTGRABCONTROL, [XTEST extension has XTestGrabControl])
77
AH_TEMPLATE(HAVE_XKEYBOARD, [XKEYBOARD extension build environment present])
78
AH_TEMPLATE(HAVE_LIBXINERAMA, [XINERAMA extension build environment present])
79 80 81
AH_TEMPLATE(HAVE_LIBXRANDR, [XRANDR extension build environment present])
AH_TEMPLATE(HAVE_LIBXFIXES, [XFIXES extension build environment present])
AH_TEMPLATE(HAVE_LIBXDAMAGE, [XDAMAGE extension build environment present])
82
AH_TEMPLATE(HAVE_LIBXTRAP, [DEC-XTRAP extension build environment present])
83
AH_TEMPLATE(HAVE_RECORD, [RECORD extension build environment present])
84 85
AH_TEMPLATE(HAVE_SOLARIS_XREADSCREEN, [Solaris XReadScreen available])
AH_TEMPLATE(HAVE_IRIX_XREADDISPLAY, [IRIX XReadDisplay available])
86
AH_TEMPLATE(HAVE_FBPM, [FBPM extension build environment present])
87
AH_TEMPLATE(HAVE_DPMS, [DPMS extension build environment present])
88 89
AH_TEMPLATE(HAVE_LINUX_VIDEODEV_H, [video4linux build environment present])
AH_TEMPLATE(HAVE_LINUX_FB_H, [linux fb device build environment present])
90 91
AH_TEMPLATE(HAVE_LINUX_INPUT_H, [linux/input.h present])
AH_TEMPLATE(HAVE_LINUX_UINPUT_H, [linux uinput device build environment present])
92
AH_TEMPLATE(HAVE_MACOSX_NATIVE_DISPLAY, [build MacOS X native display support])
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107

AC_ARG_WITH(xkeyboard,
[  --without-xkeyboard     disable xkeyboard extension support],,)
AC_ARG_WITH(xinerama,
[  --without-xinerama      disable xinerama extension support],,)
AC_ARG_WITH(xrandr,
[  --without-xrandr        disable xrandr extension support],,)
AC_ARG_WITH(xfixes,
[  --without-xfixes        disable xfixes extension support],,)
AC_ARG_WITH(xdamage,
[  --without-xdamage       disable xdamage extension support],,)
AC_ARG_WITH(xtrap,
[  --without-xtrap         disable xtrap extension support],,)
AC_ARG_WITH(xrecord,
[  --without-xrecord       disable xrecord extension support],,)
108 109
AC_ARG_WITH(fbpm,
[  --without-fbpm          disable fbpm extension support],,)
110 111
AC_ARG_WITH(dpms,
[  --without-dpms          disable dpms extension support],,)
112 113 114 115
AC_ARG_WITH(v4l,
[  --without-v4l           disable video4linux support],,)
AC_ARG_WITH(fbdev,
[  --without-fbdev         disable linux fb device support],,)
116 117
AC_ARG_WITH(uinput,
[  --without-uinput        disable linux uinput device support],,)
118 119
AC_ARG_WITH(macosx-native,
[  --without-macosx-native disable MacOS X native display support],,)
120

121 122 123
fi
# end x11vnc only.

124 125 126 127
if test "x$with_x" = "xno"; then
	HAVE_X="false"
elif test "$X_CFLAGS" != "-DX_DISPLAY_MISSING"; then
	AC_CHECK_LIB(X11, XGetImage, [AC_DEFINE(HAVE_X11) HAVE_X="true"],
128 129 130
		HAVE_X="false",
		$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)

131 132
	# x11vnc only:
	if test $HAVE_X = "true" -a "$build_x11vnc" = "yes"; then
133 134 135 136
		X_PRELIBS="$X_PRELIBS -lXext"

		AC_CHECK_LIB(Xext, XShmGetImage, 
			[AC_DEFINE(HAVE_XSHM)], ,
137
			$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
138

139 140 141 142 143 144 145 146
		AC_CHECK_LIB(Xext, XReadScreen, 
			[AC_DEFINE(HAVE_SOLARIS_XREADSCREEN)], ,
			$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)

		AC_CHECK_HEADER(X11/extensions/readdisplay.h,
			[AC_DEFINE(HAVE_IRIX_XREADDISPLAY)], ,
			[#include <X11/Xlib.h>])

147
		if test "x$with_fbpm" != "xno"; then
148
			AC_CHECK_LIB(Xext, FBPMForceLevel, 
149
				[AC_DEFINE(HAVE_FBPM)], ,
150
				$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
151
		fi
152

153
		if test "x$with_dpms" != "xno"; then
154
			AC_CHECK_LIB(Xext, DPMSForceLevel, 
155
				[AC_DEFINE(HAVE_DPMS)], ,
156
				$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
157
		fi
158

159
		AC_CHECK_LIB(Xtst, XTestGrabControl, 
160
			X_PRELIBS="-lXtst $X_PRELIBS"
161 162 163
			[AC_DEFINE(HAVE_XTESTGRABCONTROL) HAVE_XTESTGRABCONTROL="true"], ,
			$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)

164
		AC_CHECK_LIB(Xtst, XTestFakeKeyEvent, 
165
			X_PRELIBS="-lXtst $X_PRELIBS"
runge's avatar
runge committed
166
			[AC_DEFINE(HAVE_XTEST) HAVE_XTEST="true"], ,
167 168
			$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)

169 170
		if test "x$with_xrecord" != "xno"; then
			AC_CHECK_LIB(Xtst, XRecordEnableContextAsync, 
171
				X_PRELIBS="-lXtst $X_PRELIBS"
172 173 174
				[AC_DEFINE(HAVE_RECORD)], ,
				$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
		fi
175

176
		# we use XTRAP on X11R5, or user can set X11VNC_USE_XTRAP
177 178
		if test "x$with_xtrap" != "xno"; then
		    if test ! -z "$X11VNC_USE_XTRAP" -o -z "$HAVE_XTESTGRABCONTROL"; then
179 180 181 182 183 184 185 186 187
			AC_CHECK_LIB(XTrap, XETrapSetGrabServer, 
				X_PRELIBS="$X_PRELIBS -lXTrap"
				[AC_DEFINE(HAVE_LIBXTRAP)], ,
				$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
			# tru64 uses libXETrap.so
			AC_CHECK_LIB(XETrap, XETrapSetGrabServer, 
				X_PRELIBS="$X_PRELIBS -lXETrap"
				[AC_DEFINE(HAVE_LIBXTRAP)], ,
				$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
188
		    fi
189 190
		fi

191 192 193 194 195 196 197 198 199 200 201
		if test "x$with_xkeyboard" != "xno"; then
			saved_CPPFLAGS="$CPPFLAGS"
			CPPFLAGS="$CPPFLAGS $X_CFLAGS"
			AC_CHECK_HEADER(X11/XKBlib.h, HAVE_XKBLIB_H="true",
				HAVE_XKBLIB_H="false", [#include <X11/Xlib.h>])
			CPPFLAGS="$saved_CPPFLAGS"
			if test $HAVE_XKBLIB_H = "true"; then
				AC_CHECK_LIB(X11, XkbSelectEvents,
					[AC_DEFINE(HAVE_XKEYBOARD)], ,
					$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
			fi
202 203
		fi

204 205 206 207 208 209
		if test "x$with_xinerama" != "xno"; then
			AC_CHECK_LIB(Xinerama, XineramaQueryScreens,
				X_PRELIBS="$X_PRELIBS -lXinerama"
				[AC_DEFINE(HAVE_LIBXINERAMA)], ,
				$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
		fi
210

211 212 213
		if test "x$with_xrandr" != "xno"; then
			AC_CHECK_LIB(Xrandr, XRRSelectInput,
				X_PRELIBS="$X_PRELIBS -lXrandr"
214
				[AC_DEFINE(HAVE_LIBXRANDR) HAVE_LIBXRANDR="true"], ,
215 216
				$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
		fi
217

218 219 220 221 222 223
		if test "x$with_xfixes" != "xno"; then
			AC_CHECK_LIB(Xfixes, XFixesGetCursorImage,
				X_PRELIBS="$X_PRELIBS -lXfixes"
				[AC_DEFINE(HAVE_LIBXFIXES) HAVE_LIBXFIXES="true"], ,
				$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
		fi
224

225 226 227 228 229 230
		if test "x$with_xdamage" != "xno"; then
			AC_CHECK_LIB(Xdamage, XDamageQueryExtension,
				X_PRELIBS="$X_PRELIBS -lXdamage"
				[AC_DEFINE(HAVE_LIBXDAMAGE) HAVE_LIBXDAMAGE="true"], ,
				$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
		fi
231

232 233 234 235 236 237
		if test ! -z "$HAVE_LIBXFIXES" -o ! -z "$HAVE_LIBXDAMAGE"; then
			# need /usr/sfw/lib in RPATH for Solaris 10 and later
			case `(uname -sr) 2>/dev/null` in
			"SunOS 5"*) X_EXTRA_LIBS="$X_EXTRA_LIBS -R/usr/sfw/lib" ;;
			esac
		fi
238 239 240 241 242 243
		if test ! -z "$HAVE_LIBXRANDR"; then
			# also need /usr/X11/include for Solaris 10 10/08 and later
			case `(uname -sr) 2>/dev/null` in
			"SunOS 5"*) CPPFLAGS="$CPPFLAGS -I/usr/X11/include" ;;
			esac
		fi
244

245
		X_LIBS="$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS"
dscho's avatar
dscho committed
246
	fi
247
	# end x11vnc only.
dscho's avatar
dscho committed
248
fi
249

dscho's avatar
dscho committed
250 251 252
AC_SUBST(X_LIBS)
AM_CONDITIONAL(HAVE_X, test $HAVE_X != "false")

253 254 255 256
# x11vnc only:
if test "$build_x11vnc" = "yes"; then

if test "x$HAVE_X" = "xfalse" -a "x$with_x" != "xno"; then
257 258
	AC_MSG_ERROR([
==========================================================================
259 260 261 262 263 264 265 266
*** A working X window system build environment is required to build ***
x11vnc.  Make sure any required X development packages are installed.
If they are installed in non-standard locations, one can use the
--x-includes=DIR and --x-libraries=DIR configure options or set the
CPPFLAGS and LDFLAGS environment variables to indicate where the X
window system header files and libraries may be found.  On 64+32 bit
machines you may need to point to lib64 or lib32 directories to pick up
the correct word size.
runge's avatar
runge committed
267 268 269 270 271 272 273

If you want to build x11vnc without X support (e.g. for -rawfb use only
or for native Mac OS X), specify the --without-x configure option.
==========================================================================
])
fi

274
if test "x$HAVE_X" = "xtrue" -a "x$HAVE_XTEST" != "xtrue"; then
runge's avatar
runge committed
275 276
	AC_MSG_WARN([
==========================================================================
277
*** A working build environment for the XTEST extension was not found ***
278
(libXtst).  An x11vnc built this way will be *ONLY BARELY USABLE*.
279 280
You will be able to move the mouse but not click or type.  There can
also be deadlocks if an application grabs the X server.
runge's avatar
runge committed
281 282 283 284

It is recommended that you install the necessary development packages
for XTEST (perhaps it is named something like libxtst-dev) and run
configure again.
285 286
==========================================================================
])
287
	sleep 5
288 289
fi

runge's avatar
runge committed
290 291 292 293 294 295 296 297 298 299 300 301 302
# set some ld -R nonsense
#
uname_s=`(uname -s) 2>/dev/null`
ld_minus_R="yes"
if test "x$uname_s" = "xHP-UX"; then
	ld_minus_R="no"
elif test "x$uname_s" = "xOSF1"; then
	ld_minus_R="no"
elif test "x$uname_s" = "xDarwin"; then
	ld_minus_R="no"
fi


303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
AH_TEMPLATE(HAVE_LIBCRYPT, [libcrypt library present])
AC_ARG_WITH(crypt,
[  --without-crypt         disable support for libcrypt],,)
if test "x$with_crypt" != "xno"; then
	AC_CHECK_FUNCS([crypt], HAVE_LIBC_CRYPT="true")
	if test -z "$HAVE_LIBC_CRYPT"; then
		AC_CHECK_LIB(crypt, crypt,
			CRYPT_LIBS="-lcrypt"
			[AC_DEFINE(HAVE_LIBCRYPT)], ,)
	fi
fi
AC_SUBST(CRYPT_LIBS)

# some OS's need both -lssl and -lcrypto on link line:
AH_TEMPLATE(HAVE_LIBCRYPTO, [openssl libcrypto library present])
AC_ARG_WITH(crypto,
[  --without-crypto        disable support for openssl libcrypto],,)

AH_TEMPLATE(HAVE_LIBSSL, [openssl libssl library present])
AC_ARG_WITH(ssl,
runge's avatar
runge committed
323 324
[  --without-ssl           disable support for openssl libssl]
[  --with-ssl=DIR          use openssl include/library files in DIR],,)
325 326

if test "x$with_crypto" != "xno" -a "x$with_ssl" != "xno"; then
runge's avatar
runge committed
327 328 329 330 331 332 333 334 335 336 337 338 339
	if test ! -z "$with_ssl" -a "x$with_ssl" != "xyes"; then
		saved_CPPFLAGS="$CPPFLAGS"
		saved_LDFLAGS="$LDFLAGS"
		CPPFLAGS="$CPPFLAGS -I$with_ssl/include"
		LDFLAGS="$LDFLAGS -L$with_ssl/lib"
		if test "x$ld_minus_R" = "xno"; then
			:
		elif test "x$GCC" = "xyes"; then
			LDFLAGS="$LDFLAGS -Xlinker -R$with_ssl/lib"
		else
			LDFLAGS="$LDFLAGS -R$with_ssl/lib"
		fi
	fi
340 341
	AC_CHECK_LIB(crypto, RAND_file_name,
		[AC_DEFINE(HAVE_LIBCRYPTO) HAVE_LIBCRYPTO="true"], ,)
runge's avatar
runge committed
342 343 344 345 346 347
	if test ! -z "$with_ssl" -a "x$with_ssl" != "xyes"; then
		if test "x$HAVE_LIBCRYPTO" != "xtrue"; then
			CPPFLAGS="$saved_CPPFLAGS"
			LDFLAGS="$saved_LDFLAGS"
		fi
	fi
348 349
fi

350
AH_TEMPLATE(HAVE_X509_PRINT_EX_FP, [open ssl X509_print_ex_fp available])
351 352 353 354 355 356 357 358 359 360 361 362 363 364
if test "x$with_ssl" != "xno"; then
	if test "x$HAVE_LIBCRYPTO" = "xtrue"; then
		AC_CHECK_LIB(ssl, SSL_library_init,
			SSL_LIBS="-lssl -lcrypto"
			[AC_DEFINE(HAVE_LIBSSL) HAVE_LIBSSL="true"], ,
			-lcrypto)
	else
		AC_CHECK_LIB(ssl, SSL_library_init,
			SSL_LIBS="-lssl"
			[AC_DEFINE(HAVE_LIBSSL) HAVE_LIBSSL="true"], ,)
	fi
fi
AC_SUBST(SSL_LIBS)

runge's avatar
runge committed
365
	if test "x$HAVE_LIBSSL" != "xtrue" -a "x$with_ssl" != "xno"; then
runge's avatar
runge committed
366 367
		AC_MSG_WARN([
==========================================================================
368 369 370 371
*** The openssl encryption library libssl.so was not found. ***
An x11vnc built this way will not support SSL encryption.  To enable
SSL install the necessary development packages (perhaps it is named
something like libssl-dev) and run configure again.
runge's avatar
runge committed
372 373
==========================================================================
])
374
		sleep 5
runge's avatar
runge committed
375
	elif test "x$with_ssl" != "xno"; then
376 377 378
		AC_CHECK_LIB(ssl, X509_print_ex_fp, 
			[AC_DEFINE(HAVE_X509_PRINT_EX_FP) HAVE_X509_PRINT_EX_FP="true"], , $SSL_LIBS
			)
runge's avatar
runge committed
379 380
	fi

381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
if test "x$with_v4l" != "xno"; then
	AC_CHECK_HEADER(linux/videodev.h,
		[AC_DEFINE(HAVE_LINUX_VIDEODEV_H)],,)
fi
if test "x$with_fbdev" != "xno"; then
	AC_CHECK_HEADER(linux/fb.h,
		[AC_DEFINE(HAVE_LINUX_FB_H)],,)
fi
if test "x$with_uinput" != "xno"; then
	AC_CHECK_HEADER(linux/input.h,
		[AC_DEFINE(HAVE_LINUX_INPUT_H) HAVE_LINUX_INPUT_H="true"],,)
	if test "x$HAVE_LINUX_INPUT_H" = "xtrue"; then
		AC_CHECK_HEADER(linux/uinput.h,
			[AC_DEFINE(HAVE_LINUX_UINPUT_H)],, [#include <linux/input.h>])
	fi
fi

398 399 400 401
if test "x$with_macosx_native" != "xno"; then
	AC_DEFINE(HAVE_MACOSX_NATIVE_DISPLAY)
fi

402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
AH_TEMPLATE(HAVE_AVAHI, [Avahi/mDNS client build environment present])
AC_ARG_WITH(avahi,
[  --without-avahi         disable support for Avahi/mDNS]
[  --with-avahi=DIR        use avahi include/library files in DIR],,)
if test "x$with_avahi" != "xno"; then
	printf "checking for avahi... "
	if test ! -z "$with_avahi" -a "x$with_avahi" != "xyes"; then
		AVAHI_CFLAGS="-I$with_avahi/include"
		AVAHI_LIBS="-L$with_avahi/lib -lavahi-common -lavahi-client"
		echo "using $with_avahi"
		with_avahi=yes
	elif pkg-config --atleast-version=0.6.4 avahi-client >/dev/null 2>&1; then
		AVAHI_CFLAGS=`pkg-config --cflags avahi-client`
		AVAHI_LIBS=`pkg-config --libs avahi-client`
		with_avahi=yes
		echo yes
	else
		with_avahi=no
		echo no
	fi
fi
if test "x$with_avahi" = "xyes"; then
	AC_DEFINE(HAVE_AVAHI)
	AC_SUBST(AVAHI_CFLAGS)
	AC_SUBST(AVAHI_LIBS)
fi

429 430 431 432 433
fi
# end x11vnc only.

# Checks for libraries.

434 435
if test ! -z "$with_system_libvncserver" -a "x$with_system_libvncserver" != "xno"; then
	printf "checking for system libvncserver... "
436
	vneed="0.9.1"
437 438 439
	if test "X$VNEED" != "X"; then
		vneed=$VNEED
	fi
440 441 442 443 444 445 446 447 448
	if test "x$with_system_libvncserver" != "xyes"; then
		rflag=""
		if test "x$ld_minus_R" = "xno"; then
			:
		elif test "x$GCC" = "xyes"; then
			rflag="-Xlinker -R$with_system_libvncserver/lib"
		else
			rflag="-R$with_system_libvncserver/lib"
		fi
449 450 451 452 453 454 455 456 457
		cmd="$with_system_libvncserver/bin/libvncserver-config"
		if $cmd --version 1>/dev/null 2>&1; then
			cvers=`$cmd --version 2>/dev/null`
			cscore=`echo "$cvers" | tr '.' ' ' | awk '{print 10000 * $1 + 100 * $2 + $3}'`
			nscore=`echo "$vneed" | tr '.' ' ' | awk '{print 10000 * $1 + 100 * $2 + $3}'`

			if test $cscore -lt $nscore; then
				echo "no"
				with_system_libvncserver=no
458
				AC_MSG_ERROR([
459 460 461
==========================================================================
*** Need libvncserver version $vneed, have version $cvers ***
You are building with a system installed libvncserver and it is not
462
new enough.
463 464 465 466 467 468 469 470 471 472 473 474 475 476
==========================================================================
])
			else
				SYSTEM_LIBVNCSERVER_CFLAGS="-I$with_system_libvncserver/include"
				SYSTEM_LIBVNCSERVER_LIBS="-L$with_system_libvncserver/lib $rflag -lvncserver -lvncclient"
				echo "using $with_system_libvncserver"
				with_system_libvncserver=yes
			fi
		else
			echo " *** cannot run $cmd *** " 1>&2
			with_system_libvncserver=no
			echo no
		fi
	elif libvncserver-config --version 1>/dev/null 2>&1; then
477 478 479 480 481 482 483 484 485
		rflag=""
		rprefix=`libvncserver-config --prefix`
		if test "x$ld_minus_R" = "xno"; then
			:
		elif test "x$GCC" = "xyes"; then
			rflag=" -Xlinker -R$rprefix/lib "
		else
			rflag=" -R$rprefix/lib "
		fi
486 487 488 489 490 491
		cvers=`libvncserver-config --version 2>/dev/null`
		cscore=`echo "$cvers" | tr '.' ' ' | awk '{print 10000 * $1 + 100 * $2 + $3}'`
		nscore=`echo "$vneed" | tr '.' ' ' | awk '{print 10000 * $1 + 100 * $2 + $3}'`

		if test $cscore -lt $nscore; then
			echo "no"
492
				AC_MSG_ERROR([
493 494 495
==========================================================================
*** Need libvncserver version $vneed, have version $cvers ***
You are building with a system installed libvncserver and it is not
496
new enough.
497 498 499 500 501 502 503 504
==========================================================================
])
		else
			SYSTEM_LIBVNCSERVER_CFLAGS=`libvncserver-config --cflags`
			SYSTEM_LIBVNCSERVER_LIBS="$rflag"`libvncserver-config --libs`
			with_system_libvncserver=yes
			echo yes
		fi
505 506 507 508 509 510 511 512 513 514 515 516 517
	else
		with_system_libvncserver=no
		echo no
	fi
fi

if test "x$with_system_libvncserver" = "xyes"; then
	AC_DEFINE(HAVE_SYSTEM_LIBVNCSERVER)
	AC_SUBST(SYSTEM_LIBVNCSERVER_CFLAGS)
	AC_SUBST(SYSTEM_LIBVNCSERVER_LIBS)
fi
AM_CONDITIONAL(HAVE_SYSTEM_LIBVNCSERVER, test "x$with_system_libvncserver" = "xyes")

518

519
AC_ARG_WITH(jpeg,
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535
[  --without-jpeg          disable support for jpeg]
[  --with-jpeg=DIR         use jpeg include/library files in DIR],,)

# At this point:
#	no jpeg on command line   with_jpeg=""
#	-with-jpeg                with_jpeg="yes"
#	-without-jpeg             with_jpeg="no"
#	-with-jpeg=/foo/dir       with_jpeg="/foo/dir"

if test "x$with_jpeg" != "xno"; then
	if test ! -z "$with_jpeg" -a "x$with_jpeg" != "xyes"; then
		# add user supplied directory to flags:
		saved_CPPFLAGS="$CPPFLAGS"
		saved_LDFLAGS="$LDFLAGS"
		CPPFLAGS="$CPPFLAGS -I$with_jpeg/include"
		LDFLAGS="$LDFLAGS -L$with_jpeg/lib"
536
		if test "x$ld_minus_R" = "xno"; then
537 538
			:
		elif test "x$GCC" = "xyes"; then
539 540 541 542 543 544
			# this is not complete... in general a rat's nest.
			LDFLAGS="$LDFLAGS -Xlinker -R$with_jpeg/lib"
		else
			LDFLAGS="$LDFLAGS -R$with_jpeg/lib"
		fi
	fi
545
	AC_CHECK_HEADER(jpeglib.h, HAVE_JPEGLIB_H="true")
546 547 548 549 550 551 552 553 554 555
	if test "x$HAVE_JPEGLIB_H" = "xtrue"; then
		AC_CHECK_LIB(jpeg, jpeg_CreateCompress, , HAVE_JPEGLIB_H="")
	fi
	if test ! -z "$with_jpeg" -a "x$with_jpeg" != "xyes"; then
		if test "x$HAVE_JPEGLIB_H" != "xtrue"; then
			# restore old flags on failure:
			CPPFLAGS="$saved_CPPFLAGS"
			LDFLAGS="$saved_LDFLAGS"
		fi
	fi
556
	if test "$build_x11vnc" = "yes"; then
557 558
		if test "x$HAVE_JPEGLIB_H" != "xtrue"; then
			AC_MSG_WARN([
559
==========================================================================
560 561 562 563 564 565
*** The libjpeg compression library was not found. ***
This may lead to reduced performance, especially over slow links.
If libjpeg is in a non-standard location use --with-jpeg=DIR to
indicate the header file is in DIR/include/jpeglib.h and the library
in DIR/lib/libjpeg.a.  A copy of libjpeg may be obtained from:
ftp://ftp.uu.net/graphics/jpeg/
566
==========================================================================
567
])
568
			sleep 5
569 570
		fi
	fi
571
fi
572

573
AC_ARG_WITH(libz,
574 575 576 577 578 579 580 581 582 583 584
[  --without-libz          disable support for deflate],,)
AC_ARG_WITH(zlib,
[  --without-zlib          disable support for deflate]
[  --with-zlib=DIR         use zlib include/library files in DIR],,)

if test "x$with_zlib" != "xno" -a "x$with_libz" != "xno"; then
	if test ! -z "$with_zlib" -a "x$with_zlib" != "xyes"; then
		saved_CPPFLAGS="$CPPFLAGS"
		saved_LDFLAGS="$LDFLAGS"
		CPPFLAGS="$CPPFLAGS -I$with_zlib/include"
		LDFLAGS="$LDFLAGS -L$with_zlib/lib"
585
		if test "x$ld_minus_R" = "xno"; then
586 587
			:
		elif test "x$GCC" = "xyes"; then
588 589 590 591 592
			LDFLAGS="$LDFLAGS -Xlinker -R$with_zlib/lib"
		else
			LDFLAGS="$LDFLAGS -R$with_zlib/lib"
		fi
	fi
593
	AC_CHECK_HEADER(zlib.h, HAVE_ZLIB_H="true")
594 595 596 597 598 599 600 601
	if test "x$HAVE_ZLIB_H" = "xtrue"; then
		AC_CHECK_LIB(z, deflate, , HAVE_ZLIB_H="")
	fi
	if test ! -z "$with_zlib" -a "x$with_zlib" != "xyes"; then
		if test "x$HAVE_ZLIB_H" != "xtrue"; then
			CPPFLAGS="$saved_CPPFLAGS"
			LDFLAGS="$saved_LDFLAGS"
		fi
602
	fi
603
	if test "$build_x11vnc" = "yes"; then
604 605
		if test "x$HAVE_ZLIB_H" != "xtrue"; then
			AC_MSG_WARN([
606
==========================================================================
607 608 609 610 611
*** The libz compression library was not found. ***
This may lead to reduced performance, especially over slow links.
If libz is in a non-standard location use --with-zlib=DIR to indicate the
header file is in DIR/include/zlib.h and the library in DIR/lib/libz.a.
A copy of libz may be obtained from: http://www.gzip.org/zlib/
612
==========================================================================
613
])
614
			sleep 5
615 616
		fi
	fi
dscho's avatar
dscho committed
617
fi
618

619 620
AC_ARG_WITH(pthread,
[  --without-pthread       disable support for libpthread],,)
621

622 623 624 625 626 627 628
if test "x$with_pthread" != "xno"; then
	AC_CHECK_HEADER(pthread.h, HAVE_PTHREAD_H="true")
	if test ! -z "$HAVE_PTHREAD_H"; then
		AC_CHECK_LIB(pthread, pthread_mutex_lock)
		AC_CHECK_LIB(pthread, pthread_mutex_lock, HAVE_LIBPTHREAD="true")
	fi
fi
dscho's avatar
dscho committed
629
AM_CONDITIONAL(HAVE_LIBPTHREAD, test ! -z "$HAVE_LIBPTHREAD")
630 631 632 633 634 635 636 637 638 639

# tightvnc-filetransfer implemented using threads:
if test -z "$HAVE_LIBPTHREAD"; then
	with_tightvnc_filetransfer=""
fi
if test "x$with_tightvnc_filetransfer" = "xyes"; then
	AC_DEFINE(WITH_TIGHTVNC_FILETRANSFER)
fi
AM_CONDITIONAL(WITH_TIGHTVNC_FILETRANSFER, test "$with_tightvnc_filetransfer" = "yes")

640
AM_CONDITIONAL(HAVE_LIBZ, test ! -z "$HAVE_ZLIB_H")
641
AM_CONDITIONAL(HAVE_LIBJPEG, test ! -z "$HAVE_JPEGLIB_H")
642

643
if test -z "$with_sdl"; then
dscho's avatar
dscho committed
644
	if sdl-config --version >/dev/null 2>&1; then
645
		with_sdl=yes
dscho's avatar
dscho committed
646 647
		SDL_CFLAGS=`sdl-config --cflags`
		SDL_LIBS=`sdl-config --libs`
648 649 650 651 652
	else
		with_sdl=no
	fi
fi
AM_CONDITIONAL(HAVE_LIBSDL, test "x$with_sdl" = "xyes")
dscho's avatar
dscho committed
653 654
AC_SUBST(SDL_CFLAGS)
AC_SUBST(SDL_LIBS)
dscho's avatar
dscho committed
655

dscho's avatar
dscho committed
656 657 658 659 660 661 662
MINGW=`uname -s | grep MINGW 2>/dev/null`
AM_CONDITIONAL(MINGW, test ! -z "$MINGW" )
if test ! -z "$MINGW"; then
	WSOCKLIB="-lws2_32"
fi
AC_SUBST(WSOCKLIB)

dscho's avatar
dscho committed
663 664
# Checks for header files.
AC_HEADER_STDC
665 666 667 668 669 670
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])

# x11vnc only:
if test "$build_x11vnc" = "yes"; then
	AC_CHECK_HEADERS([pwd.h sys/wait.h utmpx.h termios.h sys/ioctl.h sys/stropts.h])
fi
dscho's avatar
dscho committed
671 672 673 674

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
675
AC_C_BIGENDIAN
dscho's avatar
dscho committed
676 677
AC_TYPE_SIZE_T
AC_HEADER_TIME
dscho's avatar
dscho committed
678
AC_HEADER_SYS_WAIT
679
AC_TYPE_SOCKLEN_T
680 681 682 683
if test ! -d ./rfb; then
	echo "creating subdir ./rfb for rfbint.h"
	mkdir ./rfb 
fi
dscho's avatar
dscho committed
684
AC_CREATE_STDINT_H(rfb/rfbint.h)
dscho's avatar
dscho committed
685
AC_CACHE_CHECK([for in_addr_t],
686
        vnc_cv_inaddrt, [
dscho's avatar
dscho committed
687 688 689 690 691 692
                AC_TRY_COMPILE([#include <sys/types.h>
#include <netinet/in.h>],
                        [in_addr_t foo; return 0;],
                                        [inaddrt=yes],
                                        [inaddrt=no]),
        ])
693
AH_TEMPLATE(NEED_INADDR_T, [Need a typedef for in_addr_t])
dscho's avatar
dscho committed
694
if test $inaddrt = no ; then
695
  AC_DEFINE(NEED_INADDR_T)
dscho's avatar
dscho committed
696
fi
dscho's avatar
dscho committed
697 698 699 700 701 702

# Checks for library functions.
AC_FUNC_MEMCMP
AC_FUNC_STAT
AC_FUNC_STRFTIME
AC_FUNC_VPRINTF
703
AC_FUNC_FORK
704 705
AC_CHECK_LIB(nsl,gethostbyname)
AC_CHECK_LIB(socket,socket)
706 707 708 709 710 711 712

uname_s=`(uname -s) 2>/dev/null`
if test "x$uname_s" = "xHP-UX"; then
	# need -lsec for getspnam()
	LDFLAGS="$LDFLAGS -lsec"
fi

713 714 715
AC_CHECK_FUNCS([ftime gethostbyname gethostname gettimeofday inet_ntoa memmove memset mmap mkfifo select socket strchr strcspn strdup strerror strstr])
# x11vnc only:
if test "$build_x11vnc" = "yes"; then
716
	AC_CHECK_FUNCS([setsid setpgrp getpwuid getpwnam getspnam getuid geteuid setuid setgid seteuid setegid initgroups waitpid setutxent grantpt shmat])
717
fi
dscho's avatar
dscho committed
718

dscho's avatar
dscho committed
719 720 721 722
# check, if shmget is in cygipc.a
AC_CHECK_LIB(cygipc,shmget)
AM_CONDITIONAL(CYGIPC, test "$HAVE_CYGIPC" = "true")

dscho's avatar
dscho committed
723 724 725
# Check if /dev/vcsa1 exists, if so, define LINUX
AM_CONDITIONAL(LINUX, test -c /dev/vcsa1)

dscho's avatar
dscho committed
726 727 728 729
# Check for OS X specific header
AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h, HAVE_OSX="true")
AM_CONDITIONAL(OSX, test "$HAVE_OSX" = "true")

730 731 732 733 734 735 736 737
# On Solaris 2.7, write() returns ENOENT when it really means EAGAIN
AH_TEMPLATE(ENOENT_WORKAROUND, [work around when write() returns ENOENT but does not mean it])
case `(uname -sr) 2>/dev/null` in
    "SunOS 5.7")
	AC_DEFINE(ENOENT_WORKAROUND)
    ;;
esac

738
# Check for rpm SOURCES path
739
printf "checking for rpm sources path... "
740 741 742 743 744 745 746 747
RPMSOURCEDIR="NOT-FOUND"
for directory in packages OpenLinux redhat RedHat rpm RPM "" ; do
	if test -d /usr/src/${directory}/SOURCES; then
		RPMSOURCEDIR="/usr/src/${directory}/SOURCES/"
	fi
done
echo "$RPMSOURCEDIR"
AM_CONDITIONAL(HAVE_RPM, test "$RPMSOURCEDIR" != "NOT-FOUND")
748
AM_CONDITIONAL(WITH_X11VNC,  test "$build_x11vnc" = "yes")
749 750
AC_SUBST(RPMSOURCEDIR)

dscho's avatar
dscho committed
751
AC_CONFIG_FILES([Makefile
752 753 754 755 756 757 758 759 760 761 762
	libvncserver/Makefile
	contrib/Makefile
	examples/Makefile
	vncterm/Makefile
	classes/Makefile
	classes/ssl/Makefile
	libvncclient/Makefile
	client_examples/Makefile
	test/Makefile
	libvncserver-config
	LibVNCServer.spec])
763
#
764
# x11vnc only:
765
#
766
if test "$build_x11vnc" = "yes"; then
767 768 769 770 771 772 773 774 775 776
	#
	# NOTE: if you are using the LibVNCServer-X.Y.Z.tar.gz source
	# tarball and nevertheless want to run autoconf (i.e. aclocal,
	# autoheader, automake, autoconf) AGAIN (perhaps you have a
	# special target system, e.g. embedded) then you will need to
	# comment out the following 'AC_CONFIG_FILES' line to avoid
	# automake error messages like:
	#
	# configure.ac:690: required file `x11vnc/Makefile.in' not found
	#
777
	AC_CONFIG_FILES([x11vnc/Makefile x11vnc/misc/Makefile x11vnc/misc/turbovnc/Makefile])
778 779
fi

780
AC_CONFIG_COMMANDS([chmod-libvncserver-config],[chmod a+x libvncserver-config])
dscho's avatar
dscho committed
781
AC_OUTPUT
782 783
chmod a+x ./libvncserver-config