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
45 : ${PREFIX:=/usr/local}
46 : ${EPREFIX:=${PREFIX}}
47 : ${BINDIR:=${PREFIX}/bin}
48 : ${SHAREDIR:=${PREFIX}/share}
49 : ${MANDIR:=${SHAREDIR}/man}
51 : ${PAMDIR:=${SYSCONFDIR}/pam.d}
57 --prefix) PREFIX=$var ;;
58 --exec-prefix) EPREFIX=$var ;;
59 --bindir) BINDIR=$var ;;
60 --datadir) SHAREDIR=$var ;;
61 --mandir) MANDIR=$var ;;
62 --sysconfdir) SYSCONFDIR=$var ;;
63 --pamdir) PAMDIR=$var ;;
64 --build) BUILD=$var ;;
66 --target) TARGET=$var ;;
67 --enable-debug) DEBUG=yes ;;
68 --enable-static) BUILD_STATIC=yes ;;
69 --with-pam) WITHOUT_PAM=; WITHOUT_SHADOW=yes ;;
70 --with-shadow) WITHOUT_SHADOW=; WITHOUT_PAM=yes ;;
71 --without-pam) WITHOUT_PAM=yes ;;
72 --without-shadow) WITHOUT_SHADOW=yes ;;
73 --with-timestamp) WITHOUT_TIMESTAMP= ;;
74 --without-timestamp) WITHOUT_TIMESTAMP=yes ;;
75 --uid-max) UID_MAX=$var ;;
76 --gid-max) UID_MAX=$var ;;
78 *) die "Error: unknown option $opt" ;;
84 rm -f "$CONFIG_MK" "$CONFIG_H"
92 cat <<EOF >>$CONFIG_MK
96 SHAREDIR ?= ${SHAREDIR}
98 SYSCONFDIR?= ${SYSCONFDIR}
102 if [ -z "$BUILD" ]; then
103 BUILD="$(uname -m)-unknown-$(uname -s | tr '[:upper:]' '[:lower:]')"
105 if [ -z "$HOST" ]; then
106 [ -z "$TARGET" ] && TARGET=$BUILD
109 if [ -z "$TARGET" ]; then
110 [ -z "$HOST" ] && HOST=$BUILD
114 if [ -z "$OS" ]; then
115 # Derive OS from cpu-manufacturer-os-kernel
125 OS_CFLAGS="-D__${OS}__"
129 printf 'Setting UID_MAX\t\t\t\t%d.\n' "$UID_MAX" >&2
130 printf '#define UID_MAX %s\n' "$UID_MAX" >>$CONFIG_H
131 printf 'Setting GID_MAX\t\t\t\t%d.\n' "$GID_MAX" >&2
132 printf '#define GID_MAX %s\n' "$GID_MAX" >>$CONFIG_H
133 OS_CFLAGS="$OS_CFLAGS -D_DEFAULT_SOURCE -D_GNU_SOURCE"
134 printf 'CURDIR := .\n' >>$CONFIG_MK
137 OS_CFLAGS="$OS_CFLAGS -D_OPENBSD_SOURCE"
138 printf 'LDFLAGS += -lutil\n' >>$CONFIG_MK
142 [ -n "$OS_CFLAGS" ] && \
143 printf 'CFLAGS += %s\n' "$OS_CFLAGS" >>$CONFIG_MK
146 printf 'CFLAGS += -O0 -g\n' >>$CONFIG_MK
148 [ -n "$BUILD_STATIC" ] && \
149 printf 'CFLAGS += -static\n' >>$CONFIG_MK
151 # Add CPPFLAGS/CFLAGS/LDFLAGS to CC for testing features
152 XCC="${CC:=cc} $CFLAGS $OS_CFLAGS $CPPFLAGS $LDFLAGS"
153 # Make sure to disable --as-needed for CC tests.
154 XCC="$XCC -Wl,--no-as-needed"
157 func="$1"; src="$2"; shift 2
158 printf 'Checking for %-14s\t\t' "$func ..." >&2
159 printf '%s\n' "$src" >"_$func.c"
160 $XCC "_$func.c" -o "_$func" 2>/dev/null
162 rm -f "_$func.c" "_$func"
163 upperfunc="$(printf '%s\n' "$func" | tr '[[:lower:]]' '[[:upper:]]')"
164 if [ $ret -eq 0 ]; then
166 printf '#define HAVE_%s\n' "$upperfunc" >>$CONFIG_H
169 printf '/* #define HAVE_%s */\n' "$upperfunc" >>$CONFIG_H
177 # Check for pam_appl.h.
180 #include <security/pam_appl.h>
184 [ -z "$WITHOUT_PAM" ] && check_func "pam_appl_h" "$src" && {
185 printf 'SRCS += pam.c\n' >>$CONFIG_MK
186 printf 'LDFLAGS += -lpam\n' >>$CONFIG_MK
187 printf '#define USE_PAM\n' >>$CONFIG_H
190 pam_file="pam.d__doas__${OS}"
191 [ -e "$pam_file" ] && printf 'PAM_DOAS = %s\n' "$pam_file" >>$CONFIG_MK
196 # Check for shadow.h.
203 [ -z "$WITHOUT_SHADOW" ] && check_func "shadow_h" "$src" && {
204 printf 'SRCS += shadow.c\n' >>$CONFIG_MK
205 printf 'LDFLAGS += -lcrypt\n' >>$CONFIG_MK
206 printf '#define USE_SHADOW\n' >>$CONFIG_H
215 [ -z "$WITHOUT_TIMESTAMP" ] && {
216 printf '#define USE_TIMESTAMP\n' >>$CONFIG_H
217 printf 'SRCS += timestamp.c\n' >>$CONFIG_MK
225 # Check for explicit_bzero().
230 explicit_bzero(NULL, 0);
233 check_func "explicit_bzero" "$src" || {
234 printf 'SRCS += libopenbsd/explicit_bzero.c\n' >>$CONFIG_MK
238 # Check for strlcat().
243 const char s1[] = "foo";
245 strlcat(s2, s1, sizeof(s2));
248 check_func "strlcat" "$src" || {
249 printf 'SRCS += libopenbsd/strlcat.c\n' >>$CONFIG_MK
253 # Check for strlcpy().
258 const char s1[] = "foo";
260 strlcpy(s2, s1, sizeof(s2));
263 check_func "strlcpy" "$src" || {
264 printf 'SRCS += libopenbsd/strlcpy.c\n' >>$CONFIG_MK
276 check_func "errc" "$src" || {
277 printf 'SRCS += libopenbsd/errc.c\n' >>$CONFIG_MK
289 check_func "verrc" "$src" || {
290 printf 'SRCS += libopenbsd/verrc.c\n' >>$CONFIG_MK
294 # Check for setprogname().
302 check_func "setprogname" "$src" || {
303 printf 'SRCS += libopenbsd/progname.c\n' >>$CONFIG_MK
307 # Check for readpassphrase().
310 #include <readpassphrase.h>
313 readpassphrase("", buf, sizeof(buf), 0);
316 check_func "readpassphrase" "$src" || {
317 printf 'SRCS += libopenbsd/readpassphrase.c\n' >>$CONFIG_MK
321 # Check for strtonum().
327 strtonum("", 1, 64, &errstr);
330 check_func "strtonum" "$src" || {
331 printf 'SRCS += libopenbsd/strtonum.c\n' >>$CONFIG_MK
335 # Check for reallocarray().
340 reallocarray(NULL, 0, 0);
343 check_func "reallocarray" "$src" || {
344 printf 'SRCS += libopenbsd/reallocarray.c\n' >>$CONFIG_MK
348 # Check for execvpe().
353 const char *p = { "", NULL };
357 check_func "execvpe" "$src" || die "system has no execvpe(3): not supported"
360 # Check for setresuid().
368 check_func "setresuid" "$src" || {
369 printf 'SRCS += libopenbsd/bsd-setres_id.c\n' >>$CONFIG_MK
373 # Check for closefrom().
381 check_func "closefrom" "$src" || {
382 printf 'SRCS += libopenbsd/closefrom.c\n' >>$CONFIG_MK
386 # Check for sysconf().
394 check_func "sysconf" "$src"
405 check_func "dirfd" "$src"
415 check_func "fcntl_h" "$src"
418 # Check for F_CLOSEM.
428 check_func "F_CLOSEM" "$src"
431 # Check for dirent.h.
438 check_func "dirent_h" "$src"
441 # Check for sys/ndir.h.
444 #include <sys/ndir.h>
448 check_func "sys_ndir_h" "$src"
451 # Check for sys/dir.h.
458 check_func "sys_dir_h" "$src"
468 check_func "ndir_h" "$src"
471 # Check for login_cap.h.
474 #include <sys/types.h>
475 #include <login_cap.h>
479 check_func "login_cap_h" "$src"
486 int main(void){return 0;}
487 __attribute__((__unused__)) static void foo(void){return;}
489 check_func "__attribute__" "$src" || {
490 printf 'CFLAGS += -DNO_ATTRIBUTE_ON_RETURN_TYPE=1\n' >>$CONFIG_MK
494 if [ $? -eq 0 ]; then
495 printf 'Using auth method\t\t\t%s.\n' "$auth" >&2
497 printf 'Error auth method\t\t\n' >&2
501 persist=$(persistmethod)
502 if [ $? -eq 0 ]; then
503 printf 'Using persist method\t\t\t%s.\n' "$persist" >&2
505 printf 'Using persist method\t\t\tnone.\n' >&2
508 printf '#define DOAS_CONF "%s/doas.conf"\n' "${SYSCONFDIR}" >>$CONFIG_H
510 printf '\n#endif /* CONFIG_H */\n' >>$CONFIG_H