]> git.armaanb.net Git - opendoas.git/blobdiff - configure
timestamp: error out if fstat and lstat st_ino and st_dev are not the same
[opendoas.git] / configure
index c5a4c397450539fe98c041b2db37f12434ea2f0e..4dfd287ade349527c511d53434813253b501cbb9 100755 (executable)
--- a/configure
+++ b/configure
@@ -25,13 +25,18 @@ usage: configure [options]
   --enable-static        prepare for static build
 
   --without-pam          disable pam support
-  --without-pam          disable shadow support
+  --without-shadow       disable shadow support
+
+  --with-timestamp       enable timestamp support
 
   --help, -h             display this help and exit
 EOF
        exit 0
 }
 
+# defaults
+WITHOUT_TIMESTAMP=yes
+
 for x; do
        opt=${x%%=*}
        var=${x#*=}
@@ -52,6 +57,8 @@ for x; do
        --with-shadow) WITHOUT_SHADOW=; WITHOUT_PAM=yes ;;
        --without-pam) WITHOUT_PAM=yes ;;
        --without-shadow) WITHOUT_SHADOW=yes ;;
+       --with-timestamp) WITHOUT_TIMESTAMP= ;;
+       --without-timestamp) WITHOUT_TIMESTAMP=yes ;;
        --help|-h) usage ;;
        *) die "Error: unknown option $opt" ;;
        esac
@@ -61,7 +68,7 @@ CONFIG_MK=config.mk
 rm -f "$CONFIG_MK"
 
 # : ${VERSION:="$(git describe --dirty --tags --long --always)"}
-: ${VERSION:="0.3.2"}
+: ${VERSION:="6.2"}
 
 cat <<EOF >>$CONFIG_MK
 PREFIX   ?=    ${PREFIX:="/usr"}
@@ -141,20 +148,6 @@ check_func() {
 }
 
 authmethod() {
-       #
-       # Check for bsd_auth.h.
-       #
-       src='
-#include <bsd_auth.h>
-int main(void) {
-       return 0;
-}'
-       check_func "bsd_auth_h" "$src" && {
-               have_bsd_auth_h=1
-               printf 'bsd\n'
-               return 0
-       }
-
        #
        # Check for pam_appl.h.
        #
@@ -166,6 +159,7 @@ int main(void) {
        [ -z "$WITHOUT_PAM" ] && check_func "pam_appl_h" "$src" && {
                printf 'SRCS     +=     pam.c\n' >>$CONFIG_MK
                printf 'LDFLAGS  +=     -lpam\n' >>$CONFIG_MK
+               printf 'CPPFLAGS +=     -DUSE_PAM\n' >>$CONFIG_MK
                printf 'pam\n'
                return 0
        }
@@ -179,7 +173,9 @@ int main(void) {
        return 0;
 }'
        [ -z "$WITHOUT_SHADOW" ] && check_func "shadow_h" "$src" && {
+               printf 'SRCS     +=     shadow.c\n' >>$CONFIG_MK
                printf 'LDFLAGS  +=     -lcrypt\n' >>$CONFIG_MK
+               printf 'CPPFLAGS +=     -DUSE_SHADOW\n' >>$CONFIG_MK
                printf 'shadow\n'
                return 0
        }
@@ -187,6 +183,16 @@ int main(void) {
        return 1
 }
 
+persistmethod() {
+       [ -z "$WITHOUT_TIMESTAMP" ] && {
+               printf 'CPPFLAGS += -DUSE_TIMESTAMP\n' >>$CONFIG_MK
+               printf 'SRCS    += timestamp.c\n' >>$CONFIG_MK
+               printf 'timestamp\n'
+               return 0
+       }
+       return 1
+}
+
 #
 # Check for explicit_bzero().
 #
@@ -338,18 +344,114 @@ check_func "setresuid" "$src" || {
 }
 
 #
-# Check for pledge().
+# Check for closefrom().
 #
 src='
 #include <unistd.h>
 int main(void) {
-       pledge("", NULL);
+       closefrom(0);
        return 0;
 }'
-check_func "pledge" "$src" || {
-       printf 'OPENBSD  +=     pledge-noop.o\n' >>$CONFIG_MK
+check_func "closefrom" "$src" || {
+       printf 'OPENBSD  +=     closefrom.o\n' >>$CONFIG_MK
 }
 
+#
+# Check for sysconf().
+#
+src='
+#include <unistd.h>
+int main(void) {
+       (void)sysconf(0);
+       return 0;
+}'
+check_func "sysconf" "$src"
+
+#
+# Check for /proc/$PID.
+#
+printf 'Checking for %-14s\t\t' "/proc/\$PID ..." >&2
+if test -d /proc/$$; then
+       printf 'yes.\n' >&2
+       printf 'CFLAGS   +=     -DHAVE_%s\n' "PROC_PID" >>$CONFIG_MK
+else
+       printf 'no.\n' >&2
+fi
+
+#
+# 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"
+
 #
 #
 #
@@ -369,3 +471,10 @@ else
        printf 'Error auth method\t\t\n' >&2
        exit 1
 fi
+
+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