]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - configure.ac
Introduce a config option for building on OS X GTK.
[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 AC_ARG_WITH([quartz],
52   [AS_HELP_STRING([--with-quartz],
53                   [build for the MacOS Quartz GTK back end])],
54   [AC_DEFINE([OSX_GTK], [1], [Define if building with GTK for MacOS.])],
55   [])
56
57 WITH_GSSAPI=
58 AS_IF([test "x$with_gssapi" != xno],
59   [AC_DEFINE([WITH_GSSAPI], [1], [Define if building with GSSAPI support.])])
60
61 AC_ARG_WITH([gtk],
62   [AS_HELP_STRING([--with-gtk=VER],
63                   [specify GTK version to use (`1', `2' or `3')])
64 AS_HELP_STRING([--without-gtk],
65                   [do not use GTK (build command-line tools only)])],
66   [gtk_version_desired="$withval"],
67   [gtk_version_desired="any"])
68
69 case "$gtk_version_desired" in
70   1 | 2 | 3 | any | no) ;;
71   yes) gtk_version_desired="any" ;;
72   *) AC_ERROR([Invalid GTK version specified])
73 esac
74
75 AC_CHECK_HEADERS([utmpx.h sys/select.h],,,[
76 #include <sys/types.h>
77 #include <utmp.h>])
78
79 # Look for GTK 2, GTK 3 and GTK 1, in descending order of preference.
80 #
81 # (I like GTK 2 for its faster support for X server-side fonts due to
82 # not being required to do all its drawing via Cairo; GTK 3 is
83 # tolerable if GTK 2 can't be had, and GTK 1 is an extreme fallback
84 # for platforms - of which I've heard of at least one - to which
85 # nothing newer has ever been ported.)
86 #
87 # If we can't find any, have the makefile only build the CLI programs.
88
89 gtk=none
90
91 case "$gtk_version_desired:$gtk" in
92   2:none | any:none)
93     ifdef([AM_PATH_GTK_2_0],[
94     AM_PATH_GTK_2_0([2.0.0], [gtk=2], [])
95     ],[AC_WARNING([generating configure script without GTK 2 autodetection])])
96     ;;
97 esac
98
99 case "$gtk_version_desired:$gtk" in
100   3:none | any:none)
101     ifdef([AM_PATH_GTK_3_0],[
102     AM_PATH_GTK_3_0([3.0.0], [gtk=3], [])
103     ],[AC_WARNING([generating configure script without GTK 3 autodetection])])
104     ;;
105 esac
106
107 case "$gtk_version_desired:$gtk" in
108   1:none | any:none)
109     ifdef([AM_PATH_GTK],[
110     AM_PATH_GTK([1.2.0], [gtk=1], [])
111     ],[
112     # manual check for gtk1
113     AC_PATH_PROG(GTK1_CONFIG, gtk-config, absent)
114     if test "$GTK1_CONFIG" != "absent"; then
115       GTK_CFLAGS=`"$GTK1_CONFIG" --cflags`
116       GTK_LIBS=`"$GTK1_CONFIG" --libs`
117       gtk=1
118     fi
119     ])
120     ;;
121 esac
122
123 AM_CONDITIONAL(HAVE_GTK, [test "$gtk" != "none"])
124
125 if test "$gtk" = "2" -o "$gtk" = "3"; then
126   ac_save_CFLAGS="$CFLAGS"
127   ac_save_LIBS="$LIBS"
128   CFLAGS="$CFLAGS $GTK_CFLAGS"
129   LIBS="$GTK_LIBS $LIBS"
130   AC_CHECK_FUNCS([pango_font_family_is_monospace pango_font_map_list_families])
131   CFLAGS="$ac_save_CFLAGS"
132   LIBS="$ac_save_LIBS"
133 fi
134
135 AC_SEARCH_LIBS([socket], [xnet])
136
137 AS_IF([test "x$with_gssapi" != xno],
138   [AC_SEARCH_LIBS(
139     [dlopen],[dl],
140     [],
141     [AC_DEFINE([NO_LIBDL], [1], [Define if we could not find libdl.])
142      AC_CHECK_HEADERS([gssapi/gssapi.h])
143      AC_SEARCH_LIBS(
144        [gss_init_sec_context],[gssapi gssapi_krb5 gss],
145        [],
146        [AC_DEFINE([NO_GSSAPI_LIB], [1], [Define if we could not find a gssapi library])])])])
147
148 AC_CHECK_LIB(X11, XOpenDisplay,
149              [GTK_LIBS="-lX11 $GTK_LIBS"
150               AC_DEFINE([HAVE_LIBX11],[],[Define if libX11.a is available])])
151
152 AC_CHECK_FUNCS([getaddrinfo posix_openpt ptsname setresuid strsignal updwtmpx])
153 AC_CHECK_DECLS([CLOCK_MONOTONIC], [], [], [[#include <time.h>]])
154 AC_SEARCH_LIBS([clock_gettime], [rt], [AC_DEFINE([HAVE_CLOCK_GETTIME],[],[Define if clock_gettime() is available])])
155
156 AC_CACHE_CHECK([for SO_PEERCRED and dependencies], [x_cv_linux_so_peercred], [
157     AC_COMPILE_IFELSE([
158         AC_LANG_PROGRAM([[
159             #define _GNU_SOURCE
160             #include <features.h>
161             #include <sys/socket.h>
162           ]],[[
163             struct ucred cr;
164             socklen_t crlen = sizeof(cr);
165             return getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cr, &crlen) +
166             cr.pid + cr.uid + cr.gid;
167           ]]
168         )],
169         AS_VAR_SET(x_cv_linux_so_peercred, yes),
170         AS_VAR_SET(x_cv_linux_so_peercred, no)
171     )
172 ])
173 AS_IF([test AS_VAR_GET(x_cv_linux_so_peercred) = yes],
174     [AC_DEFINE([HAVE_SO_PEERCRED], [1],
175      [Define if SO_PEERCRED works in the Linux fashion.])]
176 )
177
178 if test "x$GCC" = "xyes"; then
179   :
180   AC_SUBST(WARNINGOPTS, ['-Wall -Werror'])
181 else
182   :
183   AC_SUBST(WARNINGOPTS, [])
184 fi
185
186 AC_OUTPUT
187
188 if test "$gtk_version_desired" = "no"; then cat <<EOF
189
190 'configure' was instructed not to build using GTK. Therefore, PuTTY
191 itself and the other GUI utilities will not be built by the generated
192 Makefile: only the command-line tools such as puttygen, plink and
193 psftp will be built.
194
195 EOF
196 elif test "$gtk" = "none"; then cat <<EOF
197
198 'configure' was unable to find any version of the GTK libraries on
199 your system. Therefore, PuTTY itself and the other GUI utilities will
200 not be built by the generated Makefile: only the command-line tools
201 such as puttygen, plink and psftp will be built.
202
203 EOF
204 elif test "$gtk" = "3"; then cat <<EOF
205
206 PuTTY will be built with GTK 3. Be aware that the GTK 3 support in
207 this codebase is UNFINISHED AND EXPERIMENTAL!
208
209 EOF
210 fi
211
212 AH_BOTTOM([
213 /* Convert autoconf definitions to ones that PuTTY wants. */
214
215 #ifndef HAVE_GETADDRINFO
216 # define NO_IPV6
217 #endif
218 #ifndef HAVE_SETRESUID
219 # define HAVE_NO_SETRESUID
220 #endif
221 #ifndef HAVE_STRSIGNAL
222 # define HAVE_NO_STRSIGNAL
223 #endif
224 #if !defined(HAVE_UTMPX_H) || !defined(HAVE_UPDWTMPX)
225 # define OMIT_UTMP
226 #endif
227 #ifndef HAVE_PTSNAME
228 # define BSD_PTYS
229 #endif
230 #ifndef HAVE_SYS_SELECT_H
231 # define HAVE_NO_SYS_SELECT_H
232 #endif
233 #ifndef HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE
234 # define PANGO_PRE_1POINT4
235 #endif
236 #ifndef HAVE_PANGO_FONT_MAP_LIST_FAMILIES
237 # define PANGO_PRE_1POINT6
238 #endif
239 #if !defined(WITH_GSSAPI)
240 # define NO_GSSAPI
241 #endif
242 #if !defined(NO_GSSAPI) && defined(NO_LIBDL)
243 # if !defined(HAVE_GSSAPI_GSSAPI_H) || defined(NO_GSSAPI_LIB)
244 #  define NO_GSSAPI
245 # endif
246 #endif
247 ])