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
81 Additionally, the following environment variables are used if set:
83 CC the C compiler to use (defaults to cc, clang or gcc)
84 CFLAGS generic C compiler flags
90 #----------------------------------------------------------------------
91 # Prepare for running: move aside previous configure runs.
92 # Output file descriptor usage:
93 # 1 (stdout): config.h or Makefile.configure
94 # 2 (stderr): original stderr, usually to the console
96 # You DO NOT want to change this.
97 #----------------------------------------------------------------------
99 [ -w config.log ] && mv config.log config.log.old
100 [ -w config.h ] && mv config.h config.h.old
103 echo "config.log: writing..."
105 # GNU submake prints different output if invoked recursively, which
106 # messes up CC and CFLAGS detection. Pass --no-print-directory if
107 # we have a MAKELEVEL (GNU and FreeBSD make) and the argument is
112 if [ -n "${MAKELEVEL}" ]; then
113 if [ "${MAKELEVEL}" -gt 0 ] ; then
114 MAKE_FLAGS="--no-print-directory"
115 echo "all:" | make ${MAKE_FLAGS} -sf - 2>/dev/null || MAKE_FLAGS=""
119 if [ -n "$MAKE_FLAGS" ]; then
120 echo "GNU submake detected: using --no-print-directory" 1>&2
121 echo "GNU submake detected: using --no-print-directory" 1>&3
124 #----------------------------------------------------------------------
125 # Initialize all variables here such that nothing can leak in from the
126 # environment except for CC and CFLAGS, which we might have passed in.
127 #----------------------------------------------------------------------
129 CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | make ${MAKE_FLAGS} -sf -`
130 CFLAGS=`printf "all:\\n\\t@echo \\\$(CFLAGS)\\n" | make ${MAKE_FLAGS} -sf -`
131 CFLAGS="${CFLAGS} -g -W -Wall -Wmissing-prototypes -Wstrict-prototypes"
132 CFLAGS="${CFLAGS} -Wmissing-declarations -Wno-unused-parameter"
133 CFLAGS="${CFLAGS} -Wno-sign-compare"
140 LDADD_LIB_VORBISFILE=
161 # SunOS sets "cc", but this doesn't exist.
162 # It does have gcc, so try that instead.
163 # Prefer clang, though.
165 command -v ${CC} 2>/dev/null 1>&2 || {
166 echo "${CC} not found: trying clang" 1>&2
167 echo "${CC} not found: trying clang" 1>&3
169 command -v ${CC} 2>/dev/null 1>&2 || {
170 echo "${CC} not found: trying gcc" 1>&2
171 echo "${CC} not found: trying gcc" 1>&3
173 command -v ${CC} 2>/dev/null 1>&2 || {
174 echo "gcc not found: giving up" 1>&2
175 echo "gcc not found: giving up" 1>&3
181 command -v pkg-config 2>/dev/null 1>&2 && {
182 PKG_CONFIG=pkg-config
183 echo "pkg-config found" 1>&2
184 echo "pkg-config found" 1>&3
186 echo "pkg-config not found" 1>&2
187 echo "pkg-config not found" 1>&3
190 #----------------------------------------------------------------------
191 # Allow certain variables to be overriden on the command line.
192 #----------------------------------------------------------------------
194 while [ $# -gt 0 ]; do
198 if [ "$key" = "--prefix" ]; then
200 if [ "$1" = "--prefix" ]; then
201 if ! shift 2>&1 >/dev/null; then
202 echo "$0: missing value for --prefix" 1>&2
209 if [ "$1" = "$key" ]; then
210 echo "$0: invalid key-value: $1" 1>&2
222 LDADD_LIBEVENT="$val" ;;
224 LDADD_LIBEVENT2="$val" ;;
226 LDADD_LIBFLAC="$val" ;;
228 LDADD_LIBMPG123="$val" ;;
230 LDADD_LIBOPUSFILE="$val" ;;
232 LDADD_LIBVORBISFILE="$val" ;;
234 LDADD_SNDIO="$val" ;;
236 LDADD_LIBSOCKET="$val" ;;
260 echo "$0: invalid key: $key" 1>&2
266 #----------------------------------------------------------------------
267 # These are the values that will be pushed into config.h after we test
268 # for whether they're supported or not.
269 # Each of these must have a runtest(), below.
270 # Please sort by alpha, for clarity.
271 # You WANT to change this.
272 #----------------------------------------------------------------------
286 HAVE_LIBEVENT2=0 # may not be checked, set to zero
299 HAVE_PROGRAM_INVOCATION_SHORT_NAME=
318 #----------------------------------------------------------------------
319 # Allow configure.local to override all variables, default settings,
320 # command-line arguments, and tested features, above.
321 # You PROBABLY DO NOT want to change this.
322 #----------------------------------------------------------------------
324 if [ -r ./configure.local ]; then
325 echo "configure.local: reading..." 1>&2
326 echo "configure.local: reading..." 1>&3
327 cat ./configure.local 1>&3
330 echo "configure.local: no (fully automatic configuration)" 1>&2
331 echo "configure.local: no (fully automatic configuration)" 1>&3
336 #----------------------------------------------------------------------
337 # Infrastructure for running tests.
338 # These consists of a series of functions that will attempt to run the
339 # given test file and record its exit into a HAVE_xxx variable.
340 # You DO NOT want to change this.
341 #----------------------------------------------------------------------
343 COMP="${CC} ${CFLAGS} ${CPPFLAGS} -Wno-unused -Werror"
345 # Check whether this HAVE_ setting is manually overridden.
346 # If yes, use the override, if no, do not decide anything yet.
347 # Arguments: lower-case test name, manual value
350 [ -z "${3}" ] && return 1
351 echo "${1}: manual (HAVE_${2}=${3})" 1>&2
352 echo "${1}: manual (HAVE_${2}=${3})" 1>&3
357 # Run a single autoconfiguration test.
358 # In case of success, enable the feature.
359 # In case of failure, do not decide anything yet.
360 # Arguments: lower-case test name, upper-case test name, additional
361 # CFLAGS, additional LIBS.
368 cat 1>&3 << __HEREDOC__
370 ${COMP} -DTEST_${2} ${3} -o test-${1} tests.c ${LDFLAGS} ${4}
372 if ${COMP} -DTEST_${2} ${3} -o "test-${1}" tests.c ${LDFLAGS} ${4} 1>&3 2>&3; then
373 echo "${1}: ${CC} succeeded" 1>&3
375 if [ -n "${5}" ] ; then
376 echo "${1}: ${CC} failed with $? (retrying)" 1>&3
377 cat 1>&3 << __HEREDOC__
379 ${COMP} -DTEST_${2} ${3} -o test-${1} tests.c ${LDFLAGS} ${5}
381 if ${COMP} -DTEST_${2} ${3} -o "test-${1}" tests.c ${LDFLAGS} ${5} 1>&3 2>&3; then
382 echo "${1}: ${CC} succeeded" 1>&3
383 extralib="(with ${5})"
385 test -n "${PKG_CONFIG}" -a -n "${6}" && ${PKG_CONFIG} "$6"
386 if [ $? -eq 0 ]; then
387 echo "${1}: ${CC} failed with $? (retrying)" 1>&3
388 pkgcfs=$($PKG_CONFIG --cflags "${6}")
389 pkglib=$($PKG_CONFIG --libs "${6}")
390 cat 1>&3 << __HEREDOC__
392 ${COMP} -DTEST_${2} ${3} ${pkgcfs} -o test-${1} tests.c ${LDFLAGS} ${pkglib}
394 if ${COMP} -DTEST_${2} ${3} ${pkgcfs} -o test-${1} tests.c ${LDFLAGS} ${pkglib} 1>&3 2>&3; then
395 echo "${1}: ${CC} succeeded" 1>&3
396 extralib="(with ${pkgcfs} ${pkglib})"
398 echo "${1}: ${CC} failed with $?" 1>&3
403 echo "${1}: ${CC} failed with $?" 1>&3
409 echo "${1}: ${CC} failed with $?" 1>&3
417 if [ -n "${pkgcfs}" -o -n "${pkglib}" ]
419 CFLAGS="${CFLAGS} ${pkgcfs}"
420 eval "LDADD_${2}=\"${pkglib}\""
421 elif [ -n "${extralib}" ]
423 eval "LDADD_${2}=\"${5}\""
426 eval "LDADD_${2}=\"${4}\""
429 echo "${1}: yes ${extralib}" 1>&2
430 echo "${1}: yes ${extralib}" 1>&3
437 # Run a complete autoconfiguration test, including the check for
438 # a manual override and disabling the feature on failure.
439 # Arguments: lower case name, upper case name, additional CFLAGS,
440 # additional LDADD, alternative LDADD, pkg-config name.
443 eval _manual=\${HAVE_${2}}
444 ismanual "${1}" "${2}" "${_manual}" && return 0
445 singletest "${1}" "${2}" "${3}" "${4}" "${5}" "${6}" && return 0
451 #----------------------------------------------------------------------
452 # Begin running the tests themselves.
453 # All of your tests must be defined here.
454 # Please sort as the HAVE_xxxx values were defined.
455 # You WANT to change this.
456 # It consists of the following columns:
460 # (3) argument to cc *before* -o
461 # (4) argument to cc *after*
462 # (5) alternative argument to cc *after*
463 # (6) name for pkg-config auto-discovery
464 #----------------------------------------------------------------------
466 if runtest -MMD _MMD -MMD; then
467 CFLAGS="${CFLAGS} -MMD"
468 echo "adding -MMD to CFLAGS" 1>&2
469 echo "adding -MMD to CFLAGS" 1>&3
472 runtest capsicum CAPSICUM || true
473 runtest err ERR || true
474 runtest explicit_bzero EXPLICIT_BZERO || true
475 runtest flock FLOCK || true
476 runtest freezero FREEZERO || true
477 runtest getdtablecount GETDTABLECOUNT || true
478 runtest getexecname GETEXECNAME || true
479 runtest getprogname GETPROGNAME || true
480 runtest imsg IMSG "" "" "-lutil" || true
481 runtest INFTIM INFTIM || true
482 runtest landlock LANDLOCK || true
484 runtest libevent LIBEVENT "" "" "-levent" || \
485 runtest libevent2 LIBEVENT2 "" "" "-levent_extra -levent_core" "libevent" || true
487 runtest lib_flac LIB_FLAC "" "" "-lFLAC" "flac" || true
488 runtest lib_mpg123 LIB_MPG123 "" "" "-lmpg123" "libmpg123" || true
489 runtest lib_opusfile LIB_OPUSFILE "" "" "-lopusfile" "opusfile" || true
490 runtest lib_vorbisfile LIB_VORBISFILE "" "" "-lvorbisfile" "vorbisfile" || true
492 runtest lib_sndio LIB_SNDIO "" "" "-lsndio" "sndio" || true
493 runtest lib_socket LIB_SOCKET "" "" "-lsocket -lnsl" || true
494 runtest memmem MEMMEM || true
495 runtest memrchr MEMRCHR || true
496 runtest memset_s MEMSET_S || true
497 runtest optreset OPTRESET || true
498 runtest PATH_MAX PATH_MAX || true
499 runtest pledge PLEDGE || true
500 runtest program_invocation_short_name PROGRAM_INVOCATION_SHORT_NAME || true
501 runtest PR_SET_NAME PR_SET_NAME || true
502 runtest reallocarray REALLOCARRAY || true
503 runtest recallocarray RECALLOCARRAY || true
504 runtest sandbox_init SANDBOX_INIT "-Wno-deprecated" || true
505 runtest setproctitle SETPROCTITLE || true
506 runtest sio_flush SIO_FLUSH "" "" "${LDADD_LIB_SNDIO}" || true
507 runtest SOCK_NONBLOCK SOCK_NONBLOCK || true
508 runtest static STATIC "" "-static" || true
509 runtest strlcat STRLCAT || true
510 runtest strlcpy STRLCPY || true
511 runtest strndup STRNDUP || true
512 runtest strnlen STRNLEN || true
513 runtest strtonum STRTONUM || true
514 runtest sys_queue SYS_QUEUE || true
515 runtest sys_file SYS_FILE || true
516 runtest unveil UNVEIL || true
517 runtest __progname __PROGNAME || true
519 if [ "${HAVE_LIBEVENT}" -eq 0 -a "${HAVE_LIBEVENT2}" -eq 0 ]; then
520 echo "Fatal: missing libevent" 1>&2
521 echo "Fatal: missing libevent" 1>&3
525 if [ "${HAVE_LIB_FLAC}" -eq 0 -o \
526 "${HAVE_LIB_MPG123}" -eq 0 -o \
527 "${HAVE_LIB_OPUSFILE}" -eq 0 -o \
528 "${HAVE_LIB_VORBISFILE}" -eq 0 ]; then
529 echo "Fatal: missing required audio libraries" 1>&2
530 echo "Fatal: missing required audio libraries" 1>&3
534 if [ "${HAVE_LIB_SNDIO}" -eq 0 ]; then
535 echo "Fatal: missing libsndio" 1>&2
536 echo "Fatal: missing libsndio" 1>&3
540 #----------------------------------------------------------------------
541 # Output writing: generate the config.h file.
542 # This file contains all of the HAVE_xxxx variables necessary for
543 # compiling your source.
544 # You must include "config.h" BEFORE any other variables.
545 # You WANT to change this.
546 #----------------------------------------------------------------------
550 # Start with prologue.
553 #ifndef OCONFIGURE_CONFIG_H
554 #define OCONFIGURE_CONFIG_H
557 # error "Do not use C++: this is a C application."
559 #if !defined(__GNUC__) || (__GNUC__ < 4)
560 # define __attribute__(x)
562 #if defined(__linux__) || defined(__MINT__)
563 # define _GNU_SOURCE /* memmem, memrchr, setresuid... */
564 # define _DEFAULT_SOURCE /* le32toh, crypt, ... */
566 #if defined(__NetBSD__)
567 # define _OPENBSD_SOURCE /* reallocarray, etc. */
570 # ifndef _XOPEN_SOURCE /* SunOS already defines */
571 # define _XOPEN_SOURCE /* XPGx */
573 # define _XOPEN_SOURCE_EXTENDED 1 /* XPG4v2 */
574 # ifndef __EXTENSIONS__ /* SunOS already defines */
575 # define __EXTENSIONS__ /* reallocarray, etc. */
578 #if !defined(__BEGIN_DECLS)
579 # define __BEGIN_DECLS
581 #if !defined(__END_DECLS)
587 # This is just for size_t, mode_t, and dev_t.
588 # Most of these functions, in the real world, pull in <string.h> or
589 # someting that pulls in support for size_t.
590 # Our function declarations are standalone, so specify them here.
592 if [ ${HAVE_IMSG} -eq 0 -o \
593 ${HAVE_MEMMEM} -eq 0 -o \
594 ${HAVE_MEMRCHR} -eq 0 -o \
595 ${HAVE_REALLOCARRAY} -eq 0 -o \
596 ${HAVE_RECALLOCARRAY} -eq 0 -o \
597 ${HAVE_STRLCAT} -eq 0 -o \
598 ${HAVE_STRLCPY} -eq 0 -o \
599 ${HAVE_STRNDUP} -eq 0 -o \
600 ${HAVE_STRNLEN} -eq 0 ]
602 echo "#include <sys/types.h> /* size_t, mode_t, dev_t */ "
606 if [ ${HAVE_FLOCK} -eq 0 ]; then
607 if [ ${HAVE_SYS_FILE} -eq 0 ]; then
609 echo "#include <sys/file.h>"
612 echo "int flock(int, int);"
613 echo "#define LOCK_SH 0x1"
614 echo "#define LOCK_EX 0x2"
615 echo "#define LOCK_NB 0x4"
620 if [ ${HAVE_ERR} -eq 0 ]; then
621 echo "#include <stdarg.h> /* err(3) */"
624 echo "#include <err.h>"
628 if [ ${HAVE_PLEDGE} -eq 0 ]; then
629 echo "#define pledge(p, e) (0)"
632 echo "#include <unistd.h>"
636 # Now we handle our HAVE_xxxx values.
637 # Most will just be defined as 0 or 1.
639 if [ ${HAVE_PATH_MAX} -eq 0 ]
641 echo "#define PATH_MAX 4096"
645 if [ ${HAVE_INFTIM} -eq 0 ]
647 echo "#define INFTIM (-1) /* poll.h */"
653 * Results of configuration feature-testing.
655 #define HAVE_CAPSICUM ${HAVE_CAPSICUM}
656 #define HAVE_ERR ${HAVE_ERR}
657 #define HAVE_EXPLICIT_BZERO ${HAVE_EXPLICIT_BZERO}
658 #define HAVE_FLOCK ${HAVE_FLOCK}
659 #define HAVE_FREEZERO ${HAVE_FREEZERO}
660 #define HAVE_GETDTABLECOUNT ${HAVE_GETDTABLECOUNT}
661 #define HAVE_GETEXECNAME ${HAVE_GETEXECNAME}
662 #define HAVE_GETPROGNAME ${HAVE_GETPROGNAME}
663 #define HAVE_INFTIM ${HAVE_INFTIM}
664 #define HAVE_LANDLOCK ${HAVE_LANDLOCK}
665 #define HAVE_MEMMEM ${HAVE_MEMMEM}
666 #define HAVE_MEMRCHR ${HAVE_MEMRCHR}
667 #define HAVE_MEMSET_S ${HAVE_MEMSET_S}
668 #define HAVE_OPTRESET ${HAVE_OPTRESET}
669 #define HAVE_PATH_MAX ${HAVE_PATH_MAX}
670 #define HAVE_PLEDGE ${HAVE_PLEDGE}
671 #define HAVE_PROGRAM_INVOCATION_SHORT_NAME ${HAVE_PROGRAM_INVOCATION_SHORT_NAME}
672 #define HAVE_PR_SET_NAME ${HAVE_PR_SET_NAME}
673 #define HAVE_REALLOCARRAY ${HAVE_REALLOCARRAY}
674 #define HAVE_RECALLOCARRAY ${HAVE_RECALLOCARRAY}
675 #define HAVE_SANDBOX_INIT ${HAVE_SANDBOX_INIT}
676 #define HAVE_SETPROCTITLE ${HAVE_SETPROCTITLE}
677 #define HAVE_SIO_FLUSH ${HAVE_SIO_FLUSH}
678 #define HAVE_SOCK_NONBLOCK ${HAVE_SOCK_NONBLOCK}
679 #define HAVE_STRLCAT ${HAVE_STRLCAT}
680 #define HAVE_STRLCPY ${HAVE_STRLCPY}
681 #define HAVE_STRNDUP ${HAVE_STRNDUP}
682 #define HAVE_STRNLEN ${HAVE_STRNLEN}
683 #define HAVE_STRTONUM ${HAVE_STRTONUM}
684 #define HAVE_SYS_FILE ${HAVE_SYS_FILE}
685 #define HAVE_SYS_QUEUE ${HAVE_SYS_QUEUE}
686 #define HAVE_SYSTRACE ${HAVE_SYSTRACE}
687 #define HAVE_UNVEIL ${HAVE_UNVEIL}
688 #define HAVE___PROGNAME ${HAVE___PROGNAME}
692 # Now we do our function declarations for missing functions.
694 [ ${HAVE_ERR} -eq 0 ] && \
697 * Compatibility functions for err(3).
699 extern void err(int, const char *, ...) __attribute__((noreturn));
700 extern void errc(int, int, const char *, ...) __attribute__((noreturn));
701 extern void errx(int, const char *, ...) __attribute__((noreturn));
702 extern void verr(int, const char *, va_list) __attribute__((noreturn));
703 extern void verrc(int, int, const char *, va_list) __attribute__((noreturn));
704 extern void verrx(int, const char *, va_list) __attribute__((noreturn));
705 extern void warn(const char *, ...);
706 extern void warnx(const char *, ...);
707 extern void warnc(int, const char *, ...);
708 extern void vwarn(const char *, va_list);
709 extern void vwarnc(int, const char *, va_list);
710 extern void vwarnx(const char *, va_list);
713 [ ${HAVE_EXPLICIT_BZERO} -eq 0 ] && \
716 * Compatibility for explicit_bzero(3).
718 extern void explicit_bzero(void *, size_t);
722 [ ${HAVE_FREEZERO} -eq 0 ] && \
725 * Compatibility for freezero(3).
727 extern void freezero(void *, size_t);
731 [ ${HAVE_MEMMEM} -eq 0 ] && \
734 * Compatibility for memmem(3).
736 void *memmem(const void *, size_t, const void *, size_t);
740 [ ${HAVE_MEMRCHR} -eq 0 ] && \
743 * Compatibility for memrchr(3).
745 void *memrchr(const void *b, int, size_t);
749 [ ${HAVE_GETPROGNAME} -eq 0 ] && \
752 * Compatibility for getprogname(3).
754 extern const char *getprogname(void);
758 [ ${HAVE_REALLOCARRAY} -eq 0 ] && \
761 * Compatibility for reallocarray(3).
763 extern void *reallocarray(void *, size_t, size_t);
767 [ ${HAVE_RECALLOCARRAY} -eq 0 ] && \
770 * Compatibility for recallocarray(3).
772 extern void *recallocarray(void *, size_t, size_t, size_t);
776 [ ${HAVE_SETPROCTITLE} -eq 0 ] && \
779 * Compatibility for setproctitle(3).
781 extern void setproctitle(const char *, ...);
785 [ ${HAVE_STRLCAT} -eq 0 ] && \
788 * Compatibility for strlcat(3).
790 extern size_t strlcat(char *, const char *, size_t);
794 [ ${HAVE_STRLCPY} -eq 0 ] && \
797 * Compatibility for strlcpy(3).
799 extern size_t strlcpy(char *, const char *, size_t);
803 [ ${HAVE_STRNDUP} -eq 0 ] && \
806 * Compatibility for strndup(3).
808 extern char *strndup(const char *, size_t);
812 [ ${HAVE_STRNLEN} -eq 0 ] && \
815 * Compatibility for strnlen(3).
817 extern size_t strnlen(const char *, size_t);
821 [ ${HAVE_STRTONUM} -eq 0 ] && \
824 * Compatibility for strotnum(3).
826 extern long long strtonum(const char *, long long, long long, const char **);
830 if [ ${HAVE_SYS_QUEUE} -eq 0 ]; then
835 echo "#include <sys/queue.h>"
839 echo "#include <sys/uio.h>"
840 echo "#include <stdint.h>"
841 if [ ${HAVE_IMSG} -eq 0 ]; then
842 echo "#include \"imsg.h\""
844 echo "#include <imsg.h>"
848 if [ "${HAVE_LIBEVENT2}" -eq 1 ]; then
850 #include <event2/event.h>
851 #include <event2/event_compat.h>
852 #include <event2/event_struct.h>
853 #include <event2/buffer.h>
854 #include <event2/buffer_compat.h>
855 #include <event2/bufferevent.h>
856 #include <event2/bufferevent_struct.h>
857 #include <event2/bufferevent_compat.h>
860 elif [ "${HAVE_LIBEVENT}" -eq 1 ]; then
869 # define __dead __attribute__((noreturn))
873 #define sio_flush(hdl) (sio_stop(hdl))
876 #if !HAVE_GETDTABLECOUNT
877 /* XXX: on linux it should be possible to inspect /proc/self/fd/ */
878 #define getdtablecount() (0)
882 /* replace host' getopt with OpenBSD' one */
883 #define opterr BSDopterr
884 #define optind BSDoptind
885 #define optopt BSDoptopt
886 #define optreset BSDoptreset
887 #define optarg BSDoptarg
888 #define getopt BSDgetopt
890 extern int BSDopterr, BSDoptind, BSDoptopt, BSDoptreset;
891 extern char *BSDoptarg;
894 #endif /*!OCONFIGURE_CONFIG_H*/
897 echo "config.h: written" 1>&2
898 echo "config.h: written" 1>&3
900 #----------------------------------------------------------------------
901 # Now we go to generate our Makefile.configure.
902 # This file is simply a bunch of Makefile variables.
903 # They'll work in both GNUmakefile and BSDmakefile.
904 # You MIGHT want to change this.
905 #----------------------------------------------------------------------
907 exec > Makefile.configure
909 [ -z "${BINDIR}" ] && BINDIR="${PREFIX}/bin"
910 [ -z "${SBINDIR}" ] && SBINDIR="${PREFIX}/sbin"
911 [ -z "${INCLUDEDIR}" ] && INCLUDEDIR="${PREFIX}/include"
912 [ -z "${LIBDIR}" ] && LIBDIR="${PREFIX}/lib"
913 [ -z "${MANDIR}" ] && MANDIR="${PREFIX}/man"
914 [ -z "${SHAREDIR}" ] && SHAREDIR="${PREFIX}/share"
916 [ -z "${INSTALL_PROGRAM}" ] && INSTALL_PROGRAM="${INSTALL} -m 0555"
917 [ -z "${INSTALL_LIB}" ] && INSTALL_LIB="${INSTALL} -m 0444"
918 [ -z "${INSTALL_MAN}" ] && INSTALL_MAN="${INSTALL} -m 0444"
919 [ -z "${INSTALL_DATA}" ] && INSTALL_DATA="${INSTALL} -m 0444"
924 CPPFLAGS = ${CPPFLAGS}
925 LDADD = ${LDADD} ${LDADD_IMSG} ${LDADD_LIB_FLAC} ${LDADD_LIB_MPG123} \
926 ${LDADD_LIB_OPUSFILE} ${LDADD_LIB_VORBISFILE} ${LDADD_LIB_SOCKET} \
927 ${LDADD_LIBEVENT} ${LDADD_LIBEVENT2} ${LDADD_LIB_SNDIO}
928 LDADD_STATIC = ${LDADD_STATIC}
933 SHAREDIR = ${SHAREDIR}
935 INCLUDEDIR = ${INCLUDEDIR}
939 INSTALL_PROGRAM = ${INSTALL_PROGRAM}
940 INSTALL_LIB = ${INSTALL_LIB}
941 INSTALL_MAN = ${INSTALL_MAN}
942 INSTALL_DATA = ${INSTALL_DATA}
945 echo "Makefile.configure: written" 1>&2
946 echo "Makefile.configure: written" 1>&3