summaryrefslogtreecommitdiffstats
path: root/configure.ac
blob: 560f5fc940e33c144d94416b16e2031f6e8a6c47 (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
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ([2.57])
AC_INIT([tigervnc], [1.0.90], [http://www.tigervnc.org])
BUILD=`date +%Y%m%d`
AC_CONFIG_AUX_DIR([.])
AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])

AC_CONFIG_SUBDIRS([common/jpeg common/zlib])

AC_CONFIG_HEADERS([config.h])

dnl Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_PROG_LIBTOOL
AC_LANG([C++])
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION([0.14.1])

case "`(uname -sr) 2>/dev/null`" in
"SunOS 5"*)
	SOLARIS=yes
	USE_MITSHM=yes
	USE_SUN_OVL=yes
	;;
"IRIX 6"*)
	LDFLAGS="-L/usr/lib32 $LDFLAGS"
	USE_MITSHM=yes
	USE_READDISPLAY=yes
	;;
"LynxOS 2"*)
	SJLJ_EXCEPTIONS=yes
	;;
esac

BUILD_WIN=
case "$host_os" in
mingw*)
	CPPFLAGS="$CPPFLAGS -DWINVER=0x0500 -D_WIN32_IE=0x0500"
	CXXFLAGS="$CXXFLAGS -mthreads"
	BUILD_WIN=yes
	AC_CHECK_TOOL([WINDRES], windres, [AC_MSG_ERROR(windres not found)])
	;;
esac
AM_CONDITIONAL([BUILD_WIN], [test "x$BUILD_WIN" = xyes])

dnl FIXME: Check for MIT-SHM properly, add a corresponding --with option.
if test "$USE_MITSHM" = yes; then
	MITSHM_DEFINE="-DHAVE_MITSHM"
fi
AC_SUBST(MITSHM_DEFINE)

if test "$GCC" = yes; then
	CFLAGS="$CFLAGS -Wall"
	if test "$SOLARIS" = yes; then
		CFLAGS="$CFLAGS -Wno-unknown-pragmas -Wno-implicit-int"
	fi
fi
if test "$GXX" = yes; then
	CXXFLAGS="$CXXFLAGS -Wall"
	if test "$SOLARIS" = yes; then
		CXXFLAGS="$CXXFLAGS -Wno-unknown-pragmas -fpermissive"
	fi
	if test "$SJLJ_EXCEPTIONS" = yes; then
		CXXFLAGS="$CXXFLAGS -fsjlj-exceptions"
	fi
fi

AC_PATH_XTRA

dnl Check gnutls availability
AC_ARG_ENABLE([gnutls],
	AS_HELP_STRING([--enable-gnutls],
		       [build in GNUTLS based encryption support (default yes)]),
	[enable_gnutls="$enableval"], [enable_gnutls=yes])
AC_ARG_VAR(GNUTLS_CFLAGS, [Custom C compiler flags for using GnuTLS, e.g. -I{GnuTLS directory}/include])
AC_ARG_VAR(GNUTLS_LDFLAGS, [Custom linker flags for using GnuTLS, e.g. -L{GnuTLS directory}/lib -lgnutls])

GNUTLS_LIBS=
if test "x$enable_gnutls" = xyes; then
	if test "x$GNUTLS_LDFLAGS" = "x"; then
		GNUTLS_LDFLAGS='-lgnutls -lgcrypt -lgpg-error'
	fi
	SAVE_LIBS=${LIBS}
	LIBS="${LIBS} ${GNUTLS_LDFLAGS}"
	SAVE_CPPFLAGS=${CPPFLAGS}
	CPPFLAGS="${CPPFLAGS} ${GNUTLS_CFLAGS}"
	AC_MSG_CHECKING([for GnuTLS library])
	AC_LINK_IFELSE(AC_LANG_CALL([], gnutls_global_init),
		       [GNUTLS_LIBS=${GNUTLS_LDFLAGS}
			AC_DEFINE(HAVE_GNUTLS, 1, [Is gnutls present? ])
			AC_MSG_RESULT(yes)], AC_MSG_RESULT(no))
	AC_MSG_CHECKING([for gnutls_transport_set_global_errno() function])
	AC_LINK_IFELSE(AC_LANG_CALL([], gnutls_transport_set_global_errno),
		       AC_MSG_RESULT(yes),
		       [AC_DEFINE(HAVE_OLD_GNUTLS, 1, [Does gnutls lack the gnutls_transport_set_global_errno() function? ])
			AC_MSG_RESULT(no)])
	LIBS=${SAVE_LIBS}
fi
AC_SUBST([GNUTLS_LIBS])
AM_CONDITIONAL([HAVE_GNUTLS], [ ! test "x$GNUTLS_LIBS" = x ])

