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 --without-pam disable pam support
27 --without-shadow disable shadow support
29 --with-timestamp enable timestamp support
31 --without-insults disable insults
33 --uid-max=NUM set UID_MAX (default 65535)
34 --gid-max=NUM set GID_MAX (default 65535)
36 --help, -h display this help and exit
50 --prefix) PREFIX=$var ;;
51 --exec-prefix) EPREFIX=$var ;;
52 --bindir) BINDIR=$var ;;
53 --datadir) SHAREDIR=$var ;;
54 --mandir) MANDIR=$var ;;
55 --sysconfdir) SYSCONFDIR=$var ;;
56 --build) BUILD=$var ;;
58 --target) TARGET=$var ;;
59 --enable-debug) DEBUG=yes ;;
60 --enable-static) BUILD_STATIC=yes ;;
61 --with-pam) WITHOUT_PAM=; WITHOUT_SHADOW=yes ;;
62 --with-shadow) WITHOUT_SHADOW=; WITHOUT_PAM=yes ;;
63 --without-pam) WITHOUT_PAM=yes ;;
64 --without-shadow) WITHOUT_SHADOW=yes ;;
65 --without-insults) WITHOUT_INSULTS=yes ;;
66 --with-timestamp) WITHOUT_TIMESTAMP= ;;
67 --without-timestamp) WITHOUT_TIMESTAMP=yes ;;
68 --uid-max) UID_MAX=$var ;;
69 --gid-max) UID_MAX=$var ;;
71 *) die "Error: unknown option $opt" ;;
77 rm -f "$CONFIG_MK" "$CONFIG_H"
85 if [ -z "$BUILD" ]; then
86 BUILD="$(uname -m)-unknown-$(uname -s | tr '[:upper:]' '[:lower:]')"
88 if [ -z "$HOST" ]; then
89 [ -z "$TARGET" ] && TARGET=$BUILD
92 if [ -z "$TARGET" ]; then
93 [ -z "$HOST" ] && HOST=$BUILD
98 # Derive OS from cpu-manufacturer-os-kernel
108 OS_CFLAGS="-D__${OS}__"
112 printf 'Setting UID_MAX\t\t\t\t%d.\n' "$UID_MAX" >&2
113 printf '#define UID_MAX %s\n' "$UID_MAX" >>$CONFIG_H
114 printf 'Setting GID_MAX\t\t\t\t%d.\n' "$GID_MAX" >&2
115 printf '#define GID_MAX %s\n' "$GID_MAX" >>$CONFIG_H
116 OS_CFLAGS="$OS_CFLAGS -D_DEFAULT_SOURCE -D_GNU_SOURCE"
119 OS_CFLAGS="$OS_CFLAGS -D_OPENBSD_SOURCE"
120 printf 'LDLIBS += -lutil\n' >>$CONFIG_MK
124 printf 'LDLIBS += -lutil\n' >>$CONFIG_MK
132 : ${PREFIX:=/usr/local}
133 : ${EPREFIX:=${PREFIX}}
134 : ${BINDIR:=${PREFIX}/bin}
135 : ${SHAREDIR:=${PREFIX}/share}
136 : ${MANDIR:=${SHAREDIR}/man}
137 : ${SYSCONFDIR:=/etc}
142 cat <<EOF >>$CONFIG_MK
144 EPREFIX ?= ${EPREFIX}
146 SHAREDIR ?= ${SHAREDIR}
148 SYSCONFDIR?= ${SYSCONFDIR}
149 BINMODE ?= ${BINMODE}
154 [ -n "$OS_CFLAGS" ] && \
155 printf 'OS_CFLAGS += %s\n' "$OS_CFLAGS" >>$CONFIG_MK
158 printf 'CFLAGS += -O0 -g\n' >>$CONFIG_MK
160 [ -n "$BUILD_STATIC" ] && \
161 printf 'CFLAGS += -static\n' >>$CONFIG_MK
163 # Add CPPFLAGS/CFLAGS/LDFLAGS/LDLIBS to CC for testing features
164 XCC="${CC:=cc} $CFLAGS $OS_CFLAGS $CPPFLAGS $LDFLAGS $LDLIBS"
165 # Make sure to disable --as-needed for CC tests.
169 *) XCC="$XCC -Wl,--no-as-needed" ;;
173 func="$1"; src="$2"; shift 2
174 printf 'Checking for %-14s\t\t' "$func ..." >&2
175 printf '%s\n' "$src" >"_$func.c"
176 $XCC "_$func.c" -o "_$func" 2>/dev/null
178 rm -f "_$func.c" "_$func"
179 upperfunc="$(printf '%s\n' "$func" | tr '[[:lower:]]' '[[:upper:]]')"
180 if [ $ret -eq 0 ]; then
182 printf '#define HAVE_%s\n' "$upperfunc" >>$CONFIG_H
185 printf '/* #define HAVE_%s */\n' "$upperfunc" >>$CONFIG_H
193 # Check for pam_appl.h.
196 #include <security/pam_appl.h>
200 [ -z "$WITHOUT_PAM" ] && check_func "pam_appl_h" "$src" && {
201 printf 'SRCS += pam.c\n' >>$CONFIG_MK
202 printf 'LDLIBS += -lpam\n' >>$CONFIG_MK
203 printf '#define USE_PAM\n' >>$CONFIG_H
209 # Check for shadow.h.
216 [ -z "$WITHOUT_SHADOW" ] && check_func "shadow_h" "$src" && {
217 printf 'SRCS += shadow.c\n' >>$CONFIG_MK
218 printf 'LDLIBS += -lcrypt\n' >>$CONFIG_MK
219 printf '#define USE_SHADOW\n' >>$CONFIG_H
228 printf 'SRCS += insults.c\n' >>$CONFIG_MK
229 [ -z "$WITHOUT_INSULTS" ] && {
230 printf '#define DOAS_INSULTS\n' >>$CONFIG_H
237 [ -z "$WITHOUT_TIMESTAMP" ] && {
238 printf '#define USE_TIMESTAMP\n' >>$CONFIG_H
239 printf 'SRCS += timestamp.c\n' >>$CONFIG_MK
247 # Check for explicit_bzero().
252 explicit_bzero(NULL, 0);
255 check_func "explicit_bzero" "$src" || {
256 printf 'SRCS += libopenbsd/explicit_bzero.c\n' >>$CONFIG_MK
260 # Check for strlcat().
265 const char s1[] = "foo";
267 strlcat(s2, s1, sizeof(s2));
270 check_func "strlcat" "$src" || {
271 printf 'SRCS += libopenbsd/strlcat.c\n' >>$CONFIG_MK
275 # Check for strlcpy().
280 const char s1[] = "foo";
282 strlcpy(s2, s1, sizeof(s2));
285 check_func "strlcpy" "$src" || {
286 printf 'SRCS += libopenbsd/strlcpy.c\n' >>$CONFIG_MK
298 check_func "errc" "$src" || {
299 printf 'SRCS += libopenbsd/errc.c\n' >>$CONFIG_MK
309 verrc(0, 0, "x", NULL);
312 check_func "verrc" "$src" || {
313 printf 'SRCS += libopenbsd/verrc.c\n' >>$CONFIG_MK
317 # Check for setprogname().
325 check_func "setprogname" "$src" || {
326 printf 'SRCS += libopenbsd/progname.c\n' >>$CONFIG_MK
330 # Check for readpassphrase().
333 #include <readpassphrase.h>
336 readpassphrase("", buf, sizeof(buf), 0);
339 check_func "readpassphrase" "$src" || {
340 printf 'SRCS += libopenbsd/readpassphrase.c\n' >>$CONFIG_MK
344 # Check for strtonum().
350 strtonum("", 1, 64, &errstr);
353 check_func "strtonum" "$src" || {
354 printf 'SRCS += libopenbsd/strtonum.c\n' >>$CONFIG_MK
358 # Check for reallocarray().
363 reallocarray(NULL, 0, 0);
366 check_func "reallocarray" "$src" || {
367 printf 'SRCS += libopenbsd/reallocarray.c\n' >>$CONFIG_MK
371 # Check for execvpe().
376 const char *p = { "", NULL };
380 check_func "execvpe" "$src" || {
381 printf 'SRCS += libopenbsd/execvpe.c\n' >>$CONFIG_MK
385 # Check for setresuid().
393 check_func "setresuid" "$src"
397 # Check for setresgid().
405 check_func "setresgid" "$src"
408 if [ $have_setresuid -eq 1 -o $have_setresgid -eq 1 ]; then
409 printf 'SRCS += libopenbsd/bsd-setres_id.c\n' >>$CONFIG_MK
413 # Check for setreuid().
421 check_func "setreuid" "$src"
425 # Check for setregid().
433 check_func "setregid" "$src"
436 # Check for closefrom().
444 check_func "closefrom" "$src" || {
445 printf 'SRCS += libopenbsd/closefrom.c\n' >>$CONFIG_MK
449 # Check for sysconf().
457 check_func "sysconf" "$src"
468 check_func "dirfd" "$src"
478 check_func "fcntl_h" "$src"
481 # Check for F_CLOSEM.
491 check_func "F_CLOSEM" "$src"
494 # Check for dirent.h.
501 check_func "dirent_h" "$src"
504 # Check for sys/ndir.h.
507 #include <sys/ndir.h>
511 check_func "sys_ndir_h" "$src"
514 # Check for sys/dir.h.
521 check_func "sys_dir_h" "$src"
531 check_func "ndir_h" "$src"
534 # Check for login_cap.h.
537 #include <sys/types.h>
538 #include <login_cap.h>
542 check_func "login_cap_h" "$src"
549 int main(void){return 0;}
550 __attribute__((__unused__)) static void foo(void){return;}
552 check_func "__attribute__" "$src" || {
553 printf 'OS_CFLAGS += -DNO_ATTRIBUTE_ON_RETURN_TYPE=1\n' >>$CONFIG_MK
557 if [ $? -eq 0 ]; then
558 printf 'Using auth method\t\t\t%s.\n' "$auth" >&2
560 printf 'Error auth method\t\t\n' >&2
564 insults=$(definsults)
566 persist=$(persistmethod)
567 if [ $? -eq 0 ]; then
568 printf 'Using persist method\t\t\t%s.\n' "$persist" >&2
570 printf 'Using persist method\t\t\tnone.\n' >&2
573 printf '#define DOAS_CONF "%s/doas.conf"\n' "${SYSCONFDIR}" >>$CONFIG_H
575 printf '\n#endif /* CONFIG_H */\n' >>$CONFIG_H