10 usage: configure [options]
12 --prefix=PREFIX installation prefix [/usr]
13 --exec-prefix=EPREFIX installation prefix for executable files [PREFIX]
14 --bindir=DIR user executables [PREFIX/bin]
15 --datadir=DIR architecture-independent data files [PREFIX/share]
16 --mandir=DIR manual pages [DATADIR/man]
17 --sysconfdir=DIR directory for configuration files [/etc]
19 --build=build-alias a cpu-vendor-opsys for the system where the application will be built
20 --host=host-alias a cpu-vendor-opsys for the system where the application will run
21 --target=target-alias the machine that CC will produce code for
23 --enable-debug enable debugging
24 --enable-static prepare for static build
26 --with-timestamp enable timestamp support
28 --without-insults disable insults
30 --uid-max=NUM set UID_MAX (default 65535)
31 --gid-max=NUM set GID_MAX (default 65535)
33 --help, -h display this help and exit
47 --prefix) PREFIX=$var ;;
48 --exec-prefix) EPREFIX=$var ;;
49 --bindir) BINDIR=$var ;;
50 --datadir) SHAREDIR=$var ;;
51 --mandir) MANDIR=$var ;;
52 --sysconfdir) SYSCONFDIR=$var ;;
53 --build) BUILD=$var ;;
55 --target) TARGET=$var ;;
56 --enable-debug) DEBUG=yes ;;
57 --enable-static) BUILD_STATIC=yes ;;
58 --without-insults) WITHOUT_INSULTS=yes ;;
59 --with-timestamp) WITHOUT_TIMESTAMP= ;;
60 --without-timestamp) WITHOUT_TIMESTAMP=yes ;;
61 --uid-max) UID_MAX=$var ;;
62 --gid-max) UID_MAX=$var ;;
64 *) die "Error: unknown option $opt" ;;
70 rm -f "$CONFIG_MK" "$CONFIG_H"
78 if [ -z "$BUILD" ]; then
79 BUILD="$(uname -m)-unknown-$(uname -s | tr '[:upper:]' '[:lower:]')"
81 if [ -z "$HOST" ]; then
82 [ -z "$TARGET" ] && TARGET=$BUILD
85 if [ -z "$TARGET" ]; then
86 [ -z "$HOST" ] && HOST=$BUILD
91 # Derive OS from cpu-manufacturer-os-kernel
101 OS_CFLAGS="-D__${OS}__"
105 printf 'Setting UID_MAX\t\t\t\t%d.\n' "$UID_MAX" >&2
106 printf '#define UID_MAX %s\n' "$UID_MAX" >>$CONFIG_H
107 printf 'Setting GID_MAX\t\t\t\t%d.\n' "$GID_MAX" >&2
108 printf '#define GID_MAX %s\n' "$GID_MAX" >>$CONFIG_H
109 OS_CFLAGS="$OS_CFLAGS -D_DEFAULT_SOURCE -D_GNU_SOURCE"
112 OS_CFLAGS="$OS_CFLAGS -D_OPENBSD_SOURCE"
113 printf 'LDLIBS += -lutil\n' >>$CONFIG_MK
117 printf 'LDLIBS += -lutil\n' >>$CONFIG_MK
125 : ${PREFIX:=/usr/local}
126 : ${EPREFIX:=${PREFIX}}
127 : ${BINDIR:=${PREFIX}/bin}
128 : ${SHAREDIR:=${PREFIX}/share}
129 : ${MANDIR:=${SHAREDIR}/man}
130 : ${SYSCONFDIR:=/etc}
135 cat <<EOF >>$CONFIG_MK
137 EPREFIX ?= ${EPREFIX}
139 SHAREDIR ?= ${SHAREDIR}
141 SYSCONFDIR?= ${SYSCONFDIR}
142 BINMODE ?= ${BINMODE}
147 [ -n "$OS_CFLAGS" ] && \
148 printf 'OS_CFLAGS += %s\n' "$OS_CFLAGS" >>$CONFIG_MK
151 printf 'CFLAGS += -O0 -g\n' >>$CONFIG_MK
153 [ -n "$BUILD_STATIC" ] && \
154 printf 'CFLAGS += -static\n' >>$CONFIG_MK
156 # Add CPPFLAGS/CFLAGS/LDFLAGS/LDLIBS to CC for testing features
157 XCC="${CC:=cc} $CFLAGS $OS_CFLAGS $CPPFLAGS $LDFLAGS $LDLIBS"
158 # Make sure to disable --as-needed for CC tests.
162 *) XCC="$XCC -Wl,--no-as-needed" ;;
166 func="$1"; src="$2"; shift 2
167 printf 'Checking for %-14s\t\t' "$func ..." >&2
168 printf '%s\n' "$src" >"_$func.c"
169 $XCC "_$func.c" -o "_$func" 2>/dev/null
171 rm -f "_$func.c" "_$func"
172 upperfunc="$(printf '%s\n' "$func" | tr '[[:lower:]]' '[[:upper:]]')"
173 if [ $ret -eq 0 ]; then
175 printf '#define HAVE_%s\n' "$upperfunc" >>$CONFIG_H
178 printf '/* #define HAVE_%s */\n' "$upperfunc" >>$CONFIG_H
191 printf 'SRCS += shadow.c\n' >>$CONFIG_MK
192 printf 'LDLIBS += -lcrypt\n' >>$CONFIG_MK
197 printf 'SRCS += insults.c\n' >>$CONFIG_MK
198 [ -z "$WITHOUT_INSULTS" ] && {
199 printf '#define DOAS_INSULTS\n' >>$CONFIG_H
206 [ -z "$WITHOUT_TIMESTAMP" ] && {
207 printf '#define USE_TIMESTAMP\n' >>$CONFIG_H
208 printf 'SRCS += timestamp.c\n' >>$CONFIG_MK
216 # Check for explicit_bzero().
221 explicit_bzero(NULL, 0);
224 check_func "explicit_bzero" "$src" || {
225 printf 'SRCS += libopenbsd/explicit_bzero.c\n' >>$CONFIG_MK
229 # Check for strlcat().
234 const char s1[] = "foo";
236 strlcat(s2, s1, sizeof(s2));
239 check_func "strlcat" "$src" || {
240 printf 'SRCS += libopenbsd/strlcat.c\n' >>$CONFIG_MK
244 # Check for strlcpy().
249 const char s1[] = "foo";
251 strlcpy(s2, s1, sizeof(s2));
254 check_func "strlcpy" "$src" || {
255 printf 'SRCS += libopenbsd/strlcpy.c\n' >>$CONFIG_MK
267 check_func "errc" "$src" || {
268 printf 'SRCS += libopenbsd/errc.c\n' >>$CONFIG_MK
278 verrc(0, 0, "x", NULL);
281 check_func "verrc" "$src" || {
282 printf 'SRCS += libopenbsd/verrc.c\n' >>$CONFIG_MK
286 # Check for setprogname().
294 check_func "setprogname" "$src" || {
295 printf 'SRCS += libopenbsd/progname.c\n' >>$CONFIG_MK
299 # Check for readpassphrase().
302 #include <readpassphrase.h>
305 readpassphrase("", buf, sizeof(buf), 0);
308 check_func "readpassphrase" "$src" || {
309 printf 'SRCS += libopenbsd/readpassphrase.c\n' >>$CONFIG_MK
313 # Check for strtonum().
319 strtonum("", 1, 64, &errstr);
322 check_func "strtonum" "$src" || {
323 printf 'SRCS += libopenbsd/strtonum.c\n' >>$CONFIG_MK
327 # Check for reallocarray().
332 reallocarray(NULL, 0, 0);
335 check_func "reallocarray" "$src" || {
336 printf 'SRCS += libopenbsd/reallocarray.c\n' >>$CONFIG_MK
340 # Check for execvpe().
345 const char *p = { "", NULL };
349 check_func "execvpe" "$src" || {
350 printf 'SRCS += libopenbsd/execvpe.c\n' >>$CONFIG_MK
354 # Check for setresuid().
362 check_func "setresuid" "$src"
366 # Check for setresgid().
374 check_func "setresgid" "$src"
377 if [ $have_setresuid -eq 1 -o $have_setresgid -eq 1 ]; then
378 printf 'SRCS += libopenbsd/bsd-setres_id.c\n' >>$CONFIG_MK
382 # Check for setreuid().
390 check_func "setreuid" "$src"
394 # Check for setregid().
402 check_func "setregid" "$src"
405 # Check for closefrom().
413 check_func "closefrom" "$src" || {
414 printf 'SRCS += libopenbsd/closefrom.c\n' >>$CONFIG_MK
418 # Check for sysconf().
426 check_func "sysconf" "$src"
437 check_func "dirfd" "$src"
447 check_func "fcntl_h" "$src"
450 # Check for F_CLOSEM.
460 check_func "F_CLOSEM" "$src"
463 # Check for dirent.h.
470 check_func "dirent_h" "$src"
473 # Check for sys/ndir.h.
476 #include <sys/ndir.h>
480 check_func "sys_ndir_h" "$src"
483 # Check for sys/dir.h.
490 check_func "sys_dir_h" "$src"
500 check_func "ndir_h" "$src"
503 # Check for login_cap.h.
506 #include <sys/types.h>
507 #include <login_cap.h>
511 check_func "login_cap_h" "$src"
518 int main(void){return 0;}
519 __attribute__((__unused__)) static void foo(void){return;}
521 check_func "__attribute__" "$src" || {
522 printf 'OS_CFLAGS += -DNO_ATTRIBUTE_ON_RETURN_TYPE=1\n' >>$CONFIG_MK
527 insults=$(definsults)
529 persist=$(persistmethod)
530 if [ $? -eq 0 ]; then
531 printf 'Using persist method\t\t\t%s.\n' "$persist" >&2
533 printf 'Using persist method\t\t\tnone.\n' >&2
536 printf '#define DOAS_CONF "%s/doas.conf"\n' "${SYSCONFDIR}" >>$CONFIG_H
538 printf '\n#endif /* CONFIG_H */\n' >>$CONFIG_H