]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - configure.ac
GTK3 port: add '--with-gtk=3' to the configure script.
[PuTTY.git] / configure.ac
1 # To compile this into a configure script, you need:
2 # * Autoconf 2.50 or newer
3 # * Gtk (for $prefix/share/aclocal/gtk.m4)
4 # * Automake (for aclocal)
5 # If you've got them, running "autoreconf" should work.
6
7 # Version number is substituted by Buildscr for releases, snapshots
8 # and custom builds out of svn; X.XX shows up in ad-hoc developer
9 # builds, which shouldn't matter
10 AC_INIT(putty, X.XX)
11 AC_CONFIG_FILES([Makefile])
12 AC_CONFIG_HEADERS([uxconfig.h:uxconfig.in])
13 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
14
15 AC_PROG_INSTALL
16 AC_PROG_RANLIB
17 ifdef([AM_PROG_AR],[AM_PROG_AR])
18 AM_PROG_CC_C_O
19
20 # Mild abuse of the '--enable' option format to allow manual
21 # specification of setuid or setgid setup in pterm.
22 setidtype=none
23 AC_ARG_ENABLE([setuid],
24             [AS_HELP_STRING([--enable-setuid=USER],
25                             [make pterm setuid to a given user])],
26             [case "$enableval" in
27                no) setidtype=none;;
28                *) setidtype=setuid; setidval="$enableval";;
29              esac])
30 AC_ARG_ENABLE([setgid],
31             [AS_HELP_STRING([--enable-setgid=GROUP],
32                             [make pterm setgid to a given group])],
33             [case "$enableval" in
34                no) setidtype=none;;
35                *) setidtype=setgid; setidval="$enableval";;
36              esac])
37 AM_CONDITIONAL(HAVE_SETID_CMD, [test "$setidtype" != "none"])
38 AS_IF([test "x$setidtype" = "xsetuid"],
39       [SETID_CMD="chown $setidval"; SETID_MODE="4755"])
40 AS_IF([test "x$setidtype" = "xsetgid"],
41       [SETID_CMD="chgrp $setidval"; SETID_MODE="2755"])
42 AC_SUBST(SETID_CMD)
43 AC_SUBST(SETID_MODE)
44
45 AC_ARG_WITH([gssapi],
46   [AS_HELP_STRING([--without-gssapi],
47                   [disable GSSAPI support])],
48   [],
49   [with_gssapi=yes])
50
51 WITH_GSSAPI=
52 AS_IF([test "x$with_gssapi" != xno],
53   [AC_DEFINE([WITH_GSSAPI], [1], [Define if building with GSSAPI support.])])
54
55 AC_ARG_WITH([gtk],
56   [AS_HELP_STRING([--with-gtk=VER],
57                   [specify GTK version to use (`1', `2' or `3')])
58 AS_HELP_STRING([--without-gtk],
59                   [do not use GTK (build command-line tools only)])],
60   [gtk_version_desired="$withval"],
61   [gtk_version_desired="any"])
62
63 case "$gtk_version_desired" in
64   1 | 2 | 3 | any | no) ;;
65   yes) gtk_version_desired="any" ;;
66   *) AC_ERROR([Invalid GTK version specified])
67 esac
68
69 AC_CHECK_HEADERS([utmpx.h sys/select.h],,,[
70 #include <sys/types.h>
71 #include <utmp.h>])
72
73 # Look for GTK 2, GTK 3 and GTK 1, in descending order of preference.
74 #
75 # (I like GTK 2 for its faster support for X server-side fonts due to
76 # not being required to do all its drawing via Cairo; GTK 3 is
77 # tolerable if GTK 2 can't be had, and GTK 1 is an extreme fallback
78 # for platforms - of which I've heard of at least one - to which
79 # nothing newer has ever been ported.)
80 #
81 # If we can't find any, have the makefile only build the CLI programs.
82
83 gtk=none
84
85 case "$gtk_version_desired:$gtk" in
86   2:none | any:none)
87     ifdef([AM_PATH_GTK_2_0],[
88     AM_PATH_GTK_2_0([2.0.0], [gtk=2], [])
89     ],[AC_WARNING([generating configure script without GTK 2 autodetection])])
90     ;;
91 esac
92
93 case "$gtk_version_desired:$gtk" in
94   3:none | any:none)
95     ifdef([AM_PATH_GTK_3_0],[
96     AM_PATH_GTK_3_0([3.0.0], [
97     gtk=3
98     GTK_CFLAGS="$GTK_CFLAGS -Wno-deprecated-declarations"
99     ], [])
100     ],[AC_WARNING([generating configure script without GTK 3 autodetection])])
101     ;;
102 esac
103
104 case "$gtk_version_desired:$gtk" in
105   1:none | any:none)
106     ifdef([AM_PATH_GTK],[
107     AM_PATH_GTK([1.2.0], [gtk=1], [])
108     ],[
109     # manual check for gtk1
110     AC_PATH_PROG(GTK1_CONFIG, gtk-config, absent)
111     if test "$GTK1_CONFIG" != "absent"; then
112       GTK_CFLAGS=`"$GTK1_CONFIG" --cflags`
113       GTK_LIBS=`"$GTK1_CONFIG" --libs`
114       gtk=1
115     fi
116     ])
117     ;;
118 esac
119
120 AM_CONDITIONAL(HAVE_GTK, [test "$gtk" != "none"])
121
122 if test "$gtk" = "2" -o "$gtk" = "3"; then
123   ac_save_CFLAGS="$CFLAGS"
124   ac_save_LIBS="$LIBS"
125   CFLAGS="$CFLAGS $GTK_CFLAGS"
126   LIBS="$GTK_LIBS $LIBS"
127   AC_CHECK_FUNCS([pango_font_family_is_monospace pango_font_map_list_families])
128   CFLAGS="$ac_save_CFLAGS"
129   LIBS="$ac_save_LIBS"
130 fi
131
132 AC_SEARCH_LIBS([socket], [xnet])
133
134 AS_IF([test "x$with_gssapi" != xno],
135   [AC_SEARCH_LIBS(
136     [dlopen],[dl],
137     [],
138     [AC_DEFINE([NO_LIBDL], [1], [Define if we could not find libdl.])
139      AC_CHECK_HEADERS([gssapi/gssapi.h])
140      AC_SEARCH_LIBS(
141        [gss_init_sec_context],[gssapi gssapi_krb5 gss],
142        [],
143        [AC_DEFINE([NO_GSSAPI_LIB], [1], [Define if we could not find a gssapi library])])])])
144
145 AC_CHECK_LIB(X11, XOpenDisplay,
146              [GTK_LIBS="-lX11 $GTK_LIBS"
147               AC_DEFINE([HAVE_LIBX11],[],[Define if libX11.a is available])])
148
149 AC_CHECK_FUNCS([getaddrinfo posix_openpt ptsname setresuid strsignal updwtmpx])
150 AC_CHECK_DECLS([CLOCK_MONOTONIC], [], [], [[#include <time.h>]])
151 AC_SEARCH_LIBS([clock_gettime], [rt], [AC_DEFINE([HAVE_CLOCK_GETTIME],[],[Define if clock_gettime() is available])])
152
153 AC_CACHE_CHECK([for SO_PEERCRED and dependencies], [x_cv_linux_so_peercred], [
154     AC_COMPILE_IFELSE([
155         AC_LANG_PROGRAM([[
156             #define _GNU_SOURCE
157             #include <features.h>
158             #include <sys/socket.h>
159           ]],[[
160             struct ucred cr;
161             socklen_t crlen = sizeof(cr);
162             return getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cr, &crlen) +
163             cr.pid + cr.uid + cr.gid;
164           ]]
165         )],
166         AS_VAR_SET(x_cv_linux_so_peercred, yes),
167         AS_VAR_SET(x_cv_linux_so_peercred, no)
168     )
169 ])
170 AS_IF([test AS_VAR_GET(x_cv_linux_so_peercred) = yes],
171     [AC_DEFINE([HAVE_SO_PEERCRED], [1],
172      [Define if SO_PEERCRED works in the Linux fashion.])]
173 )
174
175 if test "x$GCC" = "xyes"; then
176   :
177   AC_SUBST(WARNINGOPTS, ['-Wall -Werror'])
178 else
179   :
180   AC_SUBST(WARNINGOPTS, [])
181 fi
182
183 AC_OUTPUT
184
185 if test "$gtk_version_desired" = "no"; then cat <<EOF
186
187 'configure' was instructed not to build using GTK. Therefore, PuTTY
188 itself and the other GUI utilities will not be built by the generated
189 Makefile: only the command-line tools such as puttygen, plink and
190 psftp will be built.
191
192 EOF
193 elif test "$gtk" = "none"; then cat <<EOF
194
195 'configure' was unable to find any version of the GTK libraries on
196 your system. Therefore, PuTTY itself and the other GUI utilities will
197 not be built by the generated Makefile: only the command-line tools
198 such as puttygen, plink and psftp will be built.
199
200 EOF
201 elif test "$gtk" = "3"; then cat <<EOF
202
203 PuTTY will be built with GTK 3. Be aware that the GTK 3 support in
204 this codebase is UNFINISHED AND EXPERIMENTAL! Many deprecated
205 functions are used, and there are known layout bugs.
206
207 EOF
208 fi
209
210 AH_BOTTOM([
211 /* Convert autoconf definitions to ones that PuTTY wants. */
212
213 #ifndef HAVE_GETADDRINFO
214 # define NO_IPV6
215 #endif
216 #ifndef HAVE_SETRESUID
217 # define HAVE_NO_SETRESUID
218 #endif
219 #ifndef HAVE_STRSIGNAL
220 # define HAVE_NO_STRSIGNAL
221 #endif
222 #if !defined(HAVE_UTMPX_H) || !defined(HAVE_UPDWTMPX)
223 # define OMIT_UTMP
224 #endif
225 #ifndef HAVE_PTSNAME
226 # define BSD_PTYS
227 #endif
228 #ifndef HAVE_SYS_SELECT_H
229 # define HAVE_NO_SYS_SELECT_H
230 #endif
231 #ifndef HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE
232 # define PANGO_PRE_1POINT4
233 #endif
234 #ifndef HAVE_PANGO_FONT_MAP_LIST_FAMILIES
235 # define PANGO_PRE_1POINT6
236 #endif
237 #if !defined(WITH_GSSAPI)
238 # define NO_GSSAPI
239 #endif
240 #if !defined(NO_GSSAPI) && defined(NO_LIBDL)
241 # if !defined(HAVE_GSSAPI_GSSAPI_H) || defined(NO_GSSAPI_LIB)
242 #  define NO_GSSAPI
243 # endif
244 #endif
245 ])