3 f36fd90a 2022-07-09 op # Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
4 f36fd90a 2022-07-09 op # Copyright (c) 2017, 2018 Kristaps Dzonsons <kristaps@bsd.lv>
5 b390815c 2022-08-13 op # Copyright (c) 2022 Omar Polo <op@omarpolo.com>
7 f36fd90a 2022-07-09 op # Permission to use, copy, modify, and distribute this software for any
8 f36fd90a 2022-07-09 op # purpose with or without fee is hereby granted, provided that the above
9 f36fd90a 2022-07-09 op # copyright notice and this permission notice appear in all copies.
11 f36fd90a 2022-07-09 op # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 f36fd90a 2022-07-09 op # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 f36fd90a 2022-07-09 op # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 f36fd90a 2022-07-09 op # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 f36fd90a 2022-07-09 op # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 f36fd90a 2022-07-09 op # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 f36fd90a 2022-07-09 op # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 f36fd90a 2022-07-09 op OCONFIGURE_VERSION="0.3.8"
22 f36fd90a 2022-07-09 op # This script outputs two files: config.h and Makefile.configure.
23 f36fd90a 2022-07-09 op # It tries to read from configure.local, which contains predefined
24 f36fd90a 2022-07-09 op # values we won't autoconfigure.
26 f36fd90a 2022-07-09 op # If you want to use configure with your project, have your GNUmakefile
27 f36fd90a 2022-07-09 op # or BSDmakefile---whichever---try to import/include Makefile.configure
28 f36fd90a 2022-07-09 op # at the beginning of the file.
30 f36fd90a 2022-07-09 op # Like so (note no quotes, no period, etc.):
32 f36fd90a 2022-07-09 op # include Makefile.configure
34 f36fd90a 2022-07-09 op # If it exists, configure was run; otherwise, it wasn't.
36 f36fd90a 2022-07-09 op # You'll probably want to change parts of this file. I've noted the
37 f36fd90a 2022-07-09 op # parts that you'll probably change in the section documentation.
39 f36fd90a 2022-07-09 op # See https://github.com/kristapsdz/oconfigure for more.
43 f36fd90a 2022-07-09 op # try to be helpful
47 f36fd90a 2022-07-09 op \`configure' configures amused to adapt to many kinds of systems.
49 f36fd90a 2022-07-09 op Usage: $0 [-h] [--prefix=path] [VAR=VALUE]...
51 f36fd90a 2022-07-09 op The options are as follows:
53 f36fd90a 2022-07-09 op -h, --help print this help message
55 19ee7f3a 2022-08-13 op --prefix=path equivalent to specify the PREFIX variable, supported
56 f36fd90a 2022-07-09 op for compatibility with other common "configure" scripts.
58 f36fd90a 2022-07-09 op Variables available:
60 f36fd90a 2022-07-09 op LDADD generic linker flags
61 f36fd90a 2022-07-09 op LDADD_IMSG linker flags for libimsg
62 f36fd90a 2022-07-09 op LDADD_LIBEVENT linker flags for libevent
63 f36fd90a 2022-07-09 op LDADD_LIBEVENT2 linker flags for libevent2
64 f36fd90a 2022-07-09 op LDADD_LIBFLAC linker flags for libflac
65 f36fd90a 2022-07-09 op LDADD_LIBMPG123 linker flags for libmpg123
66 f36fd90a 2022-07-09 op LDADD_LIBOPUSFILE linker flags for libopusfile
67 f36fd90a 2022-07-09 op LDADD_LIBVORBISFILE linker flags for libvorbisfile
68 f36fd90a 2022-07-09 op LDADD_SNDIO linker flags for libsndio
69 f36fd90a 2022-07-09 op LDADD_LIBSOCKET linker flags for libsocket
70 f36fd90a 2022-07-09 op LDFLAGS extra linker flags
71 f36fd90a 2022-07-09 op CPPFLAGS C preprocessors flags
72 f36fd90a 2022-07-09 op DESTDIR destination directory
73 f36fd90a 2022-07-09 op PREFIX where to install files
74 f36fd90a 2022-07-09 op MANDIR where to install man pages (PREFIX/man)
75 f36fd90a 2022-07-09 op LIBDIR where to install libraries (PREFIX/lib)
76 f36fd90a 2022-07-09 op BINDIR where to install executables (PREFIX/bin)
77 f36fd90a 2022-07-09 op SHAREDIR where to install misc files (PREFIX/share)
78 f36fd90a 2022-07-09 op SBINDIR where to install system executables (PREFIX/sbin)
79 f36fd90a 2022-07-09 op INCLUDEDIR where to install header files (PREFIX/include)
80 19ee7f3a 2022-08-13 op PKG_CONFIG pkg-config program, \`false' to disable (pkg-config)
82 cac555b6 2022-07-13 op Additionally, the following environment variables are used if set:
84 cac555b6 2022-07-13 op CC the C compiler to use (defaults to cc, clang or gcc)
85 cac555b6 2022-07-13 op CFLAGS generic C compiler flags
91 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
92 f36fd90a 2022-07-09 op # Prepare for running: move aside previous configure runs.
93 f36fd90a 2022-07-09 op # Output file descriptor usage:
94 f36fd90a 2022-07-09 op # 1 (stdout): config.h or Makefile.configure
95 f36fd90a 2022-07-09 op # 2 (stderr): original stderr, usually to the console
96 f36fd90a 2022-07-09 op # 3: config.log
97 f36fd90a 2022-07-09 op # You DO NOT want to change this.
98 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
100 f36fd90a 2022-07-09 op [ -w config.log ] && mv config.log config.log.old
101 f36fd90a 2022-07-09 op [ -w config.h ] && mv config.h config.h.old
103 f36fd90a 2022-07-09 op exec 3> config.log
104 f36fd90a 2022-07-09 op echo "config.log: writing..."
106 f36fd90a 2022-07-09 op # GNU submake prints different output if invoked recursively, which
107 f36fd90a 2022-07-09 op # messes up CC and CFLAGS detection. Pass --no-print-directory if
108 f36fd90a 2022-07-09 op # we have a MAKELEVEL (GNU and FreeBSD make) and the argument is
111 f36fd90a 2022-07-09 op MAKE_FLAGS=""
113 f36fd90a 2022-07-09 op if [ -n "${MAKELEVEL}" ]; then
114 f36fd90a 2022-07-09 op if [ "${MAKELEVEL}" -gt 0 ] ; then
115 f36fd90a 2022-07-09 op MAKE_FLAGS="--no-print-directory"
116 f36fd90a 2022-07-09 op echo "all:" | make ${MAKE_FLAGS} -sf - 2>/dev/null || MAKE_FLAGS=""
120 f36fd90a 2022-07-09 op if [ -n "$MAKE_FLAGS" ]; then
121 f36fd90a 2022-07-09 op echo "GNU submake detected: using --no-print-directory" 1>&2
122 f36fd90a 2022-07-09 op echo "GNU submake detected: using --no-print-directory" 1>&3
125 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
126 f36fd90a 2022-07-09 op # Initialize all variables here such that nothing can leak in from the
127 f36fd90a 2022-07-09 op # environment except for CC and CFLAGS, which we might have passed in.
128 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
130 f36fd90a 2022-07-09 op CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | make ${MAKE_FLAGS} -sf -`
131 f36fd90a 2022-07-09 op CFLAGS=`printf "all:\\n\\t@echo \\\$(CFLAGS)\\n" | make ${MAKE_FLAGS} -sf -`
132 f36fd90a 2022-07-09 op CFLAGS="${CFLAGS} -g -W -Wall -Wmissing-prototypes -Wstrict-prototypes"
133 f36fd90a 2022-07-09 op CFLAGS="${CFLAGS} -Wmissing-declarations -Wno-unused-parameter"
134 f36fd90a 2022-07-09 op CFLAGS="${CFLAGS} -Wno-sign-compare"
137 f36fd90a 2022-07-09 op LDADD_LIBEVENT=
138 f36fd90a 2022-07-09 op LDADD_LIBEVENT2=
139 f36fd90a 2022-07-09 op LDADD_LIB_FLAC=
140 f36fd90a 2022-07-09 op LDADD_LIB_MPG123=
141 f36fd90a 2022-07-09 op LDADD_LIB_VORBISFILE=
142 f36fd90a 2022-07-09 op LDADD_LIB_SNDIO=
143 f36fd90a 2022-07-09 op LDADD_LIB_SOCKET=
144 f36fd90a 2022-07-09 op LDADD_STATIC=
148 f36fd90a 2022-07-09 op PREFIX="/usr/local"
155 f36fd90a 2022-07-09 op INSTALL="install"
156 f36fd90a 2022-07-09 op INSTALL_PROGRAM=
159 f36fd90a 2022-07-09 op INSTALL_DATA=
162 f36fd90a 2022-07-09 op # SunOS sets "cc", but this doesn't exist.
163 f36fd90a 2022-07-09 op # It does have gcc, so try that instead.
164 f36fd90a 2022-07-09 op # Prefer clang, though.
166 f36fd90a 2022-07-09 op command -v ${CC} 2>/dev/null 1>&2 || {
167 f36fd90a 2022-07-09 op echo "${CC} not found: trying clang" 1>&2
168 f36fd90a 2022-07-09 op echo "${CC} not found: trying clang" 1>&3
170 f36fd90a 2022-07-09 op command -v ${CC} 2>/dev/null 1>&2 || {
171 f36fd90a 2022-07-09 op echo "${CC} not found: trying gcc" 1>&2
172 f36fd90a 2022-07-09 op echo "${CC} not found: trying gcc" 1>&3
174 f36fd90a 2022-07-09 op command -v ${CC} 2>/dev/null 1>&2 || {
175 f36fd90a 2022-07-09 op echo "gcc not found: giving up" 1>&2
176 f36fd90a 2022-07-09 op echo "gcc not found: giving up" 1>&3
182 f36fd90a 2022-07-09 op command -v pkg-config 2>/dev/null 1>&2 && {
183 f36fd90a 2022-07-09 op PKG_CONFIG=pkg-config
184 f36fd90a 2022-07-09 op echo "pkg-config found" 1>&2
185 f36fd90a 2022-07-09 op echo "pkg-config found" 1>&3
187 f36fd90a 2022-07-09 op echo "pkg-config not found" 1>&2
188 f36fd90a 2022-07-09 op echo "pkg-config not found" 1>&3
191 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
192 f36fd90a 2022-07-09 op # Allow certain variables to be overriden on the command line.
193 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
195 f36fd90a 2022-07-09 op while [ $# -gt 0 ]; do
199 f36fd90a 2022-07-09 op if [ "$key" = "--prefix" ]; then
201 f36fd90a 2022-07-09 op if [ "$1" = "--prefix" ]; then
202 f36fd90a 2022-07-09 op if ! shift 2>&1 >/dev/null; then
203 f36fd90a 2022-07-09 op echo "$0: missing value for --prefix" 1>&2
210 f36fd90a 2022-07-09 op if [ "$1" = "$key" ]; then
211 f36fd90a 2022-07-09 op echo "$0: invalid key-value: $1" 1>&2
217 f36fd90a 2022-07-09 op case "$key" in
219 f36fd90a 2022-07-09 op LDADD="$val" ;;
221 f36fd90a 2022-07-09 op LDADD_IMSG="$val" ;;
222 f36fd90a 2022-07-09 op LDADD_LIBEVENT)
223 f36fd90a 2022-07-09 op LDADD_LIBEVENT="$val" ;;
224 f36fd90a 2022-07-09 op LDADD_LIBEVENT2)
225 f36fd90a 2022-07-09 op LDADD_LIBEVENT2="$val" ;;
226 f36fd90a 2022-07-09 op LDADD_LIBFLAC)
227 f36fd90a 2022-07-09 op LDADD_LIBFLAC="$val" ;;
228 f36fd90a 2022-07-09 op LDADD_LIBMPG123)
229 f36fd90a 2022-07-09 op LDADD_LIBMPG123="$val" ;;
230 f36fd90a 2022-07-09 op LDADD_LIBOPUSFILE)
231 f36fd90a 2022-07-09 op LDADD_LIBOPUSFILE="$val" ;;
232 f36fd90a 2022-07-09 op LDADD_LIBVORBISFILE)
233 f36fd90a 2022-07-09 op LDADD_LIBVORBISFILE="$val" ;;
235 f36fd90a 2022-07-09 op LDADD_SNDIO="$val" ;;
236 f36fd90a 2022-07-09 op LDADD_LIBSOCKET)
237 f36fd90a 2022-07-09 op LDADD_LIBSOCKET="$val" ;;
239 f36fd90a 2022-07-09 op LDFLAGS="$val" ;;
241 f36fd90a 2022-07-09 op CPPFLAGS="$val" ;;
243 f36fd90a 2022-07-09 op DESTDIR="$val" ;;
245 f36fd90a 2022-07-09 op PREFIX="$val" ;;
247 f36fd90a 2022-07-09 op MANDIR="$val" ;;
249 f36fd90a 2022-07-09 op LIBDIR="$val" ;;
251 f36fd90a 2022-07-09 op BINDIR="$val" ;;
253 f36fd90a 2022-07-09 op SHAREDIR="$val" ;;
255 f36fd90a 2022-07-09 op SBINDIR="$val" ;;
257 f36fd90a 2022-07-09 op INCLUDEDIR="$val" ;;
259 f36fd90a 2022-07-09 op PKG_CONFIG="$val" ;;
261 f36fd90a 2022-07-09 op echo "$0: invalid key: $key" 1>&2
267 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
268 f36fd90a 2022-07-09 op # These are the values that will be pushed into config.h after we test
269 f36fd90a 2022-07-09 op # for whether they're supported or not.
270 f36fd90a 2022-07-09 op # Each of these must have a runtest(), below.
271 f36fd90a 2022-07-09 op # Please sort by alpha, for clarity.
272 f36fd90a 2022-07-09 op # You WANT to change this.
273 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
275 f36fd90a 2022-07-09 op HAVE_CAPSICUM=
277 f36fd90a 2022-07-09 op HAVE_EXPLICIT_BZERO=
279 f36fd90a 2022-07-09 op HAVE_FREEZERO=
280 f36fd90a 2022-07-09 op HAVE_GETDTABLECOUNT=
281 f36fd90a 2022-07-09 op HAVE_GETEXECNAME=
282 f36fd90a 2022-07-09 op HAVE_GETPROGNAME=
285 f36fd90a 2022-07-09 op HAVE_LANDLOCK=
286 f36fd90a 2022-07-09 op HAVE_LIBEVENT=
287 f36fd90a 2022-07-09 op HAVE_LIBEVENT2=0 # may not be checked, set to zero
288 f36fd90a 2022-07-09 op HAVE_LIB_FLAC=
289 f36fd90a 2022-07-09 op HAVE_LIB_MPG123=
290 f36fd90a 2022-07-09 op HAVE_LIB_OPUSFILE=
291 f36fd90a 2022-07-09 op HAVE_LIB_VORBISFILE=
292 f36fd90a 2022-07-09 op HAVE_LIB_SNDIO=
293 f36fd90a 2022-07-09 op HAVE_LIB_SOCKET=
295 f36fd90a 2022-07-09 op HAVE_MEMRCHR=
296 f36fd90a 2022-07-09 op HAVE_MEMSET_S=
297 f36fd90a 2022-07-09 op HAVE_OPTRESET=
298 f36fd90a 2022-07-09 op HAVE_PATH_MAX=
300 f36fd90a 2022-07-09 op HAVE_PROGRAM_INVOCATION_SHORT_NAME=
301 f36fd90a 2022-07-09 op HAVE_PR_SET_NAME=
302 f36fd90a 2022-07-09 op HAVE_REALLOCARRAY=
303 f36fd90a 2022-07-09 op HAVE_RECALLOCARRAY=
304 f36fd90a 2022-07-09 op HAVE_SANDBOX_INIT=
305 f36fd90a 2022-07-09 op HAVE_SETPROCTITLE=
306 f36fd90a 2022-07-09 op HAVE_SIO_FLUSH=
307 f36fd90a 2022-07-09 op HAVE_SOCK_NONBLOCK=
308 f36fd90a 2022-07-09 op HAVE_STRLCAT=
309 f36fd90a 2022-07-09 op HAVE_STRLCPY=
310 f36fd90a 2022-07-09 op HAVE_STRNDUP=
311 f36fd90a 2022-07-09 op HAVE_STRNLEN=
312 f36fd90a 2022-07-09 op HAVE_STRTONUM=
313 f36fd90a 2022-07-09 op HAVE_SYS_FILE=
314 f36fd90a 2022-07-09 op HAVE_SYS_QUEUE=
315 f36fd90a 2022-07-09 op HAVE_SYSTRACE=0
317 f36fd90a 2022-07-09 op HAVE___PROGNAME=
319 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
320 f36fd90a 2022-07-09 op # Allow configure.local to override all variables, default settings,
321 f36fd90a 2022-07-09 op # command-line arguments, and tested features, above.
322 f36fd90a 2022-07-09 op # You PROBABLY DO NOT want to change this.
323 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
325 f36fd90a 2022-07-09 op if [ -r ./configure.local ]; then
326 f36fd90a 2022-07-09 op echo "configure.local: reading..." 1>&2
327 f36fd90a 2022-07-09 op echo "configure.local: reading..." 1>&3
328 f36fd90a 2022-07-09 op cat ./configure.local 1>&3
329 f36fd90a 2022-07-09 op . ./configure.local
331 f36fd90a 2022-07-09 op echo "configure.local: no (fully automatic configuration)" 1>&2
332 f36fd90a 2022-07-09 op echo "configure.local: no (fully automatic configuration)" 1>&3
337 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
338 f36fd90a 2022-07-09 op # Infrastructure for running tests.
339 f36fd90a 2022-07-09 op # These consists of a series of functions that will attempt to run the
340 f36fd90a 2022-07-09 op # given test file and record its exit into a HAVE_xxx variable.
341 f36fd90a 2022-07-09 op # You DO NOT want to change this.
342 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
344 f36fd90a 2022-07-09 op COMP="${CC} ${CFLAGS} ${CPPFLAGS} -Wno-unused -Werror"
346 f36fd90a 2022-07-09 op # Check whether this HAVE_ setting is manually overridden.
347 f36fd90a 2022-07-09 op # If yes, use the override, if no, do not decide anything yet.
348 f36fd90a 2022-07-09 op # Arguments: lower-case test name, manual value
351 f36fd90a 2022-07-09 op [ -z "${3}" ] && return 1
352 f36fd90a 2022-07-09 op echo "${1}: manual (HAVE_${2}=${3})" 1>&2
353 f36fd90a 2022-07-09 op echo "${1}: manual (HAVE_${2}=${3})" 1>&3
358 f36fd90a 2022-07-09 op # Run a single autoconfiguration test.
359 f36fd90a 2022-07-09 op # In case of success, enable the feature.
360 f36fd90a 2022-07-09 op # In case of failure, do not decide anything yet.
361 f36fd90a 2022-07-09 op # Arguments: lower-case test name, upper-case test name, additional
362 f36fd90a 2022-07-09 op # CFLAGS, additional LIBS.
364 f36fd90a 2022-07-09 op singletest() {
369 f36fd90a 2022-07-09 op cat 1>&3 << __HEREDOC__
370 f36fd90a 2022-07-09 op ${1}: testing...
371 f36fd90a 2022-07-09 op ${COMP} -DTEST_${2} ${3} -o test-${1} tests.c ${LDFLAGS} ${4}
373 f36fd90a 2022-07-09 op if ${COMP} -DTEST_${2} ${3} -o "test-${1}" tests.c ${LDFLAGS} ${4} 1>&3 2>&3; then
374 f36fd90a 2022-07-09 op echo "${1}: ${CC} succeeded" 1>&3
376 f36fd90a 2022-07-09 op if [ -n "${5}" ] ; then
377 f36fd90a 2022-07-09 op echo "${1}: ${CC} failed with $? (retrying)" 1>&3
378 f36fd90a 2022-07-09 op cat 1>&3 << __HEREDOC__
379 f36fd90a 2022-07-09 op ${1}: testing...
380 f36fd90a 2022-07-09 op ${COMP} -DTEST_${2} ${3} -o test-${1} tests.c ${LDFLAGS} ${5}
382 f36fd90a 2022-07-09 op if ${COMP} -DTEST_${2} ${3} -o "test-${1}" tests.c ${LDFLAGS} ${5} 1>&3 2>&3; then
383 f36fd90a 2022-07-09 op echo "${1}: ${CC} succeeded" 1>&3
384 f36fd90a 2022-07-09 op extralib="(with ${5})"
386 f36fd90a 2022-07-09 op test -n "${PKG_CONFIG}" -a -n "${6}" && ${PKG_CONFIG} "$6"
387 f36fd90a 2022-07-09 op if [ $? -eq 0 ]; then
388 f36fd90a 2022-07-09 op echo "${1}: ${CC} failed with $? (retrying)" 1>&3
389 f36fd90a 2022-07-09 op pkgcfs=$($PKG_CONFIG --cflags "${6}")
390 f36fd90a 2022-07-09 op pkglib=$($PKG_CONFIG --libs "${6}")
391 f36fd90a 2022-07-09 op cat 1>&3 << __HEREDOC__
392 f36fd90a 2022-07-09 op ${1}: testing...
393 f36fd90a 2022-07-09 op ${COMP} -DTEST_${2} ${3} ${pkgcfs} -o test-${1} tests.c ${LDFLAGS} ${pkglib}
395 f36fd90a 2022-07-09 op if ${COMP} -DTEST_${2} ${3} ${pkgcfs} -o test-${1} tests.c ${LDFLAGS} ${pkglib} 1>&3 2>&3; then
396 f36fd90a 2022-07-09 op echo "${1}: ${CC} succeeded" 1>&3
397 f36fd90a 2022-07-09 op extralib="(with ${pkgcfs} ${pkglib})"
399 f36fd90a 2022-07-09 op echo "${1}: ${CC} failed with $?" 1>&3
404 f36fd90a 2022-07-09 op echo "${1}: ${CC} failed with $?" 1>&3
410 f36fd90a 2022-07-09 op echo "${1}: ${CC} failed with $?" 1>&3
416 1c53767e 2022-07-13 op rm -f test-${1}.d
418 f36fd90a 2022-07-09 op if [ -n "${pkgcfs}" -o -n "${pkglib}" ]
420 f36fd90a 2022-07-09 op CFLAGS="${CFLAGS} ${pkgcfs}"
421 f36fd90a 2022-07-09 op eval "LDADD_${2}=\"${pkglib}\""
422 f36fd90a 2022-07-09 op elif [ -n "${extralib}" ]
424 f36fd90a 2022-07-09 op eval "LDADD_${2}=\"${5}\""
425 f36fd90a 2022-07-09 op elif [ -n "${4}" ]
427 f36fd90a 2022-07-09 op eval "LDADD_${2}=\"${4}\""
430 f36fd90a 2022-07-09 op echo "${1}: yes ${extralib}" 1>&2
431 f36fd90a 2022-07-09 op echo "${1}: yes ${extralib}" 1>&3
433 f36fd90a 2022-07-09 op eval HAVE_${2}=1
434 f36fd90a 2022-07-09 op rm "test-${1}"
438 f36fd90a 2022-07-09 op # Run a complete autoconfiguration test, including the check for
439 f36fd90a 2022-07-09 op # a manual override and disabling the feature on failure.
440 f36fd90a 2022-07-09 op # Arguments: lower case name, upper case name, additional CFLAGS,
441 f36fd90a 2022-07-09 op # additional LDADD, alternative LDADD, pkg-config name.
444 f36fd90a 2022-07-09 op eval _manual=\${HAVE_${2}}
445 f36fd90a 2022-07-09 op ismanual "${1}" "${2}" "${_manual}" && return 0
446 f36fd90a 2022-07-09 op singletest "${1}" "${2}" "${3}" "${4}" "${5}" "${6}" && return 0
447 f36fd90a 2022-07-09 op echo "${1}: no" 1>&2
448 f36fd90a 2022-07-09 op eval HAVE_${2}=0
452 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
453 f36fd90a 2022-07-09 op # Begin running the tests themselves.
454 f36fd90a 2022-07-09 op # All of your tests must be defined here.
455 f36fd90a 2022-07-09 op # Please sort as the HAVE_xxxx values were defined.
456 f36fd90a 2022-07-09 op # You WANT to change this.
457 f36fd90a 2022-07-09 op # It consists of the following columns:
459 f36fd90a 2022-07-09 op # (1) test file
460 f36fd90a 2022-07-09 op # (2) macro to set
461 f36fd90a 2022-07-09 op # (3) argument to cc *before* -o
462 f36fd90a 2022-07-09 op # (4) argument to cc *after*
463 f36fd90a 2022-07-09 op # (5) alternative argument to cc *after*
464 f36fd90a 2022-07-09 op # (6) name for pkg-config auto-discovery
465 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
467 f36fd90a 2022-07-09 op if runtest -MMD _MMD -MMD; then
468 f36fd90a 2022-07-09 op CFLAGS="${CFLAGS} -MMD"
469 f36fd90a 2022-07-09 op echo "adding -MMD to CFLAGS" 1>&2
470 f36fd90a 2022-07-09 op echo "adding -MMD to CFLAGS" 1>&3
473 f36fd90a 2022-07-09 op runtest capsicum CAPSICUM || true
474 f36fd90a 2022-07-09 op runtest err ERR || true
475 f36fd90a 2022-07-09 op runtest explicit_bzero EXPLICIT_BZERO || true
476 f36fd90a 2022-07-09 op runtest flock FLOCK || true
477 f36fd90a 2022-07-09 op runtest freezero FREEZERO || true
478 f36fd90a 2022-07-09 op runtest getdtablecount GETDTABLECOUNT || true
479 f36fd90a 2022-07-09 op runtest getexecname GETEXECNAME || true
480 f36fd90a 2022-07-09 op runtest getprogname GETPROGNAME || true
481 f36fd90a 2022-07-09 op runtest imsg IMSG "" "" "-lutil" || true
482 f36fd90a 2022-07-09 op runtest INFTIM INFTIM || true
483 f36fd90a 2022-07-09 op runtest landlock LANDLOCK || true
485 f36fd90a 2022-07-09 op runtest libevent LIBEVENT "" "" "-levent" || \
486 f36fd90a 2022-07-09 op runtest libevent2 LIBEVENT2 "" "" "-levent_extra -levent_core" "libevent" || true
488 f36fd90a 2022-07-09 op runtest lib_flac LIB_FLAC "" "" "-lFLAC" "flac" || true
489 f36fd90a 2022-07-09 op runtest lib_mpg123 LIB_MPG123 "" "" "-lmpg123" "libmpg123" || true
490 f36fd90a 2022-07-09 op runtest lib_opusfile LIB_OPUSFILE "" "" "-lopusfile" "opusfile" || true
491 f36fd90a 2022-07-09 op runtest lib_vorbisfile LIB_VORBISFILE "" "" "-lvorbisfile" "vorbisfile" || true
493 f36fd90a 2022-07-09 op runtest lib_sndio LIB_SNDIO "" "" "-lsndio" "sndio" || true
494 f36fd90a 2022-07-09 op runtest lib_socket LIB_SOCKET "" "" "-lsocket -lnsl" || true
495 f36fd90a 2022-07-09 op runtest memmem MEMMEM || true
496 f36fd90a 2022-07-09 op runtest memrchr MEMRCHR || true
497 f36fd90a 2022-07-09 op runtest memset_s MEMSET_S || true
498 f36fd90a 2022-07-09 op runtest optreset OPTRESET || true
499 f36fd90a 2022-07-09 op runtest PATH_MAX PATH_MAX || true
500 f36fd90a 2022-07-09 op runtest pledge PLEDGE || true
501 f36fd90a 2022-07-09 op runtest program_invocation_short_name PROGRAM_INVOCATION_SHORT_NAME || true
502 f36fd90a 2022-07-09 op runtest PR_SET_NAME PR_SET_NAME || true
503 f36fd90a 2022-07-09 op runtest reallocarray REALLOCARRAY || true
504 f36fd90a 2022-07-09 op runtest recallocarray RECALLOCARRAY || true
505 f36fd90a 2022-07-09 op runtest sandbox_init SANDBOX_INIT "-Wno-deprecated" || true
506 f36fd90a 2022-07-09 op runtest setproctitle SETPROCTITLE || true
507 f36fd90a 2022-07-09 op runtest sio_flush SIO_FLUSH "" "" "${LDADD_LIB_SNDIO}" || true
508 f36fd90a 2022-07-09 op runtest SOCK_NONBLOCK SOCK_NONBLOCK || true
509 f36fd90a 2022-07-09 op runtest static STATIC "" "-static" || true
510 f36fd90a 2022-07-09 op runtest strlcat STRLCAT || true
511 f36fd90a 2022-07-09 op runtest strlcpy STRLCPY || true
512 f36fd90a 2022-07-09 op runtest strndup STRNDUP || true
513 f36fd90a 2022-07-09 op runtest strnlen STRNLEN || true
514 f36fd90a 2022-07-09 op runtest strtonum STRTONUM || true
515 f36fd90a 2022-07-09 op runtest sys_queue SYS_QUEUE || true
516 f36fd90a 2022-07-09 op runtest sys_file SYS_FILE || true
517 f36fd90a 2022-07-09 op runtest unveil UNVEIL || true
518 f36fd90a 2022-07-09 op runtest __progname __PROGNAME || true
520 f36fd90a 2022-07-09 op if [ "${HAVE_LIBEVENT}" -eq 0 -a "${HAVE_LIBEVENT2}" -eq 0 ]; then
521 f36fd90a 2022-07-09 op echo "Fatal: missing libevent" 1>&2
522 f36fd90a 2022-07-09 op echo "Fatal: missing libevent" 1>&3
526 f36fd90a 2022-07-09 op if [ "${HAVE_LIB_FLAC}" -eq 0 -o \
527 f36fd90a 2022-07-09 op "${HAVE_LIB_MPG123}" -eq 0 -o \
528 f36fd90a 2022-07-09 op "${HAVE_LIB_OPUSFILE}" -eq 0 -o \
529 f36fd90a 2022-07-09 op "${HAVE_LIB_VORBISFILE}" -eq 0 ]; then
530 f36fd90a 2022-07-09 op echo "Fatal: missing required audio libraries" 1>&2
531 f36fd90a 2022-07-09 op echo "Fatal: missing required audio libraries" 1>&3
535 f36fd90a 2022-07-09 op if [ "${HAVE_LIB_SNDIO}" -eq 0 ]; then
536 f36fd90a 2022-07-09 op echo "Fatal: missing libsndio" 1>&2
537 f36fd90a 2022-07-09 op echo "Fatal: missing libsndio" 1>&3
541 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
542 f36fd90a 2022-07-09 op # Output writing: generate the config.h file.
543 f36fd90a 2022-07-09 op # This file contains all of the HAVE_xxxx variables necessary for
544 f36fd90a 2022-07-09 op # compiling your source.
545 f36fd90a 2022-07-09 op # You must include "config.h" BEFORE any other variables.
546 f36fd90a 2022-07-09 op # You WANT to change this.
547 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
549 f36fd90a 2022-07-09 op exec > config.h
551 f36fd90a 2022-07-09 op # Start with prologue.
553 f36fd90a 2022-07-09 op cat << __HEREDOC__
554 f36fd90a 2022-07-09 op #ifndef OCONFIGURE_CONFIG_H
555 f36fd90a 2022-07-09 op #define OCONFIGURE_CONFIG_H
557 f36fd90a 2022-07-09 op #ifdef __cplusplus
558 f36fd90a 2022-07-09 op # error "Do not use C++: this is a C application."
560 f36fd90a 2022-07-09 op #if !defined(__GNUC__) || (__GNUC__ < 4)
561 f36fd90a 2022-07-09 op # define __attribute__(x)
563 f36fd90a 2022-07-09 op #if defined(__linux__) || defined(__MINT__)
564 f36fd90a 2022-07-09 op # define _GNU_SOURCE /* memmem, memrchr, setresuid... */
565 f36fd90a 2022-07-09 op # define _DEFAULT_SOURCE /* le32toh, crypt, ... */
567 f36fd90a 2022-07-09 op #if defined(__NetBSD__)
568 f36fd90a 2022-07-09 op # define _OPENBSD_SOURCE /* reallocarray, etc. */
570 f36fd90a 2022-07-09 op #if defined(__sun)
571 f36fd90a 2022-07-09 op # ifndef _XOPEN_SOURCE /* SunOS already defines */
572 f36fd90a 2022-07-09 op # define _XOPEN_SOURCE /* XPGx */
574 f36fd90a 2022-07-09 op # define _XOPEN_SOURCE_EXTENDED 1 /* XPG4v2 */
575 f36fd90a 2022-07-09 op # ifndef __EXTENSIONS__ /* SunOS already defines */
576 f36fd90a 2022-07-09 op # define __EXTENSIONS__ /* reallocarray, etc. */
579 f36fd90a 2022-07-09 op #if !defined(__BEGIN_DECLS)
580 f36fd90a 2022-07-09 op # define __BEGIN_DECLS
582 f36fd90a 2022-07-09 op #if !defined(__END_DECLS)
583 f36fd90a 2022-07-09 op # define __END_DECLS
588 f36fd90a 2022-07-09 op # This is just for size_t, mode_t, and dev_t.
589 f36fd90a 2022-07-09 op # Most of these functions, in the real world, pull in <string.h> or
590 f36fd90a 2022-07-09 op # someting that pulls in support for size_t.
591 f36fd90a 2022-07-09 op # Our function declarations are standalone, so specify them here.
593 f36fd90a 2022-07-09 op if [ ${HAVE_IMSG} -eq 0 -o \
594 f36fd90a 2022-07-09 op ${HAVE_MEMMEM} -eq 0 -o \
595 f36fd90a 2022-07-09 op ${HAVE_MEMRCHR} -eq 0 -o \
596 f36fd90a 2022-07-09 op ${HAVE_REALLOCARRAY} -eq 0 -o \
597 f36fd90a 2022-07-09 op ${HAVE_RECALLOCARRAY} -eq 0 -o \
598 f36fd90a 2022-07-09 op ${HAVE_STRLCAT} -eq 0 -o \
599 f36fd90a 2022-07-09 op ${HAVE_STRLCPY} -eq 0 -o \
600 f36fd90a 2022-07-09 op ${HAVE_STRNDUP} -eq 0 -o \
601 f36fd90a 2022-07-09 op ${HAVE_STRNLEN} -eq 0 ]
603 f36fd90a 2022-07-09 op echo "#include <sys/types.h> /* size_t, mode_t, dev_t */ "
607 f36fd90a 2022-07-09 op if [ ${HAVE_FLOCK} -eq 0 ]; then
608 f36fd90a 2022-07-09 op if [ ${HAVE_SYS_FILE} -eq 0 ]; then
610 f36fd90a 2022-07-09 op echo "#include <sys/file.h>"
613 f36fd90a 2022-07-09 op echo "int flock(int, int);"
614 f36fd90a 2022-07-09 op echo "#define LOCK_SH 0x1"
615 f36fd90a 2022-07-09 op echo "#define LOCK_EX 0x2"
616 f36fd90a 2022-07-09 op echo "#define LOCK_NB 0x4"
621 f36fd90a 2022-07-09 op if [ ${HAVE_ERR} -eq 0 ]; then
622 f36fd90a 2022-07-09 op echo "#include <stdarg.h> /* err(3) */"
625 f36fd90a 2022-07-09 op echo "#include <err.h>"
629 f36fd90a 2022-07-09 op if [ ${HAVE_PLEDGE} -eq 0 ]; then
630 f36fd90a 2022-07-09 op echo "#define pledge(p, e) (0)"
633 f36fd90a 2022-07-09 op echo "#include <unistd.h>"
637 f36fd90a 2022-07-09 op # Now we handle our HAVE_xxxx values.
638 f36fd90a 2022-07-09 op # Most will just be defined as 0 or 1.
640 f36fd90a 2022-07-09 op if [ ${HAVE_PATH_MAX} -eq 0 ]
642 f36fd90a 2022-07-09 op echo "#define PATH_MAX 4096"
646 f36fd90a 2022-07-09 op if [ ${HAVE_INFTIM} -eq 0 ]
648 f36fd90a 2022-07-09 op echo "#define INFTIM (-1) /* poll.h */"
652 f36fd90a 2022-07-09 op cat << __HEREDOC__
654 f36fd90a 2022-07-09 op * Results of configuration feature-testing.
656 f36fd90a 2022-07-09 op #define HAVE_CAPSICUM ${HAVE_CAPSICUM}
657 f36fd90a 2022-07-09 op #define HAVE_ERR ${HAVE_ERR}
658 f36fd90a 2022-07-09 op #define HAVE_EXPLICIT_BZERO ${HAVE_EXPLICIT_BZERO}
659 f36fd90a 2022-07-09 op #define HAVE_FLOCK ${HAVE_FLOCK}
660 f36fd90a 2022-07-09 op #define HAVE_FREEZERO ${HAVE_FREEZERO}
661 f36fd90a 2022-07-09 op #define HAVE_GETDTABLECOUNT ${HAVE_GETDTABLECOUNT}
662 f36fd90a 2022-07-09 op #define HAVE_GETEXECNAME ${HAVE_GETEXECNAME}
663 f36fd90a 2022-07-09 op #define HAVE_GETPROGNAME ${HAVE_GETPROGNAME}
664 f36fd90a 2022-07-09 op #define HAVE_INFTIM ${HAVE_INFTIM}
665 f36fd90a 2022-07-09 op #define HAVE_LANDLOCK ${HAVE_LANDLOCK}
666 f36fd90a 2022-07-09 op #define HAVE_MEMMEM ${HAVE_MEMMEM}
667 f36fd90a 2022-07-09 op #define HAVE_MEMRCHR ${HAVE_MEMRCHR}
668 f36fd90a 2022-07-09 op #define HAVE_MEMSET_S ${HAVE_MEMSET_S}
669 f36fd90a 2022-07-09 op #define HAVE_OPTRESET ${HAVE_OPTRESET}
670 f36fd90a 2022-07-09 op #define HAVE_PATH_MAX ${HAVE_PATH_MAX}
671 f36fd90a 2022-07-09 op #define HAVE_PLEDGE ${HAVE_PLEDGE}
672 f36fd90a 2022-07-09 op #define HAVE_PROGRAM_INVOCATION_SHORT_NAME ${HAVE_PROGRAM_INVOCATION_SHORT_NAME}
673 f36fd90a 2022-07-09 op #define HAVE_PR_SET_NAME ${HAVE_PR_SET_NAME}
674 f36fd90a 2022-07-09 op #define HAVE_REALLOCARRAY ${HAVE_REALLOCARRAY}
675 f36fd90a 2022-07-09 op #define HAVE_RECALLOCARRAY ${HAVE_RECALLOCARRAY}
676 f36fd90a 2022-07-09 op #define HAVE_SANDBOX_INIT ${HAVE_SANDBOX_INIT}
677 f36fd90a 2022-07-09 op #define HAVE_SETPROCTITLE ${HAVE_SETPROCTITLE}
678 f36fd90a 2022-07-09 op #define HAVE_SIO_FLUSH ${HAVE_SIO_FLUSH}
679 f36fd90a 2022-07-09 op #define HAVE_SOCK_NONBLOCK ${HAVE_SOCK_NONBLOCK}
680 f36fd90a 2022-07-09 op #define HAVE_STRLCAT ${HAVE_STRLCAT}
681 f36fd90a 2022-07-09 op #define HAVE_STRLCPY ${HAVE_STRLCPY}
682 f36fd90a 2022-07-09 op #define HAVE_STRNDUP ${HAVE_STRNDUP}
683 f36fd90a 2022-07-09 op #define HAVE_STRNLEN ${HAVE_STRNLEN}
684 f36fd90a 2022-07-09 op #define HAVE_STRTONUM ${HAVE_STRTONUM}
685 f36fd90a 2022-07-09 op #define HAVE_SYS_FILE ${HAVE_SYS_FILE}
686 f36fd90a 2022-07-09 op #define HAVE_SYS_QUEUE ${HAVE_SYS_QUEUE}
687 f36fd90a 2022-07-09 op #define HAVE_SYSTRACE ${HAVE_SYSTRACE}
688 f36fd90a 2022-07-09 op #define HAVE_UNVEIL ${HAVE_UNVEIL}
689 f36fd90a 2022-07-09 op #define HAVE___PROGNAME ${HAVE___PROGNAME}
693 f36fd90a 2022-07-09 op # Now we do our function declarations for missing functions.
695 f36fd90a 2022-07-09 op [ ${HAVE_ERR} -eq 0 ] && \
696 f36fd90a 2022-07-09 op cat << __HEREDOC__
698 f36fd90a 2022-07-09 op * Compatibility functions for err(3).
700 f36fd90a 2022-07-09 op extern void err(int, const char *, ...) __attribute__((noreturn));
701 f36fd90a 2022-07-09 op extern void errc(int, int, const char *, ...) __attribute__((noreturn));
702 f36fd90a 2022-07-09 op extern void errx(int, const char *, ...) __attribute__((noreturn));
703 f36fd90a 2022-07-09 op extern void verr(int, const char *, va_list) __attribute__((noreturn));
704 f36fd90a 2022-07-09 op extern void verrc(int, int, const char *, va_list) __attribute__((noreturn));
705 f36fd90a 2022-07-09 op extern void verrx(int, const char *, va_list) __attribute__((noreturn));
706 f36fd90a 2022-07-09 op extern void warn(const char *, ...);
707 f36fd90a 2022-07-09 op extern void warnx(const char *, ...);
708 f36fd90a 2022-07-09 op extern void warnc(int, const char *, ...);
709 f36fd90a 2022-07-09 op extern void vwarn(const char *, va_list);
710 f36fd90a 2022-07-09 op extern void vwarnc(int, const char *, va_list);
711 f36fd90a 2022-07-09 op extern void vwarnx(const char *, va_list);
714 f36fd90a 2022-07-09 op [ ${HAVE_EXPLICIT_BZERO} -eq 0 ] && \
715 f36fd90a 2022-07-09 op cat << __HEREDOC__
717 f36fd90a 2022-07-09 op * Compatibility for explicit_bzero(3).
719 f36fd90a 2022-07-09 op extern void explicit_bzero(void *, size_t);
723 f36fd90a 2022-07-09 op [ ${HAVE_FREEZERO} -eq 0 ] && \
724 f36fd90a 2022-07-09 op cat << __HEREDOC__
726 f36fd90a 2022-07-09 op * Compatibility for freezero(3).
728 f36fd90a 2022-07-09 op extern void freezero(void *, size_t);
732 f36fd90a 2022-07-09 op [ ${HAVE_MEMMEM} -eq 0 ] && \
733 f36fd90a 2022-07-09 op cat << __HEREDOC__
735 f36fd90a 2022-07-09 op * Compatibility for memmem(3).
737 f36fd90a 2022-07-09 op void *memmem(const void *, size_t, const void *, size_t);
741 f36fd90a 2022-07-09 op [ ${HAVE_MEMRCHR} -eq 0 ] && \
742 f36fd90a 2022-07-09 op cat << __HEREDOC__
744 f36fd90a 2022-07-09 op * Compatibility for memrchr(3).
746 f36fd90a 2022-07-09 op void *memrchr(const void *b, int, size_t);
750 f36fd90a 2022-07-09 op [ ${HAVE_GETPROGNAME} -eq 0 ] && \
751 f36fd90a 2022-07-09 op cat << __HEREDOC__
753 f36fd90a 2022-07-09 op * Compatibility for getprogname(3).
755 f36fd90a 2022-07-09 op extern const char *getprogname(void);
759 f36fd90a 2022-07-09 op [ ${HAVE_REALLOCARRAY} -eq 0 ] && \
760 f36fd90a 2022-07-09 op cat << __HEREDOC__
762 f36fd90a 2022-07-09 op * Compatibility for reallocarray(3).
764 f36fd90a 2022-07-09 op extern void *reallocarray(void *, size_t, size_t);
768 f36fd90a 2022-07-09 op [ ${HAVE_RECALLOCARRAY} -eq 0 ] && \
769 f36fd90a 2022-07-09 op cat << __HEREDOC__
771 f36fd90a 2022-07-09 op * Compatibility for recallocarray(3).
773 f36fd90a 2022-07-09 op extern void *recallocarray(void *, size_t, size_t, size_t);
777 f36fd90a 2022-07-09 op [ ${HAVE_SETPROCTITLE} -eq 0 ] && \
778 f36fd90a 2022-07-09 op cat << __HEREDOC__
780 f36fd90a 2022-07-09 op * Compatibility for setproctitle(3).
782 f36fd90a 2022-07-09 op extern void setproctitle(const char *, ...);
786 f36fd90a 2022-07-09 op [ ${HAVE_STRLCAT} -eq 0 ] && \
787 f36fd90a 2022-07-09 op cat << __HEREDOC__
789 f36fd90a 2022-07-09 op * Compatibility for strlcat(3).
791 f36fd90a 2022-07-09 op extern size_t strlcat(char *, const char *, size_t);
795 f36fd90a 2022-07-09 op [ ${HAVE_STRLCPY} -eq 0 ] && \
796 f36fd90a 2022-07-09 op cat << __HEREDOC__
798 f36fd90a 2022-07-09 op * Compatibility for strlcpy(3).
800 f36fd90a 2022-07-09 op extern size_t strlcpy(char *, const char *, size_t);
804 f36fd90a 2022-07-09 op [ ${HAVE_STRNDUP} -eq 0 ] && \
805 f36fd90a 2022-07-09 op cat << __HEREDOC__
807 f36fd90a 2022-07-09 op * Compatibility for strndup(3).
809 f36fd90a 2022-07-09 op extern char *strndup(const char *, size_t);
813 f36fd90a 2022-07-09 op [ ${HAVE_STRNLEN} -eq 0 ] && \
814 f36fd90a 2022-07-09 op cat << __HEREDOC__
816 f36fd90a 2022-07-09 op * Compatibility for strnlen(3).
818 f36fd90a 2022-07-09 op extern size_t strnlen(const char *, size_t);
822 f36fd90a 2022-07-09 op [ ${HAVE_STRTONUM} -eq 0 ] && \
823 f36fd90a 2022-07-09 op cat << __HEREDOC__
825 f36fd90a 2022-07-09 op * Compatibility for strotnum(3).
827 f36fd90a 2022-07-09 op extern long long strtonum(const char *, long long, long long, const char **);
831 f36fd90a 2022-07-09 op if [ ${HAVE_SYS_QUEUE} -eq 0 ]; then
832 f36fd90a 2022-07-09 op cat << __HEREDOC__
833 f36fd90a 2022-07-09 op #include "queue.h"
836 f36fd90a 2022-07-09 op echo "#include <sys/queue.h>"
840 f36fd90a 2022-07-09 op echo "#include <sys/uio.h>"
841 f36fd90a 2022-07-09 op echo "#include <stdint.h>"
842 f36fd90a 2022-07-09 op if [ ${HAVE_IMSG} -eq 0 ]; then
843 f36fd90a 2022-07-09 op echo "#include \"imsg.h\""
845 f36fd90a 2022-07-09 op echo "#include <imsg.h>"
849 f36fd90a 2022-07-09 op if [ "${HAVE_LIBEVENT2}" -eq 1 ]; then
850 f36fd90a 2022-07-09 op cat << __HEREDOC__
851 f36fd90a 2022-07-09 op #include <event2/event.h>
852 f36fd90a 2022-07-09 op #include <event2/event_compat.h>
853 f36fd90a 2022-07-09 op #include <event2/event_struct.h>
854 f36fd90a 2022-07-09 op #include <event2/buffer.h>
855 f36fd90a 2022-07-09 op #include <event2/buffer_compat.h>
856 f36fd90a 2022-07-09 op #include <event2/bufferevent.h>
857 f36fd90a 2022-07-09 op #include <event2/bufferevent_struct.h>
858 f36fd90a 2022-07-09 op #include <event2/bufferevent_compat.h>
861 f36fd90a 2022-07-09 op elif [ "${HAVE_LIBEVENT}" -eq 1 ]; then
862 f36fd90a 2022-07-09 op cat << __HEREDOC__
863 f36fd90a 2022-07-09 op #include <event.h>
868 f36fd90a 2022-07-09 op cat << __HEREDOC__
869 f36fd90a 2022-07-09 op #ifndef __dead
870 f36fd90a 2022-07-09 op # define __dead __attribute__((noreturn))
873 f36fd90a 2022-07-09 op #if !HAVE_SIO_FLUSH
874 f36fd90a 2022-07-09 op #define sio_flush(hdl) (sio_stop(hdl))
877 f36fd90a 2022-07-09 op #if !HAVE_GETDTABLECOUNT
878 f36fd90a 2022-07-09 op /* XXX: on linux it should be possible to inspect /proc/self/fd/ */
879 f36fd90a 2022-07-09 op #define getdtablecount() (0)
882 f36fd90a 2022-07-09 op #if !HAVE_OPTRESET
883 f36fd90a 2022-07-09 op /* replace host' getopt with OpenBSD' one */
884 f36fd90a 2022-07-09 op #define opterr BSDopterr
885 f36fd90a 2022-07-09 op #define optind BSDoptind
886 f36fd90a 2022-07-09 op #define optopt BSDoptopt
887 f36fd90a 2022-07-09 op #define optreset BSDoptreset
888 f36fd90a 2022-07-09 op #define optarg BSDoptarg
889 f36fd90a 2022-07-09 op #define getopt BSDgetopt
891 f36fd90a 2022-07-09 op extern int BSDopterr, BSDoptind, BSDoptopt, BSDoptreset;
892 f36fd90a 2022-07-09 op extern char *BSDoptarg;
895 f36fd90a 2022-07-09 op #endif /*!OCONFIGURE_CONFIG_H*/
898 f36fd90a 2022-07-09 op echo "config.h: written" 1>&2
899 f36fd90a 2022-07-09 op echo "config.h: written" 1>&3
901 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
902 f36fd90a 2022-07-09 op # Now we go to generate our Makefile.configure.
903 f36fd90a 2022-07-09 op # This file is simply a bunch of Makefile variables.
904 f36fd90a 2022-07-09 op # They'll work in both GNUmakefile and BSDmakefile.
905 f36fd90a 2022-07-09 op # You MIGHT want to change this.
906 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
908 f36fd90a 2022-07-09 op exec > Makefile.configure
910 f36fd90a 2022-07-09 op [ -z "${BINDIR}" ] && BINDIR="${PREFIX}/bin"
911 f36fd90a 2022-07-09 op [ -z "${SBINDIR}" ] && SBINDIR="${PREFIX}/sbin"
912 f36fd90a 2022-07-09 op [ -z "${INCLUDEDIR}" ] && INCLUDEDIR="${PREFIX}/include"
913 f36fd90a 2022-07-09 op [ -z "${LIBDIR}" ] && LIBDIR="${PREFIX}/lib"
914 f36fd90a 2022-07-09 op [ -z "${MANDIR}" ] && MANDIR="${PREFIX}/man"
915 f36fd90a 2022-07-09 op [ -z "${SHAREDIR}" ] && SHAREDIR="${PREFIX}/share"
917 f36fd90a 2022-07-09 op [ -z "${INSTALL_PROGRAM}" ] && INSTALL_PROGRAM="${INSTALL} -m 0555"
918 f36fd90a 2022-07-09 op [ -z "${INSTALL_LIB}" ] && INSTALL_LIB="${INSTALL} -m 0444"
919 f36fd90a 2022-07-09 op [ -z "${INSTALL_MAN}" ] && INSTALL_MAN="${INSTALL} -m 0444"
920 f36fd90a 2022-07-09 op [ -z "${INSTALL_DATA}" ] && INSTALL_DATA="${INSTALL} -m 0444"
922 f36fd90a 2022-07-09 op cat << __HEREDOC__
924 f36fd90a 2022-07-09 op CFLAGS = ${CFLAGS}
925 f36fd90a 2022-07-09 op CPPFLAGS = ${CPPFLAGS}
926 f36fd90a 2022-07-09 op LDADD = ${LDADD} ${LDADD_IMSG} ${LDADD_LIB_FLAC} ${LDADD_LIB_MPG123} \
927 f36fd90a 2022-07-09 op ${LDADD_LIB_OPUSFILE} ${LDADD_LIB_VORBISFILE} ${LDADD_LIB_SOCKET} \
928 f36fd90a 2022-07-09 op ${LDADD_LIBEVENT} ${LDADD_LIBEVENT2} ${LDADD_LIB_SNDIO}
929 f36fd90a 2022-07-09 op LDADD_STATIC = ${LDADD_STATIC}
930 f36fd90a 2022-07-09 op LDFLAGS = ${LDFLAGS}
931 f36fd90a 2022-07-09 op STATIC = ${STATIC}
932 f36fd90a 2022-07-09 op PREFIX = ${PREFIX}
933 f36fd90a 2022-07-09 op BINDIR = ${BINDIR}
934 f36fd90a 2022-07-09 op SHAREDIR = ${SHAREDIR}
935 f36fd90a 2022-07-09 op SBINDIR = ${SBINDIR}
936 f36fd90a 2022-07-09 op INCLUDEDIR = ${INCLUDEDIR}
937 f36fd90a 2022-07-09 op LIBDIR = ${LIBDIR}
938 f36fd90a 2022-07-09 op MANDIR = ${MANDIR}
939 f36fd90a 2022-07-09 op INSTALL = ${INSTALL}
940 f36fd90a 2022-07-09 op INSTALL_PROGRAM = ${INSTALL_PROGRAM}
941 f36fd90a 2022-07-09 op INSTALL_LIB = ${INSTALL_LIB}
942 f36fd90a 2022-07-09 op INSTALL_MAN = ${INSTALL_MAN}
943 f36fd90a 2022-07-09 op INSTALL_DATA = ${INSTALL_DATA}
946 f36fd90a 2022-07-09 op echo "Makefile.configure: written" 1>&2
947 f36fd90a 2022-07-09 op echo "Makefile.configure: written" 1>&3