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 34674849 2023-03-23 op # Copyright (c) 2022, 2023 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 34674849 2023-03-23 op --backend=name equivalent to specify the BACKEND variable, can be either
59 34674849 2023-03-23 op "sndio" or "alsa".
61 f36fd90a 2022-07-09 op Variables available:
63 34674849 2023-03-23 op BACKEND audio backend to use; can be "sndio" or "alsa"
64 f36fd90a 2022-07-09 op LDADD generic linker flags
65 f36fd90a 2022-07-09 op LDADD_IMSG linker flags for libimsg
66 f36fd90a 2022-07-09 op LDADD_LIBEVENT linker flags for libevent
67 f36fd90a 2022-07-09 op LDADD_LIBEVENT2 linker flags for libevent2
68 f36fd90a 2022-07-09 op LDADD_LIBFLAC linker flags for libflac
69 f36fd90a 2022-07-09 op LDADD_LIBMPG123 linker flags for libmpg123
70 f36fd90a 2022-07-09 op LDADD_LIBOPUSFILE linker flags for libopusfile
71 f36fd90a 2022-07-09 op LDADD_LIBVORBISFILE linker flags for libvorbisfile
72 f36fd90a 2022-07-09 op LDADD_SNDIO linker flags for libsndio
73 f36fd90a 2022-07-09 op LDADD_LIBSOCKET linker flags for libsocket
74 f36fd90a 2022-07-09 op LDFLAGS extra linker flags
75 f36fd90a 2022-07-09 op CPPFLAGS C preprocessors flags
76 f36fd90a 2022-07-09 op DESTDIR destination directory
77 f36fd90a 2022-07-09 op PREFIX where to install files
78 f36fd90a 2022-07-09 op MANDIR where to install man pages (PREFIX/man)
79 f36fd90a 2022-07-09 op LIBDIR where to install libraries (PREFIX/lib)
80 f36fd90a 2022-07-09 op BINDIR where to install executables (PREFIX/bin)
81 f36fd90a 2022-07-09 op SHAREDIR where to install misc files (PREFIX/share)
82 f36fd90a 2022-07-09 op SBINDIR where to install system executables (PREFIX/sbin)
83 f36fd90a 2022-07-09 op INCLUDEDIR where to install header files (PREFIX/include)
84 19ee7f3a 2022-08-13 op PKG_CONFIG pkg-config program, \`false' to disable (pkg-config)
86 cac555b6 2022-07-13 op Additionally, the following environment variables are used if set:
88 cac555b6 2022-07-13 op CC the C compiler to use (defaults to cc, clang or gcc)
89 cac555b6 2022-07-13 op CFLAGS generic C compiler flags
95 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
96 f36fd90a 2022-07-09 op # Prepare for running: move aside previous configure runs.
97 f36fd90a 2022-07-09 op # Output file descriptor usage:
98 f36fd90a 2022-07-09 op # 1 (stdout): config.h or Makefile.configure
99 f36fd90a 2022-07-09 op # 2 (stderr): original stderr, usually to the console
100 f36fd90a 2022-07-09 op # 3: config.log
101 f36fd90a 2022-07-09 op # You DO NOT want to change this.
102 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
104 f36fd90a 2022-07-09 op [ -w config.log ] && mv config.log config.log.old
105 f36fd90a 2022-07-09 op [ -w config.h ] && mv config.h config.h.old
107 f36fd90a 2022-07-09 op exec 3> config.log
108 f36fd90a 2022-07-09 op echo "config.log: writing..."
110 f36fd90a 2022-07-09 op # GNU submake prints different output if invoked recursively, which
111 f36fd90a 2022-07-09 op # messes up CC and CFLAGS detection. Pass --no-print-directory if
112 f36fd90a 2022-07-09 op # we have a MAKELEVEL (GNU and FreeBSD make) and the argument is
115 f36fd90a 2022-07-09 op MAKE_FLAGS=""
117 f36fd90a 2022-07-09 op if [ -n "${MAKELEVEL}" ]; then
118 f36fd90a 2022-07-09 op if [ "${MAKELEVEL}" -gt 0 ] ; then
119 f36fd90a 2022-07-09 op MAKE_FLAGS="--no-print-directory"
120 f36fd90a 2022-07-09 op echo "all:" | make ${MAKE_FLAGS} -sf - 2>/dev/null || MAKE_FLAGS=""
124 f36fd90a 2022-07-09 op if [ -n "$MAKE_FLAGS" ]; then
125 f36fd90a 2022-07-09 op echo "GNU submake detected: using --no-print-directory" 1>&2
126 f36fd90a 2022-07-09 op echo "GNU submake detected: using --no-print-directory" 1>&3
129 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
130 f36fd90a 2022-07-09 op # Initialize all variables here such that nothing can leak in from the
131 f36fd90a 2022-07-09 op # environment except for CC and CFLAGS, which we might have passed in.
132 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
135 f36fd90a 2022-07-09 op CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | make ${MAKE_FLAGS} -sf -`
136 f36fd90a 2022-07-09 op CFLAGS=`printf "all:\\n\\t@echo \\\$(CFLAGS)\\n" | make ${MAKE_FLAGS} -sf -`
137 b817795c 2023-01-08 op CFLAGS="${CFLAGS} -g -W -Wall -Wextra -Wmissing-prototypes"
138 b817795c 2023-01-08 op CFLAGS="${CFLAGS} -Wstrict-prototypes -Wmissing-declarations"
139 b817795c 2023-01-08 op CFLAGS="${CFLAGS} -Wno-unused-parameter -Wno-sign-compare"
142 f36fd90a 2022-07-09 op LDADD_LIBEVENT=
143 f36fd90a 2022-07-09 op LDADD_LIBEVENT2=
144 f36fd90a 2022-07-09 op LDADD_LIB_FLAC=
145 f36fd90a 2022-07-09 op LDADD_LIB_MPG123=
146 f36fd90a 2022-07-09 op LDADD_LIB_VORBISFILE=
147 34674849 2023-03-23 op LDADD_LIB_ASOUND=
148 f36fd90a 2022-07-09 op LDADD_LIB_SNDIO=
149 f36fd90a 2022-07-09 op LDADD_LIB_SOCKET=
150 f36fd90a 2022-07-09 op LDADD_STATIC=
154 f36fd90a 2022-07-09 op PREFIX="/usr/local"
161 f36fd90a 2022-07-09 op INSTALL="install"
162 f36fd90a 2022-07-09 op INSTALL_PROGRAM=
165 f36fd90a 2022-07-09 op INSTALL_DATA=
168 f36fd90a 2022-07-09 op # SunOS sets "cc", but this doesn't exist.
169 f36fd90a 2022-07-09 op # It does have gcc, so try that instead.
170 f36fd90a 2022-07-09 op # Prefer clang, though.
172 f36fd90a 2022-07-09 op command -v ${CC} 2>/dev/null 1>&2 || {
173 f36fd90a 2022-07-09 op echo "${CC} not found: trying clang" 1>&2
174 f36fd90a 2022-07-09 op echo "${CC} not found: trying clang" 1>&3
176 f36fd90a 2022-07-09 op command -v ${CC} 2>/dev/null 1>&2 || {
177 f36fd90a 2022-07-09 op echo "${CC} not found: trying gcc" 1>&2
178 f36fd90a 2022-07-09 op echo "${CC} not found: trying gcc" 1>&3
180 f36fd90a 2022-07-09 op command -v ${CC} 2>/dev/null 1>&2 || {
181 f36fd90a 2022-07-09 op echo "gcc not found: giving up" 1>&2
182 f36fd90a 2022-07-09 op echo "gcc not found: giving up" 1>&3
188 f36fd90a 2022-07-09 op command -v pkg-config 2>/dev/null 1>&2 && {
189 f36fd90a 2022-07-09 op PKG_CONFIG=pkg-config
190 f36fd90a 2022-07-09 op echo "pkg-config found" 1>&2
191 f36fd90a 2022-07-09 op echo "pkg-config found" 1>&3
193 f36fd90a 2022-07-09 op echo "pkg-config not found" 1>&2
194 f36fd90a 2022-07-09 op echo "pkg-config not found" 1>&3
197 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
198 f36fd90a 2022-07-09 op # Allow certain variables to be overriden on the command line.
199 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
201 f36fd90a 2022-07-09 op while [ $# -gt 0 ]; do
205 f36fd90a 2022-07-09 op if [ "$key" = "--prefix" ]; then
207 f36fd90a 2022-07-09 op if [ "$1" = "--prefix" ]; then
208 f36fd90a 2022-07-09 op if ! shift 2>&1 >/dev/null; then
209 f36fd90a 2022-07-09 op echo "$0: missing value for --prefix" 1>&2
216 34674849 2023-03-23 op if [ "$key" = "--backend" ]; then
218 34674849 2023-03-23 op if [ "$1" = "--backend" ]; then
219 34674849 2023-03-23 op if ! shift 2>&1 >/dev/null; then
220 34674849 2023-03-23 op echo "$0 missing value for --backend" 1>&2
227 f36fd90a 2022-07-09 op if [ "$1" = "$key" ]; then
228 f36fd90a 2022-07-09 op echo "$0: invalid key-value: $1" 1>&2
234 f36fd90a 2022-07-09 op case "$key" in
236 34674849 2023-03-23 op case "$val" in
237 34674849 2023-03-23 op alsa) BACKEND=alsa ;;
238 34674849 2023-03-23 op sndio) BACKEND=sndio ;;
240 34674849 2023-03-23 op echo "unknown audio backend: $val" 1>&2
244 f36fd90a 2022-07-09 op LDADD="$val" ;;
246 f36fd90a 2022-07-09 op LDADD_IMSG="$val" ;;
247 f36fd90a 2022-07-09 op LDADD_LIBEVENT)
248 f36fd90a 2022-07-09 op LDADD_LIBEVENT="$val" ;;
249 f36fd90a 2022-07-09 op LDADD_LIBEVENT2)
250 f36fd90a 2022-07-09 op LDADD_LIBEVENT2="$val" ;;
251 f36fd90a 2022-07-09 op LDADD_LIBFLAC)
252 f36fd90a 2022-07-09 op LDADD_LIBFLAC="$val" ;;
253 f36fd90a 2022-07-09 op LDADD_LIBMPG123)
254 f36fd90a 2022-07-09 op LDADD_LIBMPG123="$val" ;;
255 f36fd90a 2022-07-09 op LDADD_LIBOPUSFILE)
256 f36fd90a 2022-07-09 op LDADD_LIBOPUSFILE="$val" ;;
257 f36fd90a 2022-07-09 op LDADD_LIBVORBISFILE)
258 f36fd90a 2022-07-09 op LDADD_LIBVORBISFILE="$val" ;;
260 f36fd90a 2022-07-09 op LDADD_SNDIO="$val" ;;
261 f36fd90a 2022-07-09 op LDADD_LIBSOCKET)
262 f36fd90a 2022-07-09 op LDADD_LIBSOCKET="$val" ;;
264 f36fd90a 2022-07-09 op LDFLAGS="$val" ;;
266 f36fd90a 2022-07-09 op CPPFLAGS="$val" ;;
268 f36fd90a 2022-07-09 op DESTDIR="$val" ;;
270 f36fd90a 2022-07-09 op PREFIX="$val" ;;
272 f36fd90a 2022-07-09 op MANDIR="$val" ;;
274 f36fd90a 2022-07-09 op LIBDIR="$val" ;;
276 f36fd90a 2022-07-09 op BINDIR="$val" ;;
278 f36fd90a 2022-07-09 op SHAREDIR="$val" ;;
280 f36fd90a 2022-07-09 op SBINDIR="$val" ;;
282 f36fd90a 2022-07-09 op INCLUDEDIR="$val" ;;
284 f36fd90a 2022-07-09 op PKG_CONFIG="$val" ;;
286 f36fd90a 2022-07-09 op echo "$0: invalid key: $key" 1>&2
292 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
293 f36fd90a 2022-07-09 op # These are the values that will be pushed into config.h after we test
294 f36fd90a 2022-07-09 op # for whether they're supported or not.
295 f36fd90a 2022-07-09 op # Each of these must have a runtest(), below.
296 f36fd90a 2022-07-09 op # Please sort by alpha, for clarity.
297 f36fd90a 2022-07-09 op # You WANT to change this.
298 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
300 f36fd90a 2022-07-09 op HAVE_CAPSICUM=
302 f36fd90a 2022-07-09 op HAVE_EXPLICIT_BZERO=
304 f36fd90a 2022-07-09 op HAVE_FREEZERO=
305 f36fd90a 2022-07-09 op HAVE_GETDTABLECOUNT=
306 f36fd90a 2022-07-09 op HAVE_GETEXECNAME=
307 f36fd90a 2022-07-09 op HAVE_GETPROGNAME=
310 f36fd90a 2022-07-09 op HAVE_LANDLOCK=
311 f36fd90a 2022-07-09 op HAVE_LIBEVENT=
312 f36fd90a 2022-07-09 op HAVE_LIBEVENT2=0 # may not be checked, set to zero
313 f36fd90a 2022-07-09 op HAVE_LIB_FLAC=
314 f36fd90a 2022-07-09 op HAVE_LIB_MPG123=
315 f36fd90a 2022-07-09 op HAVE_LIB_OPUSFILE=
316 f36fd90a 2022-07-09 op HAVE_LIB_VORBISFILE=
317 34674849 2023-03-23 op HAVE_LIB_ASOUND=
318 f36fd90a 2022-07-09 op HAVE_LIB_SNDIO=
319 f36fd90a 2022-07-09 op HAVE_LIB_SOCKET=
321 f36fd90a 2022-07-09 op HAVE_MEMRCHR=
322 f36fd90a 2022-07-09 op HAVE_MEMSET_S=
323 f36fd90a 2022-07-09 op HAVE_OPTRESET=
324 f36fd90a 2022-07-09 op HAVE_PATH_MAX=
326 f36fd90a 2022-07-09 op HAVE_PROGRAM_INVOCATION_SHORT_NAME=
327 f36fd90a 2022-07-09 op HAVE_PR_SET_NAME=
328 f36fd90a 2022-07-09 op HAVE_REALLOCARRAY=
329 f36fd90a 2022-07-09 op HAVE_RECALLOCARRAY=
330 f36fd90a 2022-07-09 op HAVE_SANDBOX_INIT=
331 f36fd90a 2022-07-09 op HAVE_SETPROCTITLE=
332 f36fd90a 2022-07-09 op HAVE_SIO_FLUSH=
333 f36fd90a 2022-07-09 op HAVE_SOCK_NONBLOCK=
334 f36fd90a 2022-07-09 op HAVE_STRLCAT=
335 f36fd90a 2022-07-09 op HAVE_STRLCPY=
336 f36fd90a 2022-07-09 op HAVE_STRNDUP=
337 f36fd90a 2022-07-09 op HAVE_STRNLEN=
338 f36fd90a 2022-07-09 op HAVE_STRTONUM=
339 f36fd90a 2022-07-09 op HAVE_SYS_FILE=
340 f36fd90a 2022-07-09 op HAVE_SYS_QUEUE=
341 f36fd90a 2022-07-09 op HAVE_SYSTRACE=0
343 f36fd90a 2022-07-09 op HAVE___PROGNAME=
345 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
346 f36fd90a 2022-07-09 op # Allow configure.local to override all variables, default settings,
347 f36fd90a 2022-07-09 op # command-line arguments, and tested features, above.
348 f36fd90a 2022-07-09 op # You PROBABLY DO NOT want to change this.
349 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
351 f36fd90a 2022-07-09 op if [ -r ./configure.local ]; then
352 f36fd90a 2022-07-09 op echo "configure.local: reading..." 1>&2
353 f36fd90a 2022-07-09 op echo "configure.local: reading..." 1>&3
354 f36fd90a 2022-07-09 op cat ./configure.local 1>&3
355 f36fd90a 2022-07-09 op . ./configure.local
357 f36fd90a 2022-07-09 op echo "configure.local: no (fully automatic configuration)" 1>&2
358 f36fd90a 2022-07-09 op echo "configure.local: no (fully automatic configuration)" 1>&3
363 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
364 f36fd90a 2022-07-09 op # Infrastructure for running tests.
365 f36fd90a 2022-07-09 op # These consists of a series of functions that will attempt to run the
366 f36fd90a 2022-07-09 op # given test file and record its exit into a HAVE_xxx variable.
367 f36fd90a 2022-07-09 op # You DO NOT want to change this.
368 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
370 f36fd90a 2022-07-09 op COMP="${CC} ${CFLAGS} ${CPPFLAGS} -Wno-unused -Werror"
372 f36fd90a 2022-07-09 op # Check whether this HAVE_ setting is manually overridden.
373 f36fd90a 2022-07-09 op # If yes, use the override, if no, do not decide anything yet.
374 f36fd90a 2022-07-09 op # Arguments: lower-case test name, manual value
377 f36fd90a 2022-07-09 op [ -z "${3}" ] && return 1
378 f36fd90a 2022-07-09 op echo "${1}: manual (HAVE_${2}=${3})" 1>&2
379 f36fd90a 2022-07-09 op echo "${1}: manual (HAVE_${2}=${3})" 1>&3
384 f36fd90a 2022-07-09 op # Run a single autoconfiguration test.
385 f36fd90a 2022-07-09 op # In case of success, enable the feature.
386 f36fd90a 2022-07-09 op # In case of failure, do not decide anything yet.
387 f36fd90a 2022-07-09 op # Arguments: lower-case test name, upper-case test name, additional
388 f36fd90a 2022-07-09 op # CFLAGS, additional LIBS.
390 f36fd90a 2022-07-09 op singletest() {
395 f36fd90a 2022-07-09 op cat 1>&3 << __HEREDOC__
396 f36fd90a 2022-07-09 op ${1}: testing...
397 f36fd90a 2022-07-09 op ${COMP} -DTEST_${2} ${3} -o test-${1} tests.c ${LDFLAGS} ${4}
399 f36fd90a 2022-07-09 op if ${COMP} -DTEST_${2} ${3} -o "test-${1}" tests.c ${LDFLAGS} ${4} 1>&3 2>&3; then
400 f36fd90a 2022-07-09 op echo "${1}: ${CC} succeeded" 1>&3
402 f36fd90a 2022-07-09 op if [ -n "${5}" ] ; then
403 f36fd90a 2022-07-09 op echo "${1}: ${CC} failed with $? (retrying)" 1>&3
404 f36fd90a 2022-07-09 op cat 1>&3 << __HEREDOC__
405 f36fd90a 2022-07-09 op ${1}: testing...
406 f36fd90a 2022-07-09 op ${COMP} -DTEST_${2} ${3} -o test-${1} tests.c ${LDFLAGS} ${5}
408 f36fd90a 2022-07-09 op if ${COMP} -DTEST_${2} ${3} -o "test-${1}" tests.c ${LDFLAGS} ${5} 1>&3 2>&3; then
409 f36fd90a 2022-07-09 op echo "${1}: ${CC} succeeded" 1>&3
410 f36fd90a 2022-07-09 op extralib="(with ${5})"
412 f36fd90a 2022-07-09 op test -n "${PKG_CONFIG}" -a -n "${6}" && ${PKG_CONFIG} "$6"
413 f36fd90a 2022-07-09 op if [ $? -eq 0 ]; then
414 f36fd90a 2022-07-09 op echo "${1}: ${CC} failed with $? (retrying)" 1>&3
415 f36fd90a 2022-07-09 op pkgcfs=$($PKG_CONFIG --cflags "${6}")
416 f36fd90a 2022-07-09 op pkglib=$($PKG_CONFIG --libs "${6}")
417 f36fd90a 2022-07-09 op cat 1>&3 << __HEREDOC__
418 f36fd90a 2022-07-09 op ${1}: testing...
419 f36fd90a 2022-07-09 op ${COMP} -DTEST_${2} ${3} ${pkgcfs} -o test-${1} tests.c ${LDFLAGS} ${pkglib}
421 f36fd90a 2022-07-09 op if ${COMP} -DTEST_${2} ${3} ${pkgcfs} -o test-${1} tests.c ${LDFLAGS} ${pkglib} 1>&3 2>&3; then
422 f36fd90a 2022-07-09 op echo "${1}: ${CC} succeeded" 1>&3
423 f36fd90a 2022-07-09 op extralib="(with ${pkgcfs} ${pkglib})"
425 f36fd90a 2022-07-09 op echo "${1}: ${CC} failed with $?" 1>&3
430 f36fd90a 2022-07-09 op echo "${1}: ${CC} failed with $?" 1>&3
436 f36fd90a 2022-07-09 op echo "${1}: ${CC} failed with $?" 1>&3
442 1c53767e 2022-07-13 op rm -f test-${1}.d
444 f36fd90a 2022-07-09 op if [ -n "${pkgcfs}" -o -n "${pkglib}" ]
446 f36fd90a 2022-07-09 op CFLAGS="${CFLAGS} ${pkgcfs}"
447 f36fd90a 2022-07-09 op eval "LDADD_${2}=\"${pkglib}\""
448 f36fd90a 2022-07-09 op elif [ -n "${extralib}" ]
450 f36fd90a 2022-07-09 op eval "LDADD_${2}=\"${5}\""
451 f36fd90a 2022-07-09 op elif [ -n "${4}" ]
453 f36fd90a 2022-07-09 op eval "LDADD_${2}=\"${4}\""
456 f36fd90a 2022-07-09 op echo "${1}: yes ${extralib}" 1>&2
457 f36fd90a 2022-07-09 op echo "${1}: yes ${extralib}" 1>&3
459 f36fd90a 2022-07-09 op eval HAVE_${2}=1
460 f36fd90a 2022-07-09 op rm "test-${1}"
464 f36fd90a 2022-07-09 op # Run a complete autoconfiguration test, including the check for
465 f36fd90a 2022-07-09 op # a manual override and disabling the feature on failure.
466 f36fd90a 2022-07-09 op # Arguments: lower case name, upper case name, additional CFLAGS,
467 f36fd90a 2022-07-09 op # additional LDADD, alternative LDADD, pkg-config name.
470 f36fd90a 2022-07-09 op eval _manual=\${HAVE_${2}}
471 f36fd90a 2022-07-09 op ismanual "${1}" "${2}" "${_manual}" && return 0
472 f36fd90a 2022-07-09 op singletest "${1}" "${2}" "${3}" "${4}" "${5}" "${6}" && return 0
473 f36fd90a 2022-07-09 op echo "${1}: no" 1>&2
474 f36fd90a 2022-07-09 op eval HAVE_${2}=0
478 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
479 f36fd90a 2022-07-09 op # Begin running the tests themselves.
480 f36fd90a 2022-07-09 op # All of your tests must be defined here.
481 f36fd90a 2022-07-09 op # Please sort as the HAVE_xxxx values were defined.
482 f36fd90a 2022-07-09 op # You WANT to change this.
483 f36fd90a 2022-07-09 op # It consists of the following columns:
485 f36fd90a 2022-07-09 op # (1) test file
486 f36fd90a 2022-07-09 op # (2) macro to set
487 f36fd90a 2022-07-09 op # (3) argument to cc *before* -o
488 f36fd90a 2022-07-09 op # (4) argument to cc *after*
489 f36fd90a 2022-07-09 op # (5) alternative argument to cc *after*
490 f36fd90a 2022-07-09 op # (6) name for pkg-config auto-discovery
491 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
493 f36fd90a 2022-07-09 op if runtest -MMD _MMD -MMD; then
494 f36fd90a 2022-07-09 op CFLAGS="${CFLAGS} -MMD"
495 f36fd90a 2022-07-09 op echo "adding -MMD to CFLAGS" 1>&2
496 f36fd90a 2022-07-09 op echo "adding -MMD to CFLAGS" 1>&3
499 f36fd90a 2022-07-09 op runtest capsicum CAPSICUM || true
500 f36fd90a 2022-07-09 op runtest err ERR || true
501 f36fd90a 2022-07-09 op runtest explicit_bzero EXPLICIT_BZERO || true
502 f36fd90a 2022-07-09 op runtest flock FLOCK || true
503 f36fd90a 2022-07-09 op runtest freezero FREEZERO || true
504 f36fd90a 2022-07-09 op runtest getdtablecount GETDTABLECOUNT || true
505 f36fd90a 2022-07-09 op runtest getexecname GETEXECNAME || true
506 f36fd90a 2022-07-09 op runtest getprogname GETPROGNAME || true
507 f36fd90a 2022-07-09 op runtest imsg IMSG "" "" "-lutil" || true
508 f36fd90a 2022-07-09 op runtest INFTIM INFTIM || true
509 f36fd90a 2022-07-09 op runtest landlock LANDLOCK || true
511 f36fd90a 2022-07-09 op runtest libevent LIBEVENT "" "" "-levent" || \
512 f36fd90a 2022-07-09 op runtest libevent2 LIBEVENT2 "" "" "-levent_extra -levent_core" "libevent" || true
514 f36fd90a 2022-07-09 op runtest lib_flac LIB_FLAC "" "" "-lFLAC" "flac" || true
515 f36fd90a 2022-07-09 op runtest lib_mpg123 LIB_MPG123 "" "" "-lmpg123" "libmpg123" || true
516 f36fd90a 2022-07-09 op runtest lib_opusfile LIB_OPUSFILE "" "" "-lopusfile" "opusfile" || true
517 f36fd90a 2022-07-09 op runtest lib_vorbisfile LIB_VORBISFILE "" "" "-lvorbisfile" "vorbisfile" || true
519 f36fd90a 2022-07-09 op runtest lib_socket LIB_SOCKET "" "" "-lsocket -lnsl" || true
520 f36fd90a 2022-07-09 op runtest memmem MEMMEM || true
521 f36fd90a 2022-07-09 op runtest memrchr MEMRCHR || true
522 f36fd90a 2022-07-09 op runtest memset_s MEMSET_S || true
523 f36fd90a 2022-07-09 op runtest optreset OPTRESET || true
524 f36fd90a 2022-07-09 op runtest PATH_MAX PATH_MAX || true
525 f36fd90a 2022-07-09 op runtest pledge PLEDGE || true
526 f36fd90a 2022-07-09 op runtest program_invocation_short_name PROGRAM_INVOCATION_SHORT_NAME || true
527 f36fd90a 2022-07-09 op runtest PR_SET_NAME PR_SET_NAME || true
528 f36fd90a 2022-07-09 op runtest reallocarray REALLOCARRAY || true
529 f36fd90a 2022-07-09 op runtest recallocarray RECALLOCARRAY || true
530 f36fd90a 2022-07-09 op runtest sandbox_init SANDBOX_INIT "-Wno-deprecated" || true
531 f36fd90a 2022-07-09 op runtest setproctitle SETPROCTITLE || true
532 f36fd90a 2022-07-09 op runtest SOCK_NONBLOCK SOCK_NONBLOCK || true
533 f36fd90a 2022-07-09 op runtest static STATIC "" "-static" || true
534 f36fd90a 2022-07-09 op runtest strlcat STRLCAT || true
535 f36fd90a 2022-07-09 op runtest strlcpy STRLCPY || true
536 f36fd90a 2022-07-09 op runtest strndup STRNDUP || true
537 f36fd90a 2022-07-09 op runtest strnlen STRNLEN || true
538 f36fd90a 2022-07-09 op runtest strtonum STRTONUM || true
539 f36fd90a 2022-07-09 op runtest sys_queue SYS_QUEUE || true
540 f36fd90a 2022-07-09 op runtest sys_file SYS_FILE || true
541 f36fd90a 2022-07-09 op runtest unveil UNVEIL || true
542 f36fd90a 2022-07-09 op runtest __progname __PROGNAME || true
544 34674849 2023-03-23 op if [ $BACKEND != alsa ]; then # auto or sndio
545 34674849 2023-03-23 op runtest lib_sndio LIB_SNDIO "" "" "-lsndio" "sndio" || true
546 34674849 2023-03-23 op runtest sio_flush SIO_FLUSH "" "" "${LDADD_LIB_SNDIO}" || true
548 34674849 2023-03-23 op if [ "${HAVE_LIB_SNDIO}" -eq 0 ]; then
549 34674849 2023-03-23 op if [ $BACKEND = sndio ]; then
550 34674849 2023-03-23 op echo "Fatal: missing libsndio" 1>&2
551 34674849 2023-03-23 op echo "Fatal: missing libsndio" 1>&3
555 34674849 2023-03-23 op BACKEND=sndio
559 34674849 2023-03-23 op if [ $BACKEND != sndio ]; then # auto or alsa
560 34674849 2023-03-23 op runtest lib_asound LIB_ASOUND "" "" "-lasound" "alsa" || true
561 34674849 2023-03-23 op if [ "${HAVE_LIB_ASOUND}" -eq 0 ]; then
562 34674849 2023-03-23 op if [ $BACKEND = alsa ]; then
563 34674849 2023-03-23 op echo "Fatal: missing libasound" 1>&2
564 34674849 2023-03-23 op echo "Fatal: missing libasound" 1>&3
566 34674849 2023-03-23 op echo "Fatal: missing libasound or libsndio" 1>&2
567 34674849 2023-03-23 op echo "Fatal: missing libasound or libsndio" 1>&3
574 f36fd90a 2022-07-09 op if [ "${HAVE_LIBEVENT}" -eq 0 -a "${HAVE_LIBEVENT2}" -eq 0 ]; then
575 f36fd90a 2022-07-09 op echo "Fatal: missing libevent" 1>&2
576 f36fd90a 2022-07-09 op echo "Fatal: missing libevent" 1>&3
580 f36fd90a 2022-07-09 op if [ "${HAVE_LIB_FLAC}" -eq 0 -o \
581 f36fd90a 2022-07-09 op "${HAVE_LIB_MPG123}" -eq 0 -o \
582 f36fd90a 2022-07-09 op "${HAVE_LIB_OPUSFILE}" -eq 0 -o \
583 f36fd90a 2022-07-09 op "${HAVE_LIB_VORBISFILE}" -eq 0 ]; then
584 f36fd90a 2022-07-09 op echo "Fatal: missing required audio libraries" 1>&2
585 f36fd90a 2022-07-09 op echo "Fatal: missing required audio libraries" 1>&3
589 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
590 f36fd90a 2022-07-09 op # Output writing: generate the config.h file.
591 f36fd90a 2022-07-09 op # This file contains all of the HAVE_xxxx variables necessary for
592 f36fd90a 2022-07-09 op # compiling your source.
593 f36fd90a 2022-07-09 op # You must include "config.h" BEFORE any other variables.
594 f36fd90a 2022-07-09 op # You WANT to change this.
595 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
597 f36fd90a 2022-07-09 op exec > config.h
599 f36fd90a 2022-07-09 op # Start with prologue.
601 f36fd90a 2022-07-09 op cat << __HEREDOC__
602 f36fd90a 2022-07-09 op #ifndef OCONFIGURE_CONFIG_H
603 f36fd90a 2022-07-09 op #define OCONFIGURE_CONFIG_H
605 f36fd90a 2022-07-09 op #ifdef __cplusplus
606 f36fd90a 2022-07-09 op # error "Do not use C++: this is a C application."
608 f36fd90a 2022-07-09 op #if !defined(__GNUC__) || (__GNUC__ < 4)
609 f36fd90a 2022-07-09 op # define __attribute__(x)
611 f36fd90a 2022-07-09 op #if defined(__linux__) || defined(__MINT__)
612 f36fd90a 2022-07-09 op # define _GNU_SOURCE /* memmem, memrchr, setresuid... */
613 f36fd90a 2022-07-09 op # define _DEFAULT_SOURCE /* le32toh, crypt, ... */
615 f36fd90a 2022-07-09 op #if defined(__NetBSD__)
616 f36fd90a 2022-07-09 op # define _OPENBSD_SOURCE /* reallocarray, etc. */
618 f36fd90a 2022-07-09 op #if defined(__sun)
619 f36fd90a 2022-07-09 op # ifndef _XOPEN_SOURCE /* SunOS already defines */
620 f36fd90a 2022-07-09 op # define _XOPEN_SOURCE /* XPGx */
622 f36fd90a 2022-07-09 op # define _XOPEN_SOURCE_EXTENDED 1 /* XPG4v2 */
623 f36fd90a 2022-07-09 op # ifndef __EXTENSIONS__ /* SunOS already defines */
624 f36fd90a 2022-07-09 op # define __EXTENSIONS__ /* reallocarray, etc. */
627 f36fd90a 2022-07-09 op #if !defined(__BEGIN_DECLS)
628 f36fd90a 2022-07-09 op # define __BEGIN_DECLS
630 f36fd90a 2022-07-09 op #if !defined(__END_DECLS)
631 f36fd90a 2022-07-09 op # define __END_DECLS
636 f36fd90a 2022-07-09 op # This is just for size_t, mode_t, and dev_t.
637 f36fd90a 2022-07-09 op # Most of these functions, in the real world, pull in <string.h> or
638 f36fd90a 2022-07-09 op # someting that pulls in support for size_t.
639 f36fd90a 2022-07-09 op # Our function declarations are standalone, so specify them here.
641 f36fd90a 2022-07-09 op if [ ${HAVE_IMSG} -eq 0 -o \
642 f36fd90a 2022-07-09 op ${HAVE_MEMMEM} -eq 0 -o \
643 f36fd90a 2022-07-09 op ${HAVE_MEMRCHR} -eq 0 -o \
644 f36fd90a 2022-07-09 op ${HAVE_REALLOCARRAY} -eq 0 -o \
645 f36fd90a 2022-07-09 op ${HAVE_RECALLOCARRAY} -eq 0 -o \
646 f36fd90a 2022-07-09 op ${HAVE_STRLCAT} -eq 0 -o \
647 f36fd90a 2022-07-09 op ${HAVE_STRLCPY} -eq 0 -o \
648 f36fd90a 2022-07-09 op ${HAVE_STRNDUP} -eq 0 -o \
649 f36fd90a 2022-07-09 op ${HAVE_STRNLEN} -eq 0 ]
651 f36fd90a 2022-07-09 op echo "#include <sys/types.h> /* size_t, mode_t, dev_t */ "
655 f36fd90a 2022-07-09 op if [ ${HAVE_FLOCK} -eq 0 ]; then
656 f36fd90a 2022-07-09 op if [ ${HAVE_SYS_FILE} -eq 0 ]; then
658 f36fd90a 2022-07-09 op echo "#include <sys/file.h>"
661 f36fd90a 2022-07-09 op echo "int flock(int, int);"
662 f36fd90a 2022-07-09 op echo "#define LOCK_SH 0x1"
663 f36fd90a 2022-07-09 op echo "#define LOCK_EX 0x2"
664 f36fd90a 2022-07-09 op echo "#define LOCK_NB 0x4"
669 f36fd90a 2022-07-09 op if [ ${HAVE_ERR} -eq 0 ]; then
670 f36fd90a 2022-07-09 op echo "#include <stdarg.h> /* err(3) */"
673 f36fd90a 2022-07-09 op echo "#include <err.h>"
677 f36fd90a 2022-07-09 op if [ ${HAVE_PLEDGE} -eq 0 ]; then
678 f36fd90a 2022-07-09 op echo "#define pledge(p, e) (0)"
681 f36fd90a 2022-07-09 op echo "#include <unistd.h>"
685 f36fd90a 2022-07-09 op # Now we handle our HAVE_xxxx values.
686 f36fd90a 2022-07-09 op # Most will just be defined as 0 or 1.
688 f36fd90a 2022-07-09 op if [ ${HAVE_PATH_MAX} -eq 0 ]
690 f36fd90a 2022-07-09 op echo "#define PATH_MAX 4096"
694 f36fd90a 2022-07-09 op if [ ${HAVE_INFTIM} -eq 0 ]
696 f36fd90a 2022-07-09 op echo "#define INFTIM (-1) /* poll.h */"
700 f36fd90a 2022-07-09 op cat << __HEREDOC__
702 f36fd90a 2022-07-09 op * Results of configuration feature-testing.
704 f36fd90a 2022-07-09 op #define HAVE_CAPSICUM ${HAVE_CAPSICUM}
705 f36fd90a 2022-07-09 op #define HAVE_ERR ${HAVE_ERR}
706 f36fd90a 2022-07-09 op #define HAVE_EXPLICIT_BZERO ${HAVE_EXPLICIT_BZERO}
707 f36fd90a 2022-07-09 op #define HAVE_FLOCK ${HAVE_FLOCK}
708 f36fd90a 2022-07-09 op #define HAVE_FREEZERO ${HAVE_FREEZERO}
709 f36fd90a 2022-07-09 op #define HAVE_GETDTABLECOUNT ${HAVE_GETDTABLECOUNT}
710 f36fd90a 2022-07-09 op #define HAVE_GETEXECNAME ${HAVE_GETEXECNAME}
711 f36fd90a 2022-07-09 op #define HAVE_GETPROGNAME ${HAVE_GETPROGNAME}
712 f36fd90a 2022-07-09 op #define HAVE_INFTIM ${HAVE_INFTIM}
713 f36fd90a 2022-07-09 op #define HAVE_LANDLOCK ${HAVE_LANDLOCK}
714 f36fd90a 2022-07-09 op #define HAVE_MEMMEM ${HAVE_MEMMEM}
715 f36fd90a 2022-07-09 op #define HAVE_MEMRCHR ${HAVE_MEMRCHR}
716 f36fd90a 2022-07-09 op #define HAVE_MEMSET_S ${HAVE_MEMSET_S}
717 f36fd90a 2022-07-09 op #define HAVE_OPTRESET ${HAVE_OPTRESET}
718 f36fd90a 2022-07-09 op #define HAVE_PATH_MAX ${HAVE_PATH_MAX}
719 f36fd90a 2022-07-09 op #define HAVE_PLEDGE ${HAVE_PLEDGE}
720 f36fd90a 2022-07-09 op #define HAVE_PROGRAM_INVOCATION_SHORT_NAME ${HAVE_PROGRAM_INVOCATION_SHORT_NAME}
721 f36fd90a 2022-07-09 op #define HAVE_PR_SET_NAME ${HAVE_PR_SET_NAME}
722 f36fd90a 2022-07-09 op #define HAVE_REALLOCARRAY ${HAVE_REALLOCARRAY}
723 f36fd90a 2022-07-09 op #define HAVE_RECALLOCARRAY ${HAVE_RECALLOCARRAY}
724 f36fd90a 2022-07-09 op #define HAVE_SANDBOX_INIT ${HAVE_SANDBOX_INIT}
725 f36fd90a 2022-07-09 op #define HAVE_SETPROCTITLE ${HAVE_SETPROCTITLE}
726 f36fd90a 2022-07-09 op #define HAVE_SIO_FLUSH ${HAVE_SIO_FLUSH}
727 f36fd90a 2022-07-09 op #define HAVE_SOCK_NONBLOCK ${HAVE_SOCK_NONBLOCK}
728 f36fd90a 2022-07-09 op #define HAVE_STRLCAT ${HAVE_STRLCAT}
729 f36fd90a 2022-07-09 op #define HAVE_STRLCPY ${HAVE_STRLCPY}
730 f36fd90a 2022-07-09 op #define HAVE_STRNDUP ${HAVE_STRNDUP}
731 f36fd90a 2022-07-09 op #define HAVE_STRNLEN ${HAVE_STRNLEN}
732 f36fd90a 2022-07-09 op #define HAVE_STRTONUM ${HAVE_STRTONUM}
733 f36fd90a 2022-07-09 op #define HAVE_SYS_FILE ${HAVE_SYS_FILE}
734 f36fd90a 2022-07-09 op #define HAVE_SYS_QUEUE ${HAVE_SYS_QUEUE}
735 f36fd90a 2022-07-09 op #define HAVE_SYSTRACE ${HAVE_SYSTRACE}
736 f36fd90a 2022-07-09 op #define HAVE_UNVEIL ${HAVE_UNVEIL}
737 f36fd90a 2022-07-09 op #define HAVE___PROGNAME ${HAVE___PROGNAME}
741 f36fd90a 2022-07-09 op # Now we do our function declarations for missing functions.
743 f36fd90a 2022-07-09 op [ ${HAVE_ERR} -eq 0 ] && \
744 f36fd90a 2022-07-09 op cat << __HEREDOC__
746 f36fd90a 2022-07-09 op * Compatibility functions for err(3).
748 f36fd90a 2022-07-09 op extern void err(int, const char *, ...) __attribute__((noreturn));
749 f36fd90a 2022-07-09 op extern void errc(int, int, const char *, ...) __attribute__((noreturn));
750 f36fd90a 2022-07-09 op extern void errx(int, const char *, ...) __attribute__((noreturn));
751 f36fd90a 2022-07-09 op extern void verr(int, const char *, va_list) __attribute__((noreturn));
752 f36fd90a 2022-07-09 op extern void verrc(int, int, const char *, va_list) __attribute__((noreturn));
753 f36fd90a 2022-07-09 op extern void verrx(int, const char *, va_list) __attribute__((noreturn));
754 f36fd90a 2022-07-09 op extern void warn(const char *, ...);
755 f36fd90a 2022-07-09 op extern void warnx(const char *, ...);
756 f36fd90a 2022-07-09 op extern void warnc(int, const char *, ...);
757 f36fd90a 2022-07-09 op extern void vwarn(const char *, va_list);
758 f36fd90a 2022-07-09 op extern void vwarnc(int, const char *, va_list);
759 f36fd90a 2022-07-09 op extern void vwarnx(const char *, va_list);
762 f36fd90a 2022-07-09 op [ ${HAVE_EXPLICIT_BZERO} -eq 0 ] && \
763 f36fd90a 2022-07-09 op cat << __HEREDOC__
765 f36fd90a 2022-07-09 op * Compatibility for explicit_bzero(3).
767 f36fd90a 2022-07-09 op extern void explicit_bzero(void *, size_t);
771 f36fd90a 2022-07-09 op [ ${HAVE_FREEZERO} -eq 0 ] && \
772 f36fd90a 2022-07-09 op cat << __HEREDOC__
774 f36fd90a 2022-07-09 op * Compatibility for freezero(3).
776 f36fd90a 2022-07-09 op extern void freezero(void *, size_t);
780 f36fd90a 2022-07-09 op [ ${HAVE_MEMMEM} -eq 0 ] && \
781 f36fd90a 2022-07-09 op cat << __HEREDOC__
783 f36fd90a 2022-07-09 op * Compatibility for memmem(3).
785 f36fd90a 2022-07-09 op void *memmem(const void *, size_t, const void *, size_t);
789 f36fd90a 2022-07-09 op [ ${HAVE_MEMRCHR} -eq 0 ] && \
790 f36fd90a 2022-07-09 op cat << __HEREDOC__
792 f36fd90a 2022-07-09 op * Compatibility for memrchr(3).
794 f36fd90a 2022-07-09 op void *memrchr(const void *b, int, size_t);
798 f36fd90a 2022-07-09 op [ ${HAVE_GETPROGNAME} -eq 0 ] && \
799 f36fd90a 2022-07-09 op cat << __HEREDOC__
801 f36fd90a 2022-07-09 op * Compatibility for getprogname(3).
803 f36fd90a 2022-07-09 op extern const char *getprogname(void);
807 f36fd90a 2022-07-09 op [ ${HAVE_REALLOCARRAY} -eq 0 ] && \
808 f36fd90a 2022-07-09 op cat << __HEREDOC__
810 f36fd90a 2022-07-09 op * Compatibility for reallocarray(3).
812 f36fd90a 2022-07-09 op extern void *reallocarray(void *, size_t, size_t);
816 f36fd90a 2022-07-09 op [ ${HAVE_RECALLOCARRAY} -eq 0 ] && \
817 f36fd90a 2022-07-09 op cat << __HEREDOC__
819 f36fd90a 2022-07-09 op * Compatibility for recallocarray(3).
821 f36fd90a 2022-07-09 op extern void *recallocarray(void *, size_t, size_t, size_t);
825 f36fd90a 2022-07-09 op [ ${HAVE_SETPROCTITLE} -eq 0 ] && \
826 f36fd90a 2022-07-09 op cat << __HEREDOC__
828 f36fd90a 2022-07-09 op * Compatibility for setproctitle(3).
830 f36fd90a 2022-07-09 op extern void setproctitle(const char *, ...);
834 f36fd90a 2022-07-09 op [ ${HAVE_STRLCAT} -eq 0 ] && \
835 f36fd90a 2022-07-09 op cat << __HEREDOC__
837 f36fd90a 2022-07-09 op * Compatibility for strlcat(3).
839 f36fd90a 2022-07-09 op extern size_t strlcat(char *, const char *, size_t);
843 f36fd90a 2022-07-09 op [ ${HAVE_STRLCPY} -eq 0 ] && \
844 f36fd90a 2022-07-09 op cat << __HEREDOC__
846 f36fd90a 2022-07-09 op * Compatibility for strlcpy(3).
848 f36fd90a 2022-07-09 op extern size_t strlcpy(char *, const char *, size_t);
852 f36fd90a 2022-07-09 op [ ${HAVE_STRNDUP} -eq 0 ] && \
853 f36fd90a 2022-07-09 op cat << __HEREDOC__
855 f36fd90a 2022-07-09 op * Compatibility for strndup(3).
857 f36fd90a 2022-07-09 op extern char *strndup(const char *, size_t);
861 f36fd90a 2022-07-09 op [ ${HAVE_STRNLEN} -eq 0 ] && \
862 f36fd90a 2022-07-09 op cat << __HEREDOC__
864 f36fd90a 2022-07-09 op * Compatibility for strnlen(3).
866 f36fd90a 2022-07-09 op extern size_t strnlen(const char *, size_t);
870 f36fd90a 2022-07-09 op [ ${HAVE_STRTONUM} -eq 0 ] && \
871 f36fd90a 2022-07-09 op cat << __HEREDOC__
873 f36fd90a 2022-07-09 op * Compatibility for strotnum(3).
875 f36fd90a 2022-07-09 op extern long long strtonum(const char *, long long, long long, const char **);
879 f36fd90a 2022-07-09 op if [ ${HAVE_SYS_QUEUE} -eq 0 ]; then
880 f36fd90a 2022-07-09 op cat << __HEREDOC__
881 f36fd90a 2022-07-09 op #include "queue.h"
884 f36fd90a 2022-07-09 op echo "#include <sys/queue.h>"
888 f36fd90a 2022-07-09 op echo "#include <sys/uio.h>"
889 f36fd90a 2022-07-09 op echo "#include <stdint.h>"
890 f36fd90a 2022-07-09 op if [ ${HAVE_IMSG} -eq 0 ]; then
891 f36fd90a 2022-07-09 op echo "#include \"imsg.h\""
893 f36fd90a 2022-07-09 op echo "#include <imsg.h>"
897 f36fd90a 2022-07-09 op if [ "${HAVE_LIBEVENT2}" -eq 1 ]; then
898 f36fd90a 2022-07-09 op cat << __HEREDOC__
899 f36fd90a 2022-07-09 op #include <event2/event.h>
900 f36fd90a 2022-07-09 op #include <event2/event_compat.h>
901 f36fd90a 2022-07-09 op #include <event2/event_struct.h>
902 f36fd90a 2022-07-09 op #include <event2/buffer.h>
903 f36fd90a 2022-07-09 op #include <event2/buffer_compat.h>
904 f36fd90a 2022-07-09 op #include <event2/bufferevent.h>
905 f36fd90a 2022-07-09 op #include <event2/bufferevent_struct.h>
906 f36fd90a 2022-07-09 op #include <event2/bufferevent_compat.h>
909 f36fd90a 2022-07-09 op elif [ "${HAVE_LIBEVENT}" -eq 1 ]; then
910 f36fd90a 2022-07-09 op cat << __HEREDOC__
911 f36fd90a 2022-07-09 op #include <event.h>
916 f36fd90a 2022-07-09 op cat << __HEREDOC__
917 f36fd90a 2022-07-09 op #ifndef __dead
918 f36fd90a 2022-07-09 op # define __dead __attribute__((noreturn))
921 f36fd90a 2022-07-09 op #if !HAVE_SIO_FLUSH
922 f36fd90a 2022-07-09 op #define sio_flush(hdl) (sio_stop(hdl))
925 f36fd90a 2022-07-09 op #if !HAVE_GETDTABLECOUNT
926 f36fd90a 2022-07-09 op /* XXX: on linux it should be possible to inspect /proc/self/fd/ */
927 f36fd90a 2022-07-09 op #define getdtablecount() (0)
930 f36fd90a 2022-07-09 op #if !HAVE_OPTRESET
931 f36fd90a 2022-07-09 op /* replace host' getopt with OpenBSD' one */
932 f36fd90a 2022-07-09 op #define opterr BSDopterr
933 f36fd90a 2022-07-09 op #define optind BSDoptind
934 f36fd90a 2022-07-09 op #define optopt BSDoptopt
935 f36fd90a 2022-07-09 op #define optreset BSDoptreset
936 f36fd90a 2022-07-09 op #define optarg BSDoptarg
937 f36fd90a 2022-07-09 op #define getopt BSDgetopt
939 f36fd90a 2022-07-09 op extern int BSDopterr, BSDoptind, BSDoptopt, BSDoptreset;
940 f36fd90a 2022-07-09 op extern char *BSDoptarg;
943 f36fd90a 2022-07-09 op #endif /*!OCONFIGURE_CONFIG_H*/
946 f36fd90a 2022-07-09 op echo "config.h: written" 1>&2
947 f36fd90a 2022-07-09 op echo "config.h: written" 1>&3
949 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
950 f36fd90a 2022-07-09 op # Now we go to generate our Makefile.configure.
951 f36fd90a 2022-07-09 op # This file is simply a bunch of Makefile variables.
952 f36fd90a 2022-07-09 op # They'll work in both GNUmakefile and BSDmakefile.
953 f36fd90a 2022-07-09 op # You MIGHT want to change this.
954 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
956 f36fd90a 2022-07-09 op exec > Makefile.configure
958 f36fd90a 2022-07-09 op [ -z "${BINDIR}" ] && BINDIR="${PREFIX}/bin"
959 f36fd90a 2022-07-09 op [ -z "${SBINDIR}" ] && SBINDIR="${PREFIX}/sbin"
960 f36fd90a 2022-07-09 op [ -z "${INCLUDEDIR}" ] && INCLUDEDIR="${PREFIX}/include"
961 f36fd90a 2022-07-09 op [ -z "${LIBDIR}" ] && LIBDIR="${PREFIX}/lib"
962 f36fd90a 2022-07-09 op [ -z "${MANDIR}" ] && MANDIR="${PREFIX}/man"
963 f36fd90a 2022-07-09 op [ -z "${SHAREDIR}" ] && SHAREDIR="${PREFIX}/share"
965 f36fd90a 2022-07-09 op [ -z "${INSTALL_PROGRAM}" ] && INSTALL_PROGRAM="${INSTALL} -m 0555"
966 f36fd90a 2022-07-09 op [ -z "${INSTALL_LIB}" ] && INSTALL_LIB="${INSTALL} -m 0444"
967 f36fd90a 2022-07-09 op [ -z "${INSTALL_MAN}" ] && INSTALL_MAN="${INSTALL} -m 0444"
968 f36fd90a 2022-07-09 op [ -z "${INSTALL_DATA}" ] && INSTALL_DATA="${INSTALL} -m 0444"
970 f36fd90a 2022-07-09 op cat << __HEREDOC__
971 34674849 2023-03-23 op BACKEND = ${BACKEND}
973 f36fd90a 2022-07-09 op CFLAGS = ${CFLAGS}
974 f36fd90a 2022-07-09 op CPPFLAGS = ${CPPFLAGS}
975 f36fd90a 2022-07-09 op LDADD = ${LDADD} ${LDADD_IMSG} ${LDADD_LIB_FLAC} ${LDADD_LIB_MPG123} \
976 34674849 2023-03-23 op ${LDADD_LIB_OPUSFILE} ${LDADD_LIB_VORBISFILE} \
977 34674849 2023-03-23 op ${LDADD_LIB_SOCKET} ${LDADD_LIBEVENT} ${LDADD_LIBEVENT2} \
978 34674849 2023-03-23 op ${LDADD_LIB_SNDIO} ${LDADD_LIB_ASOUND}
979 f36fd90a 2022-07-09 op LDADD_STATIC = ${LDADD_STATIC}
980 f36fd90a 2022-07-09 op LDFLAGS = ${LDFLAGS}
981 f36fd90a 2022-07-09 op STATIC = ${STATIC}
982 f36fd90a 2022-07-09 op PREFIX = ${PREFIX}
983 f36fd90a 2022-07-09 op BINDIR = ${BINDIR}
984 f36fd90a 2022-07-09 op SHAREDIR = ${SHAREDIR}
985 f36fd90a 2022-07-09 op SBINDIR = ${SBINDIR}
986 f36fd90a 2022-07-09 op INCLUDEDIR = ${INCLUDEDIR}
987 f36fd90a 2022-07-09 op LIBDIR = ${LIBDIR}
988 f36fd90a 2022-07-09 op MANDIR = ${MANDIR}
989 f36fd90a 2022-07-09 op INSTALL = ${INSTALL}
990 f36fd90a 2022-07-09 op INSTALL_PROGRAM = ${INSTALL_PROGRAM}
991 f36fd90a 2022-07-09 op INSTALL_LIB = ${INSTALL_LIB}
992 f36fd90a 2022-07-09 op INSTALL_MAN = ${INSTALL_MAN}
993 f36fd90a 2022-07-09 op INSTALL_DATA = ${INSTALL_DATA}
996 f36fd90a 2022-07-09 op echo "Makefile.configure: written" 1>&2
997 f36fd90a 2022-07-09 op echo "Makefile.configure: written" 1>&3