]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - configure.ac
Move the Unix configure script up to the top level.
[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' or `2')])
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 | 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 both GTK 2 and GTK 1, in descending order of preference. If
74 # we can't find either, have the makefile only build the CLI programs.
75
76 gtk=none
77
78 case "$gtk_version_desired:$gtk" in
79   2:none | any:none)
80     ifdef([AM_PATH_GTK_2_0],[
81     AM_PATH_GTK_2_0([2.0.0], [gtk=2], [])
82     ],[AC_WARNING([generating configure script without GTK 2 autodetection])])
83     ;;
84 esac
85
86 case "$gtk_version_desired:$gtk" in
87   1:none | any:none)
88     ifdef([AM_PATH_GTK],[
89     AM_PATH_GTK([1.2.0], [gtk=1], [])
90     ],[
91     # manual check for gtk1
92     AC_PATH_PROG(GTK1_CONFIG, gtk-config, absent)
93     if test "$GTK1_CONFIG" != "absent"; then
94       GTK_CFLAGS=`"$GTK1_CONFIG" --cflags`
95       GTK_LIBS=`"$GTK1_CONFIG" --libs`
96       gtk=1
97     fi
98     ])
99     ;;
100 esac
101
102 AM_CONDITIONAL(HAVE_GTK, [test "$gtk" != "none"])
103
104 if test "$gtk" = "2"; then
105   ac_save_CFLAGS="$CFLAGS"
106   ac_save_LIBS="$LIBS"
107   CFLAGS="$CFLAGS $GTK_CFLAGS"
108   LIBS="$GTK_LIBS $LIBS"
109   AC_CHECK_FUNCS([pango_font_family_is_monospace pango_font_map_list_families])
110   CFLAGS="$ac_save_CFLAGS"
111   LIBS="$ac_save_LIBS"
112 fi
113
114 AC_SEARCH_LIBS([socket], [xnet])
115
116 AS_IF([test "x$with_gssapi" != xno],
117   [AC_SEARCH_LIBS(
118     [dlopen],[dl],
119     [],
120     [AC_DEFINE([NO_LIBDL], [1], [Define if we could not find libdl.])
121      AC_CHECK_HEADERS([gssapi/gssapi.h])
122      AC_SEARCH_LIBS(
123        [gss_init_sec_context],[gssapi gssapi_krb5 gss],
124        [],
125        [AC_DEFINE([NO_GSSAPI_LIB], [1], [Define if we could not find a gssapi library])])])])
126
127 AC_CHECK_LIB(X11, XOpenDisplay,
128              [GTK_LIBS="-lX11 $GTK_LIBS"
129               AC_DEFINE([HAVE_LIBX11],[],[Define if libX11.a is available])])
130
131 AC_CHECK_FUNCS([getaddrinfo posix_openpt ptsname setresuid strsignal updwtmpx])
132 AC_CHECK_DECLS([CLOCK_MONOTONIC], [], [], [[#include <time.h>]])
133 AC_SEARCH_LIBS([clock_gettime], [rt], [AC_DEFINE([HAVE_CLOCK_GETTIME],[],[Define if clock_gettime() is available])])
134
135 if test "x$GCC" = "xyes"; then
136   :
137   AC_SUBST(WARNINGOPTS, ['-Wall -Werror'])
138 else
139   :
140   AC_SUBST(WARNINGOPTS, [])
141 fi
142
143 AC_OUTPUT
144
145 if test "$gtk_version_desired" = "no"; then cat <<EOF
146
147 'configure' was instructed not to build using GTK. Therefore, PuTTY
148 itself and the other GUI utilities will not be built by the generated
149 Makefile: only the command-line tools such as puttygen, plink and
150 psftp will be built.
151
152 EOF
153 elif test "$gtk" = "none"; then cat <<EOF
154
155 'configure' was unable to find either the GTK 1 or GTK 2 libraries on
156 your system. Therefore, PuTTY itself and the other GUI utilities will
157 not be built by the generated Makefile: only the command-line tools
158 such as puttygen, plink and psftp will be built.
159
160 EOF
161 fi
162
163 AH_BOTTOM([
164 /* Convert autoconf definitions to ones that PuTTY wants. */
165
166 #ifndef HAVE_GETADDRINFO
167 # define NO_IPV6
168 #endif
169 #ifndef HAVE_SETRESUID
170 # define HAVE_NO_SETRESUID
171 #endif
172 #ifndef HAVE_STRSIGNAL
173 # define HAVE_NO_STRSIGNAL
174 #endif
175 #if !defined(HAVE_UTMPX_H) || !defined(HAVE_UPDWTMPX)
176 # define OMIT_UTMP
177 #endif
178 #ifndef HAVE_PTSNAME
179 # define BSD_PTYS
180 #endif
181 #ifndef HAVE_SYS_SELECT_H
182 # define HAVE_NO_SYS_SELECT_H
183 #endif
184 #ifndef HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE
185 # define PANGO_PRE_1POINT4
186 #endif
187 #ifndef HAVE_PANGO_FONT_MAP_LIST_FAMILIES
188 # define PANGO_PRE_1POINT6
189 #endif
190 #if !defined(WITH_GSSAPI)
191 # define NO_GSSAPI
192 #endif
193 #if !defined(NO_GSSAPI) && defined(NO_LIBDL)
194 # if !defined(HAVE_GSSAPI_GSSAPI_H) || defined(NO_GSSAPI_LIB)
195 #  define NO_GSSAPI
196 # endif
197 #endif
198 ])