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>
6 f36fd90a 2022-07-09 op # Permission to use, copy, modify, and distribute this software for any
7 f36fd90a 2022-07-09 op # purpose with or without fee is hereby granted, provided that the above
8 f36fd90a 2022-07-09 op # copyright notice and this permission notice appear in all copies.
10 f36fd90a 2022-07-09 op # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 f36fd90a 2022-07-09 op # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 f36fd90a 2022-07-09 op # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 f36fd90a 2022-07-09 op # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 f36fd90a 2022-07-09 op # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 f36fd90a 2022-07-09 op # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 f36fd90a 2022-07-09 op # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 f36fd90a 2022-07-09 op OCONFIGURE_VERSION="0.3.8"
21 f36fd90a 2022-07-09 op # This script outputs two files: config.h and Makefile.configure.
22 f36fd90a 2022-07-09 op # It tries to read from configure.local, which contains predefined
23 f36fd90a 2022-07-09 op # values we won't autoconfigure.
25 f36fd90a 2022-07-09 op # If you want to use configure with your project, have your GNUmakefile
26 f36fd90a 2022-07-09 op # or BSDmakefile---whichever---try to import/include Makefile.configure
27 f36fd90a 2022-07-09 op # at the beginning of the file.
29 f36fd90a 2022-07-09 op # Like so (note no quotes, no period, etc.):
31 f36fd90a 2022-07-09 op # include Makefile.configure
33 f36fd90a 2022-07-09 op # If it exists, configure was run; otherwise, it wasn't.
35 f36fd90a 2022-07-09 op # You'll probably want to change parts of this file. I've noted the
36 f36fd90a 2022-07-09 op # parts that you'll probably change in the section documentation.
38 f36fd90a 2022-07-09 op # See https://github.com/kristapsdz/oconfigure for more.
42 f36fd90a 2022-07-09 op # try to be helpful
46 f36fd90a 2022-07-09 op \`configure' configures amused to adapt to many kinds of systems.
48 f36fd90a 2022-07-09 op Usage: $0 [-h] [--prefix=path] [VAR=VALUE]...
50 f36fd90a 2022-07-09 op The options are as follows:
52 f36fd90a 2022-07-09 op -h, --help print this help message
54 f36fd90a 2022-07-09 op --prefix=path equivalent to specifying the PREFIX variable, supported
55 f36fd90a 2022-07-09 op for compatibility with other common "configure" scripts.
57 f36fd90a 2022-07-09 op Variables available:
59 f36fd90a 2022-07-09 op LDADD generic linker flags
60 f36fd90a 2022-07-09 op LDADD_IMSG linker flags for libimsg
61 f36fd90a 2022-07-09 op LDADD_LIBEVENT linker flags for libevent
62 f36fd90a 2022-07-09 op LDADD_LIBEVENT2 linker flags for libevent2
63 f36fd90a 2022-07-09 op LDADD_LIBFLAC linker flags for libflac
64 f36fd90a 2022-07-09 op LDADD_LIBMPG123 linker flags for libmpg123
65 f36fd90a 2022-07-09 op LDADD_LIBOPUSFILE linker flags for libopusfile
66 f36fd90a 2022-07-09 op LDADD_LIBVORBISFILE linker flags for libvorbisfile
67 f36fd90a 2022-07-09 op LDADD_SNDIO linker flags for libsndio
68 f36fd90a 2022-07-09 op LDADD_LIBSOCKET linker flags for libsocket
69 f36fd90a 2022-07-09 op LDFLAGS extra linker flags
70 f36fd90a 2022-07-09 op CPPFLAGS C preprocessors flags
71 f36fd90a 2022-07-09 op DESTDIR destination directory
72 f36fd90a 2022-07-09 op PREFIX where to install files
73 f36fd90a 2022-07-09 op MANDIR where to install man pages (PREFIX/man)
74 f36fd90a 2022-07-09 op LIBDIR where to install libraries (PREFIX/lib)
75 f36fd90a 2022-07-09 op BINDIR where to install executables (PREFIX/bin)
76 f36fd90a 2022-07-09 op SHAREDIR where to install misc files (PREFIX/share)
77 f36fd90a 2022-07-09 op SBINDIR where to install system executables (PREFIX/sbin)
78 f36fd90a 2022-07-09 op INCLUDEDIR where to install header files (PREFIX/include)
79 f36fd90a 2022-07-09 op PKG_CONFIG path to the pkg-config program or empty to disable
81 cac555b6 2022-07-13 op Additionally, the following environment variables are used if set:
83 cac555b6 2022-07-13 op CC the C compiler to use (defaults to cc, clang or gcc)
84 cac555b6 2022-07-13 op CFLAGS generic C compiler flags
90 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
91 f36fd90a 2022-07-09 op # Prepare for running: move aside previous configure runs.
92 f36fd90a 2022-07-09 op # Output file descriptor usage:
93 f36fd90a 2022-07-09 op # 1 (stdout): config.h or Makefile.configure
94 f36fd90a 2022-07-09 op # 2 (stderr): original stderr, usually to the console
95 f36fd90a 2022-07-09 op # 3: config.log
96 f36fd90a 2022-07-09 op # You DO NOT want to change this.
97 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
99 f36fd90a 2022-07-09 op [ -w config.log ] && mv config.log config.log.old
100 f36fd90a 2022-07-09 op [ -w config.h ] && mv config.h config.h.old
102 f36fd90a 2022-07-09 op exec 3> config.log
103 f36fd90a 2022-07-09 op echo "config.log: writing..."
105 f36fd90a 2022-07-09 op # GNU submake prints different output if invoked recursively, which
106 f36fd90a 2022-07-09 op # messes up CC and CFLAGS detection. Pass --no-print-directory if
107 f36fd90a 2022-07-09 op # we have a MAKELEVEL (GNU and FreeBSD make) and the argument is
110 f36fd90a 2022-07-09 op MAKE_FLAGS=""
112 f36fd90a 2022-07-09 op if [ -n "${MAKELEVEL}" ]; then
113 f36fd90a 2022-07-09 op if [ "${MAKELEVEL}" -gt 0 ] ; then
114 f36fd90a 2022-07-09 op MAKE_FLAGS="--no-print-directory"
115 f36fd90a 2022-07-09 op echo "all:" | make ${MAKE_FLAGS} -sf - 2>/dev/null || MAKE_FLAGS=""
119 f36fd90a 2022-07-09 op if [ -n "$MAKE_FLAGS" ]; then
120 f36fd90a 2022-07-09 op echo "GNU submake detected: using --no-print-directory" 1>&2
121 f36fd90a 2022-07-09 op echo "GNU submake detected: using --no-print-directory" 1>&3
124 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
125 f36fd90a 2022-07-09 op # Initialize all variables here such that nothing can leak in from the
126 f36fd90a 2022-07-09 op # environment except for CC and CFLAGS, which we might have passed in.
127 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
129 f36fd90a 2022-07-09 op CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | make ${MAKE_FLAGS} -sf -`
130 f36fd90a 2022-07-09 op CFLAGS=`printf "all:\\n\\t@echo \\\$(CFLAGS)\\n" | make ${MAKE_FLAGS} -sf -`
131 f36fd90a 2022-07-09 op CFLAGS="${CFLAGS} -g -W -Wall -Wmissing-prototypes -Wstrict-prototypes"
132 f36fd90a 2022-07-09 op CFLAGS="${CFLAGS} -Wmissing-declarations -Wno-unused-parameter"
133 f36fd90a 2022-07-09 op CFLAGS="${CFLAGS} -Wno-sign-compare"
136 f36fd90a 2022-07-09 op LDADD_LIBEVENT=
137 f36fd90a 2022-07-09 op LDADD_LIBEVENT2=
138 f36fd90a 2022-07-09 op LDADD_LIB_FLAC=
139 f36fd90a 2022-07-09 op LDADD_LIB_MPG123=
140 f36fd90a 2022-07-09 op LDADD_LIB_VORBISFILE=
141 f36fd90a 2022-07-09 op LDADD_LIB_SNDIO=
142 f36fd90a 2022-07-09 op LDADD_LIB_SOCKET=
143 f36fd90a 2022-07-09 op LDADD_STATIC=
147 f36fd90a 2022-07-09 op PREFIX="/usr/local"
154 f36fd90a 2022-07-09 op INSTALL="install"
155 f36fd90a 2022-07-09 op INSTALL_PROGRAM=
158 f36fd90a 2022-07-09 op INSTALL_DATA=
161 f36fd90a 2022-07-09 op # SunOS sets "cc", but this doesn't exist.
162 f36fd90a 2022-07-09 op # It does have gcc, so try that instead.
163 f36fd90a 2022-07-09 op # Prefer clang, though.
165 f36fd90a 2022-07-09 op command -v ${CC} 2>/dev/null 1>&2 || {
166 f36fd90a 2022-07-09 op echo "${CC} not found: trying clang" 1>&2
167 f36fd90a 2022-07-09 op echo "${CC} not found: trying clang" 1>&3
169 f36fd90a 2022-07-09 op command -v ${CC} 2>/dev/null 1>&2 || {
170 f36fd90a 2022-07-09 op echo "${CC} not found: trying gcc" 1>&2
171 f36fd90a 2022-07-09 op echo "${CC} not found: trying gcc" 1>&3
173 f36fd90a 2022-07-09 op command -v ${CC} 2>/dev/null 1>&2 || {
174 f36fd90a 2022-07-09 op echo "gcc not found: giving up" 1>&2
175 f36fd90a 2022-07-09 op echo "gcc not found: giving up" 1>&3
181 f36fd90a 2022-07-09 op command -v pkg-config 2>/dev/null 1>&2 && {
182 f36fd90a 2022-07-09 op PKG_CONFIG=pkg-config
183 f36fd90a 2022-07-09 op echo "pkg-config found" 1>&2
184 f36fd90a 2022-07-09 op echo "pkg-config found" 1>&3
186 f36fd90a 2022-07-09 op echo "pkg-config not found" 1>&2
187 f36fd90a 2022-07-09 op echo "pkg-config not found" 1>&3
190 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
191 f36fd90a 2022-07-09 op # Allow certain variables to be overriden on the command line.
192 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
194 f36fd90a 2022-07-09 op while [ $# -gt 0 ]; do
198 f36fd90a 2022-07-09 op if [ "$key" = "--prefix" ]; then
200 f36fd90a 2022-07-09 op if [ "$1" = "--prefix" ]; then
201 f36fd90a 2022-07-09 op if ! shift 2>&1 >/dev/null; then
202 f36fd90a 2022-07-09 op echo "$0: missing value for --prefix" 1>&2
209 f36fd90a 2022-07-09 op if [ "$1" = "$key" ]; then
210 f36fd90a 2022-07-09 op echo "$0: invalid key-value: $1" 1>&2
216 f36fd90a 2022-07-09 op case "$key" in
218 f36fd90a 2022-07-09 op LDADD="$val" ;;
220 f36fd90a 2022-07-09 op LDADD_IMSG="$val" ;;
221 f36fd90a 2022-07-09 op LDADD_LIBEVENT)
222 f36fd90a 2022-07-09 op LDADD_LIBEVENT="$val" ;;
223 f36fd90a 2022-07-09 op LDADD_LIBEVENT2)
224 f36fd90a 2022-07-09 op LDADD_LIBEVENT2="$val" ;;
225 f36fd90a 2022-07-09 op LDADD_LIBFLAC)
226 f36fd90a 2022-07-09 op LDADD_LIBFLAC="$val" ;;
227 f36fd90a 2022-07-09 op LDADD_LIBMPG123)
228 f36fd90a 2022-07-09 op LDADD_LIBMPG123="$val" ;;
229 f36fd90a 2022-07-09 op LDADD_LIBOPUSFILE)
230 f36fd90a 2022-07-09 op LDADD_LIBOPUSFILE="$val" ;;
231 f36fd90a 2022-07-09 op LDADD_LIBVORBISFILE)
232 f36fd90a 2022-07-09 op LDADD_LIBVORBISFILE="$val" ;;
234 f36fd90a 2022-07-09 op LDADD_SNDIO="$val" ;;
235 f36fd90a 2022-07-09 op LDADD_LIBSOCKET)
236 f36fd90a 2022-07-09 op LDADD_LIBSOCKET="$val" ;;
238 f36fd90a 2022-07-09 op LDFLAGS="$val" ;;
240 f36fd90a 2022-07-09 op CPPFLAGS="$val" ;;
242 f36fd90a 2022-07-09 op DESTDIR="$val" ;;
244 f36fd90a 2022-07-09 op PREFIX="$val" ;;
246 f36fd90a 2022-07-09 op MANDIR="$val" ;;
248 f36fd90a 2022-07-09 op LIBDIR="$val" ;;
250 f36fd90a 2022-07-09 op BINDIR="$val" ;;
252 f36fd90a 2022-07-09 op SHAREDIR="$val" ;;
254 f36fd90a 2022-07-09 op SBINDIR="$val" ;;
256 f36fd90a 2022-07-09 op INCLUDEDIR="$val" ;;
258 f36fd90a 2022-07-09 op PKG_CONFIG="$val" ;;
260 f36fd90a 2022-07-09 op echo "$0: invalid key: $key" 1>&2
266 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
267 f36fd90a 2022-07-09 op # These are the values that will be pushed into config.h after we test
268 f36fd90a 2022-07-09 op # for whether they're supported or not.
269 f36fd90a 2022-07-09 op # Each of these must have a runtest(), below.
270 f36fd90a 2022-07-09 op # Please sort by alpha, for clarity.
271 f36fd90a 2022-07-09 op # You WANT to change this.
272 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
274 f36fd90a 2022-07-09 op HAVE_CAPSICUM=
276 f36fd90a 2022-07-09 op HAVE_EXPLICIT_BZERO=
278 f36fd90a 2022-07-09 op HAVE_FREEZERO=
279 f36fd90a 2022-07-09 op HAVE_GETDTABLECOUNT=
280 f36fd90a 2022-07-09 op HAVE_GETEXECNAME=
281 f36fd90a 2022-07-09 op HAVE_GETPROGNAME=
284 f36fd90a 2022-07-09 op HAVE_LANDLOCK=
285 f36fd90a 2022-07-09 op HAVE_LIBEVENT=
286 f36fd90a 2022-07-09 op HAVE_LIBEVENT2=0 # may not be checked, set to zero
287 f36fd90a 2022-07-09 op HAVE_LIB_FLAC=
288 f36fd90a 2022-07-09 op HAVE_LIB_MPG123=
289 f36fd90a 2022-07-09 op HAVE_LIB_OPUSFILE=
290 f36fd90a 2022-07-09 op HAVE_LIB_VORBISFILE=
291 f36fd90a 2022-07-09 op HAVE_LIB_SNDIO=
292 f36fd90a 2022-07-09 op HAVE_LIB_SOCKET=
294 f36fd90a 2022-07-09 op HAVE_MEMRCHR=
295 f36fd90a 2022-07-09 op HAVE_MEMSET_S=
296 f36fd90a 2022-07-09 op HAVE_OPTRESET=
297 f36fd90a 2022-07-09 op HAVE_PATH_MAX=
299 f36fd90a 2022-07-09 op HAVE_PROGRAM_INVOCATION_SHORT_NAME=
300 f36fd90a 2022-07-09 op HAVE_PR_SET_NAME=
301 f36fd90a 2022-07-09 op HAVE_REALLOCARRAY=
302 f36fd90a 2022-07-09 op HAVE_RECALLOCARRAY=
303 f36fd90a 2022-07-09 op HAVE_SANDBOX_INIT=
304 f36fd90a 2022-07-09 op HAVE_SETPROCTITLE=
305 f36fd90a 2022-07-09 op HAVE_SIO_FLUSH=
306 f36fd90a 2022-07-09 op HAVE_SOCK_NONBLOCK=
307 f36fd90a 2022-07-09 op HAVE_STRLCAT=
308 f36fd90a 2022-07-09 op HAVE_STRLCPY=
309 f36fd90a 2022-07-09 op HAVE_STRNDUP=
310 f36fd90a 2022-07-09 op HAVE_STRNLEN=
311 f36fd90a 2022-07-09 op HAVE_STRTONUM=
312 f36fd90a 2022-07-09 op HAVE_SYS_FILE=
313 f36fd90a 2022-07-09 op HAVE_SYS_QUEUE=
314 f36fd90a 2022-07-09 op HAVE_SYSTRACE=0
316 f36fd90a 2022-07-09 op HAVE___PROGNAME=
318 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
319 f36fd90a 2022-07-09 op # Allow configure.local to override all variables, default settings,
320 f36fd90a 2022-07-09 op # command-line arguments, and tested features, above.
321 f36fd90a 2022-07-09 op # You PROBABLY DO NOT want to change this.
322 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
324 f36fd90a 2022-07-09 op if [ -r ./configure.local ]; then
325 f36fd90a 2022-07-09 op echo "configure.local: reading..." 1>&2
326 f36fd90a 2022-07-09 op echo "configure.local: reading..." 1>&3
327 f36fd90a 2022-07-09 op cat ./configure.local 1>&3
328 f36fd90a 2022-07-09 op . ./configure.local
330 f36fd90a 2022-07-09 op echo "configure.local: no (fully automatic configuration)" 1>&2
331 f36fd90a 2022-07-09 op echo "configure.local: no (fully automatic configuration)" 1>&3
336 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
337 f36fd90a 2022-07-09 op # Infrastructure for running tests.
338 f36fd90a 2022-07-09 op # These consists of a series of functions that will attempt to run the
339 f36fd90a 2022-07-09 op # given test file and record its exit into a HAVE_xxx variable.
340 f36fd90a 2022-07-09 op # You DO NOT want to change this.
341 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
343 f36fd90a 2022-07-09 op COMP="${CC} ${CFLAGS} ${CPPFLAGS} -Wno-unused -Werror"
345 f36fd90a 2022-07-09 op # Check whether this HAVE_ setting is manually overridden.
346 f36fd90a 2022-07-09 op # If yes, use the override, if no, do not decide anything yet.
347 f36fd90a 2022-07-09 op # Arguments: lower-case test name, manual value
350 f36fd90a 2022-07-09 op [ -z "${3}" ] && return 1
351 f36fd90a 2022-07-09 op echo "${1}: manual (HAVE_${2}=${3})" 1>&2
352 f36fd90a 2022-07-09 op echo "${1}: manual (HAVE_${2}=${3})" 1>&3
357 f36fd90a 2022-07-09 op # Run a single autoconfiguration test.
358 f36fd90a 2022-07-09 op # In case of success, enable the feature.
359 f36fd90a 2022-07-09 op # In case of failure, do not decide anything yet.
360 f36fd90a 2022-07-09 op # Arguments: lower-case test name, upper-case test name, additional
361 f36fd90a 2022-07-09 op # CFLAGS, additional LIBS.
363 f36fd90a 2022-07-09 op singletest() {
368 f36fd90a 2022-07-09 op cat 1>&3 << __HEREDOC__
369 f36fd90a 2022-07-09 op ${1}: testing...
370 f36fd90a 2022-07-09 op ${COMP} -DTEST_${2} ${3} -o test-${1} tests.c ${LDFLAGS} ${4}
372 f36fd90a 2022-07-09 op if ${COMP} -DTEST_${2} ${3} -o "test-${1}" tests.c ${LDFLAGS} ${4} 1>&3 2>&3; then
373 f36fd90a 2022-07-09 op echo "${1}: ${CC} succeeded" 1>&3
375 f36fd90a 2022-07-09 op if [ -n "${5}" ] ; then
376 f36fd90a 2022-07-09 op echo "${1}: ${CC} failed with $? (retrying)" 1>&3
377 f36fd90a 2022-07-09 op cat 1>&3 << __HEREDOC__
378 f36fd90a 2022-07-09 op ${1}: testing...
379 f36fd90a 2022-07-09 op ${COMP} -DTEST_${2} ${3} -o test-${1} tests.c ${LDFLAGS} ${5}
381 f36fd90a 2022-07-09 op if ${COMP} -DTEST_${2} ${3} -o "test-${1}" tests.c ${LDFLAGS} ${5} 1>&3 2>&3; then
382 f36fd90a 2022-07-09 op echo "${1}: ${CC} succeeded" 1>&3
383 f36fd90a 2022-07-09 op extralib="(with ${5})"
385 f36fd90a 2022-07-09 op test -n "${PKG_CONFIG}" -a -n "${6}" && ${PKG_CONFIG} "$6"
386 f36fd90a 2022-07-09 op if [ $? -eq 0 ]; then
387 f36fd90a 2022-07-09 op echo "${1}: ${CC} failed with $? (retrying)" 1>&3
388 f36fd90a 2022-07-09 op pkgcfs=$($PKG_CONFIG --cflags "${6}")
389 f36fd90a 2022-07-09 op pkglib=$($PKG_CONFIG --libs "${6}")
390 f36fd90a 2022-07-09 op cat 1>&3 << __HEREDOC__
391 f36fd90a 2022-07-09 op ${1}: testing...
392 f36fd90a 2022-07-09 op ${COMP} -DTEST_${2} ${3} ${pkgcfs} -o test-${1} tests.c ${LDFLAGS} ${pkglib}
394 f36fd90a 2022-07-09 op if ${COMP} -DTEST_${2} ${3} ${pkgcfs} -o test-${1} tests.c ${LDFLAGS} ${pkglib} 1>&3 2>&3; then
395 f36fd90a 2022-07-09 op echo "${1}: ${CC} succeeded" 1>&3
396 f36fd90a 2022-07-09 op extralib="(with ${pkgcfs} ${pkglib})"
398 f36fd90a 2022-07-09 op echo "${1}: ${CC} failed with $?" 1>&3
403 f36fd90a 2022-07-09 op echo "${1}: ${CC} failed with $?" 1>&3
409 f36fd90a 2022-07-09 op echo "${1}: ${CC} failed with $?" 1>&3
415 1c53767e 2022-07-13 op rm -f test-${1}.d
417 f36fd90a 2022-07-09 op if [ -n "${pkgcfs}" -o -n "${pkglib}" ]
419 f36fd90a 2022-07-09 op CFLAGS="${CFLAGS} ${pkgcfs}"
420 f36fd90a 2022-07-09 op eval "LDADD_${2}=\"${pkglib}\""
421 f36fd90a 2022-07-09 op elif [ -n "${extralib}" ]
423 f36fd90a 2022-07-09 op eval "LDADD_${2}=\"${5}\""
424 f36fd90a 2022-07-09 op elif [ -n "${4}" ]
426 f36fd90a 2022-07-09 op eval "LDADD_${2}=\"${4}\""
429 f36fd90a 2022-07-09 op echo "${1}: yes ${extralib}" 1>&2
430 f36fd90a 2022-07-09 op echo "${1}: yes ${extralib}" 1>&3
432 f36fd90a 2022-07-09 op eval HAVE_${2}=1
433 f36fd90a 2022-07-09 op rm "test-${1}"
437 f36fd90a 2022-07-09 op # Run a complete autoconfiguration test, including the check for
438 f36fd90a 2022-07-09 op # a manual override and disabling the feature on failure.
439 f36fd90a 2022-07-09 op # Arguments: lower case name, upper case name, additional CFLAGS,
440 f36fd90a 2022-07-09 op # additional LDADD, alternative LDADD, pkg-config name.
443 f36fd90a 2022-07-09 op eval _manual=\${HAVE_${2}}
444 f36fd90a 2022-07-09 op ismanual "${1}" "${2}" "${_manual}" && return 0
445 f36fd90a 2022-07-09 op singletest "${1}" "${2}" "${3}" "${4}" "${5}" "${6}" && return 0
446 f36fd90a 2022-07-09 op echo "${1}: no" 1>&2
447 f36fd90a 2022-07-09 op eval HAVE_${2}=0
451 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
452 f36fd90a 2022-07-09 op # Begin running the tests themselves.
453 f36fd90a 2022-07-09 op # All of your tests must be defined here.
454 f36fd90a 2022-07-09 op # Please sort as the HAVE_xxxx values were defined.
455 f36fd90a 2022-07-09 op # You WANT to change this.
456 f36fd90a 2022-07-09 op # It consists of the following columns:
458 f36fd90a 2022-07-09 op # (1) test file
459 f36fd90a 2022-07-09 op # (2) macro to set
460 f36fd90a 2022-07-09 op # (3) argument to cc *before* -o
461 f36fd90a 2022-07-09 op # (4) argument to cc *after*
462 f36fd90a 2022-07-09 op # (5) alternative argument to cc *after*
463 f36fd90a 2022-07-09 op # (6) name for pkg-config auto-discovery
464 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
466 f36fd90a 2022-07-09 op if runtest -MMD _MMD -MMD; then
467 f36fd90a 2022-07-09 op CFLAGS="${CFLAGS} -MMD"
468 f36fd90a 2022-07-09 op echo "adding -MMD to CFLAGS" 1>&2
469 f36fd90a 2022-07-09 op echo "adding -MMD to CFLAGS" 1>&3
472 f36fd90a 2022-07-09 op runtest capsicum CAPSICUM || true
473 f36fd90a 2022-07-09 op runtest err ERR || true
474 f36fd90a 2022-07-09 op runtest explicit_bzero EXPLICIT_BZERO || true
475 f36fd90a 2022-07-09 op runtest flock FLOCK || true
476 f36fd90a 2022-07-09 op runtest freezero FREEZERO || true
477 f36fd90a 2022-07-09 op runtest getdtablecount GETDTABLECOUNT || true
478 f36fd90a 2022-07-09 op runtest getexecname GETEXECNAME || true
479 f36fd90a 2022-07-09 op runtest getprogname GETPROGNAME || true
480 f36fd90a 2022-07-09 op runtest imsg IMSG "" "" "-lutil" || true
481 f36fd90a 2022-07-09 op runtest INFTIM INFTIM || true
482 f36fd90a 2022-07-09 op runtest landlock LANDLOCK || true
484 f36fd90a 2022-07-09 op runtest libevent LIBEVENT "" "" "-levent" || \
485 f36fd90a 2022-07-09 op runtest libevent2 LIBEVENT2 "" "" "-levent_extra -levent_core" "libevent" || true
487 f36fd90a 2022-07-09 op runtest lib_flac LIB_FLAC "" "" "-lFLAC" "flac" || true
488 f36fd90a 2022-07-09 op runtest lib_mpg123 LIB_MPG123 "" "" "-lmpg123" "libmpg123" || true
489 f36fd90a 2022-07-09 op runtest lib_opusfile LIB_OPUSFILE "" "" "-lopusfile" "opusfile" || true
490 f36fd90a 2022-07-09 op runtest lib_vorbisfile LIB_VORBISFILE "" "" "-lvorbisfile" "vorbisfile" || true
492 f36fd90a 2022-07-09 op runtest lib_sndio LIB_SNDIO "" "" "-lsndio" "sndio" || true
493 f36fd90a 2022-07-09 op runtest lib_socket LIB_SOCKET "" "" "-lsocket -lnsl" || true
494 f36fd90a 2022-07-09 op runtest memmem MEMMEM || true
495 f36fd90a 2022-07-09 op runtest memrchr MEMRCHR || true
496 f36fd90a 2022-07-09 op runtest memset_s MEMSET_S || true
497 f36fd90a 2022-07-09 op runtest optreset OPTRESET || true
498 f36fd90a 2022-07-09 op runtest PATH_MAX PATH_MAX || true
499 f36fd90a 2022-07-09 op runtest pledge PLEDGE || true
500 f36fd90a 2022-07-09 op runtest program_invocation_short_name PROGRAM_INVOCATION_SHORT_NAME || true
501 f36fd90a 2022-07-09 op runtest PR_SET_NAME PR_SET_NAME || true
502 f36fd90a 2022-07-09 op runtest reallocarray REALLOCARRAY || true
503 f36fd90a 2022-07-09 op runtest recallocarray RECALLOCARRAY || true
504 f36fd90a 2022-07-09 op runtest sandbox_init SANDBOX_INIT "-Wno-deprecated" || true
505 f36fd90a 2022-07-09 op runtest setproctitle SETPROCTITLE || true
506 f36fd90a 2022-07-09 op runtest sio_flush SIO_FLUSH "" "" "${LDADD_LIB_SNDIO}" || true
507 f36fd90a 2022-07-09 op runtest SOCK_NONBLOCK SOCK_NONBLOCK || true
508 f36fd90a 2022-07-09 op runtest static STATIC "" "-static" || true
509 f36fd90a 2022-07-09 op runtest strlcat STRLCAT || true
510 f36fd90a 2022-07-09 op runtest strlcpy STRLCPY || true
511 f36fd90a 2022-07-09 op runtest strndup STRNDUP || true
512 f36fd90a 2022-07-09 op runtest strnlen STRNLEN || true
513 f36fd90a 2022-07-09 op runtest strtonum STRTONUM || true
514 f36fd90a 2022-07-09 op runtest sys_queue SYS_QUEUE || true
515 f36fd90a 2022-07-09 op runtest sys_file SYS_FILE || true
516 f36fd90a 2022-07-09 op runtest unveil UNVEIL || true
517 f36fd90a 2022-07-09 op runtest __progname __PROGNAME || true
519 f36fd90a 2022-07-09 op if [ "${HAVE_LIBEVENT}" -eq 0 -a "${HAVE_LIBEVENT2}" -eq 0 ]; then
520 f36fd90a 2022-07-09 op echo "Fatal: missing libevent" 1>&2
521 f36fd90a 2022-07-09 op echo "Fatal: missing libevent" 1>&3
525 f36fd90a 2022-07-09 op if [ "${HAVE_LIB_FLAC}" -eq 0 -o \
526 f36fd90a 2022-07-09 op "${HAVE_LIB_MPG123}" -eq 0 -o \
527 f36fd90a 2022-07-09 op "${HAVE_LIB_OPUSFILE}" -eq 0 -o \
528 f36fd90a 2022-07-09 op "${HAVE_LIB_VORBISFILE}" -eq 0 ]; then
529 f36fd90a 2022-07-09 op echo "Fatal: missing required audio libraries" 1>&2
530 f36fd90a 2022-07-09 op echo "Fatal: missing required audio libraries" 1>&3
534 f36fd90a 2022-07-09 op if [ "${HAVE_LIB_SNDIO}" -eq 0 ]; then
535 f36fd90a 2022-07-09 op echo "Fatal: missing libsndio" 1>&2
536 f36fd90a 2022-07-09 op echo "Fatal: missing libsndio" 1>&3
540 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
541 f36fd90a 2022-07-09 op # Output writing: generate the config.h file.
542 f36fd90a 2022-07-09 op # This file contains all of the HAVE_xxxx variables necessary for
543 f36fd90a 2022-07-09 op # compiling your source.
544 f36fd90a 2022-07-09 op # You must include "config.h" BEFORE any other variables.
545 f36fd90a 2022-07-09 op # You WANT to change this.
546 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
548 f36fd90a 2022-07-09 op exec > config.h
550 f36fd90a 2022-07-09 op # Start with prologue.
552 f36fd90a 2022-07-09 op cat << __HEREDOC__
553 f36fd90a 2022-07-09 op #ifndef OCONFIGURE_CONFIG_H
554 f36fd90a 2022-07-09 op #define OCONFIGURE_CONFIG_H
556 f36fd90a 2022-07-09 op #ifdef __cplusplus
557 f36fd90a 2022-07-09 op # error "Do not use C++: this is a C application."
559 f36fd90a 2022-07-09 op #if !defined(__GNUC__) || (__GNUC__ < 4)
560 f36fd90a 2022-07-09 op # define __attribute__(x)
562 f36fd90a 2022-07-09 op #if defined(__linux__) || defined(__MINT__)
563 f36fd90a 2022-07-09 op # define _GNU_SOURCE /* memmem, memrchr, setresuid... */
564 f36fd90a 2022-07-09 op # define _DEFAULT_SOURCE /* le32toh, crypt, ... */
566 f36fd90a 2022-07-09 op #if defined(__NetBSD__)
567 f36fd90a 2022-07-09 op # define _OPENBSD_SOURCE /* reallocarray, etc. */
569 f36fd90a 2022-07-09 op #if defined(__sun)
570 f36fd90a 2022-07-09 op # ifndef _XOPEN_SOURCE /* SunOS already defines */
571 f36fd90a 2022-07-09 op # define _XOPEN_SOURCE /* XPGx */
573 f36fd90a 2022-07-09 op # define _XOPEN_SOURCE_EXTENDED 1 /* XPG4v2 */
574 f36fd90a 2022-07-09 op # ifndef __EXTENSIONS__ /* SunOS already defines */
575 f36fd90a 2022-07-09 op # define __EXTENSIONS__ /* reallocarray, etc. */
578 f36fd90a 2022-07-09 op #if !defined(__BEGIN_DECLS)
579 f36fd90a 2022-07-09 op # define __BEGIN_DECLS
581 f36fd90a 2022-07-09 op #if !defined(__END_DECLS)
582 f36fd90a 2022-07-09 op # define __END_DECLS
587 f36fd90a 2022-07-09 op # This is just for size_t, mode_t, and dev_t.
588 f36fd90a 2022-07-09 op # Most of these functions, in the real world, pull in <string.h> or
589 f36fd90a 2022-07-09 op # someting that pulls in support for size_t.
590 f36fd90a 2022-07-09 op # Our function declarations are standalone, so specify them here.
592 f36fd90a 2022-07-09 op if [ ${HAVE_IMSG} -eq 0 -o \
593 f36fd90a 2022-07-09 op ${HAVE_MEMMEM} -eq 0 -o \
594 f36fd90a 2022-07-09 op ${HAVE_MEMRCHR} -eq 0 -o \
595 f36fd90a 2022-07-09 op ${HAVE_REALLOCARRAY} -eq 0 -o \
596 f36fd90a 2022-07-09 op ${HAVE_RECALLOCARRAY} -eq 0 -o \
597 f36fd90a 2022-07-09 op ${HAVE_STRLCAT} -eq 0 -o \
598 f36fd90a 2022-07-09 op ${HAVE_STRLCPY} -eq 0 -o \
599 f36fd90a 2022-07-09 op ${HAVE_STRNDUP} -eq 0 -o \
600 f36fd90a 2022-07-09 op ${HAVE_STRNLEN} -eq 0 ]
602 f36fd90a 2022-07-09 op echo "#include <sys/types.h> /* size_t, mode_t, dev_t */ "
606 f36fd90a 2022-07-09 op if [ ${HAVE_FLOCK} -eq 0 ]; then
607 f36fd90a 2022-07-09 op if [ ${HAVE_SYS_FILE} -eq 0 ]; then
609 f36fd90a 2022-07-09 op echo "#include <sys/file.h>"
612 f36fd90a 2022-07-09 op echo "int flock(int, int);"
613 f36fd90a 2022-07-09 op echo "#define LOCK_SH 0x1"
614 f36fd90a 2022-07-09 op echo "#define LOCK_EX 0x2"
615 f36fd90a 2022-07-09 op echo "#define LOCK_NB 0x4"
620 f36fd90a 2022-07-09 op if [ ${HAVE_ERR} -eq 0 ]; then
621 f36fd90a 2022-07-09 op echo "#include <stdarg.h> /* err(3) */"
624 f36fd90a 2022-07-09 op echo "#include <err.h>"
628 f36fd90a 2022-07-09 op if [ ${HAVE_PLEDGE} -eq 0 ]; then
629 f36fd90a 2022-07-09 op echo "#define pledge(p, e) (0)"
632 f36fd90a 2022-07-09 op echo "#include <unistd.h>"
636 f36fd90a 2022-07-09 op # Now we handle our HAVE_xxxx values.
637 f36fd90a 2022-07-09 op # Most will just be defined as 0 or 1.
639 f36fd90a 2022-07-09 op if [ ${HAVE_PATH_MAX} -eq 0 ]
641 f36fd90a 2022-07-09 op echo "#define PATH_MAX 4096"
645 f36fd90a 2022-07-09 op if [ ${HAVE_INFTIM} -eq 0 ]
647 f36fd90a 2022-07-09 op echo "#define INFTIM (-1) /* poll.h */"
651 f36fd90a 2022-07-09 op cat << __HEREDOC__
653 f36fd90a 2022-07-09 op * Results of configuration feature-testing.
655 f36fd90a 2022-07-09 op #define HAVE_CAPSICUM ${HAVE_CAPSICUM}
656 f36fd90a 2022-07-09 op #define HAVE_ERR ${HAVE_ERR}
657 f36fd90a 2022-07-09 op #define HAVE_EXPLICIT_BZERO ${HAVE_EXPLICIT_BZERO}
658 f36fd90a 2022-07-09 op #define HAVE_FLOCK ${HAVE_FLOCK}
659 f36fd90a 2022-07-09 op #define HAVE_FREEZERO ${HAVE_FREEZERO}
660 f36fd90a 2022-07-09 op #define HAVE_GETDTABLECOUNT ${HAVE_GETDTABLECOUNT}
661 f36fd90a 2022-07-09 op #define HAVE_GETEXECNAME ${HAVE_GETEXECNAME}
662 f36fd90a 2022-07-09 op #define HAVE_GETPROGNAME ${HAVE_GETPROGNAME}
663 f36fd90a 2022-07-09 op #define HAVE_INFTIM ${HAVE_INFTIM}
664 f36fd90a 2022-07-09 op #define HAVE_LANDLOCK ${HAVE_LANDLOCK}
665 f36fd90a 2022-07-09 op #define HAVE_MEMMEM ${HAVE_MEMMEM}
666 f36fd90a 2022-07-09 op #define HAVE_MEMRCHR ${HAVE_MEMRCHR}
667 f36fd90a 2022-07-09 op #define HAVE_MEMSET_S ${HAVE_MEMSET_S}
668 f36fd90a 2022-07-09 op #define HAVE_OPTRESET ${HAVE_OPTRESET}
669 f36fd90a 2022-07-09 op #define HAVE_PATH_MAX ${HAVE_PATH_MAX}
670 f36fd90a 2022-07-09 op #define HAVE_PLEDGE ${HAVE_PLEDGE}
671 f36fd90a 2022-07-09 op #define HAVE_PROGRAM_INVOCATION_SHORT_NAME ${HAVE_PROGRAM_INVOCATION_SHORT_NAME}
672 f36fd90a 2022-07-09 op #define HAVE_PR_SET_NAME ${HAVE_PR_SET_NAME}
673 f36fd90a 2022-07-09 op #define HAVE_REALLOCARRAY ${HAVE_REALLOCARRAY}
674 f36fd90a 2022-07-09 op #define HAVE_RECALLOCARRAY ${HAVE_RECALLOCARRAY}
675 f36fd90a 2022-07-09 op #define HAVE_SANDBOX_INIT ${HAVE_SANDBOX_INIT}
676 f36fd90a 2022-07-09 op #define HAVE_SETPROCTITLE ${HAVE_SETPROCTITLE}
677 f36fd90a 2022-07-09 op #define HAVE_SIO_FLUSH ${HAVE_SIO_FLUSH}
678 f36fd90a 2022-07-09 op #define HAVE_SOCK_NONBLOCK ${HAVE_SOCK_NONBLOCK}
679 f36fd90a 2022-07-09 op #define HAVE_STRLCAT ${HAVE_STRLCAT}
680 f36fd90a 2022-07-09 op #define HAVE_STRLCPY ${HAVE_STRLCPY}
681 f36fd90a 2022-07-09 op #define HAVE_STRNDUP ${HAVE_STRNDUP}
682 f36fd90a 2022-07-09 op #define HAVE_STRNLEN ${HAVE_STRNLEN}
683 f36fd90a 2022-07-09 op #define HAVE_STRTONUM ${HAVE_STRTONUM}
684 f36fd90a 2022-07-09 op #define HAVE_SYS_FILE ${HAVE_SYS_FILE}
685 f36fd90a 2022-07-09 op #define HAVE_SYS_QUEUE ${HAVE_SYS_QUEUE}
686 f36fd90a 2022-07-09 op #define HAVE_SYSTRACE ${HAVE_SYSTRACE}
687 f36fd90a 2022-07-09 op #define HAVE_UNVEIL ${HAVE_UNVEIL}
688 f36fd90a 2022-07-09 op #define HAVE___PROGNAME ${HAVE___PROGNAME}
692 f36fd90a 2022-07-09 op # Now we do our function declarations for missing functions.
694 f36fd90a 2022-07-09 op [ ${HAVE_ERR} -eq 0 ] && \
695 f36fd90a 2022-07-09 op cat << __HEREDOC__
697 f36fd90a 2022-07-09 op * Compatibility functions for err(3).
699 f36fd90a 2022-07-09 op extern void err(int, const char *, ...) __attribute__((noreturn));
700 f36fd90a 2022-07-09 op extern void errc(int, int, const char *, ...) __attribute__((noreturn));
701 f36fd90a 2022-07-09 op extern void errx(int, const char *, ...) __attribute__((noreturn));
702 f36fd90a 2022-07-09 op extern void verr(int, const char *, va_list) __attribute__((noreturn));
703 f36fd90a 2022-07-09 op extern void verrc(int, int, const char *, va_list) __attribute__((noreturn));
704 f36fd90a 2022-07-09 op extern void verrx(int, const char *, va_list) __attribute__((noreturn));
705 f36fd90a 2022-07-09 op extern void warn(const char *, ...);
706 f36fd90a 2022-07-09 op extern void warnx(const char *, ...);
707 f36fd90a 2022-07-09 op extern void warnc(int, const char *, ...);
708 f36fd90a 2022-07-09 op extern void vwarn(const char *, va_list);
709 f36fd90a 2022-07-09 op extern void vwarnc(int, const char *, va_list);
710 f36fd90a 2022-07-09 op extern void vwarnx(const char *, va_list);
713 f36fd90a 2022-07-09 op [ ${HAVE_EXPLICIT_BZERO} -eq 0 ] && \
714 f36fd90a 2022-07-09 op cat << __HEREDOC__
716 f36fd90a 2022-07-09 op * Compatibility for explicit_bzero(3).
718 f36fd90a 2022-07-09 op extern void explicit_bzero(void *, size_t);
722 f36fd90a 2022-07-09 op [ ${HAVE_FREEZERO} -eq 0 ] && \
723 f36fd90a 2022-07-09 op cat << __HEREDOC__
725 f36fd90a 2022-07-09 op * Compatibility for freezero(3).
727 f36fd90a 2022-07-09 op extern void freezero(void *, size_t);
731 f36fd90a 2022-07-09 op [ ${HAVE_MEMMEM} -eq 0 ] && \
732 f36fd90a 2022-07-09 op cat << __HEREDOC__
734 f36fd90a 2022-07-09 op * Compatibility for memmem(3).
736 f36fd90a 2022-07-09 op void *memmem(const void *, size_t, const void *, size_t);
740 f36fd90a 2022-07-09 op [ ${HAVE_MEMRCHR} -eq 0 ] && \
741 f36fd90a 2022-07-09 op cat << __HEREDOC__
743 f36fd90a 2022-07-09 op * Compatibility for memrchr(3).
745 f36fd90a 2022-07-09 op void *memrchr(const void *b, int, size_t);
749 f36fd90a 2022-07-09 op [ ${HAVE_GETPROGNAME} -eq 0 ] && \
750 f36fd90a 2022-07-09 op cat << __HEREDOC__
752 f36fd90a 2022-07-09 op * Compatibility for getprogname(3).
754 f36fd90a 2022-07-09 op extern const char *getprogname(void);
758 f36fd90a 2022-07-09 op [ ${HAVE_REALLOCARRAY} -eq 0 ] && \
759 f36fd90a 2022-07-09 op cat << __HEREDOC__
761 f36fd90a 2022-07-09 op * Compatibility for reallocarray(3).
763 f36fd90a 2022-07-09 op extern void *reallocarray(void *, size_t, size_t);
767 f36fd90a 2022-07-09 op [ ${HAVE_RECALLOCARRAY} -eq 0 ] && \
768 f36fd90a 2022-07-09 op cat << __HEREDOC__
770 f36fd90a 2022-07-09 op * Compatibility for recallocarray(3).
772 f36fd90a 2022-07-09 op extern void *recallocarray(void *, size_t, size_t, size_t);
776 f36fd90a 2022-07-09 op [ ${HAVE_SETPROCTITLE} -eq 0 ] && \
777 f36fd90a 2022-07-09 op cat << __HEREDOC__
779 f36fd90a 2022-07-09 op * Compatibility for setproctitle(3).
781 f36fd90a 2022-07-09 op extern void setproctitle(const char *, ...);
785 f36fd90a 2022-07-09 op [ ${HAVE_STRLCAT} -eq 0 ] && \
786 f36fd90a 2022-07-09 op cat << __HEREDOC__
788 f36fd90a 2022-07-09 op * Compatibility for strlcat(3).
790 f36fd90a 2022-07-09 op extern size_t strlcat(char *, const char *, size_t);
794 f36fd90a 2022-07-09 op [ ${HAVE_STRLCPY} -eq 0 ] && \
795 f36fd90a 2022-07-09 op cat << __HEREDOC__
797 f36fd90a 2022-07-09 op * Compatibility for strlcpy(3).
799 f36fd90a 2022-07-09 op extern size_t strlcpy(char *, const char *, size_t);
803 f36fd90a 2022-07-09 op [ ${HAVE_STRNDUP} -eq 0 ] && \
804 f36fd90a 2022-07-09 op cat << __HEREDOC__
806 f36fd90a 2022-07-09 op * Compatibility for strndup(3).
808 f36fd90a 2022-07-09 op extern char *strndup(const char *, size_t);
812 f36fd90a 2022-07-09 op [ ${HAVE_STRNLEN} -eq 0 ] && \
813 f36fd90a 2022-07-09 op cat << __HEREDOC__
815 f36fd90a 2022-07-09 op * Compatibility for strnlen(3).
817 f36fd90a 2022-07-09 op extern size_t strnlen(const char *, size_t);
821 f36fd90a 2022-07-09 op [ ${HAVE_STRTONUM} -eq 0 ] && \
822 f36fd90a 2022-07-09 op cat << __HEREDOC__
824 f36fd90a 2022-07-09 op * Compatibility for strotnum(3).
826 f36fd90a 2022-07-09 op extern long long strtonum(const char *, long long, long long, const char **);
830 f36fd90a 2022-07-09 op if [ ${HAVE_SYS_QUEUE} -eq 0 ]; then
831 f36fd90a 2022-07-09 op cat << __HEREDOC__
832 f36fd90a 2022-07-09 op #include "queue.h"
835 f36fd90a 2022-07-09 op echo "#include <sys/queue.h>"
839 f36fd90a 2022-07-09 op echo "#include <sys/uio.h>"
840 f36fd90a 2022-07-09 op echo "#include <stdint.h>"
841 f36fd90a 2022-07-09 op if [ ${HAVE_IMSG} -eq 0 ]; then
842 f36fd90a 2022-07-09 op echo "#include \"imsg.h\""
844 f36fd90a 2022-07-09 op echo "#include <imsg.h>"
848 f36fd90a 2022-07-09 op if [ "${HAVE_LIBEVENT2}" -eq 1 ]; then
849 f36fd90a 2022-07-09 op cat << __HEREDOC__
850 f36fd90a 2022-07-09 op #include <event2/event.h>
851 f36fd90a 2022-07-09 op #include <event2/event_compat.h>
852 f36fd90a 2022-07-09 op #include <event2/event_struct.h>
853 f36fd90a 2022-07-09 op #include <event2/buffer.h>
854 f36fd90a 2022-07-09 op #include <event2/buffer_compat.h>
855 f36fd90a 2022-07-09 op #include <event2/bufferevent.h>
856 f36fd90a 2022-07-09 op #include <event2/bufferevent_struct.h>
857 f36fd90a 2022-07-09 op #include <event2/bufferevent_compat.h>
860 f36fd90a 2022-07-09 op elif [ "${HAVE_LIBEVENT}" -eq 1 ]; then
861 f36fd90a 2022-07-09 op cat << __HEREDOC__
862 f36fd90a 2022-07-09 op #include <event.h>
867 f36fd90a 2022-07-09 op cat << __HEREDOC__
868 f36fd90a 2022-07-09 op #ifndef __dead
869 f36fd90a 2022-07-09 op # define __dead __attribute__((noreturn))
872 f36fd90a 2022-07-09 op #if !HAVE_SIO_FLUSH
873 f36fd90a 2022-07-09 op #define sio_flush(hdl) (sio_stop(hdl))
876 f36fd90a 2022-07-09 op #if !HAVE_GETDTABLECOUNT
877 f36fd90a 2022-07-09 op /* XXX: on linux it should be possible to inspect /proc/self/fd/ */
878 f36fd90a 2022-07-09 op #define getdtablecount() (0)
881 f36fd90a 2022-07-09 op #if !HAVE_OPTRESET
882 f36fd90a 2022-07-09 op /* replace host' getopt with OpenBSD' one */
883 f36fd90a 2022-07-09 op #define opterr BSDopterr
884 f36fd90a 2022-07-09 op #define optind BSDoptind
885 f36fd90a 2022-07-09 op #define optopt BSDoptopt
886 f36fd90a 2022-07-09 op #define optreset BSDoptreset
887 f36fd90a 2022-07-09 op #define optarg BSDoptarg
888 f36fd90a 2022-07-09 op #define getopt BSDgetopt
890 f36fd90a 2022-07-09 op extern int BSDopterr, BSDoptind, BSDoptopt, BSDoptreset;
891 f36fd90a 2022-07-09 op extern char *BSDoptarg;
894 f36fd90a 2022-07-09 op #endif /*!OCONFIGURE_CONFIG_H*/
897 f36fd90a 2022-07-09 op echo "config.h: written" 1>&2
898 f36fd90a 2022-07-09 op echo "config.h: written" 1>&3
900 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
901 f36fd90a 2022-07-09 op # Now we go to generate our Makefile.configure.
902 f36fd90a 2022-07-09 op # This file is simply a bunch of Makefile variables.
903 f36fd90a 2022-07-09 op # They'll work in both GNUmakefile and BSDmakefile.
904 f36fd90a 2022-07-09 op # You MIGHT want to change this.
905 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
907 f36fd90a 2022-07-09 op exec > Makefile.configure
909 f36fd90a 2022-07-09 op [ -z "${BINDIR}" ] && BINDIR="${PREFIX}/bin"
910 f36fd90a 2022-07-09 op [ -z "${SBINDIR}" ] && SBINDIR="${PREFIX}/sbin"
911 f36fd90a 2022-07-09 op [ -z "${INCLUDEDIR}" ] && INCLUDEDIR="${PREFIX}/include"
912 f36fd90a 2022-07-09 op [ -z "${LIBDIR}" ] && LIBDIR="${PREFIX}/lib"
913 f36fd90a 2022-07-09 op [ -z "${MANDIR}" ] && MANDIR="${PREFIX}/man"
914 f36fd90a 2022-07-09 op [ -z "${SHAREDIR}" ] && SHAREDIR="${PREFIX}/share"
916 f36fd90a 2022-07-09 op [ -z "${INSTALL_PROGRAM}" ] && INSTALL_PROGRAM="${INSTALL} -m 0555"
917 f36fd90a 2022-07-09 op [ -z "${INSTALL_LIB}" ] && INSTALL_LIB="${INSTALL} -m 0444"
918 f36fd90a 2022-07-09 op [ -z "${INSTALL_MAN}" ] && INSTALL_MAN="${INSTALL} -m 0444"
919 f36fd90a 2022-07-09 op [ -z "${INSTALL_DATA}" ] && INSTALL_DATA="${INSTALL} -m 0444"
921 f36fd90a 2022-07-09 op cat << __HEREDOC__
923 f36fd90a 2022-07-09 op CFLAGS = ${CFLAGS}
924 f36fd90a 2022-07-09 op CPPFLAGS = ${CPPFLAGS}
925 f36fd90a 2022-07-09 op LDADD = ${LDADD} ${LDADD_IMSG} ${LDADD_LIB_FLAC} ${LDADD_LIB_MPG123} \
926 f36fd90a 2022-07-09 op ${LDADD_LIB_OPUSFILE} ${LDADD_LIB_VORBISFILE} ${LDADD_LIB_SOCKET} \
927 f36fd90a 2022-07-09 op ${LDADD_LIBEVENT} ${LDADD_LIBEVENT2} ${LDADD_LIB_SNDIO}
928 f36fd90a 2022-07-09 op LDADD_STATIC = ${LDADD_STATIC}
929 f36fd90a 2022-07-09 op LDFLAGS = ${LDFLAGS}
930 f36fd90a 2022-07-09 op STATIC = ${STATIC}
931 f36fd90a 2022-07-09 op PREFIX = ${PREFIX}
932 f36fd90a 2022-07-09 op BINDIR = ${BINDIR}
933 f36fd90a 2022-07-09 op SHAREDIR = ${SHAREDIR}
934 f36fd90a 2022-07-09 op SBINDIR = ${SBINDIR}
935 f36fd90a 2022-07-09 op INCLUDEDIR = ${INCLUDEDIR}
936 f36fd90a 2022-07-09 op LIBDIR = ${LIBDIR}
937 f36fd90a 2022-07-09 op MANDIR = ${MANDIR}
938 f36fd90a 2022-07-09 op INSTALL = ${INSTALL}
939 f36fd90a 2022-07-09 op INSTALL_PROGRAM = ${INSTALL_PROGRAM}
940 f36fd90a 2022-07-09 op INSTALL_LIB = ${INSTALL_LIB}
941 f36fd90a 2022-07-09 op INSTALL_MAN = ${INSTALL_MAN}
942 f36fd90a 2022-07-09 op INSTALL_DATA = ${INSTALL_DATA}
945 f36fd90a 2022-07-09 op echo "Makefile.configure: written" 1>&2
946 f36fd90a 2022-07-09 op echo "Makefile.configure: written" 1>&3