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 --uid-max=NUM set UID_MAX (default 65535)
32 --gid-max=NUM set GID_MAX (default 65535)
34 --help, -h display this help and exit
48 --prefix) PREFIX=$var ;;
49 --exec-prefix) EPREFIX=$var ;;
50 --bindir) BINDIR=$var ;;
51 --datadir) SHAREDIR=$var ;;
52 --mandir) MANDIR=$var ;;
53 --sysconfdir) SYSCONFDIR=$var ;;
54 --build) BUILD=$var ;;
56 --target) TARGET=$var ;;
57 --enable-debug) DEBUG=yes ;;
58 --enable-static) BUILD_STATIC=yes ;;
59 --with-pam) WITHOUT_PAM=; WITHOUT_SHADOW=yes ;;
60 --with-shadow) WITHOUT_SHADOW=; WITHOUT_PAM=yes ;;
61 --without-pam) WITHOUT_PAM=yes ;;
62 --without-shadow) WITHOUT_SHADOW=yes ;;
63 --with-timestamp) WITHOUT_TIMESTAMP= ;;
64 --without-timestamp) WITHOUT_TIMESTAMP=yes ;;
65 --uid-max) UID_MAX=$var ;;
66 --gid-max) UID_MAX=$var ;;
68 *) die "Error: unknown option $opt" ;;
74 rm -f "$CONFIG_MK" "$CONFIG_H"
82 if [ -z "$BUILD" ]; then
83 BUILD="$(uname -m)-unknown-$(uname -s | tr '[:upper:]' '[:lower:]')"
85 if [ -z "$HOST" ]; then
86 [ -z "$TARGET" ] && TARGET=$BUILD
89 if [ -z "$TARGET" ]; then
90 [ -z "$HOST" ] && HOST=$BUILD
95 # Derive OS from cpu-manufacturer-os-kernel
105 OS_CFLAGS="-D__${OS}__"
109 printf 'Setting UID_MAX\t\t\t\t%d.\n' "$UID_MAX" >&2
110 printf '#define UID_MAX %s\n' "$UID_MAX" >>$CONFIG_H
111 printf 'Setting GID_MAX\t\t\t\t%d.\n' "$GID_MAX" >&2
112 printf '#define GID_MAX %s\n' "$GID_MAX" >>$CONFIG_H
113 OS_CFLAGS="$OS_CFLAGS -D_DEFAULT_SOURCE -D_GNU_SOURCE"
116 OS_CFLAGS="$OS_CFLAGS -D_OPENBSD_SOURCE"
117 printf 'LDLIBS += -lutil\n' >>$CONFIG_MK
121 printf 'LDLIBS += -lutil\n' >>$CONFIG_MK
129 : ${PREFIX:=/usr/local}
130 : ${EPREFIX:=${PREFIX}}
131 : ${BINDIR:=${PREFIX}/bin}
132 : ${SHAREDIR:=${PREFIX}/share}
133 : ${MANDIR:=${SHAREDIR}/man}
134 : ${SYSCONFDIR:=/etc}
139 cat <<EOF >>$CONFIG_MK
141 EPREFIX ?= ${EPREFIX}
143 SHAREDIR ?= ${SHAREDIR}
145 SYSCONFDIR?= ${SYSCONFDIR}
146 BINMODE ?= ${BINMODE}
151 [ -n "$OS_CFLAGS" ] && \
152 printf 'OS_CFLAGS += %s\n' "$OS_CFLAGS" >>$CONFIG_MK
155 printf 'CFLAGS += -O0 -g\n' >>$CONFIG_MK
157 [ -n "$BUILD_STATIC" ] && \
158 printf 'CFLAGS += -static\n' >>$CONFIG_MK
160 # Add CPPFLAGS/CFLAGS/LDFLAGS/LDLIBS to CC for testing features
161 XCC="${CC:=cc} $CFLAGS $OS_CFLAGS $CPPFLAGS $LDFLAGS $LDLIBS"
162 # Make sure to disable --as-needed for CC tests.
166 *) XCC="$XCC -Wl,--no-as-needed" ;;
170 func="$1"; src="$2"; shift 2
171 printf 'Checking for %-14s\t\t' "$func ..." >&2
172 printf '%s\n' "$src" >"_$func.c"
173 $XCC "_$func.c" -o "_$func" 2>/dev/null
175 rm -f "_$func.c" "_$func"
176 upperfunc="$(printf '%s\n' "$func" | tr '[[:lower:]]' '[[:upper:]]')"
177 if [ $ret -eq 0 ]; then
179 printf '#define HAVE_%s\n' "$upperfunc" >>$CONFIG_H
182 printf '/* #define HAVE_%s */\n' "$upperfunc" >>$CONFIG_H
190 # Check for pam_appl.h.
193 #include <security/pam_appl.h>
197 [ -z "$WITHOUT_PAM" ] && check_func "pam_appl_h" "$src" && {
198 printf 'SRCS += pam.c\n' >>$CONFIG_MK
199 printf 'LDLIBS += -lpam\n' >>$CONFIG_MK
200 printf '#define USE_PAM\n' >>$CONFIG_H
206 # Check for shadow.h.
213 [ -z "$WITHOUT_SHADOW" ] && check_func "shadow_h" "$src" && {
214 printf 'SRCS += shadow.c\n' >>$CONFIG_MK
215 printf 'LDLIBS += -lcrypt\n' >>$CONFIG_MK
216 printf '#define USE_SHADOW\n' >>$CONFIG_H
225 [ -z "$WITHOUT_TIMESTAMP" ] && {
226 printf '#define USE_TIMESTAMP\n' >>$CONFIG_H
227 printf 'SRCS += timestamp.c\n' >>$CONFIG_MK
235 # Check for explicit_bzero().
240 explicit_bzero(NULL, 0);
243 check_func "explicit_bzero" "$src" || {
244 printf 'SRCS += libopenbsd/explicit_bzero.c\n' >>$CONFIG_MK
248 # Check for strlcat().
253 const char s1[] = "foo";
255 strlcat(s2, s1, sizeof(s2));
258 check_func "strlcat" "$src" || {
259 printf 'SRCS += libopenbsd/strlcat.c\n' >>$CONFIG_MK
263 # Check for strlcpy().
268 const char s1[] = "foo";
270 strlcpy(s2, s1, sizeof(s2));
273 check_func "strlcpy" "$src" || {
274 printf 'SRCS += libopenbsd/strlcpy.c\n' >>$CONFIG_MK
286 check_func "errc" "$src" || {
287 printf 'SRCS += libopenbsd/errc.c\n' >>$CONFIG_MK
297 verrc(0, 0, "x", NULL);
300 check_func "verrc" "$src" || {
301 printf 'SRCS += libopenbsd/verrc.c\n' >>$CONFIG_MK
305 # Check for setprogname().
313 check_func "setprogname" "$src" || {
314 printf 'SRCS += libopenbsd/progname.c\n' >>$CONFIG_MK
318 # Check for readpassphrase().
321 #include <readpassphrase.h>
324 readpassphrase("", buf, sizeof(buf), 0);
327 check_func "readpassphrase" "$src" || {
328 printf 'SRCS += libopenbsd/readpassphrase.c\n' >>$CONFIG_MK
332 # Check for strtonum().
338 strtonum("", 1, 64, &errstr);
341 check_func "strtonum" "$src" || {
342 printf 'SRCS += libopenbsd/strtonum.c\n' >>$CONFIG_MK
346 # Check for reallocarray().
351 reallocarray(NULL, 0, 0);
354 check_func "reallocarray" "$src" || {
355 printf 'SRCS += libopenbsd/reallocarray.c\n' >>$CONFIG_MK
359 # Check for execvpe().
364 const char *p = { "", NULL };
368 check_func "execvpe" "$src" || {
369 printf 'SRCS += libopenbsd/execvpe.c\n' >>$CONFIG_MK
373 # Check for setresuid().
381 check_func "setresuid" "$src"
385 # Check for setresgid().
393 check_func "setresgid" "$src"
396 if [ $have_setresuid -eq 1 -o $have_setresgid -eq 1 ]; then
397 printf 'SRCS += libopenbsd/bsd-setres_id.c\n' >>$CONFIG_MK
401 # Check for setreuid().
409 check_func "setreuid" "$src"
413 # Check for setregid().
421 check_func "setregid" "$src"
424 # Check for closefrom().
432 check_func "closefrom" "$src" || {
433 printf 'SRCS += libopenbsd/closefrom.c\n' >>$CONFIG_MK
437 # Check for sysconf().
445 check_func "sysconf" "$src"
456 check_func "dirfd" "$src"
466 check_func "fcntl_h" "$src"
469 # Check for F_CLOSEM.
479 check_func "F_CLOSEM" "$src"
482 # Check for dirent.h.
489 check_func "dirent_h" "$src"
492 # Check for sys/ndir.h.
495 #include <sys/ndir.h>
499 check_func "sys_ndir_h" "$src"
502 # Check for sys/dir.h.
509 check_func "sys_dir_h" "$src"
519 check_func "ndir_h" "$src"
522 # Check for login_cap.h.
525 #include <sys/types.h>
526 #include <login_cap.h>
530 check_func "login_cap_h" "$src"
537 int main(void){return 0;}
538 __attribute__((__unused__)) static void foo(void){return;}
540 check_func "__attribute__" "$src" || {
541 printf 'OS_CFLAGS += -DNO_ATTRIBUTE_ON_RETURN_TYPE=1\n' >>$CONFIG_MK
545 if [ $? -eq 0 ]; then
546 printf 'Using auth method\t\t\t%s.\n' "$auth" >&2
548 printf 'Error auth method\t\t\n' >&2
552 persist=$(persistmethod)
553 if [ $? -eq 0 ]; then
554 printf 'Using persist method\t\t\t%s.\n' "$persist" >&2
556 printf 'Using persist method\t\t\tnone.\n' >&2
559 printf '#define DOAS_CONF "%s/doas.conf"\n' "${SYSCONFDIR}" >>$CONFIG_H
561 printf '\n#endif /* CONFIG_H */\n' >>$CONFIG_H