summaryrefslogtreecommitdiff
path: root/configure.ac
blob: efce482681ed6cbd6bb4ed10459f3a4457659a3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
dnl Process this file with autoconf to produce a configure script.
dnl
dnl Written by Russ Allbery <eagle@eyrie.org>
dnl Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012,
dnl     2013, 2014
dnl     The Board of Trustees of the Leland Stanford Junior University
dnl
dnl See LICENSE for licensing terms.

AC_PREREQ([2.64])
AC_INIT([remctl], [3.10], [eagle@eyrie.org])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_LIBOBJ_DIR([portable])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([1.11 check-news dist-xz foreign silent-rules subdir-objects
    -Wall -Werror])
AM_MAINTAINER_MODE

dnl Detect unexpanded macros.
m4_pattern_forbid([^PKG_])
m4_pattern_forbid([^RRA_])

dnl AM_PROG_AR is required for Automake 1.12 by Libtool but not defined at all
dnl (or needed) in Automake 1.11.  Work around this bug.
AC_PROG_CC
AC_USE_SYSTEM_EXTENSIONS
RRA_PROG_CC_CLANG
AC_SYS_LARGEFILE
AM_PROG_CC_C_O
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_PROG_INSTALL
AC_PROG_LIBTOOL
RRA_LD_VERSION_SCRIPT

dnl Support installation of systemd unit files.
RRA_WITH_SYSTEMD_UNITDIR

dnl Only used for the test suite.
AC_ARG_VAR([PATH_FAKEROOT], [Path to fakeroot for the test suite])
AC_PATH_PROG([PATH_FAKEROOT], [fakeroot])

dnl Probes for networking libraries.
AC_SEARCH_LIBS([gethostbyname], [nsl])
AC_SEARCH_LIBS([socket], [socket], [],
    [AC_CHECK_LIB([nsl], [socket], [LIBS="-lnsl -lsocket $LIBS"], [],
        [-lsocket])])

dnl Kerberos portability checks.
RRA_LIB_KRB5_OPTIONAL
AS_IF([test x"$rra_use_KRB5" != xfalse],
    [RRA_LIB_KRB5_SWITCH
     AC_CHECK_FUNCS([krb5_free_default_realm \
         krb5_get_init_creds_opt_alloc \
         krb5_get_init_creds_opt_set_anonymous \
         krb5_get_init_creds_opt_set_default_flags \
         krb5_get_init_creds_opt_set_out_ccache \
         krb5_principal_get_realm \
         krb5_xfree])
     AC_CHECK_FUNCS([krb5_get_init_creds_opt_free],
        [RRA_FUNC_KRB5_GET_INIT_CREDS_OPT_FREE_ARGS])
     AC_CHECK_DECLS([krb5_kt_free_entry], [], [], [RRA_INCLUDES_KRB5])
     AC_LIBOBJ([krb5-extra])
     RRA_LIB_KRB5_RESTORE])
AM_CONDITIONAL([HAVE_KRB5], [test x"$rra_use_KRB5" = xtrue])

dnl GSS-API portability checks.
RRA_LIB_GSSAPI
RRA_LIB_GSSAPI_SWITCH
AC_CHECK_DECLS([GSS_KRB5_MECHANISM], [],
   [AC_CHECK_DECLS([gss_mech_krb5], [],
       [AC_LIBOBJ([gssapi-mech])], [RRA_INCLUDES_GSSAPI])],
   [RRA_INCLUDES_GSSAPI])
AC_CHECK_FUNCS([gss_krb5_ccache_name gss_krb5_import_cred gss_oid_equal])
RRA_LIB_GSSAPI_RESTORE

dnl Check for libevent, used by the server.
RRA_LIB_EVENT
RRA_LIB_EVENT_SWITCH
AC_CHECK_HEADERS([event2/event.h])
AC_CHECK_TYPES([bufferevent_data_cb, bufferevent_event_cb, event_callback_fn,
                evutil_socket_t],
    [], [], [RRA_INCLUDES_EVENT])
AC_CHECK_FUNCS([bufferevent_get_input \
    bufferevent_read_buffer \
    bufferevent_socket_new \
    evbuffer_get_length \
    event_base_got_break \
    event_base_loopbreak \
    event_free \
    event_new \
    event_set_fatal_callback \
    libevent_global_shutdown])
RRA_LIB_EVENT_RESTORE

dnl Check for the systemd daemon support library.
RRA_LIB_SYSTEMD_DAEMON_OPTIONAL

dnl Check for the CMU GPUT library.
RRA_LIB_GPUT

dnl Check for regex libraries for pcre:* and regex:* ACL support.
RRA_LIB_PCRE_OPTIONAL
AC_CHECK_HEADER([regex.h], [AC_CHECK_FUNCS([regcomp])])

dnl General C library and networking probes.
AC_HEADER_STDBOOL
AC_CHECK_HEADERS([sys/bitypes.h sys/filio.h sys/select.h sys/time.h \
                  sys/uio.h syslog.h])
