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
20 application will be built
21 --host=host-alias a cpu-vendor-opsys for the system where the
23 --target=target-alias the machine that CC will produce code for
25 --enable-debug enable debugging
26 --enable-static prepare for static build
28 --with-timestamp enable timestamp support
30 --without-insults disable insults
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 --build) BUILD=$var ;;
57 --target) TARGET=$var ;;
58 --enable-debug) DEBUG=yes ;;
59 --enable-static) BUILD_STATIC=yes ;;
60 --without-insults) WITHOUT_INSULTS=yes ;;
61 --with-timestamp) WITHOUT_TIMESTAMP= ;;
62 --without-timestamp) WITHOUT_TIMESTAMP=yes ;;
63 --uid-max) UID_MAX=$var ;;
64 --gid-max) UID_MAX=$var ;;
66 *) die "Error: unknown option $opt" ;;
72 rm -f "$CONFIG_MK" "$CONFIG_H"
80 if [ -z "$BUILD" ]; then
81 BUILD="$(uname -m)-unknown-$(uname -s | tr '[:upper:]' '[:lower:]')"
83 if [ -z "$HOST" ]; then
84 [ -z "$TARGET" ] && TARGET=$BUILD
87 if [ -z "$TARGET" ]; then
88 [ -z "$HOST" ] && HOST=$BUILD
93 # Derive OS from cpu-manufacturer-os-kernel
103 OS_CFLAGS="-D__${OS}__"
107 printf 'Setting UID_MAX\t\t\t\t%d.\n' "$UID_MAX" >&2
108 printf '#define UID_MAX %s\n' "$UID_MAX" >>$CONFIG_H
109 printf 'Setting GID_MAX\t\t\t\t%d.\n' "$GID_MAX" >&2
110 printf '#define GID_MAX %s\n' "$GID_MAX" >>$CONFIG_H
111 OS_CFLAGS="$OS_CFLAGS -D_DEFAULT_SOURCE -D_GNU_SOURCE"
114 OS_CFLAGS="$OS_CFLAGS -D_OPENBSD_SOURCE"
115 printf 'LDLIBS += -lutil\n' >>$CONFIG_MK
119 printf 'LDLIBS += -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}
137 cat <<EOF >>$CONFIG_MK
139 EPREFIX ?= ${EPREFIX}
141 SHAREDIR ?= ${SHAREDIR}
143 SYSCONFDIR?= ${SYSCONFDIR}
144 BINMODE ?= ${BINMODE}
149 [ -n "$OS_CFLAGS" ] && \
150 printf 'OS_CFLAGS += %s\n' "$OS_CFLAGS" >>$CONFIG_MK
153 printf 'CFLAGS += -O0 -g\n' >>$CONFIG_MK
155 [ -n "$BUILD_STATIC" ] && \
156 printf 'CFLAGS += -static\n' >>$CONFIG_MK
158 # Add CPPFLAGS/CFLAGS/LDFLAGS/LDLIBS to CC for testing features
159 XCC="${CC:=cc} $CFLAGS $OS_CFLAGS $CPPFLAGS $LDFLAGS $LDLIBS"
160 # Make sure to disable --as-needed for CC tests.
164 *) XCC="$XCC -Wl,--no-as-needed" ;;
168 func="$1"; src="$2"; shift 2
169 printf 'Checking for %-14s\t\t' "$func ..." >&2
170 printf '%s\n' "$src" >"_$func.c"
171 $XCC "_$func.c" -o "_$func" 2>/dev/null
173 rm -f "_$func.c" "_$func"
174 upperfunc="$(printf '%s\n' "$func" | tr '[[:lower:]]' '[[:upper:]]')"
175 if [ $ret -eq 0 ]; then
177 printf '#define HAVE_%s\n' "$upperfunc" >>$CONFIG_H
180 printf '/* #define HAVE_%s */\n' "$upperfunc" >>$CONFIG_H
193 printf 'SRCS += shadow.c\n' >>$CONFIG_MK
194 printf 'LDLIBS += -lcrypt\n' >>$CONFIG_MK
199 printf 'SRCS += insults.c\n' >>$CONFIG_MK
200 [ -z "$WITHOUT_INSULTS" ] && {
201 printf '#define DOAS_INSULTS\n' >>$CONFIG_H
208 [ -z "$WITHOUT_TIMESTAMP" ] && {
209 printf '#define USE_TIMESTAMP\n' >>$CONFIG_H
210 printf 'SRCS += timestamp.c\n' >>$CONFIG_MK
218 # Check for explicit_bzero().
223 explicit_bzero(NULL, 0);
226 check_func "explicit_bzero" "$src" || {
227 printf 'SRCS += libopenbsd/explicit_bzero.c\n' >>$CONFIG_MK
231 # Check for strlcat().
236 const char s1[] = "foo";
238 strlcat(s2, s1, sizeof(s2));
241 check_func "strlcat" "$src" || {
242 printf 'SRCS += libopenbsd/strlcat.c\n' >>$CONFIG_MK
246 # Check for strlcpy().
251 const char s1[] = "foo";
253 strlcpy(s2, s1, sizeof(s2));
256 check_func "strlcpy" "$src" || {
257 printf 'SRCS += libopenbsd/strlcpy.c\n' >>$CONFIG_MK
269 check_func "errc" "$src" || {
270 printf 'SRCS += libopenbsd/errc.c\n' >>$CONFIG_MK
280 verrc(0, 0, "x", NULL);
283 check_func "verrc" "$src" || {
284 printf 'SRCS += libopenbsd/verrc.c\n' >>$CONFIG_MK
288 # Check for setprogname().
296 check_func "setprogname" "$src" || {
297 printf 'SRCS += libopenbsd/progname.c\n' >>$CONFIG_MK
301 # Check for readpassphrase().
304 #include <readpassphrase.h>
307 readpassphrase("", buf, sizeof(buf), 0);
310 check_func "readpassphrase" "$src" || {
311 printf 'SRCS += libopenbsd/readpassphrase.c\n' >>$CONFIG_MK
315 # Check for strtonum().
321 strtonum("", 1, 64, &errstr);
324 check_func "strtonum" "$src" || {
325 printf 'SRCS += libopenbsd/strtonum.c\n' >>$CONFIG_MK
329 # Check for reallocarray().
334 reallocarray(NULL, 0, 0);
337 check_func "reallocarray" "$src" || {
338 printf 'SRCS += libopenbsd/reallocarray.c\n' >>$CONFIG_MK
342 # Check for execvpe().
347 const char *p = { "", NULL };
351 check_func "execvpe" "$src" || {
352 printf 'SRCS += libopenbsd/execvpe.c\n' >>$CONFIG_MK
356 # Check for setresuid().
364 check_func "setresuid" "$src"
368 # Check for setresgid().
376 check_func "setresgid" "$src"
379 if [ $have_setresuid -eq 1 -o $have_setresgid -eq 1 ]; then
380 printf 'SRCS += libopenbsd/bsd-setres_id.c\n' >>$CONFIG_MK
384 # Check for setreuid().
392 check_func "setreuid" "$src"
396 # Check for setregid().
404 check_func "setregid" "$src"
407 # Check for closefrom().
415 check_func "closefrom" "$src" || {
416 printf 'SRCS += libopenbsd/closefrom.c\n' >>$CONFIG_MK
420 # Check for sysconf().
428 check_func "sysconf" "$src"
439 check_func "dirfd" "$src"
449 check_func "fcntl_h" "$src"
452 # Check for F_CLOSEM.
462 check_func "F_CLOSEM" "$src"
465 # Check for dirent.h.
472 check_func "dirent_h" "$src"
475 # Check for sys/ndir.h.
478 #include <sys/ndir.h>
482 check_func "sys_ndir_h" "$src"
485 # Check for sys/dir.h.
492 check_func "sys_dir_h" "$src"
502 check_func "ndir_h" "$src"
505 # Check for login_cap.h.
508 #include <sys/types.h>
509 #include <login_cap.h>
513 check_func "login_cap_h" "$src"
520 int main(void){return 0;}
521 __attribute__((__unused__)) static void foo(void){return;}
523 check_func "__attribute__" "$src" || {
524 printf 'OS_CFLAGS += -DNO_ATTRIBUTE_ON_RETURN_TYPE=1\n' >>$CONFIG_MK
529 insults=$(definsults)
531 persist=$(persistmethod)
532 if [ $? -eq 0 ]; then
533 printf 'Using persist method\t\t\t%s.\n' "$persist" >&2
535 printf 'Using persist method\t\t\tnone.\n' >&2
538 printf '#define DOAS_CONF "%s/doas.conf"\n' "${SYSCONFDIR}" >>$CONFIG_H
540 printf '\n#endif /* CONFIG_H */\n' >>$CONFIG_H