AC_CHECK_LIB([pam], [pam_start], 
	     [AC_CHECK_HEADER([security/pam_appl.h],
			     [PAM_LIBS='-lpam'
			      AC_DEFINE(HAVE_PAM, 1, [PAM available])],
			     [], [#include <stdio.h>])])
AC_SUBST([PAM_LIBS])
AM_CONDITIONAL([HAVE_PAM], [ ! test "x$PAM_LIBS" = x ])

VNCCONFIG_DIR='vncconfig'
AC_ARG_ENABLE([vncconfig],
	AS_HELP_STRING([--enable-vncconfig],
		       [build the vncconfig utility (default yes)]),
	[if test "$enableval" = no; then VNCCONFIG_DIR=; fi ], [])
AC_SUBST(VNCCONFIG_DIR)

dnl Check for the XTest X11 extension library.
AC_CHECK_LIB(Xtst,XTestGrabControl,USE_XTEST=yes,USE_XTEST=,
	     ["$X_LIBS" -lXext -lX11])
if test "$USE_XTEST" = yes; then
	XTEST_DEFINE='-DHAVE_XTEST'
	XTEST_LIB=-lXtst
else
	echo Warning: No XTest extension, building x0vncserver view-only
	XTEST_DEFINE=
	XTEST_LIB=
fi
AC_SUBST(XTEST_DEFINE)
AC_SUBST(XTEST_LIB)

dnl Support for READDISPLAY (Irix) and SUN_OVL (Solaris) extensions
dnl FIXME: Implement corresponding --with options.
if test "$USE_READDISPLAY" = yes; then
	READDISPLAY_DEFINE='-DHAVE_READDISPLAY'
elif test "$USE_SUN_OVL" = yes; then
	READDISPLAY_DEFINE='-DHAVE_SUN_OVL'
else
	READDISPLAY_DEFINE=
fi
AC_SUBST(READDISPLAY_DEFINE)

dnl Under Lynx/OS 2.3, we have to link with -lbsd to resolve
dnl gethostbyname, inet_addr, htons etc. Check if it's necessary.
dnl NOTE: Did not want to use AC_SEARCH_LIBS which would add
dnl   -lbsd to LIBS. We set INET_LIB instead.
AC_LANG_SAVE
AC_LANG_C
AC_CHECK_FUNC(gethostbyname,INET_LIB_REQ=,INET_LIB_REQ=yes)
if test "$INET_LIB_REQ" = yes; then
	AC_CHECK_LIB(bsd,gethostbyname,INET_LIB=-lbsd,INET_LIB=)
fi
AC_LANG_RESTORE
AC_SUBST(INET_LIB)

dnl Check for zlib library
INCLUDED_ZLIB=no
AC_ARG_WITH([included-zlib],
	AS_HELP_STRING([--with-included-zlib],
		       [use libz which is distributed with VNC]),
	[INCLUDED_ZLIB=yes],
	[AC_SEARCH_LIBS([inflateEnd], [z], [], [INCLUDED_ZLIB=yes])])

AM_CONDITIONAL([INCLUDED_ZLIB], [ test "x$INCLUDED_ZLIB" = xyes ])
AC_CONFIG_SUBDIRS([zlib])

dnl Check for libjpeg library
INCLUDED_JPEG=yes
AC_ARG_WITH([system-jpeg],
	AS_HELP_STRING([--with-system-jpeg], 
		       [use libjpeg which is distributed with the O/S]),
	[AC_SEARCH_LIBS([jpeg_destroy_compress], [jpeg],
			[INCLUDED_JPEG=no], [])],
	[])

AM_CONDITIONAL([INCLUDED_JPEG], [ test "x$INCLUDED_JPEG" = xyes ])
AC_CONFIG_SUBDIRS([jpeg])

AC_CHECK_FUNCS([vsnprintf snprintf strcasecmp strncasecmp])

# Network functions
AC_SEARCH_LIBS([inet_aton], [resolv])
AC_CHECK_FUNCS([inet_aton])

# IPv6 related functions
AC_CHECK_FUNCS([inet_ntop getaddrinfo])

AC_CHECK_TYPES([socklen_t], [], [], [[#include <sys/socket.h>]])

AC_CHECK_HEADERS([sys/select.h])

# Needed for WinVNC, but not part of mingw yet
AC_CHECK_DECLS([CLSID_ActiveDesktop], [BUILD_WINVNC=yes], [],
	       [[#include <windows.h>
	         #include <shlguid.h>
	         ]])
AM_CONDITIONAL([BUILD_WINVNC], [ test "x$BUILD_WINVNC" = xyes ])

# Packaging stuff
AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64"])

AC_SUBST(BUILD)

AC_OUTPUT([
Makefile
common/Makefile
common/os/Makefile
common/rdr/Makefile
common/network/Makefile
common/Xregion/Makefile
common/rfb/Makefile
unix/Makefile
unix/tx/Makefile
unix/x0vncserver/Makefile
unix/vncviewer/Makefile
unix/vncconfig/Makefile
unix/vncpasswd/Makefile
win/Makefile
win/vncviewer/Makefile
win/rfb_win32/Makefile
win/vncconfig/Makefile
win/winvnc/Makefile
po/Makefile.in
])