configure.ac 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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. # Version number is substituted by Buildscr for releases, snapshots
  7. # and custom builds out of svn; X.XX shows up in ad-hoc developer
  8. # builds, which shouldn't matter
  9. AC_INIT(putty, X.XX)
  10. AC_CONFIG_FILES([Makefile])
  11. AC_CONFIG_HEADERS([uxconfig.h:uxconfig.in])
  12. AM_INIT_AUTOMAKE([-Wall -Werror foreign])
  13. AC_PROG_INSTALL
  14. AC_PROG_RANLIB
  15. ifdef([AM_PROG_AR],[AM_PROG_AR])
  16. AM_PROG_CC_C_O
  17. # Mild abuse of the '--enable' option format to allow manual
  18. # specification of setuid or setgid setup in pterm.
  19. setidtype=none
  20. AC_ARG_ENABLE([setuid],
  21. [AS_HELP_STRING([--enable-setuid=USER],
  22. [make pterm setuid to a given user])],
  23. [case "$enableval" in
  24. no) setidtype=none;;
  25. *) setidtype=setuid; setidval="$enableval";;
  26. esac])
  27. AC_ARG_ENABLE([setgid],
  28. [AS_HELP_STRING([--enable-setgid=GROUP],
  29. [make pterm setgid to a given group])],
  30. [case "$enableval" in
  31. no) setidtype=none;;
  32. *) setidtype=setgid; setidval="$enableval";;
  33. esac])
  34. AM_CONDITIONAL(HAVE_SETID_CMD, [test "$setidtype" != "none"])
  35. AS_IF([test "x$setidtype" = "xsetuid"],
  36. [SETID_CMD="chown $setidval"; SETID_MODE="4755"])
  37. AS_IF([test "x$setidtype" = "xsetgid"],
  38. [SETID_CMD="chgrp $setidval"; SETID_MODE="2755"])
  39. AC_SUBST(SETID_CMD)
  40. AC_SUBST(SETID_MODE)
  41. AC_ARG_WITH([gssapi],
  42. [AS_HELP_STRING([--without-gssapi],
  43. [disable GSSAPI support])],
  44. [],
  45. [with_gssapi=yes])
  46. AC_ARG_WITH([quartz],
  47. [AS_HELP_STRING([--with-quartz],
  48. [build for the MacOS Quartz GTK back end])],
  49. [AC_DEFINE([OSX_GTK], [1], [Define if building with GTK for MacOS.])
  50. with_quartz=yes],
  51. [with_quartz=no])
  52. AM_CONDITIONAL([HAVE_QUARTZ],[test "x$with_quartz" = "xyes"])
  53. WITH_GSSAPI=
  54. AS_IF([test "x$with_gssapi" != xno],
  55. [AC_DEFINE([WITH_GSSAPI], [1], [Define if building with GSSAPI support.])])
  56. AC_ARG_WITH([gtk],
  57. [AS_HELP_STRING([--with-gtk=VER],
  58. [specify GTK version to use (`1', `2' or `3')])
  59. AS_HELP_STRING([--without-gtk],
  60. [do not use GTK (build command-line tools only)])],
  61. [gtk_version_desired="$withval"],
  62. [gtk_version_desired="any"])
  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. AC_CHECK_HEADERS([utmpx.h sys/select.h],,,[
  69. #include <sys/types.h>
  70. #include <utmp.h>])
  71. # Look for GTK 3, GTK 2 and GTK 1, in descending order of preference.
  72. # If we can't find any, have the makefile only build the CLI programs.
  73. gtk=none
  74. case "$gtk_version_desired:$gtk" in
  75. 3:none | any:none)
  76. ifdef([AM_PATH_GTK_3_0],[
  77. AM_PATH_GTK_3_0([3.0.0], [gtk=3], [])
  78. ],[AC_WARNING([generating configure script without GTK 3 autodetection])])
  79. ;;
  80. esac
  81. case "$gtk_version_desired:$gtk" in
  82. 2:none | any:none)
  83. ifdef([AM_PATH_GTK_2_0],[
  84. AM_PATH_GTK_2_0([2.0.0], [gtk=2], [])
  85. ],[AC_WARNING([generating configure script without GTK 2 autodetection])])
  86. ;;
  87. esac
  88. case "$gtk_version_desired:$gtk" in
  89. 1:none | any:none)
  90. ifdef([AM_PATH_GTK],[
  91. AM_PATH_GTK([1.2.0], [gtk=1], [])
  92. ],[
  93. # manual check for gtk1
  94. AC_PATH_PROG(GTK1_CONFIG, gtk-config, absent)
  95. if test "$GTK1_CONFIG" != "absent"; then
  96. GTK_CFLAGS=`"$GTK1_CONFIG" --cflags`
  97. GTK_LIBS=`"$GTK1_CONFIG" --libs`
  98. gtk=1
  99. fi
  100. ])
  101. ;;
  102. esac
  103. AM_CONDITIONAL(HAVE_GTK, [test "$gtk" != "none"])
  104. if test "$gtk" = "2" -o "$gtk" = "3"; 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. AC_SEARCH_LIBS([socket], [xnet])
  114. AS_IF([test "x$with_gssapi" != xno],
  115. [AC_SEARCH_LIBS(
  116. [dlopen],[dl],
  117. [],
  118. [AC_DEFINE([NO_LIBDL], [1], [Define if we could not find libdl.])
  119. AC_CHECK_HEADERS([gssapi/gssapi.h])
  120. AC_SEARCH_LIBS(
  121. [gss_init_sec_context],[gssapi gssapi_krb5 gss],
  122. [],
  123. [AC_DEFINE([NO_GSSAPI_LIB], [1], [Define if we could not find a gssapi library])])])])
  124. AC_CHECK_LIB(X11, XOpenDisplay,
  125. [GTK_LIBS="-lX11 $GTK_LIBS"
  126. AC_DEFINE([HAVE_LIBX11],[],[Define if libX11.a is available])])
  127. AC_CHECK_FUNCS([getaddrinfo posix_openpt ptsname setresuid strsignal updwtmpx])
  128. AC_CHECK_DECLS([CLOCK_MONOTONIC], [], [], [[#include <time.h>]])
  129. AC_SEARCH_LIBS([clock_gettime], [rt], [AC_DEFINE([HAVE_CLOCK_GETTIME],[],[Define if clock_gettime() is available])])
  130. AC_CACHE_CHECK([for SO_PEERCRED and dependencies], [x_cv_linux_so_peercred], [
  131. AC_COMPILE_IFELSE([
  132. AC_LANG_PROGRAM([[
  133. #define _GNU_SOURCE
  134. #include <features.h>
  135. #include <sys/socket.h>
  136. ]],[[
  137. struct ucred cr;
  138. socklen_t crlen = sizeof(cr);
  139. return getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cr, &crlen) +
  140. cr.pid + cr.uid + cr.gid;
  141. ]]
  142. )],
  143. AS_VAR_SET(x_cv_linux_so_peercred, yes),
  144. AS_VAR_SET(x_cv_linux_so_peercred, no)
  145. )
  146. ])
  147. AS_IF([test AS_VAR_GET(x_cv_linux_so_peercred) = yes],
  148. [AC_DEFINE([HAVE_SO_PEERCRED], [1],
  149. [Define if SO_PEERCRED works in the Linux fashion.])]
  150. )
  151. if test "x$GCC" = "xyes"; then
  152. :
  153. AC_SUBST(WARNINGOPTS, ['-Wall -Werror'])
  154. else
  155. :
  156. AC_SUBST(WARNINGOPTS, [])
  157. fi
  158. AC_OUTPUT
  159. if test "$gtk_version_desired" = "no"; then cat <<EOF
  160. 'configure' was instructed not to build using GTK. Therefore, PuTTY
  161. itself and the other GUI utilities will not be built by the generated
  162. Makefile: only the command-line tools such as puttygen, plink and
  163. psftp will be built.
  164. EOF
  165. elif test "$gtk" = "none"; then cat <<EOF
  166. 'configure' was unable to find any version of the GTK libraries on
  167. your system. Therefore, PuTTY itself and the other GUI utilities will
  168. not be built by the generated Makefile: only the command-line tools
  169. such as puttygen, plink and psftp will be built.
  170. EOF
  171. fi
  172. AH_BOTTOM([
  173. /* Convert autoconf definitions to ones that PuTTY wants. */
  174. #ifndef HAVE_GETADDRINFO
  175. # define NO_IPV6
  176. #endif
  177. #ifndef HAVE_SETRESUID
  178. # define HAVE_NO_SETRESUID
  179. #endif
  180. #ifndef HAVE_STRSIGNAL
  181. # define HAVE_NO_STRSIGNAL
  182. #endif
  183. #if !defined(HAVE_UTMPX_H) || !defined(HAVE_UPDWTMPX)
  184. # define OMIT_UTMP
  185. #endif
  186. #ifndef HAVE_PTSNAME
  187. # define BSD_PTYS
  188. #endif
  189. #ifndef HAVE_SYS_SELECT_H
  190. # define HAVE_NO_SYS_SELECT_H
  191. #endif
  192. #ifndef HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE
  193. # define PANGO_PRE_1POINT4
  194. #endif
  195. #ifndef HAVE_PANGO_FONT_MAP_LIST_FAMILIES
  196. # define PANGO_PRE_1POINT6
  197. #endif
  198. #if !defined(WITH_GSSAPI)
  199. # define NO_GSSAPI
  200. #endif
  201. #if !defined(NO_GSSAPI) && defined(NO_LIBDL)
  202. # if !defined(HAVE_GSSAPI_GSSAPI_H) || defined(NO_GSSAPI_LIB)
  203. # define NO_GSSAPI
  204. # endif
  205. #endif
  206. ])