-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure.ac
More file actions
342 lines (279 loc) · 12.8 KB
/
configure.ac
File metadata and controls
342 lines (279 loc) · 12.8 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
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
#
# LibNetBlock - A library which blocks programs from accessing the network.
# -- configure.ac, part of the build system.
#
# Copyright (C) 2007-2024 Bogdan Drozdowski, bogdro (at) users . sourceforge . net
# License: GNU General Public License, v3+
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
AC_PREREQ([2.71])
AC_INIT([LibNetBlock],[1.8],[bogdro@users.sourceforge.net],[libnetblock],[https://libnetblock.sourceforge.io])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([-Wall])
AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile test/Makefile
doc/libnetblock.texi libnetblock.spec src/lnb_cfg.h
src/libnetblock.h src/lnb_public.c libnetblock.pc])
AC_CONFIG_SRCDIR([src/lnb_net.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
# ==================== configure arguments
AC_ARG_ENABLE([public-interface],
AS_HELP_STRING([--enable-public-interface],
[Enable the library's public interface @<:@default=no@:>@.]),
[if (test "x$enableval" = "xyes"); then
public_if=yes
else
public_if=no
fi
]
,[public_if=no])
AM_CONDITIONAL(PUBLIC_INTERFACE, test "x$public_if" = "xyes")
AC_ARG_ENABLE([environment],
AS_HELP_STRING([--enable-environment],
[Enable additional ban files pointed to by environment variables @<:@default=yes@:>@.]),
[if (test "x$enableval" = "xyes"); then
environment=yes
else
environment=no
fi
]
,[environment=yes])
if (test "x$environment" = "xyes"); then
AC_DEFINE([LNB_ENABLE_ENV], [1],
[Whether or not to enable additional ban files pointed to by environment variables.])
fi
AC_ARG_ENABLE([user-files],
AS_HELP_STRING([--enable-user-files],
[Enable additional ban files located in users' home directories @<:@default=yes@:>@.]),
[if (test "x$enableval" = "xyes"); then
user_files=yes
else
user_files=no
fi
]
,[user_files=yes])
if (test "x$user_files" = "xyes"); then
AC_DEFINE([LNB_ENABLE_USERBANS], [1],
[Whether or not to enable additional ban files located in users' home directories.])
fi
#' ==================== Checks for programs.
AC_LANG(C)
AC_PROG_CC
AM_PROG_CC_C_O
AM_PROG_AR
AM_CONDITIONAL(ISGCC, test "x$GCC" = "xyes")
LT_INIT
# ==================== Checks for libraries.
libdl=yes
AC_CHECK_LIB([dl],[dlsym],,[libdl=no])
if (test "x$libdl" = "xyes"); then
AC_DEFINE([HAVE_LIBDL], [1], [Whether you have the libdl library])
AC_DEFINE([HAVE_LIBDL_DLSYM], [1], [Whether you have the dlsym() function in the libdl library])
AC_CHECK_LIB([dl],[dlvsym],[AC_DEFINE([HAVE_LIBDL_DLVSYM], [1],
[Whether you have the dlvsym() function in the libdl library])])
fi
dlsym=yes
AC_CHECK_FUNC([dlsym],
[AC_DEFINE([HAVE_DLSYM], [1], [Whether you have the dlsym function])],[dlsym=no])
dlvsym=yes
AC_CHECK_FUNC([dlvsym],
[AC_DEFINE([HAVE_DLVSYM], [1], [Whether you have the dlvsym function])],[dlvsym=no])
if (test "x$libdl" != "xyes"); then
# AC_CHECK_FUNCS([dlsym dlvsym])
if (test "x$dlsym" != "xyes" && test "x$dlvsym" != "xyes"); then
AC_MSG_ERROR([[I need the dlsym() and optionally dlvsym() function to work.]])
fi
fi
# Adding additional libraries actually makes LibNetBlock "see" the functions
# contained in them, via dlsym/dlvsym, so the original functions can be called.
# This adds a runtime dependency, but otherwise it could make the program
# bypass LibNetBlock or make normally-working functions not available anymore.
AC_CHECK_LIB([pcap],[pcap_lookupdev])
# ==================== Checks for header files.
AC_CHECK_HEADER([dlfcn.h],[AC_DEFINE([HAVE_DLFCN_H], [1], [Whether you have the dlfcn.h header])],
AC_MSG_ERROR([[I need the dlfcn.h file to work.]]), [])
AC_CHECK_DECL([RTLD_NEXT],[AC_DEFINE([HAVE_DECL_RTLD_NEXT], [1], [Whether RTLD_NEXT is defined])],
[echo "**************************************"
AC_MSG_ERROR([[RTLD_NEXT not defined. Use the GNU C library. Sorry.]])],
[
#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
])
# AC_ HEADER_ STDC
# m4_warn([obsolete],
# [The preprocessor macro `STDC_HEADERS' is obsolete.
# Except in unusual embedded environments, you can safely include all
# ISO C90 headers unconditionally.])dnl
# Autoupdate added the next two lines to ensure that your configure
# script's behavior did not change. They are probably safe to remove.
AC_CHECK_INCLUDES_DEFAULT
AC_PROG_EGREP
AC_CHECK_HEADERS([stdlib.h string.h unistd.h errno.h malloc.h \
sys/types.h sys/socket.h netinet/in.h fcntl.h stdint.h \
inttypes.h linux/fcntl.h])
AC_CHECK_HEADER(rpc/rpc.h,AC_DEFINE([HAVE_RPC_RPC_H],[1],
[Whether you have the rpc/rpc.h header.]),
[
AC_CHECK_HEADER([rpc.h],AC_DEFINE([HAVE_RPC_H],[1],
[Whether you have the rpc.h header.]))
])
has_sys_stat_h=yes
AC_CHECK_HEADER([sys/stat.h],AC_DEFINE([HAVE_SYS_STAT_H],[1],
[Whether you have the sys/stat.h header.]),[has_sys_stat_h=no])
AC_HEADER_STAT
AC_CHECK_HEADER([stdarg.h],AC_DEFINE([HAVE_STDARG_H],[1],
[Whether you have the stdarg.h header.]),
[
AC_CHECK_HEADER([varargs.h],AC_DEFINE([HAVE_VARARGS_H],[1],
[Whether you have the varargs.h header.]))
])
AC_CHECK_HEADER(pcap.h,AC_DEFINE([HAVE_PCAP_H],[1],
[Whether you have the pcap.h header.]),
[
AC_CHECK_HEADER([pcap/pcap.h],AC_DEFINE([HAVE_PCAP_PCAP_H],[1],
[Whether you have the pcap/pcap.h header.]))
])
# ==================== Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_VOLATILE
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_CHECK_TYPES([off64_t, intptr_t],,,
[
#define _FILE_OFFSET_BITS 64
#define _LARGEFILE64_SOURCE
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#ifdef HAVE_STDDEF_H
#include <stddef.h>
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
])
AC_CHECK_TYPES([socklen_t],,,
[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
])
AC_DEFINE_PATH_STYLE()
# ==================== Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNC([malloc],
AC_DEFINE([HAVE_MALLOC],[1],[Whether you have the malloc function.]))
AC_CHECK_FUNCS([memset memcpy readlink getenv openat openat64 lstat symlink \
execveat fexecve snprintf strdup stat stat64 lstat64 realpath \
canonicalize_file_name fopen64 freopen64 open64 bindresvport \
bindresvport6 getpid])
have_check=no
#ACTION-IF-NOT-FOUND is required, otherwise 'configure' fails
PKG_CHECK_MODULES([CHECK], [check >= 0.9.8], [have_check=yes], [have_check=no])
#AM_PATH_CHECK([], [have_check=yes])
AM_CONDITIONAL([LNB_TESTS_ENABLED], [test "x$have_check" = "xyes"])
if (test "x$have_check" = "xyes"); then
AC_CHECK_HEADERS([arpa/inet.h sys/un.h])
fi
# ==================== Checks for compiler options.
if (test "x$GCC" = "xyes" ); then
AX_GCC_WARN_UNUSED_RESULT()
AX_C_CHECK_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wextra], [CFLAGS="$CFLAGS -Wextra"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-W], [CFLAGS="$CFLAGS -W"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wfloat-equal], [CFLAGS="$CFLAGS -Wfloat-equal"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wbad-function-cast], [CFLAGS="$CFLAGS -Wbad-function-cast"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wsign-compare], [CFLAGS="$CFLAGS -Wsign-compare"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wunreachable-code], [CFLAGS="$CFLAGS -Wunreachable-code"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wpointer-arith], [CFLAGS="$CFLAGS -Wpointer-arith"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wcast-qual], [CFLAGS="$CFLAGS -Wcast-qual"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wcast-align], [CFLAGS="$CFLAGS -Wcast-align"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wstrict-prototypes], [CFLAGS="$CFLAGS -Wstrict-prototypes"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wformat -Wformat-security], [CFLAGS="$CFLAGS -Wformat -Wformat-security"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wformat -Wformat-nonliteral], [CFLAGS="$CFLAGS -Wformat -Wformat-nonliteral"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wformat -Wformat-overflow=2], [CFLAGS="$CFLAGS -Wformat -Wformat-overflow=2"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wnested-externs], [CFLAGS="$CFLAGS -Wnested-externs"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wshadow], [CFLAGS="$CFLAGS -Wshadow"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wconversion], [CFLAGS="$CFLAGS -Wconversion"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wdeclaration-after-statement], [CFLAGS="$CFLAGS -Wdeclaration-after-statement"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wundef], [CFLAGS="$CFLAGS -Wundef"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wpadded], [CFLAGS="$CFLAGS -Wpadded"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wredundant-decls], [CFLAGS="$CFLAGS -Wredundant-decls"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wfatal-errors], [CFLAGS="$CFLAGS -Wfatal-errors"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-pedantic], [CFLAGS="$CFLAGS -pedantic"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wno-strict-aliasing], [CFLAGS="$CFLAGS -Wno-strict-aliasing"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wmissing-prototypes], [CFLAGS="$CFLAGS -Wmissing-prototypes"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wmissing-declarations], [CFLAGS="$CFLAGS -Wmissing-declarations"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-O1 -Wuninitialized], [CFLAGS="$CFLAGS -O1 -Wuninitialized"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Winit-self], [CFLAGS="$CFLAGS -Winit-self"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wlogical-op], [CFLAGS="$CFLAGS -Wlogical-op"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-fstack-protector-all], [CFLAGS="$CFLAGS -fstack-protector-all"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-O2], [CFLAGS="$CFLAGS -O2"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-O3], [CFLAGS="$CFLAGS -O3"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Waggregate-return], [CFLAGS="$CFLAGS -Waggregate-return"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wwrite-strings], [CFLAGS="$CFLAGS -Wwrite-strings"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wchkp], [CFLAGS="$CFLAGS -Wchkp"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wduplicated-cond], [CFLAGS="$CFLAGS -Wduplicated-cond"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wrestrict], [CFLAGS="$CFLAGS -Wrestrict"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Woverlength-strings], [CFLAGS="$CFLAGS -Woverlength-strings"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wno-nonnull-compare], [CFLAGS="$CFLAGS -Wno-nonnull-compare"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wstringop-truncation], [CFLAGS="$CFLAGS -Wstringop-truncation"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wduplicated-branches], [CFLAGS="$CFLAGS -Wduplicated-branches"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wnull-dereference], [CFLAGS="$CFLAGS -Wnull-dereference"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Walloc-zero], [CFLAGS="$CFLAGS -Walloc-zero"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wunused-parameter], [CFLAGS="$CFLAGS -Wunused-parameter"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-Wdangling-else], [CFLAGS="$CFLAGS -Wdangling-else"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-fstack-check], [CFLAGS="$CFLAGS -fstack-check"], [CFLAGS="$CFLAGS"])
AX_C_CHECK_FLAG([-fanalyzer], [CFLAGS="$CFLAGS -fanalyzer"], [CFLAGS="$CFLAGS"])
# required for the compiler, which is used by libtool instead of the linker
AX_C_CHECK_FLAG([-Wl,-z -Wl,noexecstack], [CFLAGS="$CFLAGS -Wl,-z -Wl,noexecstack"], [CFLAGS="$CFLAGS"])
# and just in case the linker was used
AX_CHECK_LINK_FLAG([-z noexecstack])
fi
# this doubles the CFLAGS on compile:
#AC_SUBST([AM_CFLAGS],[$CFLAGS])
AC_OUTPUT
# ===================== Print summary
echo "***********************************"
if (test "x$public_if" = "xyes"); then
echo " * Public interface: yes"
else
echo " * Public interface: no (default/disabled by command line)"
fi
if (test "x$environment" = "xyes"); then
echo " * Additional ban files pointed to by environment variables: yes"
else
echo " * Additional ban files pointed to by environment variables: no (disabled by command line)"
fi
if (test "x$user_files" = "xyes"); then
echo " * Additional ban files located in users' home directories: yes"
else
echo " * Additional ban files located in users' home directories: no (disabled by command line)"
fi
echo "***********************************"