configure.ac 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. # To compile this into a configure script, you need:
  2. # * Autoconf 2.59c 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 foreign])
  13. AC_PROG_INSTALL
  14. AC_PROG_RANLIB
  15. ifdef([AM_PROG_AR],[AM_PROG_AR])
  16. AM_PROG_CC_C_O
  17. AC_PROG_CC_C99
  18. # Mild abuse of the '--enable' option format to allow manual
  19. # specification of setuid or setgid setup in pterm.
  20. setidtype=none
  21. AC_ARG_ENABLE([setuid],
  22. [AS_HELP_STRING([--enable-setuid=USER],
  23. [make pterm setuid to a given user])],
  24. [case "$enableval" in
  25. no) setidtype=none;;
  26. *) setidtype=setuid; setidval="$enableval";;
  27. esac])
  28. AC_ARG_ENABLE([setgid],
  29. [AS_HELP_STRING([--enable-setgid=GROUP],
  30. [make pterm setgid to a given group])],
  31. [case "$enableval" in
  32. no) setidtype=none;;
  33. *) setidtype=setgid; setidval="$enableval";;
  34. esac])
  35. AM_CONDITIONAL(HAVE_SETID_CMD, [test "$setidtype" != "none"])
  36. AS_IF([test "x$setidtype" = "xsetuid"],
  37. [SETID_CMD="chown $setidval"; SETID_MODE="4755"])
  38. AS_IF([test "x$setidtype" = "xsetgid"],
  39. [SETID_CMD="chgrp $setidval"; SETID_MODE="2755"])
  40. AC_SUBST(SETID_CMD)
  41. AC_SUBST(SETID_MODE)
  42. AC_ARG_ENABLE([git-commit],
  43. [AS_HELP_STRING([--disable-git-commit],
  44. [disable embedding current git HEAD in binaries])],
  45. [],
  46. [if test -d "$srcdir/.git"; then
  47. enable_git_commit=yes; else enable_git_commit=no; fi])
  48. if test "x$enable_git_commit" = "xyes" -a ! -d "$srcdir/.git"; then
  49. AC_ERROR([Cannot --enable-git-commit when source tree is not a git checkout])
  50. fi
  51. AM_CONDITIONAL(AUTO_GIT_COMMIT, [test "x$enable_git_commit" = "xyes"])
  52. AC_ARG_WITH([gssapi],
  53. [AS_HELP_STRING([--without-gssapi],
  54. [disable GSSAPI support])],
  55. [],
  56. [with_gssapi=yes])
  57. AC_ARG_WITH([quartz],
  58. [AS_HELP_STRING([--with-quartz],
  59. [build for the MacOS Quartz GTK back end])],
  60. [AC_DEFINE([OSX_GTK], [1], [Define if building with GTK for MacOS.])
  61. with_quartz=yes],
  62. [with_quartz=no])
  63. AM_CONDITIONAL([HAVE_QUARTZ],[test "x$with_quartz" = "xyes"])
  64. WITH_GSSAPI=
  65. AS_IF([test "x$with_gssapi" != xno],
  66. [AC_DEFINE([WITH_GSSAPI], [1], [Define if building with GSSAPI support.])])
  67. AC_ARG_WITH([gtk],
  68. [AS_HELP_STRING([--with-gtk=VER],
  69. [specify GTK version to use (`1', `2' or `3')])
  70. AS_HELP_STRING([--without-gtk],
  71. [do not use GTK (build command-line tools only)])],
  72. [gtk_version_desired="$withval"],
  73. [gtk_version_desired="any"])
  74. case "$gtk_version_desired" in
  75. 1 | 2 | 3 | any | no) ;;
  76. yes) gtk_version_desired="any" ;;
  77. *) AC_ERROR([Invalid GTK version specified])
  78. esac
  79. AC_CHECK_HEADERS([utmpx.h],,,[
  80. #include <sys/types.h>
  81. #include <utmp.h>])
  82. # Look for GTK 3, GTK 2 and GTK 1, in descending order of preference.
  83. # If we can't find any, have the makefile only build the CLI programs.
  84. gtk=none
  85. case "$gtk_version_desired:$gtk" in
  86. 3:none | any:none)
  87. ifdef([AM_PATH_GTK_3_0],[AM_PATH_GTK_3_0([3.0.0], [gtk=3], [])],
  88. [AC_WARNING([generating configure script without GTK 3 autodetection])])
  89. ;;
  90. esac
  91. case "$gtk_version_desired:$gtk" in
  92. 2:none | any:none)
  93. ifdef([AM_PATH_GTK_2_0],[AM_PATH_GTK_2_0([2.0.0], [gtk=2], [])],
  94. [AC_WARNING([generating configure script without GTK 2 autodetection])])
  95. ;;
  96. esac
  97. case "$gtk_version_desired:$gtk" in
  98. 1:none | any:none)
  99. ifdef([AM_PATH_GTK],[AM_PATH_GTK([1.2.0], [gtk=1], [])],[
  100. # manual check for gtk1
  101. AC_PATH_PROG(GTK1_CONFIG, gtk-config, absent)
  102. if test "$GTK1_CONFIG" != "absent"; then
  103. GTK_CFLAGS="`"$GTK1_CONFIG" --cflags`"
  104. GTK_LIBS=`"$GTK1_CONFIG" --libs`
  105. AC_SUBST(GTK_CFLAGS)
  106. AC_SUBST(GTK_LIBS)
  107. gtk=1
  108. fi
  109. ])
  110. ;;
  111. esac
  112. case "$gtk" in
  113. 1)
  114. # Add some manual #defines to make the GTK 1 headers work when
  115. # compiling in C99 mode. Left to themselves, they'll expect the
  116. # old-style pre-C99 GNU semantics of 'inline' and 'extern inline',
  117. # with the effect that they'll end up defining out-of-line
  118. # versions of the inlined functions in more than one translation
  119. # unit and cause a link failure. Override them to 'static inline',
  120. # which is safe.
  121. GTK_CFLAGS="$GTK_CFLAGS -DG_INLINE_FUNC='static inline' -DG_CAN_INLINE=1"
  122. esac
  123. AM_CONDITIONAL(HAVE_GTK, [test "$gtk" != "none"])
  124. if test "$gtk" = "2" -o "$gtk" = "3"; then
  125. ac_save_CFLAGS="$CFLAGS"
  126. ac_save_LIBS="$LIBS"
  127. CFLAGS="$CFLAGS $GTK_CFLAGS"
  128. LIBS="$GTK_LIBS $LIBS"
  129. AC_CHECK_FUNCS([pango_font_family_is_monospace pango_font_map_list_families])
  130. CFLAGS="$ac_save_CFLAGS"
  131. LIBS="$ac_save_LIBS"
  132. fi
  133. AC_SEARCH_LIBS([socket], [xnet])
  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. AC_CHECK_LIB(X11, XOpenDisplay,
  145. [GTK_LIBS="-lX11 $GTK_LIBS"
  146. AC_DEFINE([HAVE_LIBX11],[],[Define if libX11.a is available])])
  147. AC_CHECK_FUNCS([getaddrinfo posix_openpt ptsname setresuid strsignal updwtmpx fstatat dirfd futimes setpwent endpwent getauxval elf_aux_info sysctlbyname])
  148. AC_CHECK_DECLS([CLOCK_MONOTONIC], [], [], [[#include <time.h>]])
  149. AC_CHECK_HEADERS([sys/auxv.h asm/hwcap.h sys/sysctl.h sys/types.h glob.h])
  150. AC_SEARCH_LIBS([clock_gettime], [rt], [AC_DEFINE([HAVE_CLOCK_GETTIME],[],[Define if clock_gettime() is available])])
  151. AC_CACHE_CHECK([for SO_PEERCRED and dependencies], [x_cv_linux_so_peercred], [
  152. AC_COMPILE_IFELSE([
  153. AC_LANG_PROGRAM([[
  154. #define _GNU_SOURCE
  155. #include <features.h>
  156. #include <sys/socket.h>
  157. ]],[[
  158. struct ucred cr;
  159. socklen_t crlen = sizeof(cr);
  160. return getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cr, &crlen) +
  161. cr.pid + cr.uid + cr.gid;
  162. ]]
  163. )],
  164. AS_VAR_SET(x_cv_linux_so_peercred, yes),
  165. AS_VAR_SET(x_cv_linux_so_peercred, no)
  166. )
  167. ])
  168. AS_IF([test AS_VAR_GET(x_cv_linux_so_peercred) = yes],
  169. [AC_DEFINE([HAVE_SO_PEERCRED], [1],
  170. [Define if SO_PEERCRED works in the Linux fashion.])]
  171. )
  172. if test "x$GCC" = "xyes"; then
  173. :
  174. AC_SUBST(WARNINGOPTS, ['-Wall -Wpointer-arith -Wvla'])
  175. else
  176. :
  177. AC_SUBST(WARNINGOPTS, [])
  178. fi
  179. AC_SEARCH_LIBS([pow], [m])
  180. AC_OUTPUT
  181. if test "$gtk_version_desired" = "no"; then cat <<EOF
  182. 'configure' was instructed not to build using GTK. Therefore, PuTTY
  183. itself and the other GUI utilities will not be built by the generated
  184. Makefile: only the command-line tools such as puttygen, plink and
  185. psftp will be built.
  186. EOF
  187. elif test "$gtk" = "none"; then cat <<EOF
  188. 'configure' was unable to find any version of the GTK libraries on
  189. your system. Therefore, PuTTY itself and the other GUI utilities will
  190. not be built by the generated Makefile: only the command-line tools
  191. such as puttygen, plink and psftp will be built.
  192. EOF
  193. fi
  194. AH_BOTTOM([
  195. /* Convert autoconf definitions to ones that PuTTY wants. */
  196. #ifndef HAVE_GETADDRINFO
  197. # define NO_IPV6
  198. #endif
  199. #ifndef HAVE_SETRESUID
  200. # define HAVE_NO_SETRESUID
  201. #endif
  202. #ifndef HAVE_STRSIGNAL
  203. # define HAVE_NO_STRSIGNAL
  204. #endif
  205. #if !defined(HAVE_UTMPX_H) || !defined(HAVE_UPDWTMPX)
  206. # define OMIT_UTMP
  207. #endif
  208. #ifndef HAVE_PTSNAME
  209. # define BSD_PTYS
  210. #endif
  211. #ifndef HAVE_SYS_SELECT_H
  212. # define HAVE_NO_SYS_SELECT_H
  213. #endif
  214. #ifndef HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE
  215. # define PANGO_PRE_1POINT4
  216. #endif
  217. #ifndef HAVE_PANGO_FONT_MAP_LIST_FAMILIES
  218. # define PANGO_PRE_1POINT6
  219. #endif
  220. #if !defined(WITH_GSSAPI)
  221. # define NO_GSSAPI
  222. #endif
  223. #if !defined(NO_GSSAPI) && defined(NO_LIBDL)
  224. # if !defined(HAVE_GSSAPI_GSSAPI_H) || defined(NO_GSSAPI_LIB)
  225. # define NO_GSSAPI
  226. # endif
  227. #endif
  228. ])