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
559 if [ $BACKEND != sndio ]; then # auto or alsa
560 runtest lib_asound LIB_ASOUND "" "" "-lasound" "alsa" || true
561 if [ "${HAVE_LIB_ASOUND}" -eq 0 ]; then
562 if [ $BACKEND = alsa ]; then
563 echo "Fatal: missing libasound" 1>&2
564 echo "Fatal: missing libasound" 1>&3
566 echo "Fatal: missing libasound or libsndio" 1>&2
567 echo "Fatal: missing libasound or libsndio" 1>&3
574 if [ "${HAVE_LIBEVENT}" -eq 0 -a "${HAVE_LIBEVENT2}" -eq 0 ]; then
575 echo "Fatal: missing libevent" 1>&2
576 echo "Fatal: missing libevent" 1>&3
580 if [ "${HAVE_LIB_FLAC}" -eq 0 -o \
581 "${HAVE_LIB_MPG123}" -eq 0 -o \
582 "${HAVE_LIB_OPUSFILE}" -eq 0 -o \
583 "${HAVE_LIB_VORBISFILE}" -eq 0 ]; then
584 echo "Fatal: missing required audio libraries" 1>&2
585 echo "Fatal: missing required audio libraries" 1>&3
589 #----------------------------------------------------------------------
590 # Output writing: generate the config.h file.
591 # This file contains all of the HAVE_xxxx variables necessary for
592 # compiling your source.
593 # You must include "config.h" BEFORE any other variables.
594 # You WANT to change this.
595 #----------------------------------------------------------------------
599 # Start with prologue.
602 #ifndef OCONFIGURE_CONFIG_H
603 #define OCONFIGURE_CONFIG_H
606 # error "Do not use C++: this is a C application."
608 #if !defined(__GNUC__) || (__GNUC__ < 4)
609 # define __attribute__(x)
611 #if defined(__linux__) || defined(__MINT__)
612 # define _GNU_SOURCE /* memmem, memrchr, setresuid... */
613 # define _DEFAULT_SOURCE /* le32toh, crypt, ... */
615 #if defined(__NetBSD__)
616 # define _OPENBSD_SOURCE /* reallocarray, etc. */
619 # ifndef _XOPEN_SOURCE /* SunOS already defines */
620 # define _XOPEN_SOURCE /* XPGx */
622 # define _XOPEN_SOURCE_EXTENDED 1 /* XPG4v2 */
623 # ifndef __EXTENSIONS__ /* SunOS already defines */
624 # define __EXTENSIONS__ /* reallocarray, etc. */
627 #if !defined(__BEGIN_DECLS)
628 # define __BEGIN_DECLS
630 #if !defined(__END_DECLS)
636 # This is just for size_t, mode_t, and dev_t.
637 # Most of these functions, in the real world, pull in <string.h> or
638 # someting that pulls in support for size_t.
639 # Our function declarations are standalone, so specify them here.
641 if [ ${HAVE_IMSG} -eq 0 -o \
642 ${HAVE_MEMMEM} -eq 0 -o \
643 ${HAVE_MEMRCHR} -eq 0 -o \
644 ${HAVE_REALLOCARRAY} -eq 0 -o \
645 ${HAVE_RECALLOCARRAY} -eq 0 -o \
646 ${HAVE_STRLCAT} -eq 0 -o \
647 ${HAVE_STRLCPY} -eq 0 -o \
648 ${HAVE_STRNDUP} -eq 0 -o \
649 ${HAVE_STRNLEN} -eq 0 ]
651 echo "#include <sys/types.h> /* size_t, mode_t, dev_t */ "
655 if [ ${HAVE_FLOCK} -eq 0 ]; then
656 if [ ${HAVE_SYS_FILE} -eq 0 ]; then
658 echo "#include <sys/file.h>"
661 echo "int flock(int, int);"
662 echo "#define LOCK_SH 0x1"
663 echo "#define LOCK_EX 0x2"
664 echo "#define LOCK_NB 0x4"
669 if [ ${HAVE_ERR} -eq 0 ]; then
670 echo "#include <stdarg.h> /* err(3) */"
673 echo "#include <err.h>"
677 if [ ${HAVE_PLEDGE} -eq 0 ]; then
678 echo "#define pledge(p, e) (0)"
681 echo "#include <unistd.h>"
685 # Now we handle our HAVE_xxxx values.
686 # Most will just be defined as 0 or 1.
688 if [ ${HAVE_PATH_MAX} -eq 0 ]
690 echo "#define PATH_MAX 4096"
694 if [ ${HAVE_INFTIM} -eq 0 ]
696 echo "#define INFTIM (-1) /* poll.h */"
702 * Results of configuration feature-testing.
704 #define HAVE_CAPSICUM ${HAVE_CAPSICUM}
705 #define HAVE_ERR ${HAVE_ERR}
706 #define HAVE_EXPLICIT_BZERO ${HAVE_EXPLICIT_BZERO}
707 #define HAVE_FLOCK ${HAVE_FLOCK}
708 #define HAVE_FREEZERO ${HAVE_FREEZERO}
709 #define HAVE_GETDTABLECOUNT ${HAVE_GETDTABLECOUNT}
710 #define HAVE_GETEXECNAME ${HAVE_GETEXECNAME}
711 #define HAVE_GETPROGNAME ${HAVE_GETPROGNAME}
712 #define HAVE_INFTIM ${HAVE_INFTIM}
713 #define HAVE_LANDLOCK ${HAVE_LANDLOCK}
714 #define HAVE_MEMMEM ${HAVE_MEMMEM}
715 #define HAVE_MEMRCHR ${HAVE_MEMRCHR}
716 #define HAVE_MEMSET_S ${HAVE_MEMSET_S}
717 #define HAVE_OPTRESET ${HAVE_OPTRESET}
718 #define HAVE_PATH_MAX ${HAVE_PATH_MAX}
719 #define HAVE_PLEDGE ${HAVE_PLEDGE}
720 #define HAVE_PROGRAM_INVOCATION_SHORT_NAME ${HAVE_PROGRAM_INVOCATION_SHORT_NAME}
721 #define HAVE_PR_SET_NAME ${HAVE_PR_SET_NAME}
722 #define HAVE_REALLOCARRAY ${HAVE_REALLOCARRAY}
723 #define HAVE_RECALLOCARRAY ${HAVE_RECALLOCARRAY}
724 #define HAVE_SANDBOX_INIT ${HAVE_SANDBOX_INIT}
725 #define HAVE_SETPROCTITLE ${HAVE_SETPROCTITLE}
726 #define HAVE_SIO_FLUSH ${HAVE_SIO_FLUSH}
727 #define HAVE_SOCK_NONBLOCK ${HAVE_SOCK_NONBLOCK}
728 #define HAVE_STRLCAT ${HAVE_STRLCAT}
729 #define HAVE_STRLCPY ${HAVE_STRLCPY}
730 #define HAVE_STRNDUP ${HAVE_STRNDUP}
731 #define HAVE_STRNLEN ${HAVE_STRNLEN}
732 #define HAVE_STRTONUM ${HAVE_STRTONUM}
733 #define HAVE_SYS_FILE ${HAVE_SYS_FILE}
734 #define HAVE_SYS_QUEUE ${HAVE_SYS_QUEUE}
735 #define HAVE_SYSTRACE ${HAVE_SYSTRACE}
736 #define HAVE_UNVEIL ${HAVE_UNVEIL}
737 #define HAVE___PROGNAME ${HAVE___PROGNAME}
741 # Now we do our function declarations for missing functions.
743 [ ${HAVE_ERR} -eq 0 ] && \
746 * Compatibility functions for err(3).
748 extern void err(int, const char *, ...) __attribute__((noreturn));
749 extern void errc(int, int, const char *, ...) __attribute__((noreturn));
750 extern void errx(int, const char *, ...) __attribute__((noreturn));
751 extern void verr(int, const char *, va_list) __attribute__((noreturn));
752 extern void verrc(int, int, const char *, va_list) __attribute__((noreturn));
753 extern void verrx(int, const char *, va_list) __attribute__((noreturn));
754 extern void warn(const char *, ...);
755 extern void warnx(const char *, ...);
756 extern void warnc(int, const char *, ...);
757 extern void vwarn(const char *, va_list);
758 extern void vwarnc(int, const char *, va_list);
759 extern void vwarnx(const char *, va_list);
762 [ ${HAVE_EXPLICIT_BZERO} -eq 0 ] && \
765 * Compatibility for explicit_bzero(3).
767 extern void explicit_bzero(void *, size_t);
771 [ ${HAVE_FREEZERO} -eq 0 ] && \
774 * Compatibility for freezero(3).
776 extern void freezero(void *, size_t);
780 [ ${HAVE_MEMMEM} -eq 0 ] && \
783 * Compatibility for memmem(3).
785 void *memmem(const void *, size_t, const void *, size_t);
789 [ ${HAVE_MEMRCHR} -eq 0 ] && \
792 * Compatibility for memrchr(3).
794 void *memrchr(const void *b, int, size_t);
798 [ ${HAVE_GETPROGNAME} -eq 0 ] && \
801 * Compatibility for getprogname(3).
803 extern const char *getprogname(void);
807 [ ${HAVE_REALLOCARRAY} -eq 0 ] && \
810 * Compatibility for reallocarray(3).
812 extern void *reallocarray(void *, size_t, size_t);
816 [ ${HAVE_RECALLOCARRAY} -eq 0 ] && \
819 * Compatibility for recallocarray(3).
821 extern void *recallocarray(void *, size_t, size_t, size_t);
825 [ ${HAVE_SETPROCTITLE} -eq 0 ] && \
828 * Compatibility for setproctitle(3).
830 extern void setproctitle(const char *, ...);
834 [ ${HAVE_STRLCAT} -eq 0 ] && \
837 * Compatibility for strlcat(3).
839 extern size_t strlcat(char *, const char *, size_t);
843 [ ${HAVE_STRLCPY} -eq 0 ] && \
846 * Compatibility for strlcpy(3).
848 extern size_t strlcpy(char *, const char *, size_t);
852 [ ${HAVE_STRNDUP} -eq 0 ] && \
855 * Compatibility for strndup(3).
857 extern char *strndup(const char *, size_t);
861 [ ${HAVE_STRNLEN} -eq 0 ] && \
864 * Compatibility for strnlen(3).
866 extern size_t strnlen(const char *, size_t);
870 [ ${HAVE_STRTONUM} -eq 0 ] && \
873 * Compatibility for strotnum(3).
875 extern long long strtonum(const char *, long long, long long, const char **);
879 if [ ${HAVE_SYS_QUEUE} -eq 0 ]; then
884 echo "#include <sys/queue.h>"
888 echo "#include <sys/uio.h>"
889 echo "#include <stdint.h>"
890 if [ ${HAVE_IMSG} -eq 0 ]; then
891 echo "#include \"imsg.h\""
893 echo "#include <imsg.h>"
897 if [ "${HAVE_LIBEVENT2}" -eq 1 ]; then
899 #include <event2/event.h>
900 #include <event2/event_compat.h>
901 #include <event2/event_struct.h>
902 #include <event2/buffer.h>
903 #include <event2/buffer_compat.h>
904 #include <event2/bufferevent.h>
905 #include <event2/bufferevent_struct.h>
906 #include <event2/bufferevent_compat.h>
909 elif [ "${HAVE_LIBEVENT}" -eq 1 ]; then
918 # define __dead __attribute__((noreturn))
922 #define sio_flush(hdl) (sio_stop(hdl))
925 #if !HAVE_GETDTABLECOUNT
926 /* XXX: on linux it should be possible to inspect /proc/self/fd/ */
927 #define getdtablecount() (0)
931 /* replace host' getopt with OpenBSD' one */
932 #define opterr BSDopterr
933 #define optind BSDoptind
934 #define optopt BSDoptopt
935 #define optreset BSDoptreset
936 #define optarg BSDoptarg
937 #define getopt BSDgetopt
939 extern int BSDopterr, BSDoptind, BSDoptopt, BSDoptreset;
940 extern char *BSDoptarg;
943 #endif /*!OCONFIGURE_CONFIG_H*/
946 echo "config.h: written" 1>&2
947 echo "config.h: written" 1>&3
949 #----------------------------------------------------------------------
950 # Now we go to generate our Makefile.configure.
951 # This file is simply a bunch of Makefile variables.
952 # They'll work in both GNUmakefile and BSDmakefile.
953 # You MIGHT want to change this.
954 #----------------------------------------------------------------------
956 exec > Makefile.configure
958 [ -z "${BINDIR}" ] && BINDIR="${PREFIX}/bin"
959 [ -z "${SBINDIR}" ] && SBINDIR="${PREFIX}/sbin"
960 [ -z "${INCLUDEDIR}" ] && INCLUDEDIR="${PREFIX}/include"
961 [ -z "${LIBDIR}" ] && LIBDIR="${PREFIX}/lib"
962 [ -z "${MANDIR}" ] && MANDIR="${PREFIX}/man"
963 [ -z "${SHAREDIR}" ] && SHAREDIR="${PREFIX}/share"
965 [ -z "${INSTALL_PROGRAM}" ] && INSTALL_PROGRAM="${INSTALL} -m 0555"
966 [ -z "${INSTALL_LIB}" ] && INSTALL_LIB="${INSTALL} -m 0444"
967 [ -z "${INSTALL_MAN}" ] && INSTALL_MAN="${INSTALL} -m 0444"
968 [ -z "${INSTALL_DATA}" ] && INSTALL_DATA="${INSTALL} -m 0444"
974 CPPFLAGS = ${CPPFLAGS}
975 LDADD = ${LDADD} ${LDADD_IMSG} ${LDADD_LIB_FLAC} ${LDADD_LIB_MPG123} \
976 ${LDADD_LIB_OPUSFILE} ${LDADD_LIB_VORBISFILE} \
977 ${LDADD_LIB_SOCKET} ${LDADD_LIBEVENT} ${LDADD_LIBEVENT2} \
978 ${LDADD_LIB_SNDIO} ${LDADD_LIB_ASOUND}
979 LDADD_STATIC = ${LDADD_STATIC}
984 SHAREDIR = ${SHAREDIR}
986 INCLUDEDIR = ${INCLUDEDIR}
990 INSTALL_PROGRAM = ${INSTALL_PROGRAM}
991 INSTALL_LIB = ${INSTALL_LIB}
992 INSTALL_MAN = ${INSTALL_MAN}
993 INSTALL_DATA = ${INSTALL_DATA}
996 echo "Makefile.configure: written" 1>&2
997 echo "Makefile.configure: written" 1>&3