AC_CHECK_DECLS([snprintf, vsnprintf])
AC_CHECK_DECLS([h_errno], [], [], [#include <netdb.h>])
AC_CHECK_DECLS([inet_aton, inet_ntoa], [], [],
    [#include <sys/types.h>
     #include <netinet/in.h>
     #include <arpa/inet.h>])
RRA_C_C99_VAMACROS
RRA_C_GNU_VAMACROS
AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [],
    [#include <sys/types.h>
     #include <sys/socket.h>])
AC_TYPE_LONG_LONG_INT
AC_CHECK_TYPES([sig_atomic_t], [], [],
    [#include <sys/types.h>
     #include <signal.h>])
AC_CHECK_TYPES([ssize_t], [], [],
    [#include <sys/types.h>])
AC_CHECK_TYPES([socklen_t], [], [],
    [#include <sys/types.h>
     #include <sys/socket.h>])
AC_CHECK_TYPES([struct sockaddr_in6],
    [AC_DEFINE([HAVE_INET6], [1],
        [Define to 1 if IPv6 library interfaces are available.])], [],
    [#include <sys/types.h>
     #include <netinet/in.h>])
AC_CHECK_TYPES([struct sockaddr_storage],
    [AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family], [], [],
        [#include <sys/types.h>
         #include <sys/socket.h>])], [],
    [#include <sys/types.h>
     #include <sys/socket.h>])
RRA_MACRO_IN6_ARE_ADDR_EQUAL
RRA_MACRO_SA_LEN
RRA_FUNC_INET_NTOA
RRA_FUNC_SNPRINTF
AC_CHECK_FUNCS([getaddrinfo],
    [RRA_FUNC_GETADDRINFO_ADDRCONFIG],
    [AC_LIBOBJ([getaddrinfo])])
AC_CHECK_FUNCS([getgrnam_r setrlimit setsid])
AC_REPLACE_FUNCS([asprintf daemon getnameinfo getopt inet_aton inet_ntop \
                  mkstemp reallocarray setenv strndup])

dnl Whether to build the Perl bindings.  Put this late so that it shows up
dnl near the bottom of the --help output.
build_perl=
AC_ARG_ENABLE([perl],
    [AC_HELP_STRING([--enable-perl], [Build Perl libremctl bindings])],
    [AS_IF([test x"$enableval" = xyes], [build_perl=yes])])
AM_CONDITIONAL([BUILD_PERL], [test x"$build_perl" = xyes])
AS_IF([test x"$build_perl" = xyes],
    [AC_PATH_PROG([PERL], [perl])
     PERL_LDFLAGS=`"$PERL" -MConfig -e 'print $Config{lddlflags}'`])
AC_SUBST([PERL_LDFLAGS])

dnl Whether to build the PHP bindings.  The dance required to be able to run
dnl phpize before AC_OUTPUT sucks like a sucking thing.
build_php=
AC_ARG_ENABLE([php],
    [AC_HELP_STRING([--enable-php], [Build remctl PECL extension for PHP])],
    [AS_IF([test x"$enableval" = xyes],
        [build_php=yes
         AC_ARG_VAR([PHPIZE], [Path to phpize])
         AC_PATH_PROG([PHPIZE], [phpize])
         AS_IF([test x"$PHPIZE" = x],
             [AC_MSG_ERROR([cannot build PECL extension without phpize])])])])
AM_CONDITIONAL([BUILD_PHP], [test x"$build_php" = xyes])

dnl Whether to build the Python bindings.
build_python=
AC_ARG_ENABLE([python],
    [AC_HELP_STRING([--enable-python], [Build Python libremctl bindings])],
    [AS_IF([test x"$enableval" = xyes], [build_python=yes])])
AM_CONDITIONAL([BUILD_PYTHON], [test x"$build_python" = xyes])

dnl Whether to build the Ruby bindings.
build_ruby=
AC_ARG_ENABLE([ruby],
    [AC_HELP_STRING([--enable-ruby], [Build Ruby libremctl bindings])],
    [AS_IF([test x"$enableval" = xyes], [build_ruby=yes])])
AM_CONDITIONAL([BUILD_RUBY], [test x"$build_ruby" = xyes])

dnl Used when building the Perl module.  Normally link against all the
dnl dependencies that libremctl may need, but don't do so if
dnl --enable-reduced-depends was specified.
AS_IF([test x"$rra_reduced_depends" = xtrue],
    [DEPEND_LIBS=],
    [DEPEND_LIBS="$GSSAPI_LDFLAGS $GSSAPI_LIBS $KRB5_LDFLAGS $KRB5_LIBS"])
AC_SUBST([DEPEND_LIBS])

AC_CONFIG_FILES([Makefile java/build.xml java/local.properties])
AC_CONFIG_FILES([tests/data/conf-simple])
AS_IF([test x"$build_php" = xyes],
    [AC_CONFIG_FILES([php/config.m4 php/php_remctl.h])])
AS_IF([test x"$build_python" = xyes],
    [AC_CONFIG_FILES([python/remctl.py python/setup.py])
     AC_CONFIG_FILES([python/test_remctl.py])])
AS_IF([test x"$build_ruby" = xyes],
    [AC_CONFIG_FILES([ruby/extconf.rb ruby/test_remctl.rb])])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_COMMANDS([docs], [test -d docs || mkdir docs])
AC_CONFIG_COMMANDS([tests/config],
    [test -d tests/config || mkdir tests/config])
AC_OUTPUT