Project

General

Profile

Download (7.68 KB) Statistics
| Branch: | Revision:
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=239
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 gethostbyname_r getpwnam_r getpwuid_r  \
37
                openpty strcasestr getresuid getresgid setresuid setresgid ])
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 Not every system has support for isnan()
59
AC_TRY_LINK([#include <math.h>],
60
            [if (isnan(0.0)) return 1;],
61
            [AC_DEFINE(HAVE_ISNAN, 1,
62
                       Define to 1 if you have support for isnan)])
63

    
64
dnl Even if utmpx.h exists, not all systems have support for updwtmpx()
65
AC_TRY_LINK([#include <utmp.h>],
66
            [updwtmp(0, 0);],
67
            [AC_DEFINE(HAVE_UPDWTMP, 1,
68
                       Define to 1 if you have support for updwtmp)])
69
AC_TRY_LINK([#include <utmpx.h>],
70
            [updwtmpx(0, 0);],
71
            [AC_DEFINE(HAVE_UPDWTMPX, 1,
72
                       Define to 1 if you have support for updwtmpx)])
73

    
74
dnl Check if the compiler supports aliasing of symbols
75
AC_TRY_LINK([void x(void) { };
76
             void y(void) __attribute__((alias("x")));],
77
            [y();],
78
            [AC_DEFINE(HAVE_ATTRIBUTE_ALIAS, 1,
79
                       Define to 1 if you have support for symbol aliasing)])
80

    
81
dnl Check if the compiler has support to mark parameters as unused
82
AC_TRY_LINK([void x(int i __attribute__((unused))) __attribute__((unused));],
83
            [],
84
            [AC_DEFINE(HAVE_ATTRIBUTE_UNUSED, 1,
85
                  Define to 1 if you have support for the "unused" attribute)])
86

    
87
dnl Check the function signature of getgrouplist()
88
AC_TRY_LINK([#define _BSD_SOURCE
89
             #include <grp.h>
90
             #include <unistd.h>],
91
            [int (*f)(const char *, int, int *, int *) = getgrouplist;],
92
            [AC_DEFINE(HAVE_GETGROUPLIST_TAKES_INTS, 1,
93
                       Define to 1 if getgrouplist() takes ints as arguments)])
94

    
95
dnl On some systems, calling /bin/login does not work. Disable the LOGIN
96
dnl feature, if the user tells us that it does not do the right thing.
97
AC_ARG_ENABLE(login,
98
              [  --disable-login           on some systems (e.g. Fedora), calling /bin/login
99
                            does not work well. If you know that your system
100
                            suffers from this problem, set this option to
101
                            remove support for the LOGIN keyword in the
102
                            service description.])
103
if test "x$enable_login" != xno; then
104
  AC_DEFINE(HAVE_BIN_LOGIN, 1,
105
                                Set if you want support for calling /bin/login)
106
fi
107

    
108
dnl We automatically detect SSL support, but allow users to disable it
109
AC_ARG_ENABLE(ssl,
110
              [  --disable-ssl             if available at built-time, support for SSL
111
                            connections will be enabled. It can still be
112
                            disabled at run-time, either on the daemon's
113
                            command line or if the operating system does not
114
                            have the OpenSSL libraries available.])
115

    
116
dnl We automatically detect PAM support, but allow users to disable it
117
AC_ARG_ENABLE(pam,
118
              [  --disable-pam             PAM support is necessary in order to authenticate
119
                            users for running programs other than their default
120
                            login shell.])
121

    
122
dnl We try to always use dlopen() instead of linking libraries dynamically, as
123
dnl this reduces the hard run-time dependencies that our binary has. But we
124
dnl allow users to disable this feature.
125
AC_ARG_ENABLE(runtime-loading,
126
              [  --disable-runtime-loading ShellInABox will try to load the OpenSSL, and PAM
127
                            libraries at run-time, if it has been compiled with
128
                            support for these libraries, and if the operating
129
                            system supports dynamic loading of libraries. This
130
                            allows you to install the same binary on different
131
                            systems independent of whether they have OpenSSL
132
                            and PAM enabled.  If you would rather directly link
133
                            these libraries into the binary, thus making them a
134
                            hard dependency, then disable runtime-loading.])
135

    
136
dnl Only test for OpenSSL headers, if not explicitly disabled
137
if test "x$enable_ssl" != xno; then
138
  AC_CHECK_HEADERS([openssl/bio.h openssl/err.h openssl/ssl.h])
139
fi
140

    
141
dnl Only test for PAM headers, if not explicitly disabled
142
if test "x$enable_pam" != xno; then
143
  AC_CHECK_HEADERS([security/pam_appl.h security/pam_client.h                 \
144
                    security/pam_misc.h ])
145
fi
146

    
147
dnl Only test for dlopen(), if not explicitly disabled. Add required libdl.so
148
dnl library if necessary. Also, if dlopen() is not available on this system,
149
dnl explicitly disable runtime loading.
150
if test "x$enable_runtime_loading" != xno; then
151
  AC_CHECK_FUNCS(dlopen, [],
152
                 [AC_CHECK_LIB(dl, dlopen,
153
                               [LIBS="-ldl $LIBS"
154
                                AC_DEFINE(HAVE_DLOPEN)],
155
                               [enable_runtime_loading=no])])
156
fi
157

    
158
dnl If runtime loading has been disabled, add OpenSSL and PAM as hard
159
dnl dependencies.
160
if test "x$enable_runtime_loading" == xno; then
161
  dnl Link against OpenSSL libraries, unless SSL support has been disabled
162
  if test "x$enable_ssl" != xno; then
163
    AC_CHECK_HEADER(openssl/bio.h,
164
      [AC_CHECK_HEADER(openssl/err.h,
165
        [AC_CHECK_HEADER(openssl/ssl.h, [LIBS="-lssl -lcrypto $LIBS"])])])
166
  fi
167

    
168
  dnl Link against PAM libraries, unless PAM support has been disabled
169
  if test "x$enable_pam" != xno; then
170
    AC_CHECK_HEADER(security/pam_appl.h, [LIBS="-lpam $LIBS"])
171
    AC_CHECK_HEADER(security/pam_misc.h, [LIBS="-lpam_misc $LIBS"])
172
  fi
173
fi
174

    
175
AC_CHECK_LIB(z, deflate, [
176
  AC_CHECK_HEADER(zlib.h, [LIBS="-lz $LIBS"
177
                           AC_DEFINE(HAVE_ZLIB, 1,
178
                           Define to 1 if zlib development files are installed)
179
])])
180

    
181
dnl Generate output files
182
AC_CONFIG_FILES([Makefile])
183
AC_OUTPUT
(20-20/56)