-
Notifications
You must be signed in to change notification settings - Fork 5
/
configure.ac
238 lines (209 loc) · 6.1 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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# $Id$
AC_INIT([file],[7.6])
RELEASE=7.6
AC_SUBST(RELEASE)
AC_CONFIG_AUX_DIR(etc)
AM_INIT_AUTOMAKE([foreign subdir-objects])
AC_CANONICAL_HOST
case $host_os in
*netbsd*)
AC_DEFINE(_OPENBSD_SOURCE)
;;
*linux*)
AC_DEFINE(_GNU_SOURCE)
;;
*)
;;
esac
: ${CFLAGS=""}
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_INSTALL
AC_SYS_LARGEFILE
test "$sysconfdir" = '${prefix}/etc' && sysconfdir=/etc
AC_ARG_ENABLE(
debug,
AS_HELP_STRING([--enable-debug], [create a debug build]),
found_debug=$enable_debug
)
AM_CONDITIONAL(IS_DEBUG, test "x$found_debug" = xyes)
#
# This option only exists because of shit operating systems.
AC_ARG_ENABLE(
pie,
AS_HELP_STRING([--disable-pie], [disable PIE build]),
found_pie=$enable_pie,
found_pie=yes
)
AM_CONDITIONAL(IS_PIE, test "x$found_pie" = xyes)
#
# This option only exists because some Linux kernels have prctl
# but do not actually implement seccomp-bpf.
AC_ARG_ENABLE(
prctl,
AS_HELP_STRING([--disable-prctl], [disable seccomp-bpf (Linux)]),
found_prctl=$enable_prctl,
found_prctl=yes
)
#
# Configure unprivileged user.
AC_ARG_WITH(
[user],
AS_HELP_STRING([--with-user=user],[privsep user (default: "_file")]),
[AC_DEFINE_UNQUOTED([FILE_USER], "$withval", [username to run with])]
)
AC_CHECK_HEADERS([sys/endian.h endian.h])
AC_CHECK_HEADERS([sys/tree.h], [], [needs_compat=yes;break])
case $host_os in
*netbsd*)
# NetBSD vis SIGSEGV's
needs_compat=yes
;;
*)
AC_CHECK_HEADERS([vis.h], [], [needs_compat=yes;break])
;;
esac
AC_CHECK_HEADERS([sys/queue.h imsg.h], [], [needs_compat=yes;break],
[#include <sys/types.h>
#include <sys/queue.h>])
AS_IF([test "x$needs_compat" = "xyes"], [CPPFLAGS="$CPPFLAGS -Icompat"])
AC_CHECK_FUNCS(
[ \
issetugid \
setgroups \
]
)
AC_SEARCH_LIBS(
imsg_init,
[util],
found_imsg=yes,
found_imsg=no
)
if test "x$found_imsg" = xyes; then
AC_DEFINE(HAVE_IMSG)
fi
AM_CONDITIONAL(NO_IMSG, [test "x$found_imsg" = xno])
AC_CHECK_DECL(strlcpy, found_strlcpy=yes, found_strlcpy=no)
if test "x$found_strlcpy" = xyes; then
AC_DEFINE(HAVE_STRLCPY)
fi
AM_CONDITIONAL(NO_STRLCPY, [test "x$found_strlcpy" = xno])
AC_CHECK_DECL(strlcat, found_strlcat=yes, found_strlcat=no)
if test "x$found_strlcat" = xyes; then
AC_DEFINE(HAVE_STRLCAT)
fi
AM_CONDITIONAL(NO_STRLCAT, [test "x$found_strlcat" = xno])
AC_CHECK_FUNC(explicit_bzero, found_explicit_bzero=yes, found_explicit_bzero=no)
if test "x$found_explicit_bzero" = xyes; then
AC_DEFINE(HAVE_EXPLICIT_BZERO)
fi
AM_CONDITIONAL(NO_EXPLICIT_BZERO, [test "x$found_explicit_bzero" = xno])
AC_CHECK_FUNC(freezero, found_freezero=yes, found_freezero=no)
if test "x$found_freezero" = xyes; then
AC_DEFINE(HAVE_FREEZERO)
fi
AM_CONDITIONAL(NO_FREEZERO, [test "x$found_freezero" = xno])
AC_CHECK_FUNC(setresgid, found_setresgid=yes, found_setresgid=no)
if test "x$found_setresgid" = xyes; then
AC_DEFINE(HAVE_SETRESGID)
fi
AM_CONDITIONAL(NO_SETRESGID, [test "x$found_setresgid" = xno])
AC_CHECK_FUNC(setresuid, found_setresuid=yes, found_setresuid=no)
if test "x$found_setresuid" = xyes; then
AC_DEFINE(HAVE_SETRESUID)
fi
AM_CONDITIONAL(NO_SETRESUID, [test "x$found_setresuid" = xno])
# Used by setresgid compat
AC_CHECK_FUNC(setregid, found_setregid=yes, found_setregid=no)
if test "x$found_setregid" = xyes; then
AC_DEFINE(HAVE_SETREGID)
fi
AM_CONDITIONAL(NO_SETREGID, [test "x$found_setregid" = xno])
# Used by setresuid compat
AC_CHECK_FUNC(setreuid, found_setreuid=yes, found_setreuid=no)
if test "x$found_setreuid" = xyes; then
AC_DEFINE(HAVE_SETREUID)
fi
AM_CONDITIONAL(NO_SETREUID, [test "x$found_setreuid" = xno])
AC_CHECK_FUNC(reallocarray, found_reallocarray=yes, found_reallocarray=no)
if test "x$found_reallocarray" = "xyes"; then
AC_MSG_CHECKING([for working reallocarray])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([[
#include <stdlib.h>
#include <assert.h>
]], [[
char *ptr, *nptr;
ptr = reallocarray(NULL, 1, sizeof(char));
assert(ptr != NULL);
nptr = reallocarray(ptr, 0, 0);
if (nptr == NULL)
exit(1);
exit(0);
]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
found_reallocarray="no" ],
[AC_MSG_WARN([cross compiling: assuming broken])
found_reallocarray="no" ]
)
if test "x$found_reallocarray" = xyes; then
AC_DEFINE(HAVE_REALLOCARRAY)
fi
fi
AM_CONDITIONAL(NO_REALLOCARRAY, [test "x$found_reallocarray" = xno])
AC_CHECK_FUNC(strnvis, found_strnvis=yes, found_strnvis=no)
dnl NetBSD added an strnvis and unfortunately made it incompatible with the
dnl existing one in OpenBSD and Linux's libbsd (the former having existed
dnl for over ten years). Despite this incompatibility being reported during
dnl development (see http://gnats.netbsd.org/44977) they still shipped it.
dnl Even more unfortunately FreeBSD and later MacOS picked up this incompatible
dnl implementation. Try to detect this mess, and assume the only safe option
dnl if we're cross compiling.
dnl
dnl OpenBSD, 2001: strnvis(char *dst, const char *src, size_t dlen, int flag);
dnl NetBSD: 2012, strnvis(char *dst, size_t dlen, const char *src, int flag);
if test "x$found_strnvis" = "xyes"; then
AC_MSG_CHECKING([for working strnvis])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([[
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <vis.h>
static void sighandler(int sig) { _exit(1); }
]], [[
char dst[16];
signal(SIGSEGV, sighandler);
if (strnvis(dst, "src", 4, 0) && strcmp(dst, "src") == 0)
exit(0);
exit(1)
]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
found_strnvis="no" ],
[AC_MSG_WARN([cross compiling: assuming broken])
found_strnvis="no" ]
)
if test "x$found_strnvis" = xyes; then
AC_DEFINE(HAVE_VIS)
fi
fi
AM_CONDITIONAL(NO_VIS, [test "x$found_strnvis" = xno])
if test "x$found_prctl" = xyes; then
AC_CHECK_FUNC(prctl, found_prctl=yes, found_prctl=no)
if test "x$found_prctl" = xyes; then
AC_DEFINE(HAVE_PRCTL)
fi
fi
AM_CONDITIONAL(PRCTL, [test "x$found_prctl" = xyes])
# Needs to be last as the preprocessor hack breaks something
AC_CHECK_FUNC(pledge, found_pledge=yes, found_pledge=no)
if test "x$found_pledge" = xno; then
CPPFLAGS="$CPPFLAGS -D\"pledge(promises,paths)=0\""
fi
AC_CONFIG_FILES([Makefile])
AC_OUTPUT