-[ -z "$have_pledge" -a -n "$BUILD_SECCOMP" ] && \
- check_func "seccomp_h" "$src" && \
- {
- have_pledge=1
- printf 'OPENBSD += pledge-seccomp.c\n' >>$CONFIG_MK
- }
-
-[ -z "$have_pledge" ] && \
- printf 'OPENBSD += pledge-noop.c\n' >>$CONFIG_MK
+check_func "sysconf" "$src"
+
+#
+# Check for dirfd().
+#
+src='
+#include <dirent.h>
+int main(void) {
+ (void)dirfd(0);
+ return 0;
+}'
+check_func "dirfd" "$src"
+
+#
+# Check for fcntl.h.
+#
+src='
+#include <fcntl.h>
+int main(void) {
+ return 0;
+}'
+check_func "fcntl_h" "$src"
+
+#
+# Check for F_CLOSEM.
+#
+src='
+#include <fcntl.h>
+#ifndef F_CLOSEM
+#error no F_CLOSEM
+#endif
+int main(void) {
+ return 0;
+}'
+check_func "F_CLOSEM" "$src"
+
+#
+# Check for dirent.h.
+#
+src='
+#include <dirent.h>
+int main(void) {
+ return 0;
+}'
+check_func "dirent_h" "$src"
+
+#
+# Check for sys/ndir.h.
+#
+src='
+#include <sys/ndir.h>
+int main(void) {
+ return 0;
+}'
+check_func "sys_ndir_h" "$src"
+
+#
+# Check for sys/dir.h.
+#
+src='
+#include <sys/dir.h>
+int main(void) {
+ return 0;
+}'
+check_func "sys_dir_h" "$src"
+
+#
+# Check for ndir.h.
+#
+src='
+#include <ndir.h>
+int main(void) {
+ return 0;
+}'
+check_func "ndir_h" "$src"
+
+#
+# Check for login_cap.h.
+#
+src='
+#include <sys/types.h>
+#include <login_cap.h>
+int main(void) {
+ return 0;
+}'
+check_func "login_cap_h" "$src"
+
+#
+#
+#
+src='
+#include <stdlib.h>
+int main(void){return 0;}
+__attribute__((__unused__)) static void foo(void){return;}
+'
+check_func "__attribute__" "$src" || {
+ printf 'OS_CFLAGS += -DNO_ATTRIBUTE_ON_RETURN_TYPE=1\n' >>$CONFIG_MK
+}
+
+auth=$(authmethod)
+
+insults=$(definsults)
+
+persist=$(persistmethod)
+if [ $? -eq 0 ]; then
+ printf 'Using persist method\t\t\t%s.\n' "$persist" >&2
+else
+ printf 'Using persist method\t\t\tnone.\n' >&2
+fi
+
+printf '#define DOAS_CONF "%s/doas.conf"\n' "${SYSCONFDIR}" >>$CONFIG_H
+
+printf '\n#endif /* CONFIG_H */\n' >>$CONFIG_H