]> andersk Git - test.git/blob - configure.ac
8dff904df388ad9f38b9aed6a2b46cb26305fa6b
[test.git] / configure.ac
1 AC_PREREQ(2.57)
2
3 dnl This is the one location where the authoritative version number is stored
4 AC_INIT(shellinabox, 2.10, markus@shellinabox.com)
5 VCS_REVISION=198
6 AC_SUBST(VCS_REVISION)
7 AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}",
8                    [Most recent revision number in the version control system])
9
10 dnl Set up autoconf/automake for building C libraries and binaries with GCC
11 CFLAGS="${CFLAGS:--Os}"
12 AM_INIT_AUTOMAKE
13 AM_CONFIG_HEADER(config.h)
14 AC_PROG_CC
15 AC_LANG_WERROR
16 AC_PROG_INSTALL
17 AC_PROG_LIBTOOL
18 AC_SUBST(LIBTOOL_DEPS)
19 AC_C_CONST
20 AC_PROG_GCC_TRADITIONAL
21
22 dnl Check for header files that do not exist on all platforms
23 AC_CHECK_HEADERS([libutil.h pthread.h pty.h strings.h sys/prctl.h sys/uio.h  \
24                   util.h utmp.h utmpx.h])
25
26 dnl Most systems require linking against libutil.so in order to get login_tty()
27 AC_CHECK_FUNCS(login_tty, [],
28                [AC_CHECK_LIB(util, login_tty,
29                 [LIBS="-lutil $LIBS"
30                  AC_DEFINE(HAVE_LOGIN_TTY)])])
31
32 dnl Use strlcat() instead of strncat() to avoid spurious warnings
33 AC_CHECK_FUNCS([strlcat])
34
35 dnl Prefer thread-safe functions, if available
36 AC_CHECK_FUNCS([getgrgid_r getgrnam_r getpwnam_r getpwuid_r openpty          \
37                 strcasestr ])
38
39 dnl We prefer ptsname_r(), but will settle for ptsname() if necessary
40 AC_TRY_LINK([#ifndef _XOPEN_SOURCE
41              #define _XOPEN_SOURCE
42              #endif
43              #ifndef _GNU_SOURCE
44              #define _GNU_SOURCE
45              #endif
46              #include <stdlib.h>],
47             [char buf[10]; ptsname_r(0, buf, sizeof(buf));],
48             [AC_DEFINE(HAVE_PTSNAME_R, 1,
49                      Define to 1 if you have a re-entrant version of ptsname)])
50
51 dnl Apparently, some systems define sigwait() but fail to implement it
52 AC_TRY_LINK([#include <pthread.h>
53              #include <signal.h>],
54             [sigset_t s; int n; sigwait(&s, &n);],
55             [AC_DEFINE(HAVE_SIGWAIT, 1,
56                        Define to 1 if you have a working sigwait)])
57
58 dnl On some systems, calling /bin/login does not work. Disable the LOGIN
59 dnl feature, if the user tells us that it does not do the right thing.
60 AC_ARG_ENABLE(login,
61               [  --disable-login           on some systems (e.g. Fedora), calling /bin/login
62                             does not work well. If you know that your system
63                             suffers from this problem, set this option to
64                             remove support for the LOGIN keyword in the
65                             service description.])
66 if test "x$enable_login" != xno; then
67   AC_DEFINE(HAVE_BIN_LOGIN, 1,
68                                 Set if you want support for calling /bin/login)
69 fi
70
71 dnl We automatically detect SSL support, but allow users to disable it
72 AC_ARG_ENABLE(ssl,
73               [  --disable-ssl             if available at built-time, support for SSL
74                             connections will be enabled. It can still be
75                             disabled at run-time, either on the daemon's
76                             command line or if the operating system does not
77                             have the OpenSSL libraries available.])
78
79 dnl We automatically detect PAM support, but allow users to disable it
80 AC_ARG_ENABLE(pam,
81               [  --disable-pam             PAM support is necessary in order to authenticate
82                             users for running programs other than their default
83                             login shell.])
84
85 dnl We try to always use dlopen() instead of linking libraries dynamically, as
86 dnl this reduces the hard run-time dependencies that our binary has. But we
87 dnl allow users to disable this feature.
88 AC_ARG_ENABLE(runtime-loading,
89               [  --disable-runtime-loading ShellInABox will try to load the OpenSSL, and PAM
90                             libraries at run-time, if it has been compiled with
91                             support for these libraries, and if the operating
92                             system supports dynamic loading of libraries. This
93                             allows you to install the same binary on different
94                             systems independent of whether they have OpenSSL
95                             and PAM enabled.  If you would rather directly link
96                             these libraries into the binary, thus making them a
97                             hard dependency, then disable runtime-loading.])
98
99 dnl Only test for OpenSSL headers, if not explicitly disabled
100 if test "x$enable_ssl" != xno; then
101   AC_CHECK_HEADERS([openssl/bio.h openssl/err.h openssl/ssl.h])
102 fi
103
104 dnl Only test for PAM headers, if not explicitly disabled
105 if test "x$enable_pam" != xno; then
106   AC_CHECK_HEADERS([security/pam_appl.h security/pam_client.h                 \
107                     security/pam_misc.h ])
108 fi
109
110 dnl Only test for dlopen(), if not explicitly disabled. Add required libdl.so
111 dnl library if necessary. Also, if dlopen() is not available on this system,
112 dnl explicitly disable runtime loading.
113 if test "x$enable_runtime_loading" != xno; then
114   AC_CHECK_FUNCS(dlopen, [],
115                  [AC_CHECK_LIB(dl, dlopen,
116                                [LIBS="-ldl $LIBS"
117                                 AC_DEFINE(HAVE_DLOPEN)],
118                                [enable_runtime_loading=no])])
119 fi
120
121 dnl If runtime loading has been disabled, add OpenSSL and PAM as hard
122 dnl dependencies.
123 if test "x$enable_runtime_loading" == xno; then
124   dnl Link against OpenSSL libraries, unless SSL support has been disabled
125   if test "x$enable_ssl" != xno; then
126     AC_CHECK_HEADER(openssl/bio.h,
127       [AC_CHECK_HEADER(openssl/err.h,
128         [AC_CHECK_HEADER(openssl/ssl.h, [LIBS="-lssl -lcrypto $LIBS"])])])
129   fi
130
131   dnl Link against PAM libraries, unless PAM support has been disabled
132   if test "x$enable_pam" != xno; then
133     AC_CHECK_HEADER(security/pam_appl.h, [LIBS="-lpam $LIBS"])
134     AC_CHECK_HEADER(security/pam_misc.h, [LIBS="-lpam_misc $LIBS"])
135   fi
136 fi
137
138 AC_CHECK_LIB(z, deflate, [
139   AC_CHECK_HEADER(zlib.h, [LIBS="-lz $LIBS"
140                            AC_DEFINE(HAVE_ZLIB, 1,
141                            Define to 1 if zlib development files are installed)
142 ])])
143
144 dnl Generate output files
145 AC_CONFIG_FILES([Makefile])
146 AC_OUTPUT
This page took 0.045802 seconds and 3 git commands to generate.