-
-
Notifications
You must be signed in to change notification settings - Fork 191
Expand file tree
/
Copy pathconfigure.ac
More file actions
413 lines (363 loc) · 15.1 KB
/
Copy pathconfigure.ac
File metadata and controls
413 lines (363 loc) · 15.1 KB
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
#
# This file is part of libhttpserver
# Copyright (C) 2011-2021 Sebastiano Merlino
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
m4_define([libhttpserver_MAJOR_VERSION],[2])dnl
m4_define([libhttpserver_MINOR_VERSION],[0])dnl
m4_define([libhttpserver_REVISION],[0])dnl
m4_define([libhttpserver_PKG_VERSION],[libhttpserver_MAJOR_VERSION.libhttpserver_MINOR_VERSION.libhttpserver_REVISION])dnl
m4_define([libhttpserver_LDF_VERSION],[libhttpserver_MAJOR_VERSION:libhttpserver_MINOR_VERSION:libhttpserver_REVISION])dnl
AC_INIT([libhttpserver], libhttpserver_PKG_VERSION, [electrictwister2000@gmail.com])
AM_INIT_AUTOMAKE([subdir-objects])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AC_CANONICAL_HOST
# TASK-088: sgcheck (exp-sgcheck) was removed upstream in Valgrind 3.20; the
# CI Valgrind (ubuntu-latest -> 3.22) no longer ships it, so it is disabled
# by default here rather than probed and skipped. helgrind + drd stay on
# (their default) so the Valgrind lane runs memcheck + both race detectors.
# AX_VALGRIND_DFLT calls must precede AX_VALGRIND_CHECK.
AX_VALGRIND_DFLT([sgcheck], [off])
AX_VALGRIND_CHECK
OLD_CXXFLAGS=$CXXFLAGS
LT_INIT
AC_PROG_CC
AC_PROG_CXX()
AC_PROG_LN_S
CXXFLAGS=$OLD_CXXFLAGS
AC_LANG([C++])
AC_SYS_LARGEFILE
# Minimal feature-set required
AX_CXX_COMPILE_STDCXX([20], [noext], [mandatory])
native_srcdir=$srcdir
AC_MSG_CHECKING([whether it is possible to compile in the same directory])
AC_ARG_ENABLE([same-directory-build],
[AS_HELP_STRING([--enable-same-directory-build],
[enable to compile in the same directory. This is heavily discouraged. (def=no)])],
[samedirectory="$enableval"],
[samedirectory=no])
AC_MSG_RESULT([$samedirectory])
if test x"$samedirectory" = x"no"; then
if test "`cd $srcdir; /bin/pwd`" = "`/bin/pwd`"; then
AC_MSG_ERROR("you must configure in a separate build directory")
fi
fi
is_windows=yes;
NETWORK_LIBS=""
case "$host" in
*-mingw*)
NETWORK_HEADER="winsock2.h"
ADDITIONAL_LIBS="-lpthread -no-undefined"
NETWORK_LIBS="-lws2_32"
native_srcdir=$(cd $srcdir; pwd -W)
;;
*-msys*)
AC_MSG_WARN([
Building from MSYS environment. Binaries will depend on msys-2.0.dll.
For native Windows binaries, use the MinGW64 shell instead.
])
NETWORK_HEADER="winsock2.h"
ADDITIONAL_LIBS="-lpthread -no-undefined"
NETWORK_LIBS="-lws2_32"
native_srcdir=$(cd $srcdir; pwd -W)
# libmicrohttpd's <microhttpd.h> asserts _SYS_TYPES_FD_SET on Cygwin/MSYS.
# newlib defines that macro via <sys/select.h>, included from <sys/types.h>
# only when __BSD_VISIBLE -- i.e. when _DEFAULT_SOURCE is set. Strict ANSI
# C++ (-std=c++NN, AX_CXX_COMPILE_STDCXX noext) suppresses newlib's
# auto-define, so expose it explicitly here.
CPPFLAGS="-D_DEFAULT_SOURCE $CPPFLAGS"
;;
*-cygwin*)
NETWORK_HEADER="arpa/inet.h"
ADDITIONAL_LIBS="-lpthread -no-undefined"
# See *-msys* note: libmicrohttpd's fd_set check needs _DEFAULT_SOURCE
# under -std=c++NN strict mode.
CPPFLAGS="-D_DEFAULT_SOURCE $CPPFLAGS"
;;
*)
NETWORK_HEADER="arpa/inet.h"
ADDITIONAL_LIBS=""
is_windows=no
;;
esac
# Checks for header files.
AC_CHECK_HEADER([stdint.h],[],[AC_MSG_ERROR("stdint.h not found")])
AC_CHECK_HEADER([inttypes.h],[],[AC_MSG_ERROR("inttypes.h not found")])
AC_CHECK_HEADER([errno.h],[],[AC_MSG_ERROR("errno.h not found")])
AC_CHECK_HEADER([unistd.h],[],[AC_MSG_ERROR("unistd.h not found")])
AC_CHECK_HEADER([ctype.h],[],[AC_MSG_ERROR("cctype not found")])
AC_CHECK_HEADER([sys/stat.h],[],[AC_MSG_ERROR("sys/stat.h not found")])
AC_CHECK_HEADER([sys/types.h],[],[AC_MSG_ERROR("sys/types.h not found")])
AC_CHECK_HEADER([$NETWORK_HEADER],[],[AC_MSG_ERROR("$NETWORK_HEADER not found")])
AC_CHECK_HEADER([signal.h],[],[AC_MSG_ERROR("signal.h not found")])
AC_CHECK_HEADER([gnutls/gnutls.h],[have_gnutls="yes"],[AC_MSG_WARN("gnutls/gnutls.h not found. TLS will be disabled"); have_gnutls="no"])
# TASK-068: portable secure-zero primitive selection. Probe for
# explicit_bzero (glibc / musl / FreeBSD / OpenBSD / *BSD). The header
# httpserver/detail/secure_zero.hpp dispatches at compile time based on
# whether this is available. Windows takes the RtlSecureZeroMemory
# branch; macOS and other platforms without explicit_bzero take the
# portable volatile + asm-clobber fallback (which has the same security
# guarantee without the __STDC_WANT_LIB_EXT1__ include-order coupling
# that memset_s would impose on a transitively-included header).
#
# The HAVE_EXPLICIT_BZERO macro is pushed into AM_CXXFLAGS / AM_CFLAGS
# (matching the established libhttpserver pattern for HAVE_GNUTLS /
# HAVE_BAUTH / etc.) so it reaches the header without requiring an
# explicit `#include "config.h"` from secure_zero.hpp.
AC_CHECK_DECLS([explicit_bzero], [], [], [[#include <string.h>]])
AS_IF([test "x$ac_cv_have_decl_explicit_bzero" = "xyes"],
[AM_CXXFLAGS="$AM_CXXFLAGS -DHAVE_EXPLICIT_BZERO"
AM_CFLAGS="$AM_CFLAGS -DHAVE_EXPLICIT_BZERO"])
# Checks for libmicrohttpd
if test x"$host" = x"$build"; then
AC_CHECK_HEADER([microhttpd.h],
AC_CHECK_LIB([microhttpd], [MHD_start_daemon],
[AC_MSG_CHECKING([for libmicrohttpd >= 1.0.0])
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([
#include <microhttpd.h>
#if (MHD_VERSION < 0x01000000)
#error needs at least version 1.0.0
#endif
int main () { return 0; }
])],
[],
[AC_MSG_ERROR("libmicrohttpd is too old - install libmicrohttpd >= 1.0.0")]
)
],
[AC_MSG_ERROR(["libmicrohttpd not found"])]
),
[AC_MSG_ERROR(["microhttpd.h not found"])]
)
# -DHTTPSERVER_COMPILATION is intentionally NOT injected globally into
# CXXFLAGS. It is added per-target via AM_CPPFLAGS in src/Makefile.am and
# test/Makefile.am so that examples (and any other consumer-style TUs)
# build through the umbrella header without seeing the internal macro.
CXXFLAGS="-D_REENTRANT $LIBMICROHTTPD_CFLAGS $CXXFLAGS"
LDFLAGS="$LIBMICROHTTPD_LIBS $NETWORK_LIBS $ADDITIONAL_LIBS $LDFLAGS"
cond_cross_compile="no"
else
AC_CHECK_HEADER([microhttpd.h],
AC_CHECK_LIB([microhttpd], [MHD_start_daemon],
[],
[AC_MSG_ERROR(["libmicrohttpd not found"])]
),
[AC_MSG_ERROR(["microhttpd.h not found"])]
)
# See note above: HTTPSERVER_COMPILATION is scoped to lib + tests via
# per-directory AM_CPPFLAGS, not injected globally into CXXFLAGS.
CXXFLAGS="-D_REENTRANT $CXXFLAGS"
LDFLAGS="$NETWORK_LIBS $ADDITIONAL_LIBS $LDFLAGS"
cond_cross_compile="yes"
fi
AM_CONDITIONAL([COND_CROSS_COMPILE],[test x"$cond_cross_compile" = x"yes"])
AC_SUBST(COND_CROSS_COMPILE)
# Check for basic auth v3 support in libmicrohttpd
AC_CHECK_LIB([microhttpd], [MHD_basic_auth_get_username_password3],
[have_bauth="yes"],
[have_bauth="no"; AC_MSG_WARN("libmicrohttpd basic auth v3 support not found. Basic auth will be disabled")])
# Check for digest auth v3 support in libmicrohttpd
AC_CHECK_LIB([microhttpd], [MHD_digest_auth_check3],
[have_dauth="yes"],
[have_dauth="no"; AC_MSG_WARN("libmicrohttpd digest auth v3 support not found. Digest auth will be disabled")])
# Check for WebSocket support in libmicrohttpd_ws
AC_CHECK_HEADER([microhttpd_ws.h],
[AC_CHECK_LIB([microhttpd_ws], [MHD_websocket_stream_init],
[have_websocket="yes"],
[have_websocket="no"; AC_MSG_WARN("libmicrohttpd_ws not found. WebSocket support will be disabled")])],
[have_websocket="no"; AC_MSG_WARN("microhttpd_ws.h not found. WebSocket support will be disabled")])
AC_MSG_CHECKING([whether to build with TCP_FASTOPEN support])
AC_ARG_ENABLE([fastopen],
[AS_HELP_STRING([--enable-fastopen],
[enable use of TCP_FASTOPEN (def=yes)])],
[fastopen="$enableval"],
[fastopen=yes])
AC_MSG_RESULT([$fastopen])
is_fastopen_supported=no;
if test x"$fastopen" = x"yes" && test x"$is_windows" = x"no"; then
major=`uname -r | cut -d. -f1`
minor=`uname -r | cut -d. -f2`
if test "$major" -ge 4 || { test "$major" -eq 3 && test "$minor" -ge 7; }; then
CXXFLAGS="-DUSE_FASTOPEN $CXXFLAGS";
is_fastopen_supported=yes;
fi
fi
AC_MSG_CHECKING([whether to link statically])
AC_ARG_ENABLE([static],
[AS_HELP_STRING([--enable-static],
[enable use static linking (def=yes)])],
[static="$enableval"],
[static=yes])
AC_MSG_RESULT([$static])
if test x"$static" = x"$yes"; then
LDFLAGS="-static $LDFLAGS";
fi
m4_pattern_allow([AC_TYPE_SIZE_T])
m4_pattern_allow([AC_TYPE_UINT16_T])
m4_pattern_allow([AC_TYPE_UINT32_T])
m4_pattern_allow([AC_TYPE_UINT64_T])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
LHT_LIBDEPS="-lmicrohttpd"
AC_MSG_CHECKING([whether to build with debug information])
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
[enable debug data generation (def=no)])],
[debugit="$enableval"],
[debugit=no])
AC_MSG_RESULT([$debugit])
AM_LDFLAGS="-lstdc++"
if test x"$debugit" = x"yes"; then
AC_DEFINE([DEBUG],[],[Debug Mode])
# -std=c++20 is injected by AX_CXX_COMPILE_STDCXX into the CXX variable,
# not repeated here. Omitting it avoids a double-standard flag conflict.
AM_CXXFLAGS="$AM_CXXFLAGS -DDEBUG -g -Wall -Wextra -Werror -pedantic -Wno-unused-command-line-argument -O0"
AM_CFLAGS="$AM_CXXFLAGS -DDEBUG -g -Wall -Wextra -Werror -pedantic -Wno-unused-command-line-argument -O0"
else
AC_DEFINE([NDEBUG],[],[No-debug Mode])
AM_CXXFLAGS="$AM_CXXFLAGS -O3"
AM_CFLAGS="$AM_CXXFLAGS -O3"
fi
case $host_os in
darwin* )
AM_CXXFLAGS="$AM_CXXFLAGS -DDARWIN"
AM_CFLAGS="$AM_CFLAGS -DDARWIN"
;;
freebsd* )
AM_LDFLAGS=""
;;
esac
AC_MSG_CHECKING([whether to build with coverage information])
AC_ARG_ENABLE([coverage],
[AS_HELP_STRING([--enable-coverage],
[enable coverage data generation (def=no)])],
[coverit="$enableval"],
[coverit=no])
AC_MSG_RESULT([$coverit])
if test x"$coverit" = x"yes"; then
case $host_os in
darwin* )
echo "Coverage not supported on OSX"
cond_gcov="no"
;;
*)
AC_CHECK_PROG(GCOV, gcov, gcov)
cond_gcov="yes"
;;
esac
fi
AC_ARG_ENABLE([[examples]],
[AS_HELP_STRING([[--disable-examples]], [do not build any examples])], ,
[enable_examples=yes])
test "x$enable_examples" = "xno" || enable_examples=yes
AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$enable_examples" = "xyes"])
AM_CONDITIONAL([COND_GCOV],[test x"$cond_gcov" = x"yes"])
AC_SUBST(COND_GCOV)
if test x"$have_gnutls" = x"yes"; then
AM_CXXFLAGS="$AM_CXXFLAGS -DHAVE_GNUTLS"
AM_CFLAGS="$AM_CXXFLAGS -DHAVE_GNUTLS"
fi
AM_CONDITIONAL([HAVE_GNUTLS],[test x"$have_gnutls" = x"yes"])
if test x"$have_bauth" = x"yes"; then
AM_CXXFLAGS="$AM_CXXFLAGS -DHAVE_BAUTH"
AM_CFLAGS="$AM_CXXFLAGS -DHAVE_BAUTH"
fi
AM_CONDITIONAL([HAVE_BAUTH],[test x"$have_bauth" = x"yes"])
if test x"$have_dauth" = x"yes"; then
AM_CXXFLAGS="$AM_CXXFLAGS -DHAVE_DAUTH"
AM_CFLAGS="$AM_CXXFLAGS -DHAVE_DAUTH"
fi
AM_CONDITIONAL([HAVE_DAUTH],[test x"$have_dauth" = x"yes"])
if test x"$have_websocket" = x"yes"; then
AM_CXXFLAGS="$AM_CXXFLAGS -DHAVE_WEBSOCKET"
AM_CFLAGS="$AM_CXXFLAGS -DHAVE_WEBSOCKET"
LHT_LIBDEPS="$LHT_LIBDEPS -lmicrohttpd_ws"
fi
AM_CONDITIONAL([HAVE_WEBSOCKET],[test x"$have_websocket" = x"yes"])
DX_HTML_FEATURE(ON)
DX_CHM_FEATURE(OFF)
DX_CHI_FEATURE(OFF)
DX_MAN_FEATURE(ON)
DX_RTF_FEATURE(OFF)
DX_XML_FEATURE(OFF)
DX_PDF_FEATURE(OFF)
DX_PS_FEATURE(OFF)
DX_INIT_DOXYGEN([$PACKAGE_NAME],[doxyconfig.in])
# Export the libtool version-number triple so src/Makefile.am can scope it
# to libhttpserver_la_LDFLAGS rather than injecting it into the global LDFLAGS
# (which would affect all link steps, not just the shared library).
LHT_LDF_VERSION="libhttpserver_LDF_VERSION"
AC_SUBST(LHT_LDF_VERSION)
AC_SUBST(LHT_LIBDEPS)
AC_SUBST(AM_CXXFLAGS)
AC_SUBST(AM_CFLAGS)
AC_SUBST(AM_LDFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LIBS)
AC_SUBST(LDFLAGS)
AC_SUBST(EXT_LIB_PATH)
AC_SUBST(EXT_LIBS)
AC_CONFIG_FILES([test/test_content:test/test_content])
AC_CONFIG_FILES([test/test_content_2:test/test_content_2])
AC_CONFIG_FILES([test/test_content_empty:test/test_content_empty])
AC_CONFIG_FILES([test/test_content_large:test/test_content_large])
AC_CONFIG_FILES([test/cert.pem:test/cert.pem])
AC_CONFIG_FILES([test/key.pem:test/key.pem])
AC_CONFIG_FILES([test/test_root_ca.pem:test/test_root_ca.pem])
AC_CONFIG_FILES([test/client_cert.pem:test/client_cert.pem])
AC_CONFIG_FILES([test/client_key.pem:test/client_key.pem])
AC_CONFIG_FILES([test/client_cert_no_cn.pem:test/client_cert_no_cn.pem])
AC_CONFIG_FILES([test/client_key_no_cn.pem:test/client_key_no_cn.pem])
AC_CONFIG_FILES([test/client_cert_untrusted.pem:test/client_cert_untrusted.pem])
AC_CONFIG_FILES([test/client_key_untrusted.pem:test/client_key_untrusted.pem])
AC_CONFIG_FILES([test/libhttpserver.supp:test/libhttpserver.supp])
# TASK-088: helgrind/drd suppression files must be copied into the build dir
# so VALGRIND_SUPPRESSIONS_FILES (bare filenames, resolved against builddir)
# find them in an out-of-tree build — mirroring libhttpserver.supp above.
AC_CONFIG_FILES([test/valgrind-helgrind.supp:test/valgrind-helgrind.supp])
AC_CONFIG_FILES([test/valgrind-drd.supp:test/valgrind-drd.supp])
AC_CONFIG_FILES([examples/cert.pem:examples/cert.pem])
AC_CONFIG_FILES([examples/key.pem:examples/key.pem])
AC_CONFIG_FILES([examples/test_content:examples/test_content])
AC_OUTPUT(
libhttpserver.pc
Makefile
doc/Makefile
src/Makefile
test/Makefile
examples/Makefile
)
AC_MSG_NOTICE([Configuration Summary:
Operating System: ${host_os}
Host triplet : ${host}
Target directory: ${prefix}
License : LGPL only
Debug : ${debugit}
TLS Enabled : ${have_gnutls}
Basic Auth : ${have_bauth}
Digest Auth : ${have_dauth}
WebSocket : ${have_websocket}
TCP_FASTOPEN : ${is_fastopen_supported}
Static : ${static}
Windows build : ${is_windows}
Build examples : ${enable_examples}
])