-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathconfigure.ac
224 lines (189 loc) · 7.28 KB
/
configure.ac
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
212
213
214
215
216
217
218
219
220
221
222
223
224
AC_PREREQ([2.69])
AC_INIT([x0], [0.11.0-dev], [christian@parpart.family], [], [https://github.com/christianparpart/x0])
dnl AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_SRCDIR([configure.ac])
dnl AC_CONFIG_MACRO_DIRS([m4])
AM_INIT_AUTOMAKE([foreign subdir-objects serial-tests])
AM_MAINTAINER_MODE([enable])
AM_SILENT_RULES([yes])
AC_LANG_CPLUSPLUS
AC_PROG_CXX
AM_PROG_AR
AC_PROG_RANLIB
#AC_PROG_CC
#AC_PROG_CC_FOR_BUILD
#AC_PROG_CXX_FOR_BUILD
#AC_PROC_LIBTOOL
#AM_PROG_AS
#LT_INIT
PKG_PROG_PKG_CONFIG([0.25])
uname_system=`uname -s`
AC_MSG_NOTICE("Operating system: $uname_system")
AM_CONDITIONAL([PLATFORM_DARWIN], [test x$uname_system = xDarwin])
AM_CONDITIONAL([PLATFORM_LINUX], [test x$uname_system = xLinux])
AM_CONDITIONAL([PLATFORM_WSL], [uname -r | grep -q Microsoft])
AS_IF([uname -r | grep -q Microsoft],
[AC_DEFINE([PLATFORM_WSL], [1], [Platform: Windows Subsystem for Linux])])
AC_HEADER_STDC
AC_CHECK_HEADERS([sys/sendfile.h])
AC_CHECK_HEADERS([sys/resource.h])
AC_CHECK_HEADERS([sys/inotify.h])
AC_CHECK_HEADERS([sys/limits.h])
AC_CHECK_HEADERS([sys/mman.h])
AC_CHECK_HEADERS([sys/utsname.h])
AC_CHECK_HEADERS([security/pam_appl.h])
AC_CHECK_HEADERS([bzlib.h])
AC_CHECK_HEADERS([dlfcn.h])
AC_CHECK_HEADERS([execinfo.h])
AC_CHECK_HEADERS([netdb.h])
AC_CHECK_HEADERS([pwd.h])
AC_CHECK_HEADERS([pthread.h])
AC_CHECK_HEADERS([signal.h])
AC_CHECK_HEADERS([syslog.h])
AC_CHECK_HEADERS([unistd.h])
AC_CHECK_HEADERS([zlib.h])
AC_CHECK_DECLS([pthread_getname_np], [], [], [[#include <pthread.h>]])
AC_CHECK_DECLS([pthread_setname_np], [], [], [[#include <pthread.h>]])
AC_CHECK_DECLS([pthread_setaffinity_np], [], [], [[#include <pthread.h>]])
AC_CHECK_FUNCS([inotify_init1])
AC_CHECK_FUNCS([chroot])
AC_CHECK_FUNCS([pathconf])
AC_CHECK_FUNCS([sendfile])
AC_CHECK_FUNCS([posix_fadvise])
AC_CHECK_FUNCS([readahead])
AC_CHECK_FUNCS([pread])
AC_CHECK_FUNCS([nanosleep])
AC_CHECK_FUNCS([daemon])
AC_CHECK_FUNCS([sysconf])
AC_CHECK_FUNCS([pipe2])
AC_CHECK_FUNCS([dup2])
AC_CHECK_FUNCS([fork])
AC_CHECK_FUNCS([backtrace])
AC_CHECK_FUNCS([clock_gettime])
AC_CHECK_FUNCS([mkostemps])
AC_CHECK_FUNCS([backtrace])
# ----------------------------------------------------------------------------
# libxzero configuration
AC_ARG_WITH([clusterdir],
AS_HELP_STRING([--with-clusterdir],
[Path to HTTP cluster config directory]))
AS_IF([test "x$with_clusterdir" = "x"],
[XZERO_CLUSTERDIR="$localstatedir/cluster"],
[XZERO_CLUSTERDIR="$with_clusterdir"])
AC_SUBST([XZERO_CLUSTERDIR])
# ----------------------------------------------------------------------------
# x0d configuration
AC_ARG_WITH([configfile],
AS_HELP_STRING([--with-configfile=PATH],
[Path to x0d.conf file]))
AS_IF([test "x$with_configfile" = "x"],
[X0D_CONFIGFILE="$sysconfdir/cluster"],
[X0D_CONFIGFILE="$with_configfile"])
AC_SUBST([X0D_CONFIGFILE])
AC_ARG_WITH([logdir],
AS_HELP_STRING([--with-logdir=PATH],
[x0d log dir]))
AS_IF([test "x$with_logdir" = "x"],
[X0D_LOGDIR="$localstatedir/log"],
[X0D_LOGDIR="$with_logdir"])
AC_SUBST([X0D_LOGDIR])
AC_ARG_WITH([pidfile], AS_HELP_STRING([--with-pidfile=PATH], [Path to x0d.pid file]))
AS_IF([test "x$with_pidfile" = "x"],
[X0D_PIDFILE=""],
[X0D_PIDFILE="$with_pidfile"])
AC_SUBST([X0D_PIDFILE])
# ----------------------------------------------------------------------------
# Conditional Features
AC_ARG_ENABLE([inotify],
AS_HELP_STRING([--disable-inotify],
[Disables inotify support.]))
AS_IF([test "x$enable_inotify" != xno],
[AC_DEFINE([ENABLE_INOTIFY], [1], [to inotify or not to inotify])])
AC_ARG_ENABLE([accept4],
AS_HELP_STRING([--disable-accept4],
[Disables accept4() support, using accept() + fcntl() instead.]))
AS_IF([test "x$enable_accept4" != xno],
[AC_DEFINE([ENABLE_ACCEPT4], [1], [Enables use of accept4()])])
AC_ARG_ENABLE([pipe2],
AS_HELP_STRING([--disable-pipe2],
[Disables pipe2() support, using pipe() + fcntl() instead.]))
AS_IF([test "x$enable_pipe2" != xno],
[AC_DEFINE([ENABLE_PIPE2], [1], [Enables use of pipe2()])])
AC_ARG_ENABLE([multi-accept],
AS_HELP_STRING([--disable-multi-accept],
[Disables multiple-accept() call support.]))
AS_IF([test "x$enable_multi_accept" != xno],
[AC_DEFINE([ENABLE_MULTI_ACCEPT], [1], [Enables use of multiple accept() calls])])
AC_ARG_ENABLE([o_tmpfile],
AS_HELP_STRING([--disable-o_tmpfile],
[Disables use of O_TMPFILE feature.]))
AS_IF([test "x$enable_o_tmpfile" != xno],
[AC_DEFINE([ENABLE_O_TMPFILE], [1], [Enables use of O_TMPFILE])])
# ----------------------------------------------------------------------------
# Conditional Binaries
AC_ARG_ENABLE([xurl],
AS_HELP_STRING([--enable-xurl],
[Enables building xurl CLI.]))
AM_CONDITIONAL([ENABLE_XURL], [test x$enable_xurl = xyes])
# ----------------------------------------------------------------------------
# some more dependencies
dnl OpenSSL
# PKG_CHECK_MODULES([OPENSSL], [openssl], [HAVE_OPENSSL=1])
# AC_SUBST([HAVE_OPENSSL])
AS_IF([test "x$uname_system" = xDarwin],
[OPENSSL_CFLAGS="-I/usr/local/opt/openssl/include"
OPENSSL_LDADD="/usr/local/opt/openssl/lib/libssl.dylib /usr/local/opt/openssl/lib/libcrypto.dylib"],
[OPENSSL_CFLAGS=""
OPENSSL_LDADD="-lssl -lcrypto"])
AC_SUBST(OPENSSL_CFLAGS)
AC_SUBST(OPENSSL_LDADD)
PAM_LDFLAGS="-lpam" # TODO
AC_SUBST(PAM_LDFLAGS)
BZLIB_LIBS="" # TODO
AC_SUBST([BZLIB_LIBS])
PKG_CHECK_MODULES([ZLIB], [zlib], [HAVE_ZLIB=1])
AC_SUBST([HAVE_ZLIB])
####### Platform Flags ########################################################
AC_RUN_IFELSE([
AC_LANG_SOURCE([[
#include <utsname.h>
#include <string.h>
#include <stdio.h>
int main() {
struct utsname uts;
uname(&uts);
if (strstr(uts.release, "Microsoft") != NULL) {
return 0;
} else {
return 1;
}
}
]])],
[is_wsl=no; AC_MSG_NOTICE([Yay, no WSL])],
[is_wsl=yes; uname_all=`uname -a`; AC_MSG_NOTICE([Microsoft Windows Subsystem for Linux: ] $uname_all)]
)
AS_IF([test "x$is_wsl" != xno],
[AC_DEFINE([XZERO_WSL], [1], [Works around WSL oddities (Windows Subsystem for Linux)])])
AS_IF([test "x$uname_system" = xDarwin],
[PLATFORM_CXXFLAGS="-stdlib=libc++"])
AS_IF([test "x$uname_system" = xLinux],
[PLATFORM_LDFLAGS="-lrt"])
AC_SUBST([PLATFORM_CXXFLAGS])
AC_SUBST([PLATFORM_LDFLAGS])
####### OUTPUT ################################################################
BASE_CXXFLAGS="-DXOPEN_SOURCE=600 -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE \
-D_LARGEFILE_SOURCE -D_LARGE_FILES -Wall -Wextra -std=c++1z \
-Wno-unused-variable -Wno-unused-parameter \
$PLATFORM_CXXFLAGS $OPENSSL_CFLAGS"
AC_SUBST([BASE_CXXFLAGS])
BASE_LIBS="$PLATFORM_LDFLAGS $OPENSSL_LDADD $OPENSSL_LIBS \
$ZLIB_LIBS $BZLIB_LIBS -lresolv"
AC_SUBST([BASE_LIBS])
BASE_LDFLAGS="-rdynamic"
AC_SUBST([BASE_LDFLAGS])
AS_IF([test "x$enable_xurl" = xyes],
[AC_MSG_NOTICE([Builds with CLI xurl: yes])],
[AC_MSG_NOTICE([Builds with CLI xurl: no])])
AC_CONFIG_HEADERS(src/xzero/sysconfig.h)
AC_CONFIG_FILES(Makefile XzeroBase.pc XzeroFlow.pc XzeroTest.pc)
AC_OUTPUT