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