3 # Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
4 # Copyright (c) 2017, 2018 Kristaps Dzonsons <kristaps@bsd.lv>
5 # Copyright (c) 2022, 2023 Omar Polo <op@omarpolo.com>
7 # Permission to use, copy, modify, and distribute this software for any
8 # purpose with or without fee is hereby granted, provided that the above
9 # copyright notice and this permission notice appear in all copies.
11 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 OCONFIGURE_VERSION="0.3.8"
22 # This script outputs two files: config.h and Makefile.configure.
23 # It tries to read from configure.local, which contains predefined
24 # values we won't autoconfigure.
26 # If you want to use configure with your project, have your GNUmakefile
27 # or BSDmakefile---whichever---try to import/include Makefile.configure
28 # at the beginning of the file.
30 # Like so (note no quotes, no period, etc.):
32 # include Makefile.configure
34 # If it exists, configure was run; otherwise, it wasn't.
36 # You'll probably want to change parts of this file. I've noted the
37 # parts that you'll probably change in the section documentation.
39 # See https://github.com/kristapsdz/oconfigure for more.
47 \`configure' configures amused to adapt to many kinds of systems.
49 Usage: $0 [-h] [--prefix=path] [VAR=VALUE]...
51 The options are as follows:
53 -h, --help print this help message
55 --prefix=path equivalent to specify the PREFIX variable, supported
56 for compatibility with other common "configure" scripts.
58 --backend=name equivalent to specify the BACKEND variable, can be either
63 BACKEND audio backend to use; can be "sndio" or "alsa"
64 LDADD generic linker flags
65 LDADD_IMSG linker flags for libimsg
66 LDADD_LIBEVENT linker flags for libevent
67 LDADD_LIBEVENT2 linker flags for libevent2
68 LDADD_LIBFLAC linker flags for libflac
69 LDADD_LIBMPG123 linker flags for libmpg123
70 LDADD_LIBOPUSFILE linker flags for libopusfile
71 LDADD_LIBVORBISFILE linker flags for libvorbisfile
72 LDADD_SNDIO linker flags for libsndio
73 LDADD_LIBSOCKET linker flags for libsocket
74 LDFLAGS extra linker flags
75 CPPFLAGS C preprocessors flags
76 DESTDIR destination directory
77 PREFIX where to install files
78 MANDIR where to install man pages (PREFIX/man)
79 LIBDIR where to install libraries (PREFIX/lib)
80 BINDIR where to install executables (PREFIX/bin)
81 SHAREDIR where to install misc files (PREFIX/share)
82 SBINDIR where to install system executables (PREFIX/sbin)
83 INCLUDEDIR where to install header files (PREFIX/include)
84 PKG_CONFIG pkg-config program, \`false' to disable (pkg-config)
86 Additionally, the following environment variables are used if set:
88 CC the C compiler to use (defaults to cc, clang or gcc)
89 CFLAGS generic C compiler flags
95 #----------------------------------------------------------------------
96 # Prepare for running: move aside previous configure runs.
97 # Output file descriptor usage:
98 # 1 (stdout): config.h or Makefile.configure
99 # 2 (stderr): original stderr, usually to the console
101 # You DO NOT want to change this.
102 #----------------------------------------------------------------------
104 [ -w config.log ] && mv config.log config.log.old
105 [ -w config.h ] && mv config.h config.h.old
108 echo "config.log: writing..."
110 # GNU submake prints different output if invoked recursively, which
111 # messes up CC and CFLAGS detection. Pass --no-print-directory if
112 # we have a MAKELEVEL (GNU and FreeBSD make) and the argument is
117 if [ -n "${MAKELEVEL}" ]; then
118 if [ "${MAKELEVEL}" -gt 0 ] ; then
119 MAKE_FLAGS="--no-print-directory"
120 echo "all:" | make ${MAKE_FLAGS} -sf - 2>/dev/null || MAKE_FLAGS=""
124 if [ -n "$MAKE_FLAGS" ]; then
125 echo "GNU submake detected: using --no-print-directory" 1>&2
126 echo "GNU submake detected: using --no-print-directory" 1>&3
129 #----------------------------------------------------------------------
130 # Initialize all variables here such that nothing can leak in from the
131 # environment except for CC and CFLAGS, which we might have passed in.
132 #----------------------------------------------------------------------
135 CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | make ${MAKE_FLAGS} -sf -`
136 CFLAGS=`printf "all:\\n\\t@echo \\\$(CFLAGS)\\n" | make ${MAKE_FLAGS} -sf -`
137 CFLAGS="${CFLAGS} -g -W -Wall -Wextra -Wmissing-prototypes"
138 CFLAGS="${CFLAGS} -Wstrict-prototypes -Wmissing-declarations"
139 CFLAGS="${CFLAGS} -Wno-unused-parameter -Wno-sign-compare"
146 LDADD_LIB_VORBISFILE=
168 # SunOS sets "cc", but this doesn't exist.
169 # It does have gcc, so try that instead.
170 # Prefer clang, though.
172 command -v ${CC} 2>/dev/null 1>&2 || {
173 echo "${CC} not found: trying clang" 1>&2
174 echo "${CC} not found: trying clang" 1>&3
176 command -v ${CC} 2>/dev/null 1>&2 || {
177 echo "${CC} not found: trying gcc" 1>&2
178 echo "${CC} not found: trying gcc" 1>&3
180 command -v ${CC} 2>/dev/null 1>&2 || {
181 echo "gcc not found: giving up" 1>&2
182 echo "gcc not found: giving up" 1>&3
188 command -v pkg-config 2>/dev/null 1>&2 && {
189 PKG_CONFIG=pkg-config
190 echo "pkg-config found" 1>&2
191 echo "pkg-config found" 1>&3
193 echo "pkg-config not found" 1>&2
194 echo "pkg-config not found" 1>&3
197 #----------------------------------------------------------------------
198 # Allow certain variables to be overriden on the command line.
199 #----------------------------------------------------------------------
201 while [ $# -gt 0 ]; do
205 if [ "$key" = "--prefix" ]; then
207 if [ "$1" = "--prefix" ]; then
208 if ! shift 2>&1 >/dev/null; then
209 echo "$0: missing value for --prefix" 1>&2
216 if [ "$key" = "--backend" ]; then
218 if [ "$1" = "--backend" ]; then
219 if ! shift 2>&1 >/dev/null; then
220 echo "$0 missing value for --backend" 1>&2
227 if [ "$1" = "$key" ]; then
228 echo "$0: invalid key-value: $1" 1>&2
237 alsa) BACKEND=alsa ;;
238 sndio) BACKEND=sndio ;;
240 echo "unknown audio backend: $val" 1>&2
248 LDADD_LIBEVENT="$val" ;;
250 LDADD_LIBEVENT2="$val" ;;
252 LDADD_LIBFLAC="$val" ;;
254 LDADD_LIBMPG123="$val" ;;
256 LDADD_LIBOPUSFILE="$val" ;;
258 LDADD_LIBVORBISFILE="$val" ;;
260 LDADD_SNDIO="$val" ;;
262 LDADD_LIBSOCKET="$val" ;;
286 echo "$0: invalid key: $key" 1>&2
292 #----------------------------------------------------------------------
293 # These are the values that will be pushed into config.h after we test
294 # for whether they're supported or not.
295 # Each of these must have a runtest(), below.
296 # Please sort by alpha, for clarity.
297 # You WANT to change this.
298 #----------------------------------------------------------------------
312 HAVE_LIBEVENT2=0 # may not be checked, set to zero
326 HAVE_PROGRAM_INVOCATION_SHORT_NAME=
345 #----------------------------------------------------------------------
346 # Allow configure.local to override all variables, default settings,
347 # command-line arguments, and tested features, above.
348 # You PROBABLY DO NOT want to change this.
349 #----------------------------------------------------------------------
351 if [ -r ./configure.local ]; then
352 echo "configure.local: reading..." 1>&2
353 echo "configure.local: reading..." 1>&3
354 cat ./configure.local 1>&3
357 echo "configure.local: no (fully automatic configuration)" 1>&2
358 echo "configure.local: no (fully automatic configuration)" 1>&3
363 #----------------------------------------------------------------------
364 # Infrastructure for running tests.
365 # These consists of a series of functions that will attempt to run the
366 # given test file and record its exit into a HAVE_xxx variable.
367 # You DO NOT want to change this.
368 #----------------------------------------------------------------------
370 COMP="${CC} ${CFLAGS} ${CPPFLAGS} -Wno-unused -Werror"
372 # Check whether this HAVE_ setting is manually overridden.
373 # If yes, use the override, if no, do not decide anything yet.
374 # Arguments: lower-case test name, manual value
377 [ -z "${3}" ] && return 1
378 echo "${1}: manual (HAVE_${2}=${3})" 1>&2
379 echo "${1}: manual (HAVE_${2}=${3})" 1>&3
384 # Run a single autoconfiguration test.
385 # In case of success, enable the feature.
386 # In case of failure, do not decide anything yet.
387 # Arguments: lower-case test name, upper-case test name, additional
388 # CFLAGS, additional LIBS.
395 cat 1>&3 << __HEREDOC__
397 ${COMP} -DTEST_${2} ${3} -o test-${1} tests.c ${LDFLAGS} ${4}
399 if ${COMP} -DTEST_${2} ${3} -o "test-${1}" tests.c ${LDFLAGS} ${4} 1>&3 2>&3; then
400 echo "${1}: ${CC} succeeded" 1>&3
402 if [ -n "${5}" ] ; then
403 echo "${1}: ${CC} failed with $? (retrying)" 1>&3
404 cat 1>&3 << __HEREDOC__
406 ${COMP} -DTEST_${2} ${3} -o test-${1} tests.c ${LDFLAGS} ${5}
408 if ${COMP} -DTEST_${2} ${3} -o "test-${1}" tests.c ${LDFLAGS} ${5} 1>&3 2>&3; then
409 echo "${1}: ${CC} succeeded" 1>&3
410 extralib="(with ${5})"
412 test -n "${PKG_CONFIG}" -a -n "${6}" && ${PKG_CONFIG} "$6"
413 if [ $? -eq 0 ]; then
414 echo "${1}: ${CC} failed with $? (retrying)" 1>&3
415 pkgcfs=$($PKG_CONFIG --cflags "${6}")
416 pkglib=$($PKG_CONFIG --libs "${6}")
417 cat 1>&3 << __HEREDOC__
419 ${COMP} -DTEST_${2} ${3} ${pkgcfs} -o test-${1} tests.c ${LDFLAGS} ${pkglib}
421 if ${COMP} -DTEST_${2} ${3} ${pkgcfs} -o test-${1} tests.c ${LDFLAGS} ${pkglib} 1>&3 2>&3; then
422 echo "${1}: ${CC} succeeded" 1>&3
423 extralib="(with ${pkgcfs} ${pkglib})"
425 echo "${1}: ${CC} failed with $?" 1>&3
430 echo "${1}: ${CC} failed with $?" 1>&3
436 echo "${1}: ${CC} failed with $?" 1>&3
444 if [ -n "${pkgcfs}" -o -n "${pkglib}" ]
446 CFLAGS="${CFLAGS} ${pkgcfs}"
447 eval "LDADD_${2}=\"${pkglib}\""
448 elif [ -n "${extralib}" ]
450 eval "LDADD_${2}=\"${5}\""
453 eval "LDADD_${2}=\"${4}\""
456 echo "${1}: yes ${extralib}" 1>&2
457 echo "${1}: yes ${extralib}" 1>&3
464 # Run a complete autoconfiguration test, including the check for
465 # a manual override and disabling the feature on failure.
466 # Arguments: lower case name, upper case name, additional CFLAGS,
467 # additional LDADD, alternative LDADD, pkg-config name.
470 eval _manual=\${HAVE_${2}}
471 ismanual "${1}" "${2}" "${_manual}" && return 0
472 singletest "${1}" "${2}" "${3}" "${4}" "${5}" "${6}" && return 0
478 #----------------------------------------------------------------------
479 # Begin running the tests themselves.
480 # All of your tests must be defined here.
481 # Please sort as the HAVE_xxxx values were defined.
482 # You WANT to change this.
483 # It consists of the following columns:
487 # (3) argument to cc *before* -o
488 # (4) argument to cc *after*
489 # (5) alternative argument to cc *after*
490 # (6) name for pkg-config auto-discovery
491 #----------------------------------------------------------------------
493 if runtest -MMD _MMD -MMD; then
494 CFLAGS="${CFLAGS} -MMD"
495 echo "adding -MMD to CFLAGS" 1>&2
496 echo "adding -MMD to CFLAGS" 1>&3
499 runtest capsicum CAPSICUM || true
500 runtest err ERR || true
501 runtest explicit_bzero EXPLICIT_BZERO || true
502 runtest flock FLOCK || true
503 runtest freezero FREEZERO || true
504 runtest getdtablecount GETDTABLECOUNT || true
505 runtest getexecname GETEXECNAME || true
506 runtest getprogname GETPROGNAME || true
507 runtest imsg IMSG "" "" "-lutil" || true
508 runtest INFTIM INFTIM || true
509 runtest landlock LANDLOCK || true
511 runtest libevent LIBEVENT "" "" "-levent" || \
512 runtest libevent2 LIBEVENT2 "" "" "-levent_extra -levent_core" "libevent" || true
514 runtest lib_flac LIB_FLAC "" "" "-lFLAC" "flac" || true
515 runtest lib_mpg123 LIB_MPG123 "" "" "-lmpg123" "libmpg123" || true
516 runtest lib_opusfile LIB_OPUSFILE "" "" "-lopusfile" "opusfile" || true
517 runtest lib_vorbisfile LIB_VORBISFILE "" "" "-lvorbisfile" "vorbisfile" || true
519 runtest lib_socket LIB_SOCKET "" "" "-lsocket -lnsl" || true
520 runtest memmem MEMMEM || true
521 runtest memrchr MEMRCHR || true
522 runtest memset_s MEMSET_S || true
523 runtest optreset OPTRESET || true
524 runtest PATH_MAX PATH_MAX || true
525 runtest pledge PLEDGE || true
526 runtest program_invocation_short_name PROGRAM_INVOCATION_SHORT_NAME || true
527 runtest PR_SET_NAME PR_SET_NAME || true
528 runtest reallocarray REALLOCARRAY || true
529 runtest recallocarray RECALLOCARRAY || true
530 runtest sandbox_init SANDBOX_INIT "-Wno-deprecated" || true
531 runtest setproctitle SETPROCTITLE || true
532 runtest SOCK_NONBLOCK SOCK_NONBLOCK || true
533 runtest static STATIC "" "-static" || true
534 runtest strlcat STRLCAT || true
535 runtest strlcpy STRLCPY || true
536 runtest strndup STRNDUP || true
537 runtest strnlen STRNLEN || true
538 runtest strtonum STRTONUM || true
539 runtest sys_queue SYS_QUEUE || true
540 runtest sys_file SYS_FILE || true
541 runtest unveil UNVEIL || true
542 runtest __progname __PROGNAME || true
544 if [ $BACKEND != alsa ]; then # auto or sndio
545 runtest lib_sndio LIB_SNDIO "" "" "-lsndio" "sndio" || true
546 runtest sio_flush SIO_FLUSH "" "" "${LDADD_LIB_SNDIO}" || true
548 if [ "${HAVE_LIB_SNDIO}" -eq 0 ]; then
549 if [ $BACKEND = sndio ]; then
550 echo "Fatal: missing libsndio" 1>&2
551 echo "Fatal: missing libsndio" 1>&3
561 if [ $BACKEND != sndio ]; then # auto or alsa
562 runtest lib_asound LIB_ASOUND "" "" "-lasound" "alsa" || true
563 if [ "${HAVE_LIB_ASOUND}" -eq 0 ]; then
564 if [ $BACKEND = alsa ]; then
565 echo "Fatal: missing libasound" 1>&2
566 echo "Fatal: missing libasound" 1>&3
568 echo "Fatal: missing libasound or libsndio" 1>&2
569 echo "Fatal: missing libasound or libsndio" 1>&3
576 if [ "${HAVE_LIBEVENT}" -eq 0 -a "${HAVE_LIBEVENT2}" -eq 0 ]; then
577 echo "Fatal: missing libevent" 1>&2
578 echo "Fatal: missing libevent" 1>&3
582 if [ "${HAVE_LIB_FLAC}" -eq 0 -o \
583 "${HAVE_LIB_MPG123}" -eq 0 -o \
584 "${HAVE_LIB_OPUSFILE}" -eq 0 -o \
585 "${HAVE_LIB_VORBISFILE}" -eq 0 ]; then
586 echo "Fatal: missing required audio libraries" 1>&2
587 echo "Fatal: missing required audio libraries" 1>&3
591 #----------------------------------------------------------------------
592 # Output writing: generate the config.h file.
593 # This file contains all of the HAVE_xxxx variables necessary for
594 # compiling your source.
595 # You must include "config.h" BEFORE any other variables.
596 # You WANT to change this.
597 #----------------------------------------------------------------------
601 # Start with prologue.
604 #ifndef OCONFIGURE_CONFIG_H
605 #define OCONFIGURE_CONFIG_H
608 # error "Do not use C++: this is a C application."
610 #if !defined(__GNUC__) || (__GNUC__ < 4)
611 # define __attribute__(x)
613 #if defined(__linux__) || defined(__MINT__)
614 # define _GNU_SOURCE /* memmem, memrchr, setresuid... */
615 # define _DEFAULT_SOURCE /* le32toh, crypt, ... */
617 #if defined(__NetBSD__)
618 # define _OPENBSD_SOURCE /* reallocarray, etc. */
621 # ifndef _XOPEN_SOURCE /* SunOS already defines */
622 # define _XOPEN_SOURCE /* XPGx */
624 # define _XOPEN_SOURCE_EXTENDED 1 /* XPG4v2 */
625 # ifndef __EXTENSIONS__ /* SunOS already defines */
626 # define __EXTENSIONS__ /* reallocarray, etc. */
629 #if !defined(__BEGIN_DECLS)
630 # define __BEGIN_DECLS
632 #if !defined(__END_DECLS)
638 # This is just for size_t, mode_t, and dev_t.
639 # Most of these functions, in the real world, pull in <string.h> or
640 # someting that pulls in support for size_t.
641 # Our function declarations are standalone, so specify them here.
643 if [ ${HAVE_IMSG} -eq 0 -o \
644 ${HAVE_MEMMEM} -eq 0 -o \
645 ${HAVE_MEMRCHR} -eq 0 -o \
646 ${HAVE_REALLOCARRAY} -eq 0 -o \
647 ${HAVE_RECALLOCARRAY} -eq 0 -o \
648 ${HAVE_STRLCAT} -eq 0 -o \
649 ${HAVE_STRLCPY} -eq 0 -o \
650 ${HAVE_STRNDUP} -eq 0 -o \
651 ${HAVE_STRNLEN} -eq 0 ]
653 echo "#include <sys/types.h> /* size_t, mode_t, dev_t */ "
657 if [ ${HAVE_FLOCK} -eq 0 ]; then
658 if [ ${HAVE_SYS_FILE} -eq 0 ]; then
660 echo "#include <sys/file.h>"
663 echo "int flock(int, int);"
664 echo "#define LOCK_SH 0x1"
665 echo "#define LOCK_EX 0x2"
666 echo "#define LOCK_NB 0x4"
671 if [ ${HAVE_ERR} -eq 0 ]; then
672 echo "#include <stdarg.h> /* err(3) */"
675 echo "#include <err.h>"
679 if [ ${HAVE_PLEDGE} -eq 0 ]; then
680 echo "#define pledge(p, e) (0)"
683 echo "#include <unistd.h>"
687 # Now we handle our HAVE_xxxx values.
688 # Most will just be defined as 0 or 1.
690 if [ ${HAVE_PATH_MAX} -eq 0 ]
692 echo "#define PATH_MAX 4096"
696 if [ ${HAVE_INFTIM} -eq 0 ]
698 echo "#define INFTIM (-1) /* poll.h */"
704 * Results of configuration feature-testing.
706 #define HAVE_CAPSICUM ${HAVE_CAPSICUM}
707 #define HAVE_ERR ${HAVE_ERR}
708 #define HAVE_EXPLICIT_BZERO ${HAVE_EXPLICIT_BZERO}
709 #define HAVE_FLOCK ${HAVE_FLOCK}
710 #define HAVE_FREEZERO ${HAVE_FREEZERO}
711 #define HAVE_GETDTABLECOUNT ${HAVE_GETDTABLECOUNT}
712 #define HAVE_GETEXECNAME ${HAVE_GETEXECNAME}
713 #define HAVE_GETPROGNAME ${HAVE_GETPROGNAME}
714 #define HAVE_INFTIM ${HAVE_INFTIM}
715 #define HAVE_LANDLOCK ${HAVE_LANDLOCK}
716 #define HAVE_MEMMEM ${HAVE_MEMMEM}
717 #define HAVE_MEMRCHR ${HAVE_MEMRCHR}
718 #define HAVE_MEMSET_S ${HAVE_MEMSET_S}
719 #define HAVE_OPTRESET ${HAVE_OPTRESET}
720 #define HAVE_PATH_MAX ${HAVE_PATH_MAX}
721 #define HAVE_PLEDGE ${HAVE_PLEDGE}
722 #define HAVE_PROGRAM_INVOCATION_SHORT_NAME ${HAVE_PROGRAM_INVOCATION_SHORT_NAME}
723 #define HAVE_PR_SET_NAME ${HAVE_PR_SET_NAME}
724 #define HAVE_REALLOCARRAY ${HAVE_REALLOCARRAY}
725 #define HAVE_RECALLOCARRAY ${HAVE_RECALLOCARRAY}
726 #define HAVE_SANDBOX_INIT ${HAVE_SANDBOX_INIT}
727 #define HAVE_SETPROCTITLE ${HAVE_SETPROCTITLE}
728 #define HAVE_SIO_FLUSH ${HAVE_SIO_FLUSH}
729 #define HAVE_SOCK_NONBLOCK ${HAVE_SOCK_NONBLOCK}
730 #define HAVE_STRLCAT ${HAVE_STRLCAT}
731 #define HAVE_STRLCPY ${HAVE_STRLCPY}
732 #define HAVE_STRNDUP ${HAVE_STRNDUP}
733 #define HAVE_STRNLEN ${HAVE_STRNLEN}
734 #define HAVE_STRTONUM ${HAVE_STRTONUM}
735 #define HAVE_SYS_FILE ${HAVE_SYS_FILE}
736 #define HAVE_SYS_QUEUE ${HAVE_SYS_QUEUE}
737 #define HAVE_SYSTRACE ${HAVE_SYSTRACE}
738 #define HAVE_UNVEIL ${HAVE_UNVEIL}
739 #define HAVE___PROGNAME ${HAVE___PROGNAME}
743 # Now we do our function declarations for missing functions.
745 [ ${HAVE_ERR} -eq 0 ] && \
748 * Compatibility functions for err(3).
750 extern void err(int, const char *, ...) __attribute__((noreturn));
751 extern void errc(int, int, const char *, ...) __attribute__((noreturn));
752 extern void errx(int, const char *, ...) __attribute__((noreturn));
753 extern void verr(int, const char *, va_list) __attribute__((noreturn));
754 extern void verrc(int, int, const char *, va_list) __attribute__((noreturn));
755 extern void verrx(int, const char *, va_list) __attribute__((noreturn));
756 extern void warn(const char *, ...);
757 extern void warnx(const char *, ...);
758 extern void warnc(int, const char *, ...);
759 extern void vwarn(const char *, va_list);
760 extern void vwarnc(int, const char *, va_list);
761 extern void vwarnx(const char *, va_list);
764 [ ${HAVE_EXPLICIT_BZERO} -eq 0 ] && \
767 * Compatibility for explicit_bzero(3).
769 extern void explicit_bzero(void *, size_t);
773 [ ${HAVE_FREEZERO} -eq 0 ] && \
776 * Compatibility for freezero(3).
778 extern void freezero(void *, size_t);
782 [ ${HAVE_MEMMEM} -eq 0 ] && \
785 * Compatibility for memmem(3).
787 void *memmem(const void *, size_t, const void *, size_t);
791 [ ${HAVE_MEMRCHR} -eq 0 ] && \
794 * Compatibility for memrchr(3).
796 void *memrchr(const void *b, int, size_t);
800 [ ${HAVE_GETPROGNAME} -eq 0 ] && \
803 * Compatibility for getprogname(3).
805 extern const char *getprogname(void);
809 [ ${HAVE_REALLOCARRAY} -eq 0 ] && \
812 * Compatibility for reallocarray(3).
814 extern void *reallocarray(void *, size_t, size_t);
818 [ ${HAVE_RECALLOCARRAY} -eq 0 ] && \
821 * Compatibility for recallocarray(3).
823 extern void *recallocarray(void *, size_t, size_t, size_t);
827 [ ${HAVE_SETPROCTITLE} -eq 0 ] && \
830 * Compatibility for setproctitle(3).
832 extern void setproctitle(const char *, ...);
836 [ ${HAVE_STRLCAT} -eq 0 ] && \
839 * Compatibility for strlcat(3).
841 extern size_t strlcat(char *, const char *, size_t);
845 [ ${HAVE_STRLCPY} -eq 0 ] && \
848 * Compatibility for strlcpy(3).
850 extern size_t strlcpy(char *, const char *, size_t);
854 [ ${HAVE_STRNDUP} -eq 0 ] && \
857 * Compatibility for strndup(3).
859 extern char *strndup(const char *, size_t);
863 [ ${HAVE_STRNLEN} -eq 0 ] && \
866 * Compatibility for strnlen(3).
868 extern size_t strnlen(const char *, size_t);
872 [ ${HAVE_STRTONUM} -eq 0 ] && \
875 * Compatibility for strotnum(3).
877 extern long long strtonum(const char *, long long, long long, const char **);
881 if [ ${HAVE_SYS_QUEUE} -eq 0 ]; then
886 echo "#include <sys/queue.h>"
890 echo "#include <sys/uio.h>"
891 echo "#include <stdint.h>"
892 if [ ${HAVE_IMSG} -eq 0 ]; then
893 echo "#include \"imsg.h\""
895 echo "#include <imsg.h>"
899 if [ "${HAVE_LIBEVENT2}" -eq 1 ]; then
901 #include <event2/event.h>
902 #include <event2/event_compat.h>
903 #include <event2/event_struct.h>
904 #include <event2/buffer.h>
905 #include <event2/buffer_compat.h>
906 #include <event2/bufferevent.h>
907 #include <event2/bufferevent_struct.h>
908 #include <event2/bufferevent_compat.h>
911 elif [ "${HAVE_LIBEVENT}" -eq 1 ]; then
920 # define __dead __attribute__((noreturn))
924 #define sio_flush(hdl) (sio_stop(hdl))
927 #if !HAVE_GETDTABLECOUNT
928 /* XXX: on linux it should be possible to inspect /proc/self/fd/ */
929 #define getdtablecount() (0)
933 /* replace host' getopt with OpenBSD' one */
934 #define opterr BSDopterr
935 #define optind BSDoptind
936 #define optopt BSDoptopt
937 #define optreset BSDoptreset
938 #define optarg BSDoptarg
939 #define getopt BSDgetopt
941 extern int BSDopterr, BSDoptind, BSDoptopt, BSDoptreset;
942 extern char *BSDoptarg;
945 #endif /*!OCONFIGURE_CONFIG_H*/
948 echo "config.h: written" 1>&2
949 echo "config.h: written" 1>&3
951 #----------------------------------------------------------------------
952 # Now we go to generate our Makefile.configure.
953 # This file is simply a bunch of Makefile variables.
954 # They'll work in both GNUmakefile and BSDmakefile.
955 # You MIGHT want to change this.
956 #----------------------------------------------------------------------
958 exec > Makefile.configure
960 [ -z "${BINDIR}" ] && BINDIR="${PREFIX}/bin"
961 [ -z "${SBINDIR}" ] && SBINDIR="${PREFIX}/sbin"
962 [ -z "${INCLUDEDIR}" ] && INCLUDEDIR="${PREFIX}/include"
963 [ -z "${LIBDIR}" ] && LIBDIR="${PREFIX}/lib"
964 [ -z "${MANDIR}" ] && MANDIR="${PREFIX}/man"
965 [ -z "${SHAREDIR}" ] && SHAREDIR="${PREFIX}/share"
967 [ -z "${INSTALL_PROGRAM}" ] && INSTALL_PROGRAM="${INSTALL} -m 0555"
968 [ -z "${INSTALL_LIB}" ] && INSTALL_LIB="${INSTALL} -m 0444"
969 [ -z "${INSTALL_MAN}" ] && INSTALL_MAN="${INSTALL} -m 0444"
970 [ -z "${INSTALL_DATA}" ] && INSTALL_DATA="${INSTALL} -m 0444"
976 CPPFLAGS = ${CPPFLAGS}
977 LDADD = ${LDADD} ${LDADD_IMSG} ${LDADD_LIB_FLAC} ${LDADD_LIB_MPG123} \
978 ${LDADD_LIB_OPUSFILE} ${LDADD_LIB_VORBISFILE} \
979 ${LDADD_LIB_SOCKET} ${LDADD_LIBEVENT} ${LDADD_LIBEVENT2} \
980 ${LDADD_LIB_SNDIO} ${LDADD_LIB_ASOUND}
981 LDADD_STATIC = ${LDADD_STATIC}
986 SHAREDIR = ${SHAREDIR}
988 INCLUDEDIR = ${INCLUDEDIR}
992 INSTALL_PROGRAM = ${INSTALL_PROGRAM}
993 INSTALL_LIB = ${INSTALL_LIB}
994 INSTALL_MAN = ${INSTALL_MAN}
995 INSTALL_DATA = ${INSTALL_DATA}
998 echo "Makefile.configure: written" 1>&2
999 echo "Makefile.configure: written" 1>&3