3 # Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
4 # Copyright (c) 2017, 2018 Kristaps Dzonsons <kristaps@bsd.lv>
6 # Permission to use, copy, modify, and distribute this software for any
7 # purpose with or without fee is hereby granted, provided that the above
8 # copyright notice and this permission notice appear in all copies.
10 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 OCONFIGURE_VERSION="0.3.8"
21 # This script outputs two files: config.h and Makefile.configure.
22 # It tries to read from configure.local, which contains predefined
23 # values we won't autoconfigure.
25 # If you want to use configure with your project, have your GNUmakefile
26 # or BSDmakefile---whichever---try to import/include Makefile.configure
27 # at the beginning of the file.
29 # Like so (note no quotes, no period, etc.):
31 # include Makefile.configure
33 # If it exists, configure was run; otherwise, it wasn't.
35 # You'll probably want to change parts of this file. I've noted the
36 # parts that you'll probably change in the section documentation.
38 # See https://github.com/kristapsdz/oconfigure for more.
46 \`configure' configures amused to adapt to many kinds of systems.
48 Usage: $0 [-h] [--prefix=path] [VAR=VALUE]...
50 The options are as follows:
52 -h, --help print this help message
54 --prefix=path equivalent to specifying the PREFIX variable, supported
55 for compatibility with other common "configure" scripts.
59 LDADD generic linker flags
60 LDADD_IMSG linker flags for libimsg
61 LDADD_LIBEVENT linker flags for libevent
62 LDADD_LIBEVENT2 linker flags for libevent2
63 LDADD_LIBFLAC linker flags for libflac
64 LDADD_LIBMPG123 linker flags for libmpg123
65 LDADD_LIBOPUSFILE linker flags for libopusfile
66 LDADD_LIBVORBISFILE linker flags for libvorbisfile
67 LDADD_SNDIO linker flags for libsndio
68 LDADD_LIBSOCKET linker flags for libsocket
69 LDFLAGS extra linker flags
70 CPPFLAGS C preprocessors flags
71 DESTDIR destination directory
72 PREFIX where to install files
73 MANDIR where to install man pages (PREFIX/man)
74 LIBDIR where to install libraries (PREFIX/lib)
75 BINDIR where to install executables (PREFIX/bin)
76 SHAREDIR where to install misc files (PREFIX/share)
77 SBINDIR where to install system executables (PREFIX/sbin)
78 INCLUDEDIR where to install header files (PREFIX/include)
79 PKG_CONFIG path to the pkg-config program or empty to disable
85 #----------------------------------------------------------------------
86 # Prepare for running: move aside previous configure runs.
87 # Output file descriptor usage:
88 # 1 (stdout): config.h or Makefile.configure
89 # 2 (stderr): original stderr, usually to the console
91 # You DO NOT want to change this.
92 #----------------------------------------------------------------------
94 [ -w config.log ] && mv config.log config.log.old
95 [ -w config.h ] && mv config.h config.h.old
98 echo "config.log: writing..."
100 # GNU submake prints different output if invoked recursively, which
101 # messes up CC and CFLAGS detection. Pass --no-print-directory if
102 # we have a MAKELEVEL (GNU and FreeBSD make) and the argument is
107 if [ -n "${MAKELEVEL}" ]; then
108 if [ "${MAKELEVEL}" -gt 0 ] ; then
109 MAKE_FLAGS="--no-print-directory"
110 echo "all:" | make ${MAKE_FLAGS} -sf - 2>/dev/null || MAKE_FLAGS=""
114 if [ -n "$MAKE_FLAGS" ]; then
115 echo "GNU submake detected: using --no-print-directory" 1>&2
116 echo "GNU submake detected: using --no-print-directory" 1>&3
119 #----------------------------------------------------------------------
120 # Initialize all variables here such that nothing can leak in from the
121 # environment except for CC and CFLAGS, which we might have passed in.
122 #----------------------------------------------------------------------
124 CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | make ${MAKE_FLAGS} -sf -`
125 CFLAGS=`printf "all:\\n\\t@echo \\\$(CFLAGS)\\n" | make ${MAKE_FLAGS} -sf -`
126 CFLAGS="${CFLAGS} -g -W -Wall -Wmissing-prototypes -Wstrict-prototypes"
127 CFLAGS="${CFLAGS} -Wmissing-declarations -Wno-unused-parameter"
128 CFLAGS="${CFLAGS} -Wno-sign-compare"
135 LDADD_LIB_VORBISFILE=
156 # SunOS sets "cc", but this doesn't exist.
157 # It does have gcc, so try that instead.
158 # Prefer clang, though.
160 command -v ${CC} 2>/dev/null 1>&2 || {
161 echo "${CC} not found: trying clang" 1>&2
162 echo "${CC} not found: trying clang" 1>&3
164 command -v ${CC} 2>/dev/null 1>&2 || {
165 echo "${CC} not found: trying gcc" 1>&2
166 echo "${CC} not found: trying gcc" 1>&3
168 command -v ${CC} 2>/dev/null 1>&2 || {
169 echo "gcc not found: giving up" 1>&2
170 echo "gcc not found: giving up" 1>&3
176 command -v pkg-config 2>/dev/null 1>&2 && {
177 PKG_CONFIG=pkg-config
178 echo "pkg-config found" 1>&2
179 echo "pkg-config found" 1>&3
181 echo "pkg-config not found" 1>&2
182 echo "pkg-config not found" 1>&3
185 #----------------------------------------------------------------------
186 # Allow certain variables to be overriden on the command line.
187 #----------------------------------------------------------------------
189 while [ $# -gt 0 ]; do
193 if [ "$key" = "--prefix" ]; then
195 if [ "$1" = "--prefix" ]; then
196 if ! shift 2>&1 >/dev/null; then
197 echo "$0: missing value for --prefix" 1>&2
204 if [ "$1" = "$key" ]; then
205 echo "$0: invalid key-value: $1" 1>&2
217 LDADD_LIBEVENT="$val" ;;
219 LDADD_LIBEVENT2="$val" ;;
221 LDADD_LIBFLAC="$val" ;;
223 LDADD_LIBMPG123="$val" ;;
225 LDADD_LIBOPUSFILE="$val" ;;
227 LDADD_LIBVORBISFILE="$val" ;;
229 LDADD_SNDIO="$val" ;;
231 LDADD_LIBSOCKET="$val" ;;
255 echo "$0: invalid key: $key" 1>&2
261 #----------------------------------------------------------------------
262 # These are the values that will be pushed into config.h after we test
263 # for whether they're supported or not.
264 # Each of these must have a runtest(), below.
265 # Please sort by alpha, for clarity.
266 # You WANT to change this.
267 #----------------------------------------------------------------------
281 HAVE_LIBEVENT2=0 # may not be checked, set to zero
294 HAVE_PROGRAM_INVOCATION_SHORT_NAME=
313 #----------------------------------------------------------------------
314 # Allow configure.local to override all variables, default settings,
315 # command-line arguments, and tested features, above.
316 # You PROBABLY DO NOT want to change this.
317 #----------------------------------------------------------------------
319 if [ -r ./configure.local ]; then
320 echo "configure.local: reading..." 1>&2
321 echo "configure.local: reading..." 1>&3
322 cat ./configure.local 1>&3
325 echo "configure.local: no (fully automatic configuration)" 1>&2
326 echo "configure.local: no (fully automatic configuration)" 1>&3
331 #----------------------------------------------------------------------
332 # Infrastructure for running tests.
333 # These consists of a series of functions that will attempt to run the
334 # given test file and record its exit into a HAVE_xxx variable.
335 # You DO NOT want to change this.
336 #----------------------------------------------------------------------
338 COMP="${CC} ${CFLAGS} ${CPPFLAGS} -Wno-unused -Werror"
340 # Check whether this HAVE_ setting is manually overridden.
341 # If yes, use the override, if no, do not decide anything yet.
342 # Arguments: lower-case test name, manual value
345 [ -z "${3}" ] && return 1
346 echo "${1}: manual (HAVE_${2}=${3})" 1>&2
347 echo "${1}: manual (HAVE_${2}=${3})" 1>&3
352 # Run a single autoconfiguration test.
353 # In case of success, enable the feature.
354 # In case of failure, do not decide anything yet.
355 # Arguments: lower-case test name, upper-case test name, additional
356 # CFLAGS, additional LIBS.
363 cat 1>&3 << __HEREDOC__
365 ${COMP} -DTEST_${2} ${3} -o test-${1} tests.c ${LDFLAGS} ${4}
367 if ${COMP} -DTEST_${2} ${3} -o "test-${1}" tests.c ${LDFLAGS} ${4} 1>&3 2>&3; then
368 echo "${1}: ${CC} succeeded" 1>&3
370 if [ -n "${5}" ] ; then
371 echo "${1}: ${CC} failed with $? (retrying)" 1>&3
372 cat 1>&3 << __HEREDOC__
374 ${COMP} -DTEST_${2} ${3} -o test-${1} tests.c ${LDFLAGS} ${5}
376 if ${COMP} -DTEST_${2} ${3} -o "test-${1}" tests.c ${LDFLAGS} ${5} 1>&3 2>&3; then
377 echo "${1}: ${CC} succeeded" 1>&3
378 extralib="(with ${5})"
380 test -n "${PKG_CONFIG}" -a -n "${6}" && ${PKG_CONFIG} "$6"
381 if [ $? -eq 0 ]; then
382 echo "${1}: ${CC} failed with $? (retrying)" 1>&3
383 pkgcfs=$($PKG_CONFIG --cflags "${6}")
384 pkglib=$($PKG_CONFIG --libs "${6}")
385 cat 1>&3 << __HEREDOC__
387 ${COMP} -DTEST_${2} ${3} ${pkgcfs} -o test-${1} tests.c ${LDFLAGS} ${pkglib}
389 if ${COMP} -DTEST_${2} ${3} ${pkgcfs} -o test-${1} tests.c ${LDFLAGS} ${pkglib} 1>&3 2>&3; then
390 echo "${1}: ${CC} succeeded" 1>&3
391 extralib="(with ${pkgcfs} ${pkglib})"
393 echo "${1}: ${CC} failed with $?" 1>&3
398 echo "${1}: ${CC} failed with $?" 1>&3
404 echo "${1}: ${CC} failed with $?" 1>&3
412 if [ -n "${pkgcfs}" -o -n "${pkglib}" ]
414 CFLAGS="${CFLAGS} ${pkgcfs}"
415 eval "LDADD_${2}=\"${pkglib}\""
416 elif [ -n "${extralib}" ]
418 eval "LDADD_${2}=\"${5}\""
421 eval "LDADD_${2}=\"${4}\""
424 echo "${1}: yes ${extralib}" 1>&2
425 echo "${1}: yes ${extralib}" 1>&3
432 # Run a complete autoconfiguration test, including the check for
433 # a manual override and disabling the feature on failure.
434 # Arguments: lower case name, upper case name, additional CFLAGS,
435 # additional LDADD, alternative LDADD, pkg-config name.
438 eval _manual=\${HAVE_${2}}
439 ismanual "${1}" "${2}" "${_manual}" && return 0
440 singletest "${1}" "${2}" "${3}" "${4}" "${5}" "${6}" && return 0
446 #----------------------------------------------------------------------
447 # Begin running the tests themselves.
448 # All of your tests must be defined here.
449 # Please sort as the HAVE_xxxx values were defined.
450 # You WANT to change this.
451 # It consists of the following columns:
455 # (3) argument to cc *before* -o
456 # (4) argument to cc *after*
457 # (5) alternative argument to cc *after*
458 # (6) name for pkg-config auto-discovery
459 #----------------------------------------------------------------------
461 if runtest -MMD _MMD -MMD; then
462 CFLAGS="${CFLAGS} -MMD"
463 echo "adding -MMD to CFLAGS" 1>&2
464 echo "adding -MMD to CFLAGS" 1>&3
467 runtest capsicum CAPSICUM || true
468 runtest err ERR || true
469 runtest explicit_bzero EXPLICIT_BZERO || true
470 runtest flock FLOCK || true
471 runtest freezero FREEZERO || true
472 runtest getdtablecount GETDTABLECOUNT || true
473 runtest getexecname GETEXECNAME || true
474 runtest getprogname GETPROGNAME || true
475 runtest imsg IMSG "" "" "-lutil" || true
476 runtest INFTIM INFTIM || true
477 runtest landlock LANDLOCK || true
479 runtest libevent LIBEVENT "" "" "-levent" || \
480 runtest libevent2 LIBEVENT2 "" "" "-levent_extra -levent_core" "libevent" || true
482 runtest lib_flac LIB_FLAC "" "" "-lFLAC" "flac" || true
483 runtest lib_mpg123 LIB_MPG123 "" "" "-lmpg123" "libmpg123" || true
484 runtest lib_opusfile LIB_OPUSFILE "" "" "-lopusfile" "opusfile" || true
485 runtest lib_vorbisfile LIB_VORBISFILE "" "" "-lvorbisfile" "vorbisfile" || true
487 runtest lib_sndio LIB_SNDIO "" "" "-lsndio" "sndio" || true
488 runtest lib_socket LIB_SOCKET "" "" "-lsocket -lnsl" || true
489 runtest memmem MEMMEM || true
490 runtest memrchr MEMRCHR || true
491 runtest memset_s MEMSET_S || true
492 runtest optreset OPTRESET || true
493 runtest PATH_MAX PATH_MAX || true
494 runtest pledge PLEDGE || true
495 runtest program_invocation_short_name PROGRAM_INVOCATION_SHORT_NAME || true
496 runtest PR_SET_NAME PR_SET_NAME || true
497 runtest reallocarray REALLOCARRAY || true
498 runtest recallocarray RECALLOCARRAY || true
499 runtest sandbox_init SANDBOX_INIT "-Wno-deprecated" || true
500 runtest setproctitle SETPROCTITLE || true
501 runtest sio_flush SIO_FLUSH "" "" "${LDADD_LIB_SNDIO}" || true
502 runtest SOCK_NONBLOCK SOCK_NONBLOCK || true
503 runtest static STATIC "" "-static" || true
504 runtest strlcat STRLCAT || true
505 runtest strlcpy STRLCPY || true
506 runtest strndup STRNDUP || true
507 runtest strnlen STRNLEN || true
508 runtest strtonum STRTONUM || true
509 runtest sys_queue SYS_QUEUE || true
510 runtest sys_file SYS_FILE || true
511 runtest unveil UNVEIL || true
512 runtest __progname __PROGNAME || true
514 if [ "${HAVE_LIBEVENT}" -eq 0 -a "${HAVE_LIBEVENT2}" -eq 0 ]; then
515 echo "Fatal: missing libevent" 1>&2
516 echo "Fatal: missing libevent" 1>&3
520 if [ "${HAVE_LIB_FLAC}" -eq 0 -o \
521 "${HAVE_LIB_MPG123}" -eq 0 -o \
522 "${HAVE_LIB_OPUSFILE}" -eq 0 -o \
523 "${HAVE_LIB_VORBISFILE}" -eq 0 ]; then
524 echo "Fatal: missing required audio libraries" 1>&2
525 echo "Fatal: missing required audio libraries" 1>&3
529 if [ "${HAVE_LIB_SNDIO}" -eq 0 ]; then
530 echo "Fatal: missing libsndio" 1>&2
531 echo "Fatal: missing libsndio" 1>&3
535 #----------------------------------------------------------------------
536 # Output writing: generate the config.h file.
537 # This file contains all of the HAVE_xxxx variables necessary for
538 # compiling your source.
539 # You must include "config.h" BEFORE any other variables.
540 # You WANT to change this.
541 #----------------------------------------------------------------------
545 # Start with prologue.
548 #ifndef OCONFIGURE_CONFIG_H
549 #define OCONFIGURE_CONFIG_H
552 # error "Do not use C++: this is a C application."
554 #if !defined(__GNUC__) || (__GNUC__ < 4)
555 # define __attribute__(x)
557 #if defined(__linux__) || defined(__MINT__)
558 # define _GNU_SOURCE /* memmem, memrchr, setresuid... */
559 # define _DEFAULT_SOURCE /* le32toh, crypt, ... */
561 #if defined(__NetBSD__)
562 # define _OPENBSD_SOURCE /* reallocarray, etc. */
565 # ifndef _XOPEN_SOURCE /* SunOS already defines */
566 # define _XOPEN_SOURCE /* XPGx */
568 # define _XOPEN_SOURCE_EXTENDED 1 /* XPG4v2 */
569 # ifndef __EXTENSIONS__ /* SunOS already defines */
570 # define __EXTENSIONS__ /* reallocarray, etc. */
573 #if !defined(__BEGIN_DECLS)
574 # define __BEGIN_DECLS
576 #if !defined(__END_DECLS)
582 # This is just for size_t, mode_t, and dev_t.
583 # Most of these functions, in the real world, pull in <string.h> or
584 # someting that pulls in support for size_t.
585 # Our function declarations are standalone, so specify them here.
587 if [ ${HAVE_IMSG} -eq 0 -o \
588 ${HAVE_MEMMEM} -eq 0 -o \
589 ${HAVE_MEMRCHR} -eq 0 -o \
590 ${HAVE_REALLOCARRAY} -eq 0 -o \
591 ${HAVE_RECALLOCARRAY} -eq 0 -o \
592 ${HAVE_STRLCAT} -eq 0 -o \
593 ${HAVE_STRLCPY} -eq 0 -o \
594 ${HAVE_STRNDUP} -eq 0 -o \
595 ${HAVE_STRNLEN} -eq 0 ]
597 echo "#include <sys/types.h> /* size_t, mode_t, dev_t */ "
601 if [ ${HAVE_FLOCK} -eq 0 ]; then
602 if [ ${HAVE_SYS_FILE} -eq 0 ]; then
604 echo "#include <sys/file.h>"
607 echo "int flock(int, int);"
608 echo "#define LOCK_SH 0x1"
609 echo "#define LOCK_EX 0x2"
610 echo "#define LOCK_NB 0x4"
615 if [ ${HAVE_ERR} -eq 0 ]; then
616 echo "#include <stdarg.h> /* err(3) */"
619 echo "#include <err.h>"
623 if [ ${HAVE_PLEDGE} -eq 0 ]; then
624 echo "#define pledge(p, e) (0)"
627 echo "#include <unistd.h>"
631 # Now we handle our HAVE_xxxx values.
632 # Most will just be defined as 0 or 1.
634 if [ ${HAVE_PATH_MAX} -eq 0 ]
636 echo "#define PATH_MAX 4096"
640 if [ ${HAVE_INFTIM} -eq 0 ]
642 echo "#define INFTIM (-1) /* poll.h */"
648 * Results of configuration feature-testing.
650 #define HAVE_CAPSICUM ${HAVE_CAPSICUM}
651 #define HAVE_ERR ${HAVE_ERR}
652 #define HAVE_EXPLICIT_BZERO ${HAVE_EXPLICIT_BZERO}
653 #define HAVE_FLOCK ${HAVE_FLOCK}
654 #define HAVE_FREEZERO ${HAVE_FREEZERO}
655 #define HAVE_GETDTABLECOUNT ${HAVE_GETDTABLECOUNT}
656 #define HAVE_GETEXECNAME ${HAVE_GETEXECNAME}
657 #define HAVE_GETPROGNAME ${HAVE_GETPROGNAME}
658 #define HAVE_INFTIM ${HAVE_INFTIM}
659 #define HAVE_LANDLOCK ${HAVE_LANDLOCK}
660 #define HAVE_MEMMEM ${HAVE_MEMMEM}
661 #define HAVE_MEMRCHR ${HAVE_MEMRCHR}
662 #define HAVE_MEMSET_S ${HAVE_MEMSET_S}
663 #define HAVE_OPTRESET ${HAVE_OPTRESET}
664 #define HAVE_PATH_MAX ${HAVE_PATH_MAX}
665 #define HAVE_PLEDGE ${HAVE_PLEDGE}
666 #define HAVE_PROGRAM_INVOCATION_SHORT_NAME ${HAVE_PROGRAM_INVOCATION_SHORT_NAME}
667 #define HAVE_PR_SET_NAME ${HAVE_PR_SET_NAME}
668 #define HAVE_REALLOCARRAY ${HAVE_REALLOCARRAY}
669 #define HAVE_RECALLOCARRAY ${HAVE_RECALLOCARRAY}
670 #define HAVE_SANDBOX_INIT ${HAVE_SANDBOX_INIT}
671 #define HAVE_SETPROCTITLE ${HAVE_SETPROCTITLE}
672 #define HAVE_SIO_FLUSH ${HAVE_SIO_FLUSH}
673 #define HAVE_SOCK_NONBLOCK ${HAVE_SOCK_NONBLOCK}
674 #define HAVE_STRLCAT ${HAVE_STRLCAT}
675 #define HAVE_STRLCPY ${HAVE_STRLCPY}
676 #define HAVE_STRNDUP ${HAVE_STRNDUP}
677 #define HAVE_STRNLEN ${HAVE_STRNLEN}
678 #define HAVE_STRTONUM ${HAVE_STRTONUM}
679 #define HAVE_SYS_FILE ${HAVE_SYS_FILE}
680 #define HAVE_SYS_QUEUE ${HAVE_SYS_QUEUE}
681 #define HAVE_SYSTRACE ${HAVE_SYSTRACE}
682 #define HAVE_UNVEIL ${HAVE_UNVEIL}
683 #define HAVE___PROGNAME ${HAVE___PROGNAME}
687 # Now we do our function declarations for missing functions.
689 [ ${HAVE_ERR} -eq 0 ] && \
692 * Compatibility functions for err(3).
694 extern void err(int, const char *, ...) __attribute__((noreturn));
695 extern void errc(int, int, const char *, ...) __attribute__((noreturn));
696 extern void errx(int, const char *, ...) __attribute__((noreturn));
697 extern void verr(int, const char *, va_list) __attribute__((noreturn));
698 extern void verrc(int, int, const char *, va_list) __attribute__((noreturn));
699 extern void verrx(int, const char *, va_list) __attribute__((noreturn));
700 extern void warn(const char *, ...);
701 extern void warnx(const char *, ...);
702 extern void warnc(int, const char *, ...);
703 extern void vwarn(const char *, va_list);
704 extern void vwarnc(int, const char *, va_list);
705 extern void vwarnx(const char *, va_list);
708 [ ${HAVE_EXPLICIT_BZERO} -eq 0 ] && \
711 * Compatibility for explicit_bzero(3).
713 extern void explicit_bzero(void *, size_t);
717 [ ${HAVE_FREEZERO} -eq 0 ] && \
720 * Compatibility for freezero(3).
722 extern void freezero(void *, size_t);
726 [ ${HAVE_MEMMEM} -eq 0 ] && \
729 * Compatibility for memmem(3).
731 void *memmem(const void *, size_t, const void *, size_t);
735 [ ${HAVE_MEMRCHR} -eq 0 ] && \
738 * Compatibility for memrchr(3).
740 void *memrchr(const void *b, int, size_t);
744 [ ${HAVE_GETPROGNAME} -eq 0 ] && \
747 * Compatibility for getprogname(3).
749 extern const char *getprogname(void);
753 [ ${HAVE_REALLOCARRAY} -eq 0 ] && \
756 * Compatibility for reallocarray(3).
758 extern void *reallocarray(void *, size_t, size_t);
762 [ ${HAVE_RECALLOCARRAY} -eq 0 ] && \
765 * Compatibility for recallocarray(3).
767 extern void *recallocarray(void *, size_t, size_t, size_t);
771 [ ${HAVE_SETPROCTITLE} -eq 0 ] && \
774 * Compatibility for setproctitle(3).
776 extern void setproctitle(const char *, ...);
780 [ ${HAVE_STRLCAT} -eq 0 ] && \
783 * Compatibility for strlcat(3).
785 extern size_t strlcat(char *, const char *, size_t);
789 [ ${HAVE_STRLCPY} -eq 0 ] && \
792 * Compatibility for strlcpy(3).
794 extern size_t strlcpy(char *, const char *, size_t);
798 [ ${HAVE_STRNDUP} -eq 0 ] && \
801 * Compatibility for strndup(3).
803 extern char *strndup(const char *, size_t);
807 [ ${HAVE_STRNLEN} -eq 0 ] && \
810 * Compatibility for strnlen(3).
812 extern size_t strnlen(const char *, size_t);
816 [ ${HAVE_STRTONUM} -eq 0 ] && \
819 * Compatibility for strotnum(3).
821 extern long long strtonum(const char *, long long, long long, const char **);
825 if [ ${HAVE_SYS_QUEUE} -eq 0 ]; then
830 echo "#include <sys/queue.h>"
834 echo "#include <sys/uio.h>"
835 echo "#include <stdint.h>"
836 if [ ${HAVE_IMSG} -eq 0 ]; then
837 echo "#include \"imsg.h\""
839 echo "#include <imsg.h>"
843 if [ "${HAVE_LIBEVENT2}" -eq 1 ]; then
845 #include <event2/event.h>
846 #include <event2/event_compat.h>
847 #include <event2/event_struct.h>
848 #include <event2/buffer.h>
849 #include <event2/buffer_compat.h>
850 #include <event2/bufferevent.h>
851 #include <event2/bufferevent_struct.h>
852 #include <event2/bufferevent_compat.h>
855 elif [ "${HAVE_LIBEVENT}" -eq 1 ]; then
864 # define __dead __attribute__((noreturn))
868 #define sio_flush(hdl) (sio_stop(hdl))
871 #if !HAVE_GETDTABLECOUNT
872 /* XXX: on linux it should be possible to inspect /proc/self/fd/ */
873 #define getdtablecount() (0)
877 /* replace host' getopt with OpenBSD' one */
878 #define opterr BSDopterr
879 #define optind BSDoptind
880 #define optopt BSDoptopt
881 #define optreset BSDoptreset
882 #define optarg BSDoptarg
883 #define getopt BSDgetopt
885 extern int BSDopterr, BSDoptind, BSDoptopt, BSDoptreset;
886 extern char *BSDoptarg;
889 #endif /*!OCONFIGURE_CONFIG_H*/
892 echo "config.h: written" 1>&2
893 echo "config.h: written" 1>&3
895 #----------------------------------------------------------------------
896 # Now we go to generate our Makefile.configure.
897 # This file is simply a bunch of Makefile variables.
898 # They'll work in both GNUmakefile and BSDmakefile.
899 # You MIGHT want to change this.
900 #----------------------------------------------------------------------
902 exec > Makefile.configure
904 [ -z "${BINDIR}" ] && BINDIR="${PREFIX}/bin"
905 [ -z "${SBINDIR}" ] && SBINDIR="${PREFIX}/sbin"
906 [ -z "${INCLUDEDIR}" ] && INCLUDEDIR="${PREFIX}/include"
907 [ -z "${LIBDIR}" ] && LIBDIR="${PREFIX}/lib"
908 [ -z "${MANDIR}" ] && MANDIR="${PREFIX}/man"
909 [ -z "${SHAREDIR}" ] && SHAREDIR="${PREFIX}/share"
911 [ -z "${INSTALL_PROGRAM}" ] && INSTALL_PROGRAM="${INSTALL} -m 0555"
912 [ -z "${INSTALL_LIB}" ] && INSTALL_LIB="${INSTALL} -m 0444"
913 [ -z "${INSTALL_MAN}" ] && INSTALL_MAN="${INSTALL} -m 0444"
914 [ -z "${INSTALL_DATA}" ] && INSTALL_DATA="${INSTALL} -m 0444"
919 CPPFLAGS = ${CPPFLAGS}
920 LDADD = ${LDADD} ${LDADD_IMSG} ${LDADD_LIB_FLAC} ${LDADD_LIB_MPG123} \
921 ${LDADD_LIB_OPUSFILE} ${LDADD_LIB_VORBISFILE} ${LDADD_LIB_SOCKET} \
922 ${LDADD_LIBEVENT} ${LDADD_LIBEVENT2} ${LDADD_LIB_SNDIO}
923 LDADD_STATIC = ${LDADD_STATIC}
928 SHAREDIR = ${SHAREDIR}
930 INCLUDEDIR = ${INCLUDEDIR}
934 INSTALL_PROGRAM = ${INSTALL_PROGRAM}
935 INSTALL_LIB = ${INSTALL_LIB}
936 INSTALL_MAN = ${INSTALL_MAN}
937 INSTALL_DATA = ${INSTALL_DATA}
940 echo "Makefile.configure: written" 1>&2
941 echo "Makefile.configure: written" 1>&3