Blame


1 80189b3a 2022-08-13 op #! /bin/sh
2 80189b3a 2022-08-13 op #
3 80189b3a 2022-08-13 op # Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
4 80189b3a 2022-08-13 op # Copyright (c) 2017, 2018 Kristaps Dzonsons <kristaps@bsd.lv>
5 80189b3a 2022-08-13 op #
6 80189b3a 2022-08-13 op # Permission to use, copy, modify, and distribute this software for any
7 80189b3a 2022-08-13 op # purpose with or without fee is hereby granted, provided that the above
8 80189b3a 2022-08-13 op # copyright notice and this permission notice appear in all copies.
9 80189b3a 2022-08-13 op #
10 80189b3a 2022-08-13 op # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 80189b3a 2022-08-13 op # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 80189b3a 2022-08-13 op # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 80189b3a 2022-08-13 op # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 80189b3a 2022-08-13 op # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 80189b3a 2022-08-13 op # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 80189b3a 2022-08-13 op # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 80189b3a 2022-08-13 op
18 80189b3a 2022-08-13 op OCONFIGURE_VERSION="0.3.8"
19 80189b3a 2022-08-13 op
20 80189b3a 2022-08-13 op #
21 80189b3a 2022-08-13 op # This script outputs two files: config.h and Makefile.configure.
22 80189b3a 2022-08-13 op # It tries to read from configure.local, which contains predefined
23 80189b3a 2022-08-13 op # values we won't autoconfigure.
24 80189b3a 2022-08-13 op #
25 80189b3a 2022-08-13 op # If you want to use configure with your project, have your GNUmakefile
26 80189b3a 2022-08-13 op # or BSDmakefile---whichever---try to import/include Makefile.configure
27 80189b3a 2022-08-13 op # at the beginning of the file.
28 80189b3a 2022-08-13 op #
29 80189b3a 2022-08-13 op # Like so (note no quotes, no period, etc.):
30 80189b3a 2022-08-13 op #
31 80189b3a 2022-08-13 op # include Makefile.configure
32 80189b3a 2022-08-13 op #
33 80189b3a 2022-08-13 op # If it exists, configure was run; otherwise, it wasn't.
34 80189b3a 2022-08-13 op #
35 80189b3a 2022-08-13 op # You'll probably want to change parts of this file. I've noted the
36 80189b3a 2022-08-13 op # parts that you'll probably change in the section documentation.
37 80189b3a 2022-08-13 op #
38 80189b3a 2022-08-13 op # See https://github.com/kristapsdz/oconfigure for more.
39 80189b3a 2022-08-13 op
40 80189b3a 2022-08-13 op set -e
41 80189b3a 2022-08-13 op
42 80189b3a 2022-08-13 op # try to be helpful
43 80189b3a 2022-08-13 op case "$1" in
44 80189b3a 2022-08-13 op --help|-h)
45 80189b3a 2022-08-13 op cat <<EOF
46 80189b3a 2022-08-13 op \`configure' configures amused to adapt to many kinds of systems.
47 80189b3a 2022-08-13 op
48 80189b3a 2022-08-13 op Usage: $0 [-h] [--prefix=path] [VAR=VALUE]...
49 80189b3a 2022-08-13 op
50 80189b3a 2022-08-13 op The options are as follows:
51 80189b3a 2022-08-13 op
52 80189b3a 2022-08-13 op -h, --help print this help message
53 80189b3a 2022-08-13 op
54 80189b3a 2022-08-13 op --prefix=path equivalent to specify the PREFIX variable, supported
55 80189b3a 2022-08-13 op for compatibility with other common "configure" scripts.
56 80189b3a 2022-08-13 op
57 80189b3a 2022-08-13 op Variables available:
58 80189b3a 2022-08-13 op
59 80189b3a 2022-08-13 op LDADD generic linker flags
60 80189b3a 2022-08-13 op LDADD_LIBEVENT linker flags for libevent
61 80189b3a 2022-08-13 op LDADD_LIBEVENT2 linker flags for libevent2
62 80189b3a 2022-08-13 op LDADD_LIB_SOCKET linker flags for libsocket
63 80189b3a 2022-08-13 op LDFLAGS extra linker flags
64 80189b3a 2022-08-13 op CPPFLAGS C preprocessor flags
65 80189b3a 2022-08-13 op DESTDIR destination directory
66 80189b3a 2022-08-13 op MANDIR where to install man pages (PREFIX/man)
67 80189b3a 2022-08-13 op LIBDIR where to install libraries (PREFIX/lib)
68 80189b3a 2022-08-13 op BINDIR where to install executables (PREFIX/bin)
69 80189b3a 2022-08-13 op SHAREDIR where to install misc files (PREFIX/share)
70 80189b3a 2022-08-13 op SBINDIR where to install system executables (PREFIX/sbin)
71 80189b3a 2022-08-13 op INCLUDEDIR where to install header files (PREFIX/include)
72 80189b3a 2022-08-13 op PKG_CONFIG pkg-config program, \`false' to disable (pkg-config)
73 80189b3a 2022-08-13 op
74 80189b3a 2022-08-13 op Additionally, the following environment variables are used if set:
75 80189b3a 2022-08-13 op
76 80189b3a 2022-08-13 op CC the C compiler to use (defaults to cc, clang or gcc)
77 80189b3a 2022-08-13 op CFLAGS generic C compiler flags
78 80189b3a 2022-08-13 op
79 80189b3a 2022-08-13 op EOF
80 80189b3a 2022-08-13 op exit 0 ;;
81 80189b3a 2022-08-13 op esac
82 80189b3a 2022-08-13 op
83 80189b3a 2022-08-13 op #----------------------------------------------------------------------
84 80189b3a 2022-08-13 op # Prepare for running: move aside previous configure runs.
85 80189b3a 2022-08-13 op # Output file descriptor usage:
86 80189b3a 2022-08-13 op # 1 (stdout): config.h or Makefile.configure
87 80189b3a 2022-08-13 op # 2 (stderr): original stderr, usually to the console
88 80189b3a 2022-08-13 op # 3: config.log
89 80189b3a 2022-08-13 op # You DO NOT want to change this.
90 80189b3a 2022-08-13 op #----------------------------------------------------------------------
91 80189b3a 2022-08-13 op
92 80189b3a 2022-08-13 op [ -w config.log ] && mv config.log config.log.old
93 80189b3a 2022-08-13 op [ -w config.h ] && mv config.h config.h.old
94 80189b3a 2022-08-13 op
95 80189b3a 2022-08-13 op exec 3> config.log
96 80189b3a 2022-08-13 op echo "config.log: writing..."
97 80189b3a 2022-08-13 op
98 80189b3a 2022-08-13 op # GNU submake prints different output if invoked recursively, which
99 80189b3a 2022-08-13 op # messes up CC and CFLAGS detection. Pass --no-print-directory if
100 80189b3a 2022-08-13 op # we have a MAKELEVEL (GNU and FreeBSD make) and the argument is
101 80189b3a 2022-08-13 op # allowed.
102 80189b3a 2022-08-13 op
103 80189b3a 2022-08-13 op MAKE_FLAGS=""
104 80189b3a 2022-08-13 op
105 80189b3a 2022-08-13 op if [ -n "${MAKELEVEL}" ]; then
106 80189b3a 2022-08-13 op if [ "${MAKELEVEL}" -gt 0 ] ; then
107 80189b3a 2022-08-13 op MAKE_FLAGS="--no-print-directory"
108 80189b3a 2022-08-13 op echo "all:" | make ${MAKE_FLAGS} -sf - 2>/dev/null || MAKE_FLAGS=""
109 80189b3a 2022-08-13 op fi
110 80189b3a 2022-08-13 op fi
111 80189b3a 2022-08-13 op
112 80189b3a 2022-08-13 op if [ -n "$MAKE_FLAGS" ]; then
113 80189b3a 2022-08-13 op echo "GNU submake detected: using --no-print-directory" 1>&2
114 80189b3a 2022-08-13 op echo "GNU submake detected: using --no-print-directory" 1>&3
115 80189b3a 2022-08-13 op fi
116 80189b3a 2022-08-13 op
117 80189b3a 2022-08-13 op #----------------------------------------------------------------------
118 80189b3a 2022-08-13 op # Initialize all variables here such that nothing can leak in from the
119 80189b3a 2022-08-13 op # environment except for CC and CFLAGS, which we might have passed in.
120 80189b3a 2022-08-13 op #----------------------------------------------------------------------
121 80189b3a 2022-08-13 op
122 80189b3a 2022-08-13 op CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | make ${MAKE_FLAGS} -sf -`
123 80189b3a 2022-08-13 op CFLAGS=`printf "all:\\n\\t@echo \\\$(CFLAGS)\\n" | make ${MAKE_FLAGS} -sf -`
124 80189b3a 2022-08-13 op CFLAGS="${CFLAGS} -g -W -Wall -Wextra -Wmissing-prototypes -Wstrict-prototypes"
125 80189b3a 2022-08-13 op CFLAGS="${CFLAGS} -Wwrite-strings -Wno-unused-parameter"
126 80189b3a 2022-08-13 op LDADD=
127 80189b3a 2022-08-13 op LDADD_LIBEVENT=
128 80189b3a 2022-08-13 op LDADD_LIBEVENT2=
129 80189b3a 2022-08-13 op LDADD_LIB_SOCKET=
130 80189b3a 2022-08-13 op LDADD_STATIC=
131 80189b3a 2022-08-13 op CPPFLAGS=
132 80189b3a 2022-08-13 op LDFLAGS=
133 80189b3a 2022-08-13 op DESTDIR=
134 80189b3a 2022-08-13 op PREFIX="/usr/local"
135 80189b3a 2022-08-13 op BINDIR=
136 80189b3a 2022-08-13 op SBINDIR=
137 80189b3a 2022-08-13 op INCLUDEDIR=
138 80189b3a 2022-08-13 op LIBDIR=
139 80189b3a 2022-08-13 op MANDIR=
140 80189b3a 2022-08-13 op SHAREDIR=
141 80189b3a 2022-08-13 op INSTALL="install"
142 80189b3a 2022-08-13 op INSTALL_PROGRAM=
143 80189b3a 2022-08-13 op INSTALL_LIB=
144 80189b3a 2022-08-13 op INSTALL_MAN=
145 80189b3a 2022-08-13 op INSTALL_DATA=
146 80189b3a 2022-08-13 op
147 80189b3a 2022-08-13 op # SunOS sets "cc", but this doesn't exist.
148 80189b3a 2022-08-13 op # It does have gcc, so try that instead.
149 80189b3a 2022-08-13 op # Prefer clang, though.
150 80189b3a 2022-08-13 op
151 80189b3a 2022-08-13 op command -v ${CC} 2>/dev/null 1>&2 || {
152 80189b3a 2022-08-13 op echo "${CC} not found: trying clang" 1>&2
153 80189b3a 2022-08-13 op echo "${CC} not found: trying clang" 1>&3
154 80189b3a 2022-08-13 op CC=clang
155 80189b3a 2022-08-13 op command -v ${CC} 2>/dev/null 1>&2 || {
156 80189b3a 2022-08-13 op echo "${CC} not found: trying gcc" 1>&2
157 80189b3a 2022-08-13 op echo "${CC} not found: trying gcc" 1>&3
158 80189b3a 2022-08-13 op CC=gcc
159 80189b3a 2022-08-13 op command -v ${CC} 2>/dev/null 1>&2 || {
160 80189b3a 2022-08-13 op echo "gcc not found: giving up" 1>&2
161 80189b3a 2022-08-13 op echo "gcc not found: giving up" 1>&3
162 80189b3a 2022-08-13 op exit 1
163 80189b3a 2022-08-13 op }
164 80189b3a 2022-08-13 op }
165 80189b3a 2022-08-13 op }
166 80189b3a 2022-08-13 op
167 80189b3a 2022-08-13 op #----------------------------------------------------------------------
168 80189b3a 2022-08-13 op # Allow certain variables to be overriden on the command line.
169 80189b3a 2022-08-13 op #----------------------------------------------------------------------
170 80189b3a 2022-08-13 op
171 80189b3a 2022-08-13 op while [ $# -gt 0 ]; do
172 80189b3a 2022-08-13 op key"${1%%=*}"
173 80189b3a 2022-08-13 op val="${1#*=}"
174 80189b3a 2022-08-13 op
175 80189b3a 2022-08-13 op if [ "$key" "-prefix" ]; then
176 80189b3a 2022-08-13 op key=PREFIX
177 80189b3a 2022-08-13 op if [ "$1" = "--prefix" ]; then
178 80189b3a 2022-08-13 op if ! shift 2>&1 >/dev/null; then
179 80189b3a 2022-08-13 op echo "$0: missing value for --prefix" >&2
180 80189b3a 2022-08-13 op exit 1
181 80189b3a 2022-08-13 op fi
182 80189b3a 2022-08-13 op val="$1"
183 80189b3a 2022-08-13 op fi
184 80189b3a 2022-08-13 op fi
185 80189b3a 2022-08-13 op
186 80189b3a 2022-08-13 op if [ "$1" = "$key" ]; then
187 80189b3a 2022-08-13 op echo "$0: invalid key-value: $1" >&2
188 80189b3a 2022-08-13 op exit 1
189 80189b3a 2022-08-13 op fi
190 80189b3a 2022-08-13 op
191 80189b3a 2022-08-13 op shift
192 80189b3a 2022-08-13 op
193 80189b3a 2022-08-13 op case "$key" in
194 80189b3a 2022-08-13 op LDADD)
195 80189b3a 2022-08-13 op LDADD="$val" ;;
196 80189b3a 2022-08-13 op LDADD_LIBEVENT)
197 80189b3a 2022-08-13 op LDADD_LIBEVENT="$val" ;;
198 80189b3a 2022-08-13 op LDADD_LIBEVENT2)
199 80189b3a 2022-08-13 op LDADD_LIBEVENT2="$val" ;;
200 80189b3a 2022-08-13 op LDADD_LIB_SOCKET)
201 80189b3a 2022-08-13 op LDADD_LIB_SOCKET="$val" ;;
202 80189b3a 2022-08-13 op LDFLAGS)
203 80189b3a 2022-08-13 op LDFLAGS="$val" ;;
204 80189b3a 2022-08-13 op CPPFLAGS)
205 80189b3a 2022-08-13 op CPPFLAGS="$val" ;;
206 80189b3a 2022-08-13 op DESTDIR)
207 80189b3a 2022-08-13 op DESTDIR="$val" ;;
208 80189b3a 2022-08-13 op PREFIX)
209 80189b3a 2022-08-13 op PREFIX="$val" ;;
210 80189b3a 2022-08-13 op MANDIR)
211 80189b3a 2022-08-13 op MANDIR="$val" ;;
212 80189b3a 2022-08-13 op LIBDIR)
213 80189b3a 2022-08-13 op LIBDIR="$val" ;;
214 80189b3a 2022-08-13 op BINDIR)
215 80189b3a 2022-08-13 op BINDIR="$val" ;;
216 80189b3a 2022-08-13 op SHAREDIR)
217 80189b3a 2022-08-13 op SHAREDIR="$val" ;;
218 80189b3a 2022-08-13 op SBINDIR)
219 80189b3a 2022-08-13 op SBINDIR="$val" ;;
220 80189b3a 2022-08-13 op INCLUDEDIR)
221 80189b3a 2022-08-13 op INCLUDEDIR="$val" ;;
222 80189b3a 2022-08-13 op PKG_CONFIG)
223 80189b3a 2022-08-13 op PKG_CONFIG="$val" ;;
224 80189b3a 2022-08-13 op *)
225 80189b3a 2022-08-13 op echo "$0: invalid key: $key" 1>&2
226 80189b3a 2022-08-13 op exit 1
227 80189b3a 2022-08-13 op esac
228 80189b3a 2022-08-13 op done
229 80189b3a 2022-08-13 op
230 80189b3a 2022-08-13 op test -z "${PKG_CONFIG}" && {
231 80189b3a 2022-08-13 op PKG_CONFIG="$(command -v pkg-config)" 2>/dev/null && {
232 80189b3a 2022-08-13 op echo "found pkg-config: $PKG_CONFIG" 1>&2
233 80189b3a 2022-08-13 op echo "found pkg-config: $PKG_CONFIG" 1>&3
234 80189b3a 2022-08-13 op } || {
235 80189b3a 2022-08-13 op PKG_CONFIG=false
236 80189b3a 2022-08-13 op echo "pkg-config not found: $PKG_CONFIG" 1>&2
237 80189b3a 2022-08-13 op echo "pkg-config not found: $PKG_CONFIG" 1>&3
238 80189b3a 2022-08-13 op }
239 80189b3a 2022-08-13 op }
240 80189b3a 2022-08-13 op
241 80189b3a 2022-08-13 op
242 80189b3a 2022-08-13 op #----------------------------------------------------------------------
243 80189b3a 2022-08-13 op # These are the values that will be pushed into config.h after we test
244 80189b3a 2022-08-13 op # for whether they're supported or not.
245 80189b3a 2022-08-13 op # Each of these must have a runtest(), below.
246 80189b3a 2022-08-13 op # Please sort by alpha, for clarity.
247 80189b3a 2022-08-13 op # You WANT to change this.
248 80189b3a 2022-08-13 op #----------------------------------------------------------------------
249 80189b3a 2022-08-13 op
250 80189b3a 2022-08-13 op HAVE_ENDIAN_H=
251 80189b3a 2022-08-13 op HAVE_ERR=
252 80189b3a 2022-08-13 op HAVE_GETDTABLECOUNT=
253 80189b3a 2022-08-13 op HAVE_GETEXECNAME=
254 80189b3a 2022-08-13 op HAVE_GETPROGNAME=
255 80189b3a 2022-08-13 op HAVE_OSBYTEORDER_H=
256 80189b3a 2022-08-13 op HAVE_PATH_MAX=
257 80189b3a 2022-08-13 op HAVE_PLEDGE=
258 80189b3a 2022-08-13 op HAVE_PROGRAM_INVOCATION_SHORT_NAME=
259 80189b3a 2022-08-13 op HAVE_SETRESGID=
260 80189b3a 2022-08-13 op HAVE_SETRESUID=
261 80189b3a 2022-08-13 op HAVE_SOCK_NONBLOCK=
262 80189b3a 2022-08-13 op HAVE_STRLCAT=
263 80189b3a 2022-08-13 op HAVE_STRLCPY=
264 80189b3a 2022-08-13 op HAVE_STRTONUM=
265 80189b3a 2022-08-13 op HAVE_SYS_BYTEORDER_H=
266 80189b3a 2022-08-13 op HAVE_SYS_ENDIAN_H=
267 80189b3a 2022-08-13 op HAVE_SYS_QUEUE=
268 80189b3a 2022-08-13 op HAVE_WAIT_ANY=
269 80189b3a 2022-08-13 op HAVE___PROGNAME=
270 80189b3a 2022-08-13 op
271 80189b3a 2022-08-13 op #----------------------------------------------------------------------
272 80189b3a 2022-08-13 op # Allow configure.local to override all variables, default settings,
273 80189b3a 2022-08-13 op # command-line arguments, and tested features, above.
274 80189b3a 2022-08-13 op # You PROBABLY DO NOT want to change this.
275 80189b3a 2022-08-13 op #----------------------------------------------------------------------
276 80189b3a 2022-08-13 op
277 80189b3a 2022-08-13 op if [ -r ./configure.local ]; then
278 80189b3a 2022-08-13 op echo "configure.local: reading..." 1>&2
279 80189b3a 2022-08-13 op echo "configure.local: reading..." 1>&3
280 80189b3a 2022-08-13 op cat ./configure.local 1>&3
281 80189b3a 2022-08-13 op . ./configure.local
282 80189b3a 2022-08-13 op else
283 80189b3a 2022-08-13 op echo "configure.local: no (fully automatic configuration)" 1>&2
284 80189b3a 2022-08-13 op echo "configure.local: no (fully automatic configuration)" 1>&3
285 80189b3a 2022-08-13 op fi
286 80189b3a 2022-08-13 op
287 80189b3a 2022-08-13 op echo 1>&3
288 80189b3a 2022-08-13 op
289 80189b3a 2022-08-13 op #----------------------------------------------------------------------
290 80189b3a 2022-08-13 op # Infrastructure for running tests.
291 80189b3a 2022-08-13 op # These consists of a series of functions that will attempt to run the
292 80189b3a 2022-08-13 op # given test file and record its exit into a HAVE_xxx variable.
293 80189b3a 2022-08-13 op # You DO NOT want to change this.
294 80189b3a 2022-08-13 op #----------------------------------------------------------------------
295 80189b3a 2022-08-13 op
296 80189b3a 2022-08-13 op COMP="${CC} ${CFLAGS} ${CPPFLAGS} -Wno-unused -Werror"
297 80189b3a 2022-08-13 op
298 80189b3a 2022-08-13 op # Check whether this HAVE_ setting is manually overridden.
299 80189b3a 2022-08-13 op # If yes, use the override, if no, do not decide anything yet.
300 80189b3a 2022-08-13 op # Arguments: lower-case test name, manual value
301 80189b3a 2022-08-13 op
302 80189b3a 2022-08-13 op ismanual() {
303 80189b3a 2022-08-13 op [ -z "${3}" ] && return 1
304 80189b3a 2022-08-13 op echo "${1}: manual (HAVE_${2}=${3})" 1>&2
305 80189b3a 2022-08-13 op echo "${1}: manual (HAVE_${2}=${3})" 1>&3
306 80189b3a 2022-08-13 op echo 1>&3
307 80189b3a 2022-08-13 op return 0
308 80189b3a 2022-08-13 op }
309 80189b3a 2022-08-13 op
310 80189b3a 2022-08-13 op # Run a single autoconfiguration test.
311 80189b3a 2022-08-13 op # In case of success, enable the feature.
312 80189b3a 2022-08-13 op # In case of failure, do not decide anything yet.
313 80189b3a 2022-08-13 op # Arguments: lower-case test name, upper-case test name, additional
314 80189b3a 2022-08-13 op # CFLAGS, additional LIBS.
315 80189b3a 2022-08-13 op
316 80189b3a 2022-08-13 op singletest() {
317 80189b3a 2022-08-13 op extralib=""
318 80189b3a 2022-08-13 op cat 1>&3 << __HEREDOC__
319 80189b3a 2022-08-13 op ${1}: testing...
320 80189b3a 2022-08-13 op ${COMP} -DTEST_${2} ${3} -o test-${1} tests.c ${LDFLAGS} ${4}
321 80189b3a 2022-08-13 op __HEREDOC__
322 80189b3a 2022-08-13 op if ${COMP} -DTEST_${2} ${3} -o "test-${1}" tests.c ${LDFLAGS} ${4} 1>&3 2>&3; then
323 80189b3a 2022-08-13 op echo "${1}: ${CC} succeeded" 1>&3
324 80189b3a 2022-08-13 op else
325 80189b3a 2022-08-13 op if [ -n "${5}" ] ; then
326 80189b3a 2022-08-13 op echo "${1}: ${CC} failed with $? (retrying)" 1>&3
327 80189b3a 2022-08-13 op cat 1>&3 << __HEREDOC__
328 80189b3a 2022-08-13 op ${1}: testing...
329 80189b3a 2022-08-13 op ${COMP} -DTEST_${2} ${3} -o test-${1} tests.c ${LDFLAGS} ${5}
330 80189b3a 2022-08-13 op __HEREDOC__
331 80189b3a 2022-08-13 op if ${COMP} -DTEST_${2} ${3} -o "test-${1}" tests.c ${LDFLAGS} ${5} 1>&3 2>&3; then
332 80189b3a 2022-08-13 op echo "${1}: ${CC} succeeded" 1>&3
333 80189b3a 2022-08-13 op extralib="(with ${5})"
334 80189b3a 2022-08-13 op else
335 80189b3a 2022-08-13 op test -n "${6}" && ${PKG_CONFIG} "${6}"
336 80189b3a 2022-08-13 op if [ $? -eq 0 ]; then
337 80189b3a 2022-08-13 op echo "${1}: ${CC} failed with $? (retrying)" 1>&3
338 80189b3a 2022-08-13 op pkgcfs="$($PKG_CONFIG --cflags "$6")"
339 80189b3a 2022-08-13 op pkglib="$($PKG_CONFIG --libs "$6")"
340 80189b3a 2022-08-13 op cat 1>&3 <<EOF
341 80189b3a 2022-08-13 op ${1}: testing...
342 80189b3a 2022-08-13 op ${COMP} -DTEST_${2} ${3} ${pkgcfs} -o test-${1} tests.c ${LDFLAGS} ${pkglib}
343 80189b3a 2022-08-13 op EOF
344 80189b3a 2022-08-13 op if ${COMP} -DTEST_${2} ${3} ${pkgcfs} -o test-${1} tests.c ${LDFLAGS} ${pkglib} 1>&3 2>&3; then
345 80189b3a 2022-08-13 op echo "${1}: ${CC} succeeded" 1>&3
346 80189b3a 2022-08-13 op extralib="(with ${pkgcfs} ${pkglib})"
347 80189b3a 2022-08-13 op else
348 80189b3a 2022-08-13 op echo "${1}: ${CC} failed with $?" 1>&3
349 80189b3a 2022-08-13 op echo 1>&3
350 80189b3a 2022-08-13 op return 1
351 80189b3a 2022-08-13 op fi
352 80189b3a 2022-08-13 op else
353 80189b3a 2022-08-13 op echo "${1}: ${CC} failed with $?" 1>&3
354 80189b3a 2022-08-13 op echo 1>&3
355 80189b3a 2022-08-13 op return 1
356 80189b3a 2022-08-13 op fi
357 80189b3a 2022-08-13 op fi
358 80189b3a 2022-08-13 op else
359 80189b3a 2022-08-13 op echo "${1}: ${CC} failed with $?" 1>&3
360 80189b3a 2022-08-13 op echo 1>&3
361 80189b3a 2022-08-13 op return 1
362 80189b3a 2022-08-13 op fi
363 80189b3a 2022-08-13 op fi
364 80189b3a 2022-08-13 op
365 80189b3a 2022-08-13 op if [ -n "${pkgcfs}" -o -n "${pkglib}" ]
366 80189b3a 2022-08-13 op then
367 80189b3a 2022-08-13 op CFLAGS="${CFLAGS} ${pkgcfs}"
368 80189b3a 2022-08-13 op eval "LDADD_${2}=\"${pkglib}\""
369 80189b3a 2022-08-13 op elif [ -n "${extralib}" ]
370 80189b3a 2022-08-13 op then
371 80189b3a 2022-08-13 op eval "LDADD_${2}=\"${5}\""
372 80189b3a 2022-08-13 op elif [ -n "${4}" ]
373 80189b3a 2022-08-13 op then
374 80189b3a 2022-08-13 op eval "LDADD_${2}=\"${4}\""
375 80189b3a 2022-08-13 op fi
376 80189b3a 2022-08-13 op
377 80189b3a 2022-08-13 op echo "${1}: yes ${extralib}" 1>&2
378 80189b3a 2022-08-13 op echo "${1}: yes ${extralib}" 1>&3
379 80189b3a 2022-08-13 op echo 1>&3
380 80189b3a 2022-08-13 op eval HAVE_${2}=1
381 80189b3a 2022-08-13 op rm "test-${1}"
382 80189b3a 2022-08-13 op return 0
383 80189b3a 2022-08-13 op }
384 80189b3a 2022-08-13 op
385 80189b3a 2022-08-13 op # Run a complete autoconfiguration test, including the check for
386 80189b3a 2022-08-13 op # a manual override and disabling the feature on failure.
387 80189b3a 2022-08-13 op # Arguments: lower case name, upper case name, additional CFLAGS,
388 80189b3a 2022-08-13 op # additional LDADD, alternative LDADD, pkg-config name.
389 80189b3a 2022-08-13 op
390 80189b3a 2022-08-13 op runtest() {
391 80189b3a 2022-08-13 op eval _manual=\${HAVE_${2}}
392 80189b3a 2022-08-13 op ismanual "${1}" "${2}" "${_manual}" && return 0
393 80189b3a 2022-08-13 op singletest "${1}" "${2}" "${3}" "${4}" "${5}" && return 0
394 80189b3a 2022-08-13 op echo "${1}: no" 1>&2
395 80189b3a 2022-08-13 op eval HAVE_${2}=0
396 80189b3a 2022-08-13 op return 1
397 80189b3a 2022-08-13 op }
398 80189b3a 2022-08-13 op
399 80189b3a 2022-08-13 op #----------------------------------------------------------------------
400 80189b3a 2022-08-13 op # Begin running the tests themselves.
401 80189b3a 2022-08-13 op # All of your tests must be defined here.
402 80189b3a 2022-08-13 op # Please sort as the HAVE_xxxx values were defined.
403 80189b3a 2022-08-13 op # You WANT to change this.
404 80189b3a 2022-08-13 op # It consists of the following columns:
405 80189b3a 2022-08-13 op # runtest
406 80189b3a 2022-08-13 op # (1) test file
407 80189b3a 2022-08-13 op # (2) macro to set
408 80189b3a 2022-08-13 op # (3) argument to cc *before* -o
409 80189b3a 2022-08-13 op # (4) argument to cc *after*
410 80189b3a 2022-08-13 op # (5) alternative argument to cc *after*
411 80189b3a 2022-08-13 op #----------------------------------------------------------------------
412 80189b3a 2022-08-13 op
413 80189b3a 2022-08-13 op runtest endian_h ENDIAN_H || true
414 80189b3a 2022-08-13 op runtest err ERR || true
415 80189b3a 2022-08-13 op runtest getdtablecount GETDTABLECOUNT || true
416 80189b3a 2022-08-13 op runtest getexecname GETEXECNAME || true
417 80189b3a 2022-08-13 op runtest getprogname GETPROGNAME || true
418 80189b3a 2022-08-13 op
419 80189b3a 2022-08-13 op runtest libevent LIBEVENT "" "" "-levent" || \
420 80189b3a 2022-08-13 op runtest libevent2 LIBEVENT2 "" "" "-levent_extra -levent_core" "libevent" || true
421 80189b3a 2022-08-13 op
422 80189b3a 2022-08-13 op runtest lib_socket LIB_SOCKET "" "" "-lsocket -lnsl" || true
423 80189b3a 2022-08-13 op runtest osbyteorder_h OSBYTEORDER_H || true
424 80189b3a 2022-08-13 op runtest PATH_MAX PATH_MAX || true
425 80189b3a 2022-08-13 op runtest pledge PLEDGE || true
426 80189b3a 2022-08-13 op runtest program_invocation_short_name PROGRAM_INVOCATION_SHORT_NAME || true
427 80189b3a 2022-08-13 op runtest setresgid SETRESGID || true
428 80189b3a 2022-08-13 op runtest setresuid SETRESUID || true
429 80189b3a 2022-08-13 op runtest SOCK_NONBLOCK SOCK_NONBLOCK || true
430 80189b3a 2022-08-13 op runtest static STATIC "" "-static" || true
431 80189b3a 2022-08-13 op runtest strlcat STRLCAT || true
432 80189b3a 2022-08-13 op runtest strlcpy STRLCPY || true
433 80189b3a 2022-08-13 op runtest strtonum STRTONUM || true
434 80189b3a 2022-08-13 op runtest sys_byteorder_h SYS_BYTEORDER_H || true
435 80189b3a 2022-08-13 op runtest sys_endian_h SYS_ENDIAN_H || true
436 80189b3a 2022-08-13 op runtest sys_queue SYS_QUEUE || true
437 80189b3a 2022-08-13 op runtest WAIT_ANY WAIT_ANY || true
438 80189b3a 2022-08-13 op runtest __progname __PROGNAME || true
439 80189b3a 2022-08-13 op
440 80189b3a 2022-08-13 op if [ "${HAVE_LIBEVENT}" -eq 0 -a "${HAVE_LIBEVENT2:-0}" -eq 0 ]; then
441 80189b3a 2022-08-13 op echo "Fatal: missing libevent" 1>&2
442 80189b3a 2022-08-13 op echo "Fatal: missing libevent" 1>&3
443 80189b3a 2022-08-13 op exit 1
444 80189b3a 2022-08-13 op fi
445 80189b3a 2022-08-13 op
446 80189b3a 2022-08-13 op #----------------------------------------------------------------------
447 80189b3a 2022-08-13 op # Output writing: generate the config.h file.
448 80189b3a 2022-08-13 op # This file contains all of the HAVE_xxxx variables necessary for
449 80189b3a 2022-08-13 op # compiling your source.
450 80189b3a 2022-08-13 op # You must include "config.h" BEFORE any other variables.
451 80189b3a 2022-08-13 op # You WANT to change this.
452 80189b3a 2022-08-13 op #----------------------------------------------------------------------
453 80189b3a 2022-08-13 op
454 80189b3a 2022-08-13 op exec > config.h
455 80189b3a 2022-08-13 op
456 80189b3a 2022-08-13 op # Start with prologue.
457 80189b3a 2022-08-13 op
458 80189b3a 2022-08-13 op cat << __HEREDOC__
459 80189b3a 2022-08-13 op #ifndef OCONFIGURE_CONFIG_H
460 80189b3a 2022-08-13 op #define OCONFIGURE_CONFIG_H
461 80189b3a 2022-08-13 op
462 80189b3a 2022-08-13 op #ifdef __cplusplus
463 80189b3a 2022-08-13 op # error "Do not use C++: this is a C application."
464 80189b3a 2022-08-13 op #endif
465 80189b3a 2022-08-13 op #if !defined(__GNUC__) || (__GNUC__ < 4)
466 80189b3a 2022-08-13 op # define __attribute__(x)
467 80189b3a 2022-08-13 op #endif
468 80189b3a 2022-08-13 op #if defined(__linux__) || defined(__MINT__)
469 80189b3a 2022-08-13 op # define _GNU_SOURCE /* memmem, memrchr, setresuid... */
470 80189b3a 2022-08-13 op # define _DEFAULT_SOURCE /* le32toh, crypt, ... */
471 80189b3a 2022-08-13 op #endif
472 80189b3a 2022-08-13 op #if defined(__NetBSD__)
473 80189b3a 2022-08-13 op # define _OPENBSD_SOURCE /* reallocarray, etc. */
474 80189b3a 2022-08-13 op #endif
475 80189b3a 2022-08-13 op #if defined(__sun)
476 80189b3a 2022-08-13 op # ifndef _XOPEN_SOURCE /* SunOS already defines */
477 80189b3a 2022-08-13 op # define _XOPEN_SOURCE /* XPGx */
478 80189b3a 2022-08-13 op # endif
479 80189b3a 2022-08-13 op # define _XOPEN_SOURCE_EXTENDED 1 /* XPG4v2 */
480 80189b3a 2022-08-13 op # ifndef __EXTENSIONS__ /* SunOS already defines */
481 80189b3a 2022-08-13 op # define __EXTENSIONS__ /* reallocarray, etc. */
482 80189b3a 2022-08-13 op # endif
483 80189b3a 2022-08-13 op #endif
484 80189b3a 2022-08-13 op #if !defined(__BEGIN_DECLS)
485 80189b3a 2022-08-13 op # define __BEGIN_DECLS
486 80189b3a 2022-08-13 op #endif
487 80189b3a 2022-08-13 op #if !defined(__END_DECLS)
488 80189b3a 2022-08-13 op # define __END_DECLS
489 80189b3a 2022-08-13 op #endif
490 80189b3a 2022-08-13 op
491 80189b3a 2022-08-13 op __HEREDOC__
492 80189b3a 2022-08-13 op
493 80189b3a 2022-08-13 op # This is just for size_t, mode_t, and dev_t.
494 80189b3a 2022-08-13 op # Most of these functions, in the real world, pull in <string.h> or
495 80189b3a 2022-08-13 op # someting that pulls in support for size_t.
496 80189b3a 2022-08-13 op # Our function declarations are standalone, so specify them here.
497 80189b3a 2022-08-13 op
498 80189b3a 2022-08-13 op if [ ${HAVE_SETRESGID} -eq 0 -o \
499 80189b3a 2022-08-13 op ${HAVE_SETRESUID} -eq 0 -o \
500 80189b3a 2022-08-13 op ${HAVE_STRLCAT} -eq 0 -o \
501 80189b3a 2022-08-13 op ${HAVE_STRLCPY} -eq 0 ]
502 80189b3a 2022-08-13 op then
503 80189b3a 2022-08-13 op echo "#include <sys/types.h> /* size_t, mode_t, dev_t */ "
504 80189b3a 2022-08-13 op echo
505 80189b3a 2022-08-13 op fi
506 80189b3a 2022-08-13 op
507 80189b3a 2022-08-13 op if [ ${HAVE_SYS_QUEUE} -eq 1 ]
508 80189b3a 2022-08-13 op then
509 80189b3a 2022-08-13 op echo "#include <sys/queue.h>"
510 80189b3a 2022-08-13 op echo
511 80189b3a 2022-08-13 op fi
512 80189b3a 2022-08-13 op
513 80189b3a 2022-08-13 op if [ ${HAVE_ERR} -eq 1 ]
514 80189b3a 2022-08-13 op then
515 80189b3a 2022-08-13 op echo "#include <err.h> /* err(3) */"
516 80189b3a 2022-08-13 op echo
517 80189b3a 2022-08-13 op fi
518 80189b3a 2022-08-13 op
519 80189b3a 2022-08-13 op if [ ${HAVE_LIBEVENT2:-0} -eq 1 ]; then
520 80189b3a 2022-08-13 op cat <<EOF
521 80189b3a 2022-08-13 op #include <event2/event.h>
522 80189b3a 2022-08-13 op #include <event2/event_compat.h>
523 80189b3a 2022-08-13 op #include <event2/event_struct.h>
524 80189b3a 2022-08-13 op #include <event2/buffer.h>
525 80189b3a 2022-08-13 op #include <event2/buffer_compat.h>
526 80189b3a 2022-08-13 op #include <event2/bufferevent.h>
527 80189b3a 2022-08-13 op #include <event2/bufferevent_struct.h>
528 80189b3a 2022-08-13 op #include <event2/bufferevent_compat.h>
529 80189b3a 2022-08-13 op
530 80189b3a 2022-08-13 op EOF
531 80189b3a 2022-08-13 op fi
532 80189b3a 2022-08-13 op
533 80189b3a 2022-08-13 op if [ ${HAVE_LIBEVENT} -eq 1 ]; then
534 80189b3a 2022-08-13 op cat <<EOF
535 80189b3a 2022-08-13 op #include <event.h>
536 80189b3a 2022-08-13 op
537 80189b3a 2022-08-13 op EOF
538 80189b3a 2022-08-13 op fi
539 80189b3a 2022-08-13 op
540 80189b3a 2022-08-13 op # Now we handle our HAVE_xxxx values.
541 80189b3a 2022-08-13 op # Most will just be defined as 0 or 1.
542 80189b3a 2022-08-13 op
543 80189b3a 2022-08-13 op if [ ${HAVE_PATH_MAX} -eq 0 ]
544 80189b3a 2022-08-13 op then
545 80189b3a 2022-08-13 op echo "#define PATH_MAX 4096"
546 80189b3a 2022-08-13 op echo
547 80189b3a 2022-08-13 op fi
548 80189b3a 2022-08-13 op
549 80189b3a 2022-08-13 op if [ ${HAVE_WAIT_ANY} -eq 0 ]
550 80189b3a 2022-08-13 op then
551 80189b3a 2022-08-13 op echo "#define WAIT_ANY (-1) /* sys/wait.h */"
552 80189b3a 2022-08-13 op echo "#define WAIT_MYPGRP 0"
553 80189b3a 2022-08-13 op echo
554 80189b3a 2022-08-13 op fi
555 80189b3a 2022-08-13 op
556 80189b3a 2022-08-13 op
557 80189b3a 2022-08-13 op cat << __HEREDOC__
558 80189b3a 2022-08-13 op /*
559 80189b3a 2022-08-13 op * Results of configuration feature-testing.
560 80189b3a 2022-08-13 op */
561 80189b3a 2022-08-13 op #define HAVE_ENDIAN_H ${HAVE_ENDIAN_H}
562 80189b3a 2022-08-13 op #define HAVE_ERR ${HAVE_ERR}
563 80189b3a 2022-08-13 op #define HAVE_GETDTABLECOUNT ${HAVE_GETDTABLECOUNT}
564 80189b3a 2022-08-13 op #define HAVE_GETEXECNAME ${HAVE_GETEXECNAME}
565 80189b3a 2022-08-13 op #define HAVE_GETPROGNAME ${HAVE_GETPROGNAME}
566 80189b3a 2022-08-13 op #define HAVE_OSBYTEORDER_H ${HAVE_OSBYTEORDER_H}
567 80189b3a 2022-08-13 op #define HAVE_PATH_MAX ${HAVE_PATH_MAX}
568 80189b3a 2022-08-13 op #define HAVE_PLEDGE ${HAVE_PLEDGE}
569 80189b3a 2022-08-13 op #define HAVE_PROGRAM_INVOCATION_SHORT_NAME ${HAVE_PROGRAM_INVOCATION_SHORT_NAME}
570 80189b3a 2022-08-13 op #define HAVE_SETRESGID ${HAVE_SETRESGID}
571 80189b3a 2022-08-13 op #define HAVE_SETRESUID ${HAVE_SETRESUID}
572 80189b3a 2022-08-13 op #define HAVE_SOCK_NONBLOCK ${HAVE_SOCK_NONBLOCK}
573 80189b3a 2022-08-13 op #define HAVE_STRLCAT ${HAVE_STRLCAT}
574 80189b3a 2022-08-13 op #define HAVE_STRLCPY ${HAVE_STRLCPY}
575 80189b3a 2022-08-13 op #define HAVE_STRTONUM ${HAVE_STRTONUM}
576 80189b3a 2022-08-13 op #define HAVE_SYS_BYTEORDER_H ${HAVE_SYS_BYTEORDER_H}
577 80189b3a 2022-08-13 op #define HAVE_SYS_ENDIAN_H ${HAVE_SYS_ENDIAN_H}
578 80189b3a 2022-08-13 op #define HAVE_SYS_QUEUE ${HAVE_SYS_QUEUE}
579 80189b3a 2022-08-13 op #define HAVE_WAIT_ANY ${HAVE_WAIT_ANY}
580 80189b3a 2022-08-13 op #define HAVE___PROGNAME ${HAVE___PROGNAME}
581 80189b3a 2022-08-13 op
582 80189b3a 2022-08-13 op __HEREDOC__
583 80189b3a 2022-08-13 op
584 80189b3a 2022-08-13 op # Compat for libkern/OSByteOrder.h in place of endian.h.
585 80189b3a 2022-08-13 op
586 80189b3a 2022-08-13 op [ ${HAVE_OSBYTEORDER_H} -eq 1 -a \
587 80189b3a 2022-08-13 op ${HAVE_ENDIAN_H} -eq 0 -a \
588 80189b3a 2022-08-13 op ${HAVE_SYS_BYTEORDER_H} -eq 0 -a \
589 80189b3a 2022-08-13 op ${HAVE_SYS_ENDIAN_H} -eq 0 ] \
590 80189b3a 2022-08-13 op && cat << __HEREDOC__
591 80189b3a 2022-08-13 op /*
592 80189b3a 2022-08-13 op * endian.h compatibility with libkern/OSByteOrder.h.
593 80189b3a 2022-08-13 op */
594 80189b3a 2022-08-13 op #define htobe16(x) OSSwapHostToBigInt16(x)
595 80189b3a 2022-08-13 op #define htole16(x) OSSwapHostToLittleInt16(x)
596 80189b3a 2022-08-13 op #define be16toh(x) OSSwapBigToHostInt16(x)
597 80189b3a 2022-08-13 op #define le16toh(x) OSSwapLittleToHostInt16(x)
598 80189b3a 2022-08-13 op #define htobe32(x) OSSwapHostToBigInt32(x)
599 80189b3a 2022-08-13 op #define htole32(x) OSSwapHostToLittleInt32(x)
600 80189b3a 2022-08-13 op #define be32toh(x) OSSwapBigToHostInt32(x)
601 80189b3a 2022-08-13 op #define le32toh(x) OSSwapLittleToHostInt32(x)
602 80189b3a 2022-08-13 op #define htobe64(x) OSSwapHostToBigInt64(x)
603 80189b3a 2022-08-13 op #define htole64(x) OSSwapHostToLittleInt64(x)
604 80189b3a 2022-08-13 op #define be64toh(x) OSSwapBigToHostInt64(x)
605 80189b3a 2022-08-13 op #define le64toh(x) OSSwapLittleToHostInt64(x)
606 80189b3a 2022-08-13 op
607 80189b3a 2022-08-13 op __HEREDOC__
608 80189b3a 2022-08-13 op
609 80189b3a 2022-08-13 op [ ${HAVE_SYS_BYTEORDER_H} -eq 1 -a \
610 80189b3a 2022-08-13 op ${HAVE_ENDIAN_H} -eq 0 -a \
611 80189b3a 2022-08-13 op ${HAVE_OSBYTEORDER_H} -eq 0 -a \
612 80189b3a 2022-08-13 op ${HAVE_SYS_ENDIAN_H} -eq 0 ] \
613 80189b3a 2022-08-13 op && cat << __HEREDOC__
614 80189b3a 2022-08-13 op /*
615 80189b3a 2022-08-13 op * endian.h compatibility with sys/byteorder.h.
616 80189b3a 2022-08-13 op */
617 80189b3a 2022-08-13 op #define htobe16(x) BE_16(x)
618 80189b3a 2022-08-13 op #define htole16(x) LE_16(x)
619 80189b3a 2022-08-13 op #define be16toh(x) BE_16(x)
620 80189b3a 2022-08-13 op #define le16toh(x) LE_16(x)
621 80189b3a 2022-08-13 op #define htobe32(x) BE_32(x)
622 80189b3a 2022-08-13 op #define htole32(x) LE_32(x)
623 80189b3a 2022-08-13 op #define be32toh(x) BE_32(x)
624 80189b3a 2022-08-13 op #define le32toh(x) LE_32(x)
625 80189b3a 2022-08-13 op #define htobe64(x) BE_64(x)
626 80189b3a 2022-08-13 op #define htole64(x) LE_64(x)
627 80189b3a 2022-08-13 op #define be64toh(x) BE_64(x)
628 80189b3a 2022-08-13 op #define le64toh(x) LE_64(x)
629 80189b3a 2022-08-13 op
630 80189b3a 2022-08-13 op __HEREDOC__
631 80189b3a 2022-08-13 op
632 80189b3a 2022-08-13 op # Make endian.h easier by providing a COMPAT_ENDIAN_H.
633 80189b3a 2022-08-13 op
634 80189b3a 2022-08-13 op cat << __HEREDOC__
635 80189b3a 2022-08-13 op /*
636 80189b3a 2022-08-13 op * Make it easier to include endian.h forms.
637 80189b3a 2022-08-13 op */
638 80189b3a 2022-08-13 op #if HAVE_ENDIAN_H
639 80189b3a 2022-08-13 op # define COMPAT_ENDIAN_H <endian.h>
640 80189b3a 2022-08-13 op #elif HAVE_SYS_ENDIAN_H
641 80189b3a 2022-08-13 op # define COMPAT_ENDIAN_H <sys/endian.h>
642 80189b3a 2022-08-13 op #elif HAVE_OSBYTEORDER_H
643 80189b3a 2022-08-13 op # define COMPAT_ENDIAN_H <libkern/OSByteOrder.h>
644 80189b3a 2022-08-13 op #elif HAVE_SYS_BYTEORDER_H
645 80189b3a 2022-08-13 op # define COMPAT_ENDIAN_H <sys/byteorder.h>
646 80189b3a 2022-08-13 op #else
647 80189b3a 2022-08-13 op # warning No suitable endian.h could be found.
648 80189b3a 2022-08-13 op # warning Please e-mail the maintainers with your OS.
649 80189b3a 2022-08-13 op # define COMPAT_ENDIAN_H <endian.h>
650 80189b3a 2022-08-13 op #endif
651 80189b3a 2022-08-13 op
652 80189b3a 2022-08-13 op __HEREDOC__
653 80189b3a 2022-08-13 op
654 80189b3a 2022-08-13 op # Now we do our function declarations for missing functions.
655 80189b3a 2022-08-13 op
656 80189b3a 2022-08-13 op [ ${HAVE_ERR} -eq 0 ] && \
657 80189b3a 2022-08-13 op cat << __HEREDOC__
658 80189b3a 2022-08-13 op /*
659 80189b3a 2022-08-13 op * Compatibility functions for err(3).
660 80189b3a 2022-08-13 op */
661 80189b3a 2022-08-13 op extern void err(int, const char *, ...) __attribute__((noreturn));
662 80189b3a 2022-08-13 op extern void errc(int, int, const char *, ...) __attribute__((noreturn));
663 80189b3a 2022-08-13 op extern void errx(int, const char *, ...) __attribute__((noreturn));
664 80189b3a 2022-08-13 op extern void verr(int, const char *, va_list) __attribute__((noreturn));
665 80189b3a 2022-08-13 op extern void verrc(int, int, const char *, va_list) __attribute__((noreturn));
666 80189b3a 2022-08-13 op extern void verrx(int, const char *, va_list) __attribute__((noreturn));
667 80189b3a 2022-08-13 op extern void warn(const char *, ...);
668 80189b3a 2022-08-13 op extern void warnx(const char *, ...);
669 80189b3a 2022-08-13 op extern void warnc(int, const char *, ...);
670 80189b3a 2022-08-13 op extern void vwarn(const char *, va_list);
671 80189b3a 2022-08-13 op extern void vwarnc(int, const char *, va_list);
672 80189b3a 2022-08-13 op extern void vwarnx(const char *, va_list);
673 80189b3a 2022-08-13 op __HEREDOC__
674 80189b3a 2022-08-13 op
675 80189b3a 2022-08-13 op [ ${HAVE_GETDTABLECOUNT} -eq 0 ] && \
676 80189b3a 2022-08-13 op cat << __HEREDOC__
677 80189b3a 2022-08-13 op /*
678 80189b3a 2022-08-13 op * Compatibility for getdtablecount(2).
679 80189b3a 2022-08-13 op */
680 80189b3a 2022-08-13 op /* on linux could be implemented by looking in /proc/self/fd */
681 80189b3a 2022-08-13 op #define getdtablecount() (0)
682 80189b3a 2022-08-13 op
683 80189b3a 2022-08-13 op __HEREDOC__
684 80189b3a 2022-08-13 op
685 80189b3a 2022-08-13 op [ ${HAVE_GETPROGNAME} -eq 0 ] && \
686 80189b3a 2022-08-13 op cat << __HEREDOC__
687 80189b3a 2022-08-13 op /*
688 80189b3a 2022-08-13 op * Compatibility for getprogname(3).
689 80189b3a 2022-08-13 op */
690 80189b3a 2022-08-13 op extern const char *getprogname(void);
691 80189b3a 2022-08-13 op
692 80189b3a 2022-08-13 op __HEREDOC__
693 80189b3a 2022-08-13 op
694 80189b3a 2022-08-13 op [ ${HAVE_PLEDGE} -eq 0 ] && \
695 80189b3a 2022-08-13 op cat << __HEREDOC__
696 80189b3a 2022-08-13 op /*
697 80189b3a 2022-08-13 op * Compatibility for pledge(2).
698 80189b3a 2022-08-13 op */
699 80189b3a 2022-08-13 op #define pledge(p, e) (0)
700 80189b3a 2022-08-13 op
701 80189b3a 2022-08-13 op __HEREDOC__
702 80189b3a 2022-08-13 op
703 80189b3a 2022-08-13 op [ ${HAVE_STRLCAT} -eq 0 ] && \
704 80189b3a 2022-08-13 op cat << __HEREDOC__
705 80189b3a 2022-08-13 op /*
706 80189b3a 2022-08-13 op * Compatibility for strlcat(3).
707 80189b3a 2022-08-13 op */
708 80189b3a 2022-08-13 op extern size_t strlcat(char *, const char *, size_t);
709 80189b3a 2022-08-13 op
710 80189b3a 2022-08-13 op __HEREDOC__
711 80189b3a 2022-08-13 op
712 80189b3a 2022-08-13 op [ ${HAVE_STRLCPY} -eq 0 ] && \
713 80189b3a 2022-08-13 op cat << __HEREDOC__
714 80189b3a 2022-08-13 op /*
715 80189b3a 2022-08-13 op * Compatibility for strlcpy(3).
716 80189b3a 2022-08-13 op */
717 80189b3a 2022-08-13 op extern size_t strlcpy(char *, const char *, size_t);
718 80189b3a 2022-08-13 op
719 80189b3a 2022-08-13 op __HEREDOC__
720 80189b3a 2022-08-13 op
721 80189b3a 2022-08-13 op [ ${HAVE_STRTONUM} -eq 0 ] && \
722 80189b3a 2022-08-13 op cat << __HEREDOC__
723 80189b3a 2022-08-13 op /*
724 80189b3a 2022-08-13 op * Compatibility for strotnum(3).
725 80189b3a 2022-08-13 op */
726 80189b3a 2022-08-13 op extern long long strtonum(const char *, long long, long long, const char **);
727 80189b3a 2022-08-13 op
728 80189b3a 2022-08-13 op __HEREDOC__
729 80189b3a 2022-08-13 op
730 80189b3a 2022-08-13 op [ ${HAVE_SETRESGID} -eq 0 ] && \
731 80189b3a 2022-08-13 op cat << __HEREDOC__
732 80189b3a 2022-08-13 op /*
733 80189b3a 2022-08-13 op * Compatibility for setresgid(2).
734 80189b3a 2022-08-13 op */
735 80189b3a 2022-08-13 op int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
736 80189b3a 2022-08-13 op
737 80189b3a 2022-08-13 op __HEREDOC__
738 80189b3a 2022-08-13 op
739 80189b3a 2022-08-13 op [ ${HAVE_SETRESUID} -eq 0 ] && \
740 80189b3a 2022-08-13 op cat << __HEREDOC__
741 80189b3a 2022-08-13 op /*
742 80189b3a 2022-08-13 op * Compatibility for setresuid(2).
743 80189b3a 2022-08-13 op */
744 80189b3a 2022-08-13 op int setresuid(uid_t ruid, uid_t euid, uid_t suid);
745 80189b3a 2022-08-13 op
746 80189b3a 2022-08-13 op __HEREDOC__
747 80189b3a 2022-08-13 op
748 80189b3a 2022-08-13 op [ ${HAVE_SYS_QUEUE} -eq 0 ] && \
749 80189b3a 2022-08-13 op cat << __HEREDOC__
750 80189b3a 2022-08-13 op #include "queue.h"
751 80189b3a 2022-08-13 op
752 80189b3a 2022-08-13 op __HEREDOC__
753 80189b3a 2022-08-13 op
754 80189b3a 2022-08-13 op cat << __HEREDOC__
755 80189b3a 2022-08-13 op #ifndef __dead
756 80189b3a 2022-08-13 op #define __dead __attribute__((noreturn))
757 80189b3a 2022-08-13 op #endif
758 80189b3a 2022-08-13 op
759 80189b3a 2022-08-13 op #ifndef __packed
760 80189b3a 2022-08-13 op #define __packed __attribute__((packed))
761 80189b3a 2022-08-13 op #endif
762 80189b3a 2022-08-13 op
763 80189b3a 2022-08-13 op #endif /*!OCONFIGURE_CONFIG_H*/
764 80189b3a 2022-08-13 op __HEREDOC__
765 80189b3a 2022-08-13 op
766 80189b3a 2022-08-13 op echo "config.h: written" 1>&2
767 80189b3a 2022-08-13 op echo "config.h: written" 1>&3
768 80189b3a 2022-08-13 op
769 80189b3a 2022-08-13 op #----------------------------------------------------------------------
770 80189b3a 2022-08-13 op # Now we go to generate our Makefile.configure.
771 80189b3a 2022-08-13 op # This file is simply a bunch of Makefile variables.
772 80189b3a 2022-08-13 op # They'll work in both GNUmakefile and BSDmakefile.
773 80189b3a 2022-08-13 op # You MIGHT want to change this.
774 80189b3a 2022-08-13 op #----------------------------------------------------------------------
775 80189b3a 2022-08-13 op
776 80189b3a 2022-08-13 op exec > Makefile.configure
777 80189b3a 2022-08-13 op
778 80189b3a 2022-08-13 op [ -z "${BINDIR}" ] && BINDIR="${PREFIX}/bin"
779 80189b3a 2022-08-13 op [ -z "${SBINDIR}" ] && SBINDIR="${PREFIX}/sbin"
780 80189b3a 2022-08-13 op [ -z "${INCLUDEDIR}" ] && INCLUDEDIR="${PREFIX}/include"
781 80189b3a 2022-08-13 op [ -z "${LIBDIR}" ] && LIBDIR="${PREFIX}/lib"
782 80189b3a 2022-08-13 op [ -z "${MANDIR}" ] && MANDIR="${PREFIX}/man"
783 80189b3a 2022-08-13 op [ -z "${SHAREDIR}" ] && SHAREDIR="${PREFIX}/share"
784 80189b3a 2022-08-13 op
785 80189b3a 2022-08-13 op [ -z "${INSTALL_PROGRAM}" ] && INSTALL_PROGRAM="${INSTALL} -m 0555"
786 80189b3a 2022-08-13 op [ -z "${INSTALL_LIB}" ] && INSTALL_LIB="${INSTALL} -m 0444"
787 80189b3a 2022-08-13 op [ -z "${INSTALL_MAN}" ] && INSTALL_MAN="${INSTALL} -m 0444"
788 80189b3a 2022-08-13 op [ -z "${INSTALL_DATA}" ] && INSTALL_DATA="${INSTALL} -m 0444"
789 80189b3a 2022-08-13 op
790 80189b3a 2022-08-13 op cat << __HEREDOC__
791 80189b3a 2022-08-13 op CC = ${CC}
792 80189b3a 2022-08-13 op CFLAGS = ${CFLAGS}
793 80189b3a 2022-08-13 op CPPFLAGS = ${CPPFLAGS}
794 80189b3a 2022-08-13 op LDADD = ${LDADD} ${LDADD_LIB_SOCKET} ${LDADD_LIBEVENT} ${LDADD_LIBEVENT2}
795 80189b3a 2022-08-13 op LDADD_STATIC = ${LDADD_STATIC}
796 80189b3a 2022-08-13 op LDFLAGS = ${LDFLAGS}
797 80189b3a 2022-08-13 op STATIC = ${STATIC}
798 80189b3a 2022-08-13 op PREFIX = ${PREFIX}
799 80189b3a 2022-08-13 op BINDIR = ${BINDIR}
800 80189b3a 2022-08-13 op SHAREDIR = ${SHAREDIR}
801 80189b3a 2022-08-13 op SBINDIR = ${SBINDIR}
802 80189b3a 2022-08-13 op INCLUDEDIR = ${INCLUDEDIR}
803 80189b3a 2022-08-13 op LIBDIR = ${LIBDIR}
804 80189b3a 2022-08-13 op MANDIR = ${MANDIR}
805 80189b3a 2022-08-13 op INSTALL = ${INSTALL}
806 80189b3a 2022-08-13 op INSTALL_PROGRAM = ${INSTALL_PROGRAM}
807 80189b3a 2022-08-13 op INSTALL_LIB = ${INSTALL_LIB}
808 80189b3a 2022-08-13 op INSTALL_MAN = ${INSTALL_MAN}
809 80189b3a 2022-08-13 op INSTALL_DATA = ${INSTALL_DATA}
810 80189b3a 2022-08-13 op __HEREDOC__
811 80189b3a 2022-08-13 op
812 80189b3a 2022-08-13 op echo "Makefile.configure: written" 1>&2
813 80189b3a 2022-08-13 op echo "Makefile.configure: written" 1>&3
814 80189b3a 2022-08-13 op
815 80189b3a 2022-08-13 op exit 0