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
85 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
86 f36fd90a 2022-07-09 op # Prepare for running: move aside previous configure runs.
87 f36fd90a 2022-07-09 op # Output file descriptor usage:
88 f36fd90a 2022-07-09 op # 1 (stdout): config.h or Makefile.configure
89 f36fd90a 2022-07-09 op # 2 (stderr): original stderr, usually to the console
90 f36fd90a 2022-07-09 op # 3: config.log
91 f36fd90a 2022-07-09 op # You DO NOT want to change this.
92 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
94 f36fd90a 2022-07-09 op [ -w config.log ] && mv config.log config.log.old
95 f36fd90a 2022-07-09 op [ -w config.h ] && mv config.h config.h.old
97 f36fd90a 2022-07-09 op exec 3> config.log
98 f36fd90a 2022-07-09 op echo "config.log: writing..."
100 f36fd90a 2022-07-09 op # GNU submake prints different output if invoked recursively, which
101 f36fd90a 2022-07-09 op # messes up CC and CFLAGS detection. Pass --no-print-directory if
102 f36fd90a 2022-07-09 op # we have a MAKELEVEL (GNU and FreeBSD make) and the argument is
105 f36fd90a 2022-07-09 op MAKE_FLAGS=""
107 f36fd90a 2022-07-09 op if [ -n "${MAKELEVEL}" ]; then
108 f36fd90a 2022-07-09 op if [ "${MAKELEVEL}" -gt 0 ] ; then
109 f36fd90a 2022-07-09 op MAKE_FLAGS="--no-print-directory"
110 f36fd90a 2022-07-09 op echo "all:" | make ${MAKE_FLAGS} -sf - 2>/dev/null || MAKE_FLAGS=""
114 f36fd90a 2022-07-09 op if [ -n "$MAKE_FLAGS" ]; then
115 f36fd90a 2022-07-09 op echo "GNU submake detected: using --no-print-directory" 1>&2
116 f36fd90a 2022-07-09 op echo "GNU submake detected: using --no-print-directory" 1>&3
119 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
120 f36fd90a 2022-07-09 op # Initialize all variables here such that nothing can leak in from the
121 f36fd90a 2022-07-09 op # environment except for CC and CFLAGS, which we might have passed in.
122 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
124 f36fd90a 2022-07-09 op CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | make ${MAKE_FLAGS} -sf -`
125 f36fd90a 2022-07-09 op CFLAGS=`printf "all:\\n\\t@echo \\\$(CFLAGS)\\n" | make ${MAKE_FLAGS} -sf -`
126 f36fd90a 2022-07-09 op CFLAGS="${CFLAGS} -g -W -Wall -Wmissing-prototypes -Wstrict-prototypes"
127 f36fd90a 2022-07-09 op CFLAGS="${CFLAGS} -Wmissing-declarations -Wno-unused-parameter"
128 f36fd90a 2022-07-09 op CFLAGS="${CFLAGS} -Wno-sign-compare"
131 f36fd90a 2022-07-09 op LDADD_LIBEVENT=
132 f36fd90a 2022-07-09 op LDADD_LIBEVENT2=
133 f36fd90a 2022-07-09 op LDADD_LIB_FLAC=
134 f36fd90a 2022-07-09 op LDADD_LIB_MPG123=
135 f36fd90a 2022-07-09 op LDADD_LIB_VORBISFILE=
136 f36fd90a 2022-07-09 op LDADD_LIB_SNDIO=
137 f36fd90a 2022-07-09 op LDADD_LIB_SOCKET=
138 f36fd90a 2022-07-09 op LDADD_STATIC=
142 f36fd90a 2022-07-09 op PREFIX="/usr/local"
149 f36fd90a 2022-07-09 op INSTALL="install"
150 f36fd90a 2022-07-09 op INSTALL_PROGRAM=
153 f36fd90a 2022-07-09 op INSTALL_DATA=
156 f36fd90a 2022-07-09 op # SunOS sets "cc", but this doesn't exist.
157 f36fd90a 2022-07-09 op # It does have gcc, so try that instead.
158 f36fd90a 2022-07-09 op # Prefer clang, though.
160 f36fd90a 2022-07-09 op command -v ${CC} 2>/dev/null 1>&2 || {
161 f36fd90a 2022-07-09 op echo "${CC} not found: trying clang" 1>&2
162 f36fd90a 2022-07-09 op echo "${CC} not found: trying clang" 1>&3
164 f36fd90a 2022-07-09 op command -v ${CC} 2>/dev/null 1>&2 || {
165 f36fd90a 2022-07-09 op echo "${CC} not found: trying gcc" 1>&2
166 f36fd90a 2022-07-09 op echo "${CC} not found: trying gcc" 1>&3
168 f36fd90a 2022-07-09 op command -v ${CC} 2>/dev/null 1>&2 || {
169 f36fd90a 2022-07-09 op echo "gcc not found: giving up" 1>&2
170 f36fd90a 2022-07-09 op echo "gcc not found: giving up" 1>&3
176 f36fd90a 2022-07-09 op command -v pkg-config 2>/dev/null 1>&2 && {
177 f36fd90a 2022-07-09 op PKG_CONFIG=pkg-config
178 f36fd90a 2022-07-09 op echo "pkg-config found" 1>&2
179 f36fd90a 2022-07-09 op echo "pkg-config found" 1>&3
181 f36fd90a 2022-07-09 op echo "pkg-config not found" 1>&2
182 f36fd90a 2022-07-09 op echo "pkg-config not found" 1>&3
185 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
186 f36fd90a 2022-07-09 op # Allow certain variables to be overriden on the command line.
187 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
189 f36fd90a 2022-07-09 op while [ $# -gt 0 ]; do
193 f36fd90a 2022-07-09 op if [ "$key" = "--prefix" ]; then
195 f36fd90a 2022-07-09 op if [ "$1" = "--prefix" ]; then
196 f36fd90a 2022-07-09 op if ! shift 2>&1 >/dev/null; then
197 f36fd90a 2022-07-09 op echo "$0: missing value for --prefix" 1>&2
204 f36fd90a 2022-07-09 op if [ "$1" = "$key" ]; then
205 f36fd90a 2022-07-09 op echo "$0: invalid key-value: $1" 1>&2
211 f36fd90a 2022-07-09 op case "$key" in
213 f36fd90a 2022-07-09 op LDADD="$val" ;;
215 f36fd90a 2022-07-09 op LDADD_IMSG="$val" ;;
216 f36fd90a 2022-07-09 op LDADD_LIBEVENT)
217 f36fd90a 2022-07-09 op LDADD_LIBEVENT="$val" ;;
218 f36fd90a 2022-07-09 op LDADD_LIBEVENT2)
219 f36fd90a 2022-07-09 op LDADD_LIBEVENT2="$val" ;;
220 f36fd90a 2022-07-09 op LDADD_LIBFLAC)
221 f36fd90a 2022-07-09 op LDADD_LIBFLAC="$val" ;;
222 f36fd90a 2022-07-09 op LDADD_LIBMPG123)
223 f36fd90a 2022-07-09 op LDADD_LIBMPG123="$val" ;;
224 f36fd90a 2022-07-09 op LDADD_LIBOPUSFILE)
225 f36fd90a 2022-07-09 op LDADD_LIBOPUSFILE="$val" ;;
226 f36fd90a 2022-07-09 op LDADD_LIBVORBISFILE)
227 f36fd90a 2022-07-09 op LDADD_LIBVORBISFILE="$val" ;;
229 f36fd90a 2022-07-09 op LDADD_SNDIO="$val" ;;
230 f36fd90a 2022-07-09 op LDADD_LIBSOCKET)
231 f36fd90a 2022-07-09 op LDADD_LIBSOCKET="$val" ;;
233 f36fd90a 2022-07-09 op LDFLAGS="$val" ;;
235 f36fd90a 2022-07-09 op CPPFLAGS="$val" ;;
237 f36fd90a 2022-07-09 op DESTDIR="$val" ;;
239 f36fd90a 2022-07-09 op PREFIX="$val" ;;
241 f36fd90a 2022-07-09 op MANDIR="$val" ;;
243 f36fd90a 2022-07-09 op LIBDIR="$val" ;;
245 f36fd90a 2022-07-09 op BINDIR="$val" ;;
247 f36fd90a 2022-07-09 op SHAREDIR="$val" ;;
249 f36fd90a 2022-07-09 op SBINDIR="$val" ;;
251 f36fd90a 2022-07-09 op INCLUDEDIR="$val" ;;
253 f36fd90a 2022-07-09 op PKG_CONFIG="$val" ;;
255 f36fd90a 2022-07-09 op echo "$0: invalid key: $key" 1>&2
261 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
262 f36fd90a 2022-07-09 op # These are the values that will be pushed into config.h after we test
263 f36fd90a 2022-07-09 op # for whether they're supported or not.
264 f36fd90a 2022-07-09 op # Each of these must have a runtest(), below.
265 f36fd90a 2022-07-09 op # Please sort by alpha, for clarity.
266 f36fd90a 2022-07-09 op # You WANT to change this.
267 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
269 f36fd90a 2022-07-09 op HAVE_CAPSICUM=
271 f36fd90a 2022-07-09 op HAVE_EXPLICIT_BZERO=
273 f36fd90a 2022-07-09 op HAVE_FREEZERO=
274 f36fd90a 2022-07-09 op HAVE_GETDTABLECOUNT=
275 f36fd90a 2022-07-09 op HAVE_GETEXECNAME=
276 f36fd90a 2022-07-09 op HAVE_GETPROGNAME=
279 f36fd90a 2022-07-09 op HAVE_LANDLOCK=
280 f36fd90a 2022-07-09 op HAVE_LIBEVENT=
281 f36fd90a 2022-07-09 op HAVE_LIBEVENT2=0 # may not be checked, set to zero
282 f36fd90a 2022-07-09 op HAVE_LIB_FLAC=
283 f36fd90a 2022-07-09 op HAVE_LIB_MPG123=
284 f36fd90a 2022-07-09 op HAVE_LIB_OPUSFILE=
285 f36fd90a 2022-07-09 op HAVE_LIB_VORBISFILE=
286 f36fd90a 2022-07-09 op HAVE_LIB_SNDIO=
287 f36fd90a 2022-07-09 op HAVE_LIB_SOCKET=
289 f36fd90a 2022-07-09 op HAVE_MEMRCHR=
290 f36fd90a 2022-07-09 op HAVE_MEMSET_S=
291 f36fd90a 2022-07-09 op HAVE_OPTRESET=
292 f36fd90a 2022-07-09 op HAVE_PATH_MAX=
294 f36fd90a 2022-07-09 op HAVE_PROGRAM_INVOCATION_SHORT_NAME=
295 f36fd90a 2022-07-09 op HAVE_PR_SET_NAME=
296 f36fd90a 2022-07-09 op HAVE_REALLOCARRAY=
297 f36fd90a 2022-07-09 op HAVE_RECALLOCARRAY=
298 f36fd90a 2022-07-09 op HAVE_SANDBOX_INIT=
299 f36fd90a 2022-07-09 op HAVE_SETPROCTITLE=
300 f36fd90a 2022-07-09 op HAVE_SIO_FLUSH=
301 f36fd90a 2022-07-09 op HAVE_SOCK_NONBLOCK=
302 f36fd90a 2022-07-09 op HAVE_STRLCAT=
303 f36fd90a 2022-07-09 op HAVE_STRLCPY=
304 f36fd90a 2022-07-09 op HAVE_STRNDUP=
305 f36fd90a 2022-07-09 op HAVE_STRNLEN=
306 f36fd90a 2022-07-09 op HAVE_STRTONUM=
307 f36fd90a 2022-07-09 op HAVE_SYS_FILE=
308 f36fd90a 2022-07-09 op HAVE_SYS_QUEUE=
309 f36fd90a 2022-07-09 op HAVE_SYSTRACE=0
311 f36fd90a 2022-07-09 op HAVE___PROGNAME=
313 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
314 f36fd90a 2022-07-09 op # Allow configure.local to override all variables, default settings,
315 f36fd90a 2022-07-09 op # command-line arguments, and tested features, above.
316 f36fd90a 2022-07-09 op # You PROBABLY DO NOT want to change this.
317 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
319 f36fd90a 2022-07-09 op if [ -r ./configure.local ]; then
320 f36fd90a 2022-07-09 op echo "configure.local: reading..." 1>&2
321 f36fd90a 2022-07-09 op echo "configure.local: reading..." 1>&3
322 f36fd90a 2022-07-09 op cat ./configure.local 1>&3
323 f36fd90a 2022-07-09 op . ./configure.local
325 f36fd90a 2022-07-09 op echo "configure.local: no (fully automatic configuration)" 1>&2
326 f36fd90a 2022-07-09 op echo "configure.local: no (fully automatic configuration)" 1>&3
331 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
332 f36fd90a 2022-07-09 op # Infrastructure for running tests.
333 f36fd90a 2022-07-09 op # These consists of a series of functions that will attempt to run the
334 f36fd90a 2022-07-09 op # given test file and record its exit into a HAVE_xxx variable.
335 f36fd90a 2022-07-09 op # You DO NOT want to change this.
336 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
338 f36fd90a 2022-07-09 op COMP="${CC} ${CFLAGS} ${CPPFLAGS} -Wno-unused -Werror"
340 f36fd90a 2022-07-09 op # Check whether this HAVE_ setting is manually overridden.
341 f36fd90a 2022-07-09 op # If yes, use the override, if no, do not decide anything yet.
342 f36fd90a 2022-07-09 op # Arguments: lower-case test name, manual value
345 f36fd90a 2022-07-09 op [ -z "${3}" ] && return 1
346 f36fd90a 2022-07-09 op echo "${1}: manual (HAVE_${2}=${3})" 1>&2
347 f36fd90a 2022-07-09 op echo "${1}: manual (HAVE_${2}=${3})" 1>&3
352 f36fd90a 2022-07-09 op # Run a single autoconfiguration test.
353 f36fd90a 2022-07-09 op # In case of success, enable the feature.
354 f36fd90a 2022-07-09 op # In case of failure, do not decide anything yet.
355 f36fd90a 2022-07-09 op # Arguments: lower-case test name, upper-case test name, additional
356 f36fd90a 2022-07-09 op # CFLAGS, additional LIBS.
358 f36fd90a 2022-07-09 op singletest() {
363 f36fd90a 2022-07-09 op cat 1>&3 << __HEREDOC__
364 f36fd90a 2022-07-09 op ${1}: testing...
365 f36fd90a 2022-07-09 op ${COMP} -DTEST_${2} ${3} -o test-${1} tests.c ${LDFLAGS} ${4}
367 f36fd90a 2022-07-09 op if ${COMP} -DTEST_${2} ${3} -o "test-${1}" tests.c ${LDFLAGS} ${4} 1>&3 2>&3; then
368 f36fd90a 2022-07-09 op echo "${1}: ${CC} succeeded" 1>&3
370 f36fd90a 2022-07-09 op if [ -n "${5}" ] ; then
371 f36fd90a 2022-07-09 op echo "${1}: ${CC} failed with $? (retrying)" 1>&3
372 f36fd90a 2022-07-09 op cat 1>&3 << __HEREDOC__
373 f36fd90a 2022-07-09 op ${1}: testing...
374 f36fd90a 2022-07-09 op ${COMP} -DTEST_${2} ${3} -o test-${1} tests.c ${LDFLAGS} ${5}
376 f36fd90a 2022-07-09 op if ${COMP} -DTEST_${2} ${3} -o "test-${1}" tests.c ${LDFLAGS} ${5} 1>&3 2>&3; then
377 f36fd90a 2022-07-09 op echo "${1}: ${CC} succeeded" 1>&3
378 f36fd90a 2022-07-09 op extralib="(with ${5})"
380 f36fd90a 2022-07-09 op test -n "${PKG_CONFIG}" -a -n "${6}" && ${PKG_CONFIG} "$6"
381 f36fd90a 2022-07-09 op if [ $? -eq 0 ]; then
382 f36fd90a 2022-07-09 op echo "${1}: ${CC} failed with $? (retrying)" 1>&3
383 f36fd90a 2022-07-09 op pkgcfs=$($PKG_CONFIG --cflags "${6}")
384 f36fd90a 2022-07-09 op pkglib=$($PKG_CONFIG --libs "${6}")
385 f36fd90a 2022-07-09 op cat 1>&3 << __HEREDOC__
386 f36fd90a 2022-07-09 op ${1}: testing...
387 f36fd90a 2022-07-09 op ${COMP} -DTEST_${2} ${3} ${pkgcfs} -o test-${1} tests.c ${LDFLAGS} ${pkglib}
389 f36fd90a 2022-07-09 op if ${COMP} -DTEST_${2} ${3} ${pkgcfs} -o test-${1} tests.c ${LDFLAGS} ${pkglib} 1>&3 2>&3; then
390 f36fd90a 2022-07-09 op echo "${1}: ${CC} succeeded" 1>&3
391 f36fd90a 2022-07-09 op extralib="(with ${pkgcfs} ${pkglib})"
393 f36fd90a 2022-07-09 op echo "${1}: ${CC} failed with $?" 1>&3
398 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 if [ -n "${pkgcfs}" -o -n "${pkglib}" ]
412 f36fd90a 2022-07-09 op CFLAGS="${CFLAGS} ${pkgcfs}"
413 f36fd90a 2022-07-09 op eval "LDADD_${2}=\"${pkglib}\""
414 f36fd90a 2022-07-09 op elif [ -n "${extralib}" ]
416 f36fd90a 2022-07-09 op eval "LDADD_${2}=\"${5}\""
417 f36fd90a 2022-07-09 op elif [ -n "${4}" ]
419 f36fd90a 2022-07-09 op eval "LDADD_${2}=\"${4}\""
422 f36fd90a 2022-07-09 op echo "${1}: yes ${extralib}" 1>&2
423 f36fd90a 2022-07-09 op echo "${1}: yes ${extralib}" 1>&3
425 f36fd90a 2022-07-09 op eval HAVE_${2}=1
426 f36fd90a 2022-07-09 op rm "test-${1}"
430 f36fd90a 2022-07-09 op # Run a complete autoconfiguration test, including the check for
431 f36fd90a 2022-07-09 op # a manual override and disabling the feature on failure.
432 f36fd90a 2022-07-09 op # Arguments: lower case name, upper case name, additional CFLAGS,
433 f36fd90a 2022-07-09 op # additional LDADD, alternative LDADD, pkg-config name.
436 f36fd90a 2022-07-09 op eval _manual=\${HAVE_${2}}
437 f36fd90a 2022-07-09 op ismanual "${1}" "${2}" "${_manual}" && return 0
438 f36fd90a 2022-07-09 op singletest "${1}" "${2}" "${3}" "${4}" "${5}" "${6}" && return 0
439 f36fd90a 2022-07-09 op echo "${1}: no" 1>&2
440 f36fd90a 2022-07-09 op eval HAVE_${2}=0
444 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
445 f36fd90a 2022-07-09 op # Begin running the tests themselves.
446 f36fd90a 2022-07-09 op # All of your tests must be defined here.
447 f36fd90a 2022-07-09 op # Please sort as the HAVE_xxxx values were defined.
448 f36fd90a 2022-07-09 op # You WANT to change this.
449 f36fd90a 2022-07-09 op # It consists of the following columns:
451 f36fd90a 2022-07-09 op # (1) test file
452 f36fd90a 2022-07-09 op # (2) macro to set
453 f36fd90a 2022-07-09 op # (3) argument to cc *before* -o
454 f36fd90a 2022-07-09 op # (4) argument to cc *after*
455 f36fd90a 2022-07-09 op # (5) alternative argument to cc *after*
456 f36fd90a 2022-07-09 op # (6) name for pkg-config auto-discovery
457 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
459 f36fd90a 2022-07-09 op if runtest -MMD _MMD -MMD; then
460 f36fd90a 2022-07-09 op CFLAGS="${CFLAGS} -MMD"
461 f36fd90a 2022-07-09 op echo "adding -MMD to CFLAGS" 1>&2
462 f36fd90a 2022-07-09 op echo "adding -MMD to CFLAGS" 1>&3
465 f36fd90a 2022-07-09 op runtest capsicum CAPSICUM || true
466 f36fd90a 2022-07-09 op runtest err ERR || true
467 f36fd90a 2022-07-09 op runtest explicit_bzero EXPLICIT_BZERO || true
468 f36fd90a 2022-07-09 op runtest flock FLOCK || true
469 f36fd90a 2022-07-09 op runtest freezero FREEZERO || true
470 f36fd90a 2022-07-09 op runtest getdtablecount GETDTABLECOUNT || true
471 f36fd90a 2022-07-09 op runtest getexecname GETEXECNAME || true
472 f36fd90a 2022-07-09 op runtest getprogname GETPROGNAME || true
473 f36fd90a 2022-07-09 op runtest imsg IMSG "" "" "-lutil" || true
474 f36fd90a 2022-07-09 op runtest INFTIM INFTIM || true
475 f36fd90a 2022-07-09 op runtest landlock LANDLOCK || true
477 f36fd90a 2022-07-09 op runtest libevent LIBEVENT "" "" "-levent" || \
478 f36fd90a 2022-07-09 op runtest libevent2 LIBEVENT2 "" "" "-levent_extra -levent_core" "libevent" || true
480 f36fd90a 2022-07-09 op runtest lib_flac LIB_FLAC "" "" "-lFLAC" "flac" || true
481 f36fd90a 2022-07-09 op runtest lib_mpg123 LIB_MPG123 "" "" "-lmpg123" "libmpg123" || true
482 f36fd90a 2022-07-09 op runtest lib_opusfile LIB_OPUSFILE "" "" "-lopusfile" "opusfile" || true
483 f36fd90a 2022-07-09 op runtest lib_vorbisfile LIB_VORBISFILE "" "" "-lvorbisfile" "vorbisfile" || true
485 f36fd90a 2022-07-09 op runtest lib_sndio LIB_SNDIO "" "" "-lsndio" "sndio" || true
486 f36fd90a 2022-07-09 op runtest lib_socket LIB_SOCKET "" "" "-lsocket -lnsl" || true
487 f36fd90a 2022-07-09 op runtest memmem MEMMEM || true
488 f36fd90a 2022-07-09 op runtest memrchr MEMRCHR || true
489 f36fd90a 2022-07-09 op runtest memset_s MEMSET_S || true
490 f36fd90a 2022-07-09 op runtest optreset OPTRESET || true
491 f36fd90a 2022-07-09 op runtest PATH_MAX PATH_MAX || true
492 f36fd90a 2022-07-09 op runtest pledge PLEDGE || true
493 f36fd90a 2022-07-09 op runtest program_invocation_short_name PROGRAM_INVOCATION_SHORT_NAME || true
494 f36fd90a 2022-07-09 op runtest PR_SET_NAME PR_SET_NAME || true
495 f36fd90a 2022-07-09 op runtest reallocarray REALLOCARRAY || true
496 f36fd90a 2022-07-09 op runtest recallocarray RECALLOCARRAY || true
497 f36fd90a 2022-07-09 op runtest sandbox_init SANDBOX_INIT "-Wno-deprecated" || true
498 f36fd90a 2022-07-09 op runtest setproctitle SETPROCTITLE || true
499 f36fd90a 2022-07-09 op runtest sio_flush SIO_FLUSH "" "" "${LDADD_LIB_SNDIO}" || true
500 f36fd90a 2022-07-09 op runtest SOCK_NONBLOCK SOCK_NONBLOCK || true
501 f36fd90a 2022-07-09 op runtest static STATIC "" "-static" || true
502 f36fd90a 2022-07-09 op runtest strlcat STRLCAT || true
503 f36fd90a 2022-07-09 op runtest strlcpy STRLCPY || true
504 f36fd90a 2022-07-09 op runtest strndup STRNDUP || true
505 f36fd90a 2022-07-09 op runtest strnlen STRNLEN || true
506 f36fd90a 2022-07-09 op runtest strtonum STRTONUM || true
507 f36fd90a 2022-07-09 op runtest sys_queue SYS_QUEUE || true
508 f36fd90a 2022-07-09 op runtest sys_file SYS_FILE || true
509 f36fd90a 2022-07-09 op runtest unveil UNVEIL || true
510 f36fd90a 2022-07-09 op runtest __progname __PROGNAME || true
512 f36fd90a 2022-07-09 op if [ "${HAVE_LIBEVENT}" -eq 0 -a "${HAVE_LIBEVENT2}" -eq 0 ]; then
513 f36fd90a 2022-07-09 op echo "Fatal: missing libevent" 1>&2
514 f36fd90a 2022-07-09 op echo "Fatal: missing libevent" 1>&3
518 f36fd90a 2022-07-09 op if [ "${HAVE_LIB_FLAC}" -eq 0 -o \
519 f36fd90a 2022-07-09 op "${HAVE_LIB_MPG123}" -eq 0 -o \
520 f36fd90a 2022-07-09 op "${HAVE_LIB_OPUSFILE}" -eq 0 -o \
521 f36fd90a 2022-07-09 op "${HAVE_LIB_VORBISFILE}" -eq 0 ]; then
522 f36fd90a 2022-07-09 op echo "Fatal: missing required audio libraries" 1>&2
523 f36fd90a 2022-07-09 op echo "Fatal: missing required audio libraries" 1>&3
527 f36fd90a 2022-07-09 op if [ "${HAVE_LIB_SNDIO}" -eq 0 ]; then
528 f36fd90a 2022-07-09 op echo "Fatal: missing libsndio" 1>&2
529 f36fd90a 2022-07-09 op echo "Fatal: missing libsndio" 1>&3
533 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
534 f36fd90a 2022-07-09 op # Output writing: generate the config.h file.
535 f36fd90a 2022-07-09 op # This file contains all of the HAVE_xxxx variables necessary for
536 f36fd90a 2022-07-09 op # compiling your source.
537 f36fd90a 2022-07-09 op # You must include "config.h" BEFORE any other variables.
538 f36fd90a 2022-07-09 op # You WANT to change this.
539 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
541 f36fd90a 2022-07-09 op exec > config.h
543 f36fd90a 2022-07-09 op # Start with prologue.
545 f36fd90a 2022-07-09 op cat << __HEREDOC__
546 f36fd90a 2022-07-09 op #ifndef OCONFIGURE_CONFIG_H
547 f36fd90a 2022-07-09 op #define OCONFIGURE_CONFIG_H
549 f36fd90a 2022-07-09 op #ifdef __cplusplus
550 f36fd90a 2022-07-09 op # error "Do not use C++: this is a C application."
552 f36fd90a 2022-07-09 op #if !defined(__GNUC__) || (__GNUC__ < 4)
553 f36fd90a 2022-07-09 op # define __attribute__(x)
555 f36fd90a 2022-07-09 op #if defined(__linux__) || defined(__MINT__)
556 f36fd90a 2022-07-09 op # define _GNU_SOURCE /* memmem, memrchr, setresuid... */
557 f36fd90a 2022-07-09 op # define _DEFAULT_SOURCE /* le32toh, crypt, ... */
559 f36fd90a 2022-07-09 op #if defined(__NetBSD__)
560 f36fd90a 2022-07-09 op # define _OPENBSD_SOURCE /* reallocarray, etc. */
562 f36fd90a 2022-07-09 op #if defined(__sun)
563 f36fd90a 2022-07-09 op # ifndef _XOPEN_SOURCE /* SunOS already defines */
564 f36fd90a 2022-07-09 op # define _XOPEN_SOURCE /* XPGx */
566 f36fd90a 2022-07-09 op # define _XOPEN_SOURCE_EXTENDED 1 /* XPG4v2 */
567 f36fd90a 2022-07-09 op # ifndef __EXTENSIONS__ /* SunOS already defines */
568 f36fd90a 2022-07-09 op # define __EXTENSIONS__ /* reallocarray, etc. */
571 f36fd90a 2022-07-09 op #if !defined(__BEGIN_DECLS)
572 f36fd90a 2022-07-09 op # define __BEGIN_DECLS
574 f36fd90a 2022-07-09 op #if !defined(__END_DECLS)
575 f36fd90a 2022-07-09 op # define __END_DECLS
580 f36fd90a 2022-07-09 op # This is just for size_t, mode_t, and dev_t.
581 f36fd90a 2022-07-09 op # Most of these functions, in the real world, pull in <string.h> or
582 f36fd90a 2022-07-09 op # someting that pulls in support for size_t.
583 f36fd90a 2022-07-09 op # Our function declarations are standalone, so specify them here.
585 f36fd90a 2022-07-09 op if [ ${HAVE_IMSG} -eq 0 -o \
586 f36fd90a 2022-07-09 op ${HAVE_MEMMEM} -eq 0 -o \
587 f36fd90a 2022-07-09 op ${HAVE_MEMRCHR} -eq 0 -o \
588 f36fd90a 2022-07-09 op ${HAVE_REALLOCARRAY} -eq 0 -o \
589 f36fd90a 2022-07-09 op ${HAVE_RECALLOCARRAY} -eq 0 -o \
590 f36fd90a 2022-07-09 op ${HAVE_STRLCAT} -eq 0 -o \
591 f36fd90a 2022-07-09 op ${HAVE_STRLCPY} -eq 0 -o \
592 f36fd90a 2022-07-09 op ${HAVE_STRNDUP} -eq 0 -o \
593 f36fd90a 2022-07-09 op ${HAVE_STRNLEN} -eq 0 ]
595 f36fd90a 2022-07-09 op echo "#include <sys/types.h> /* size_t, mode_t, dev_t */ "
599 f36fd90a 2022-07-09 op if [ ${HAVE_FLOCK} -eq 0 ]; then
600 f36fd90a 2022-07-09 op if [ ${HAVE_SYS_FILE} -eq 0 ]; then
602 f36fd90a 2022-07-09 op echo "#include <sys/file.h>"
605 f36fd90a 2022-07-09 op echo "int flock(int, int);"
606 f36fd90a 2022-07-09 op echo "#define LOCK_SH 0x1"
607 f36fd90a 2022-07-09 op echo "#define LOCK_EX 0x2"
608 f36fd90a 2022-07-09 op echo "#define LOCK_NB 0x4"
613 f36fd90a 2022-07-09 op if [ ${HAVE_ERR} -eq 0 ]; then
614 f36fd90a 2022-07-09 op echo "#include <stdarg.h> /* err(3) */"
617 f36fd90a 2022-07-09 op echo "#include <err.h>"
621 f36fd90a 2022-07-09 op if [ ${HAVE_PLEDGE} -eq 0 ]; then
622 f36fd90a 2022-07-09 op echo "#define pledge(p, e) (0)"
625 f36fd90a 2022-07-09 op echo "#include <unistd.h>"
629 f36fd90a 2022-07-09 op # Now we handle our HAVE_xxxx values.
630 f36fd90a 2022-07-09 op # Most will just be defined as 0 or 1.
632 f36fd90a 2022-07-09 op if [ ${HAVE_PATH_MAX} -eq 0 ]
634 f36fd90a 2022-07-09 op echo "#define PATH_MAX 4096"
638 f36fd90a 2022-07-09 op if [ ${HAVE_INFTIM} -eq 0 ]
640 f36fd90a 2022-07-09 op echo "#define INFTIM (-1) /* poll.h */"
644 f36fd90a 2022-07-09 op cat << __HEREDOC__
646 f36fd90a 2022-07-09 op * Results of configuration feature-testing.
648 f36fd90a 2022-07-09 op #define HAVE_CAPSICUM ${HAVE_CAPSICUM}
649 f36fd90a 2022-07-09 op #define HAVE_ERR ${HAVE_ERR}
650 f36fd90a 2022-07-09 op #define HAVE_EXPLICIT_BZERO ${HAVE_EXPLICIT_BZERO}
651 f36fd90a 2022-07-09 op #define HAVE_FLOCK ${HAVE_FLOCK}
652 f36fd90a 2022-07-09 op #define HAVE_FREEZERO ${HAVE_FREEZERO}
653 f36fd90a 2022-07-09 op #define HAVE_GETDTABLECOUNT ${HAVE_GETDTABLECOUNT}
654 f36fd90a 2022-07-09 op #define HAVE_GETEXECNAME ${HAVE_GETEXECNAME}
655 f36fd90a 2022-07-09 op #define HAVE_GETPROGNAME ${HAVE_GETPROGNAME}
656 f36fd90a 2022-07-09 op #define HAVE_INFTIM ${HAVE_INFTIM}
657 f36fd90a 2022-07-09 op #define HAVE_LANDLOCK ${HAVE_LANDLOCK}
658 f36fd90a 2022-07-09 op #define HAVE_MEMMEM ${HAVE_MEMMEM}
659 f36fd90a 2022-07-09 op #define HAVE_MEMRCHR ${HAVE_MEMRCHR}
660 f36fd90a 2022-07-09 op #define HAVE_MEMSET_S ${HAVE_MEMSET_S}
661 f36fd90a 2022-07-09 op #define HAVE_OPTRESET ${HAVE_OPTRESET}
662 f36fd90a 2022-07-09 op #define HAVE_PATH_MAX ${HAVE_PATH_MAX}
663 f36fd90a 2022-07-09 op #define HAVE_PLEDGE ${HAVE_PLEDGE}
664 f36fd90a 2022-07-09 op #define HAVE_PROGRAM_INVOCATION_SHORT_NAME ${HAVE_PROGRAM_INVOCATION_SHORT_NAME}
665 f36fd90a 2022-07-09 op #define HAVE_PR_SET_NAME ${HAVE_PR_SET_NAME}
666 f36fd90a 2022-07-09 op #define HAVE_REALLOCARRAY ${HAVE_REALLOCARRAY}
667 f36fd90a 2022-07-09 op #define HAVE_RECALLOCARRAY ${HAVE_RECALLOCARRAY}
668 f36fd90a 2022-07-09 op #define HAVE_SANDBOX_INIT ${HAVE_SANDBOX_INIT}
669 f36fd90a 2022-07-09 op #define HAVE_SETPROCTITLE ${HAVE_SETPROCTITLE}
670 f36fd90a 2022-07-09 op #define HAVE_SIO_FLUSH ${HAVE_SIO_FLUSH}
671 f36fd90a 2022-07-09 op #define HAVE_SOCK_NONBLOCK ${HAVE_SOCK_NONBLOCK}
672 f36fd90a 2022-07-09 op #define HAVE_STRLCAT ${HAVE_STRLCAT}
673 f36fd90a 2022-07-09 op #define HAVE_STRLCPY ${HAVE_STRLCPY}
674 f36fd90a 2022-07-09 op #define HAVE_STRNDUP ${HAVE_STRNDUP}
675 f36fd90a 2022-07-09 op #define HAVE_STRNLEN ${HAVE_STRNLEN}
676 f36fd90a 2022-07-09 op #define HAVE_STRTONUM ${HAVE_STRTONUM}
677 f36fd90a 2022-07-09 op #define HAVE_SYS_FILE ${HAVE_SYS_FILE}
678 f36fd90a 2022-07-09 op #define HAVE_SYS_QUEUE ${HAVE_SYS_QUEUE}
679 f36fd90a 2022-07-09 op #define HAVE_SYSTRACE ${HAVE_SYSTRACE}
680 f36fd90a 2022-07-09 op #define HAVE_UNVEIL ${HAVE_UNVEIL}
681 f36fd90a 2022-07-09 op #define HAVE___PROGNAME ${HAVE___PROGNAME}
685 f36fd90a 2022-07-09 op # Now we do our function declarations for missing functions.
687 f36fd90a 2022-07-09 op [ ${HAVE_ERR} -eq 0 ] && \
688 f36fd90a 2022-07-09 op cat << __HEREDOC__
690 f36fd90a 2022-07-09 op * Compatibility functions for err(3).
692 f36fd90a 2022-07-09 op extern void err(int, const char *, ...) __attribute__((noreturn));
693 f36fd90a 2022-07-09 op extern void errc(int, int, const char *, ...) __attribute__((noreturn));
694 f36fd90a 2022-07-09 op extern void errx(int, const char *, ...) __attribute__((noreturn));
695 f36fd90a 2022-07-09 op extern void verr(int, const char *, va_list) __attribute__((noreturn));
696 f36fd90a 2022-07-09 op extern void verrc(int, int, const char *, va_list) __attribute__((noreturn));
697 f36fd90a 2022-07-09 op extern void verrx(int, const char *, va_list) __attribute__((noreturn));
698 f36fd90a 2022-07-09 op extern void warn(const char *, ...);
699 f36fd90a 2022-07-09 op extern void warnx(const char *, ...);
700 f36fd90a 2022-07-09 op extern void warnc(int, const char *, ...);
701 f36fd90a 2022-07-09 op extern void vwarn(const char *, va_list);
702 f36fd90a 2022-07-09 op extern void vwarnc(int, const char *, va_list);
703 f36fd90a 2022-07-09 op extern void vwarnx(const char *, va_list);
706 f36fd90a 2022-07-09 op [ ${HAVE_EXPLICIT_BZERO} -eq 0 ] && \
707 f36fd90a 2022-07-09 op cat << __HEREDOC__
709 f36fd90a 2022-07-09 op * Compatibility for explicit_bzero(3).
711 f36fd90a 2022-07-09 op extern void explicit_bzero(void *, size_t);
715 f36fd90a 2022-07-09 op [ ${HAVE_FREEZERO} -eq 0 ] && \
716 f36fd90a 2022-07-09 op cat << __HEREDOC__
718 f36fd90a 2022-07-09 op * Compatibility for freezero(3).
720 f36fd90a 2022-07-09 op extern void freezero(void *, size_t);
724 f36fd90a 2022-07-09 op [ ${HAVE_MEMMEM} -eq 0 ] && \
725 f36fd90a 2022-07-09 op cat << __HEREDOC__
727 f36fd90a 2022-07-09 op * Compatibility for memmem(3).
729 f36fd90a 2022-07-09 op void *memmem(const void *, size_t, const void *, size_t);
733 f36fd90a 2022-07-09 op [ ${HAVE_MEMRCHR} -eq 0 ] && \
734 f36fd90a 2022-07-09 op cat << __HEREDOC__
736 f36fd90a 2022-07-09 op * Compatibility for memrchr(3).
738 f36fd90a 2022-07-09 op void *memrchr(const void *b, int, size_t);
742 f36fd90a 2022-07-09 op [ ${HAVE_GETPROGNAME} -eq 0 ] && \
743 f36fd90a 2022-07-09 op cat << __HEREDOC__
745 f36fd90a 2022-07-09 op * Compatibility for getprogname(3).
747 f36fd90a 2022-07-09 op extern const char *getprogname(void);
751 f36fd90a 2022-07-09 op [ ${HAVE_REALLOCARRAY} -eq 0 ] && \
752 f36fd90a 2022-07-09 op cat << __HEREDOC__
754 f36fd90a 2022-07-09 op * Compatibility for reallocarray(3).
756 f36fd90a 2022-07-09 op extern void *reallocarray(void *, size_t, size_t);
760 f36fd90a 2022-07-09 op [ ${HAVE_RECALLOCARRAY} -eq 0 ] && \
761 f36fd90a 2022-07-09 op cat << __HEREDOC__
763 f36fd90a 2022-07-09 op * Compatibility for recallocarray(3).
765 f36fd90a 2022-07-09 op extern void *recallocarray(void *, size_t, size_t, size_t);
769 f36fd90a 2022-07-09 op [ ${HAVE_SETPROCTITLE} -eq 0 ] && \
770 f36fd90a 2022-07-09 op cat << __HEREDOC__
772 f36fd90a 2022-07-09 op * Compatibility for setproctitle(3).
774 f36fd90a 2022-07-09 op extern void setproctitle(const char *, ...);
778 f36fd90a 2022-07-09 op [ ${HAVE_STRLCAT} -eq 0 ] && \
779 f36fd90a 2022-07-09 op cat << __HEREDOC__
781 f36fd90a 2022-07-09 op * Compatibility for strlcat(3).
783 f36fd90a 2022-07-09 op extern size_t strlcat(char *, const char *, size_t);
787 f36fd90a 2022-07-09 op [ ${HAVE_STRLCPY} -eq 0 ] && \
788 f36fd90a 2022-07-09 op cat << __HEREDOC__
790 f36fd90a 2022-07-09 op * Compatibility for strlcpy(3).
792 f36fd90a 2022-07-09 op extern size_t strlcpy(char *, const char *, size_t);
796 f36fd90a 2022-07-09 op [ ${HAVE_STRNDUP} -eq 0 ] && \
797 f36fd90a 2022-07-09 op cat << __HEREDOC__
799 f36fd90a 2022-07-09 op * Compatibility for strndup(3).
801 f36fd90a 2022-07-09 op extern char *strndup(const char *, size_t);
805 f36fd90a 2022-07-09 op [ ${HAVE_STRNLEN} -eq 0 ] && \
806 f36fd90a 2022-07-09 op cat << __HEREDOC__
808 f36fd90a 2022-07-09 op * Compatibility for strnlen(3).
810 f36fd90a 2022-07-09 op extern size_t strnlen(const char *, size_t);
814 f36fd90a 2022-07-09 op [ ${HAVE_STRTONUM} -eq 0 ] && \
815 f36fd90a 2022-07-09 op cat << __HEREDOC__
817 f36fd90a 2022-07-09 op * Compatibility for strotnum(3).
819 f36fd90a 2022-07-09 op extern long long strtonum(const char *, long long, long long, const char **);
823 f36fd90a 2022-07-09 op if [ ${HAVE_SYS_QUEUE} -eq 0 ]; then
824 f36fd90a 2022-07-09 op cat << __HEREDOC__
825 f36fd90a 2022-07-09 op #include "queue.h"
828 f36fd90a 2022-07-09 op echo "#include <sys/queue.h>"
832 f36fd90a 2022-07-09 op echo "#include <sys/uio.h>"
833 f36fd90a 2022-07-09 op echo "#include <stdint.h>"
834 f36fd90a 2022-07-09 op if [ ${HAVE_IMSG} -eq 0 ]; then
835 f36fd90a 2022-07-09 op echo "#include \"imsg.h\""
837 f36fd90a 2022-07-09 op echo "#include <imsg.h>"
841 f36fd90a 2022-07-09 op if [ "${HAVE_LIBEVENT2}" -eq 1 ]; then
842 f36fd90a 2022-07-09 op cat << __HEREDOC__
843 f36fd90a 2022-07-09 op #include <event2/event.h>
844 f36fd90a 2022-07-09 op #include <event2/event_compat.h>
845 f36fd90a 2022-07-09 op #include <event2/event_struct.h>
846 f36fd90a 2022-07-09 op #include <event2/buffer.h>
847 f36fd90a 2022-07-09 op #include <event2/buffer_compat.h>
848 f36fd90a 2022-07-09 op #include <event2/bufferevent.h>
849 f36fd90a 2022-07-09 op #include <event2/bufferevent_struct.h>
850 f36fd90a 2022-07-09 op #include <event2/bufferevent_compat.h>
853 f36fd90a 2022-07-09 op elif [ "${HAVE_LIBEVENT}" -eq 1 ]; then
854 f36fd90a 2022-07-09 op cat << __HEREDOC__
855 f36fd90a 2022-07-09 op #include <event.h>
860 f36fd90a 2022-07-09 op cat << __HEREDOC__
861 f36fd90a 2022-07-09 op #ifndef __dead
862 f36fd90a 2022-07-09 op # define __dead __attribute__((noreturn))
865 f36fd90a 2022-07-09 op #if !HAVE_SIO_FLUSH
866 f36fd90a 2022-07-09 op #define sio_flush(hdl) (sio_stop(hdl))
869 f36fd90a 2022-07-09 op #if !HAVE_GETDTABLECOUNT
870 f36fd90a 2022-07-09 op /* XXX: on linux it should be possible to inspect /proc/self/fd/ */
871 f36fd90a 2022-07-09 op #define getdtablecount() (0)
874 f36fd90a 2022-07-09 op #if !HAVE_OPTRESET
875 f36fd90a 2022-07-09 op /* replace host' getopt with OpenBSD' one */
876 f36fd90a 2022-07-09 op #define opterr BSDopterr
877 f36fd90a 2022-07-09 op #define optind BSDoptind
878 f36fd90a 2022-07-09 op #define optopt BSDoptopt
879 f36fd90a 2022-07-09 op #define optreset BSDoptreset
880 f36fd90a 2022-07-09 op #define optarg BSDoptarg
881 f36fd90a 2022-07-09 op #define getopt BSDgetopt
883 f36fd90a 2022-07-09 op extern int BSDopterr, BSDoptind, BSDoptopt, BSDoptreset;
884 f36fd90a 2022-07-09 op extern char *BSDoptarg;
887 f36fd90a 2022-07-09 op #endif /*!OCONFIGURE_CONFIG_H*/
890 f36fd90a 2022-07-09 op echo "config.h: written" 1>&2
891 f36fd90a 2022-07-09 op echo "config.h: written" 1>&3
893 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
894 f36fd90a 2022-07-09 op # Now we go to generate our Makefile.configure.
895 f36fd90a 2022-07-09 op # This file is simply a bunch of Makefile variables.
896 f36fd90a 2022-07-09 op # They'll work in both GNUmakefile and BSDmakefile.
897 f36fd90a 2022-07-09 op # You MIGHT want to change this.
898 f36fd90a 2022-07-09 op #----------------------------------------------------------------------
900 f36fd90a 2022-07-09 op exec > Makefile.configure
902 f36fd90a 2022-07-09 op [ -z "${BINDIR}" ] && BINDIR="${PREFIX}/bin"
903 f36fd90a 2022-07-09 op [ -z "${SBINDIR}" ] && SBINDIR="${PREFIX}/sbin"
904 f36fd90a 2022-07-09 op [ -z "${INCLUDEDIR}" ] && INCLUDEDIR="${PREFIX}/include"
905 f36fd90a 2022-07-09 op [ -z "${LIBDIR}" ] && LIBDIR="${PREFIX}/lib"
906 f36fd90a 2022-07-09 op [ -z "${MANDIR}" ] && MANDIR="${PREFIX}/man"
907 f36fd90a 2022-07-09 op [ -z "${SHAREDIR}" ] && SHAREDIR="${PREFIX}/share"
909 f36fd90a 2022-07-09 op [ -z "${INSTALL_PROGRAM}" ] && INSTALL_PROGRAM="${INSTALL} -m 0555"
910 f36fd90a 2022-07-09 op [ -z "${INSTALL_LIB}" ] && INSTALL_LIB="${INSTALL} -m 0444"
911 f36fd90a 2022-07-09 op [ -z "${INSTALL_MAN}" ] && INSTALL_MAN="${INSTALL} -m 0444"
912 f36fd90a 2022-07-09 op [ -z "${INSTALL_DATA}" ] && INSTALL_DATA="${INSTALL} -m 0444"
914 f36fd90a 2022-07-09 op cat << __HEREDOC__
916 f36fd90a 2022-07-09 op CFLAGS = ${CFLAGS}
917 f36fd90a 2022-07-09 op CPPFLAGS = ${CPPFLAGS}
918 f36fd90a 2022-07-09 op LDADD = ${LDADD} ${LDADD_IMSG} ${LDADD_LIB_FLAC} ${LDADD_LIB_MPG123} \
919 f36fd90a 2022-07-09 op ${LDADD_LIB_OPUSFILE} ${LDADD_LIB_VORBISFILE} ${LDADD_LIB_SOCKET} \
920 f36fd90a 2022-07-09 op ${LDADD_LIBEVENT} ${LDADD_LIBEVENT2} ${LDADD_LIB_SNDIO}
921 f36fd90a 2022-07-09 op LDADD_STATIC = ${LDADD_STATIC}
922 f36fd90a 2022-07-09 op LDFLAGS = ${LDFLAGS}
923 f36fd90a 2022-07-09 op STATIC = ${STATIC}
924 f36fd90a 2022-07-09 op PREFIX = ${PREFIX}
925 f36fd90a 2022-07-09 op BINDIR = ${BINDIR}
926 f36fd90a 2022-07-09 op SHAREDIR = ${SHAREDIR}
927 f36fd90a 2022-07-09 op SBINDIR = ${SBINDIR}
928 f36fd90a 2022-07-09 op INCLUDEDIR = ${INCLUDEDIR}
929 f36fd90a 2022-07-09 op LIBDIR = ${LIBDIR}
930 f36fd90a 2022-07-09 op MANDIR = ${MANDIR}
931 f36fd90a 2022-07-09 op INSTALL = ${INSTALL}
932 f36fd90a 2022-07-09 op INSTALL_PROGRAM = ${INSTALL_PROGRAM}
933 f36fd90a 2022-07-09 op INSTALL_LIB = ${INSTALL_LIB}
934 f36fd90a 2022-07-09 op INSTALL_MAN = ${INSTALL_MAN}
935 f36fd90a 2022-07-09 op INSTALL_DATA = ${INSTALL_DATA}
938 f36fd90a 2022-07-09 op echo "Makefile.configure: written" 1>&2
939 f36fd90a 2022-07-09 op echo "Makefile.configure: written" 1>&3