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]
18 --pamdir=DIR PAM directory [SYSCONFDIR/pam.d]
20 --build=build-alias a cpu-vendor-opsys for the system where the application will be built
21 --host=host-alias a cpu-vendor-opsys for the system where the application will run
22 --target=target-alias the machine that CC will produce code for
24 --enable-debug enable debugging
25 --enable-static prepare for static build
27 --without-pam disable pam support
28 --without-shadow disable shadow support
30 --with-timestamp enable timestamp support
32 --uid-max=NUM set UID_MAX (default 65535)
33 --gid-max=NUM set GID_MAX (default 65535)
35 --help, -h display this help and exit
49 --prefix) PREFIX=$var ;;
50 --exec-prefix) EPREFIX=$var ;;
51 --bindir) BINDIR=$var ;;
52 --datadir) SHAREDIR=$var ;;
53 --mandir) MANDIR=$var ;;
54 --sysconfdir) SYSCONFDIR=$var ;;
55 --pamdir) PAMDIR=$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 --with-timestamp) WITHOUT_TIMESTAMP= ;;
66 --without-timestamp) WITHOUT_TIMESTAMP=yes ;;
67 --uid-max) UID_MAX=$var ;;
68 --gid-max) UID_MAX=$var ;;
70 *) die "Error: unknown option $opt" ;;
76 rm -f "$CONFIG_MK" "$CONFIG_H"
84 if [ -z "$BUILD" ]; then
85 BUILD="$(uname -m)-unknown-$(uname -s | tr '[:upper:]' '[:lower:]')"
87 if [ -z "$HOST" ]; then
88 [ -z "$TARGET" ] && TARGET=$BUILD
91 if [ -z "$TARGET" ]; then
92 [ -z "$HOST" ] && HOST=$BUILD
97 # Derive OS from cpu-manufacturer-os-kernel
107 OS_CFLAGS="-D__${OS}__"
111 printf 'Setting UID_MAX\t\t\t\t%d.\n' "$UID_MAX" >&2
112 printf '#define UID_MAX %s\n' "$UID_MAX" >>$CONFIG_H
113 printf 'Setting GID_MAX\t\t\t\t%d.\n' "$GID_MAX" >&2
114 printf '#define GID_MAX %s\n' "$GID_MAX" >>$CONFIG_H
115 OS_CFLAGS="$OS_CFLAGS -D_DEFAULT_SOURCE -D_GNU_SOURCE"
118 OS_CFLAGS="$OS_CFLAGS -D_OPENBSD_SOURCE"
119 printf 'LDFLAGS += -lutil\n' >>$CONFIG_MK
127 : ${PREFIX:=/usr/local}
128 : ${EPREFIX:=${PREFIX}}
129 : ${BINDIR:=${PREFIX}/bin}
130 : ${SHAREDIR:=${PREFIX}/share}
131 : ${MANDIR:=${SHAREDIR}/man}
132 : ${SYSCONFDIR:=/etc}
133 : ${PAMDIR:=${SYSCONFDIR}/pam.d}
138 cat <<EOF >>$CONFIG_MK
140 EPREFIX ?= ${EPREFIX}
142 SHAREDIR ?= ${SHAREDIR}
144 SYSCONFDIR?= ${SYSCONFDIR}
146 BINMODE ?= ${BINMODE}
151 [ -n "$OS_CFLAGS" ] && \
152 printf '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 to CC for testing features
161 XCC="${CC:=cc} $CFLAGS $OS_CFLAGS $CPPFLAGS $LDFLAGS"
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 'LDFLAGS += -lpam\n' >>$CONFIG_MK
200 printf '#define USE_PAM\n' >>$CONFIG_H
203 pam_file="pam.d__doas__${OS}"
204 [ -e "$pam_file" ] && printf 'PAM_DOAS = %s\n' "$pam_file" >>$CONFIG_MK
209 # Check for shadow.h.
216 [ -z "$WITHOUT_SHADOW" ] && check_func "shadow_h" "$src" && {
217 printf 'SRCS += shadow.c\n' >>$CONFIG_MK
218 printf 'LDFLAGS += -lcrypt\n' >>$CONFIG_MK
219 printf '#define USE_SHADOW\n' >>$CONFIG_H
228 [ -z "$WITHOUT_TIMESTAMP" ] && {
229 printf '#define USE_TIMESTAMP\n' >>$CONFIG_H
230 printf 'SRCS += timestamp.c\n' >>$CONFIG_MK
238 # Check for explicit_bzero().
243 explicit_bzero(NULL, 0);
246 check_func "explicit_bzero" "$src" || {
247 printf 'SRCS += libopenbsd/explicit_bzero.c\n' >>$CONFIG_MK
251 # Check for strlcat().
256 const char s1[] = "foo";
258 strlcat(s2, s1, sizeof(s2));
261 check_func "strlcat" "$src" || {
262 printf 'SRCS += libopenbsd/strlcat.c\n' >>$CONFIG_MK
266 # Check for strlcpy().
271 const char s1[] = "foo";
273 strlcpy(s2, s1, sizeof(s2));
276 check_func "strlcpy" "$src" || {
277 printf 'SRCS += libopenbsd/strlcpy.c\n' >>$CONFIG_MK
289 check_func "errc" "$src" || {
290 printf 'SRCS += libopenbsd/errc.c\n' >>$CONFIG_MK
302 check_func "verrc" "$src" || {
303 printf 'SRCS += libopenbsd/verrc.c\n' >>$CONFIG_MK
307 # Check for setprogname().
315 check_func "setprogname" "$src" || {
316 printf 'SRCS += libopenbsd/progname.c\n' >>$CONFIG_MK
320 # Check for readpassphrase().
323 #include <readpassphrase.h>
326 readpassphrase("", buf, sizeof(buf), 0);
329 check_func "readpassphrase" "$src" || {
330 printf 'SRCS += libopenbsd/readpassphrase.c\n' >>$CONFIG_MK
334 # Check for strtonum().
340 strtonum("", 1, 64, &errstr);
343 check_func "strtonum" "$src" || {
344 printf 'SRCS += libopenbsd/strtonum.c\n' >>$CONFIG_MK
348 # Check for reallocarray().
353 reallocarray(NULL, 0, 0);
356 check_func "reallocarray" "$src" || {
357 printf 'SRCS += libopenbsd/reallocarray.c\n' >>$CONFIG_MK
361 # Check for execvpe().
366 const char *p = { "", NULL };
370 check_func "execvpe" "$src" || {
371 printf 'SRCS += libopenbsd/execvpe.c\n' >>$CONFIG_MK
375 # Check for setresuid().
383 check_func "setresuid" "$src" || {
384 printf 'SRCS += libopenbsd/bsd-setres_id.c\n' >>$CONFIG_MK
388 # Check for closefrom().
396 check_func "closefrom" "$src" || {
397 printf 'SRCS += libopenbsd/closefrom.c\n' >>$CONFIG_MK
401 # Check for sysconf().
409 check_func "sysconf" "$src"
420 check_func "dirfd" "$src"
430 check_func "fcntl_h" "$src"
433 # Check for F_CLOSEM.
443 check_func "F_CLOSEM" "$src"
446 # Check for dirent.h.
453 check_func "dirent_h" "$src"
456 # Check for sys/ndir.h.
459 #include <sys/ndir.h>
463 check_func "sys_ndir_h" "$src"
466 # Check for sys/dir.h.
473 check_func "sys_dir_h" "$src"
483 check_func "ndir_h" "$src"
486 # Check for login_cap.h.
489 #include <sys/types.h>
490 #include <login_cap.h>
494 check_func "login_cap_h" "$src"
501 int main(void){return 0;}
502 __attribute__((__unused__)) static void foo(void){return;}
504 check_func "__attribute__" "$src" || {
505 printf 'CFLAGS += -DNO_ATTRIBUTE_ON_RETURN_TYPE=1\n' >>$CONFIG_MK
509 if [ $? -eq 0 ]; then
510 printf 'Using auth method\t\t\t%s.\n' "$auth" >&2
512 printf 'Error auth method\t\t\n' >&2
516 persist=$(persistmethod)
517 if [ $? -eq 0 ]; then
518 printf 'Using persist method\t\t\t%s.\n' "$persist" >&2
520 printf 'Using persist method\t\t\tnone.\n' >&2
523 printf '#define DOAS_CONF "%s/doas.conf"\n' "${SYSCONFDIR}" >>$CONFIG_H
525 printf '\n#endif /* CONFIG_H */\n' >>$CONFIG_H