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 --with-kiss-insults enable kiss 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
43 WITHOUT_KISS_INSULTS=""
51 --prefix) PREFIX=$var ;;
52 --exec-prefix) EPREFIX=$var ;;
53 --bindir) BINDIR=$var ;;
54 --datadir) SHAREDIR=$var ;;
55 --mandir) MANDIR=$var ;;
56 --sysconfdir) SYSCONFDIR=$var ;;
57 --build) BUILD=$var ;;
59 --target) TARGET=$var ;;
60 --enable-debug) DEBUG=yes ;;
61 --enable-static) BUILD_STATIC=yes ;;
62 --with-pam) WITHOUT_PAM=; WITHOUT_SHADOW=yes ;;
63 --with-shadow) WITHOUT_SHADOW=; WITHOUT_PAM=yes ;;
64 --without-pam) WITHOUT_PAM=yes ;;
65 --without-shadow) WITHOUT_SHADOW=yes ;;
66 --with-kiss-insults) WITH_KISS_INSULTS=yes ;;
67 --with-timestamp) WITHOUT_TIMESTAMP= ;;
68 --without-timestamp) WITHOUT_TIMESTAMP=yes ;;
69 --uid-max) UID_MAX=$var ;;
70 --gid-max) UID_MAX=$var ;;
72 *) die "Error: unknown option $opt" ;;
78 rm -f "$CONFIG_MK" "$CONFIG_H"
86 if [ -z "$BUILD" ]; then
87 BUILD="$(uname -m)-unknown-$(uname -s | tr '[:upper:]' '[:lower:]')"
89 if [ -z "$HOST" ]; then
90 [ -z "$TARGET" ] && TARGET=$BUILD
93 if [ -z "$TARGET" ]; then
94 [ -z "$HOST" ] && HOST=$BUILD
99 # Derive OS from cpu-manufacturer-os-kernel
109 OS_CFLAGS="-D__${OS}__"
113 printf 'Setting UID_MAX\t\t\t\t%d.\n' "$UID_MAX" >&2
114 printf '#define UID_MAX %s\n' "$UID_MAX" >>$CONFIG_H
115 printf 'Setting GID_MAX\t\t\t\t%d.\n' "$GID_MAX" >&2
116 printf '#define GID_MAX %s\n' "$GID_MAX" >>$CONFIG_H
117 OS_CFLAGS="$OS_CFLAGS -D_DEFAULT_SOURCE -D_GNU_SOURCE"
120 OS_CFLAGS="$OS_CFLAGS -D_OPENBSD_SOURCE"
121 printf 'LDLIBS += -lutil\n' >>$CONFIG_MK
125 printf 'LDLIBS += -lutil\n' >>$CONFIG_MK
133 : ${PREFIX:=/usr/local}
134 : ${EPREFIX:=${PREFIX}}
135 : ${BINDIR:=${PREFIX}/bin}
136 : ${SHAREDIR:=${PREFIX}/share}
137 : ${MANDIR:=${SHAREDIR}/man}
138 : ${SYSCONFDIR:=/etc}
143 cat <<EOF >>$CONFIG_MK
145 EPREFIX ?= ${EPREFIX}
147 SHAREDIR ?= ${SHAREDIR}
149 SYSCONFDIR?= ${SYSCONFDIR}
150 BINMODE ?= ${BINMODE}
155 [ -n "$OS_CFLAGS" ] && \
156 printf 'OS_CFLAGS += %s\n' "$OS_CFLAGS" >>$CONFIG_MK
159 printf 'CFLAGS += -O0 -g\n' >>$CONFIG_MK
161 [ -n "$BUILD_STATIC" ] && \
162 printf 'CFLAGS += -static\n' >>$CONFIG_MK
164 # Add CPPFLAGS/CFLAGS/LDFLAGS/LDLIBS to CC for testing features
165 XCC="${CC:=cc} $CFLAGS $OS_CFLAGS $CPPFLAGS $LDFLAGS $LDLIBS"
166 # Make sure to disable --as-needed for CC tests.
170 *) XCC="$XCC -Wl,--no-as-needed" ;;
174 func="$1"; src="$2"; shift 2
175 printf 'Checking for %-14s\t\t' "$func ..." >&2
176 printf '%s\n' "$src" >"_$func.c"
177 $XCC "_$func.c" -o "_$func" 2>/dev/null
179 rm -f "_$func.c" "_$func"
180 upperfunc="$(printf '%s\n' "$func" | tr '[[:lower:]]' '[[:upper:]]')"
181 if [ $ret -eq 0 ]; then
183 printf '#define HAVE_%s\n' "$upperfunc" >>$CONFIG_H
186 printf '/* #define HAVE_%s */\n' "$upperfunc" >>$CONFIG_H
194 # Check for pam_appl.h.
197 #include <security/pam_appl.h>
201 [ -z "$WITHOUT_PAM" ] && check_func "pam_appl_h" "$src" && {
202 printf 'SRCS += pam.c\n' >>$CONFIG_MK
203 printf 'LDLIBS += -lpam\n' >>$CONFIG_MK
204 printf '#define USE_PAM\n' >>$CONFIG_H
210 # Check for shadow.h.
217 [ -z "$WITHOUT_SHADOW" ] && check_func "shadow_h" "$src" && {
218 printf 'SRCS += shadow.c\n' >>$CONFIG_MK
219 printf 'LDLIBS += -lcrypt\n' >>$CONFIG_MK
220 printf '#define USE_SHADOW\n' >>$CONFIG_H
229 printf 'SRCS += insults.c\n' >>$CONFIG_MK
230 [ -n "$WITH_KISS_INSULTS" ] && {
231 printf '#define DOAS_INSULTS_KISS\n' >>$CONFIG_H
238 [ -z "$WITHOUT_TIMESTAMP" ] && {
239 printf '#define USE_TIMESTAMP\n' >>$CONFIG_H
240 printf 'SRCS += timestamp.c\n' >>$CONFIG_MK
248 # Check for explicit_bzero().
253 explicit_bzero(NULL, 0);
256 check_func "explicit_bzero" "$src" || {
257 printf 'SRCS += libopenbsd/explicit_bzero.c\n' >>$CONFIG_MK
261 # Check for strlcat().
266 const char s1[] = "foo";
268 strlcat(s2, s1, sizeof(s2));
271 check_func "strlcat" "$src" || {
272 printf 'SRCS += libopenbsd/strlcat.c\n' >>$CONFIG_MK
276 # Check for strlcpy().
281 const char s1[] = "foo";
283 strlcpy(s2, s1, sizeof(s2));
286 check_func "strlcpy" "$src" || {
287 printf 'SRCS += libopenbsd/strlcpy.c\n' >>$CONFIG_MK
299 check_func "errc" "$src" || {
300 printf 'SRCS += libopenbsd/errc.c\n' >>$CONFIG_MK
310 verrc(0, 0, "x", NULL);
313 check_func "verrc" "$src" || {
314 printf 'SRCS += libopenbsd/verrc.c\n' >>$CONFIG_MK
318 # Check for setprogname().
326 check_func "setprogname" "$src" || {
327 printf 'SRCS += libopenbsd/progname.c\n' >>$CONFIG_MK
331 # Check for readpassphrase().
334 #include <readpassphrase.h>
337 readpassphrase("", buf, sizeof(buf), 0);
340 check_func "readpassphrase" "$src" || {
341 printf 'SRCS += libopenbsd/readpassphrase.c\n' >>$CONFIG_MK
345 # Check for strtonum().
351 strtonum("", 1, 64, &errstr);
354 check_func "strtonum" "$src" || {
355 printf 'SRCS += libopenbsd/strtonum.c\n' >>$CONFIG_MK
359 # Check for reallocarray().
364 reallocarray(NULL, 0, 0);
367 check_func "reallocarray" "$src" || {
368 printf 'SRCS += libopenbsd/reallocarray.c\n' >>$CONFIG_MK
372 # Check for execvpe().
377 const char *p = { "", NULL };
381 check_func "execvpe" "$src" || {
382 printf 'SRCS += libopenbsd/execvpe.c\n' >>$CONFIG_MK
386 # Check for setresuid().
394 check_func "setresuid" "$src"
398 # Check for setresgid().
406 check_func "setresgid" "$src"
409 if [ $have_setresuid -eq 1 -o $have_setresgid -eq 1 ]; then
410 printf 'SRCS += libopenbsd/bsd-setres_id.c\n' >>$CONFIG_MK
414 # Check for setreuid().
422 check_func "setreuid" "$src"
426 # Check for setregid().
434 check_func "setregid" "$src"
437 # Check for closefrom().
445 check_func "closefrom" "$src" || {
446 printf 'SRCS += libopenbsd/closefrom.c\n' >>$CONFIG_MK
450 # Check for sysconf().
458 check_func "sysconf" "$src"
469 check_func "dirfd" "$src"
479 check_func "fcntl_h" "$src"
482 # Check for F_CLOSEM.
492 check_func "F_CLOSEM" "$src"
495 # Check for dirent.h.
502 check_func "dirent_h" "$src"
505 # Check for sys/ndir.h.
508 #include <sys/ndir.h>
512 check_func "sys_ndir_h" "$src"
515 # Check for sys/dir.h.
522 check_func "sys_dir_h" "$src"
532 check_func "ndir_h" "$src"
535 # Check for login_cap.h.
538 #include <sys/types.h>
539 #include <login_cap.h>
543 check_func "login_cap_h" "$src"
550 int main(void){return 0;}
551 __attribute__((__unused__)) static void foo(void){return;}
553 check_func "__attribute__" "$src" || {
554 printf 'OS_CFLAGS += -DNO_ATTRIBUTE_ON_RETURN_TYPE=1\n' >>$CONFIG_MK
558 if [ $? -eq 0 ]; then
559 printf 'Using auth method\t\t\t%s.\n' "$auth" >&2
561 printf 'Error auth method\t\t\n' >&2
565 insults=$(definsults)
567 persist=$(persistmethod)
568 if [ $? -eq 0 ]; then
569 printf 'Using persist method\t\t\t%s.\n' "$persist" >&2
571 printf 'Using persist method\t\t\tnone.\n' >&2
574 printf '#define DOAS_CONF "%s/doas.conf"\n' "${SYSCONFDIR}" >>$CONFIG_H
576 printf '\n#endif /* CONFIG_H */\n' >>$CONFIG_H