]> git.armaanb.net Git - opendoas.git/blobdiff - configure
bump to version v0.3.2
[opendoas.git] / configure
index 732854761a136a33b2631cbd5e448af804548d21..e15e50969dfbe992c9e5a38e6938e27de3e2640c 100755 (executable)
--- a/configure
+++ b/configure
@@ -7,7 +7,7 @@ die() {
 
 usage() {
        cat <<EOF
-usage: configure [options] [settings]
+usage: configure [options]
 
   --prefix=PREFIX        installation prefix [/usr]
   --exec-prefix=EPREFIX  installation prefix for executable files [PREFIX]
@@ -22,9 +22,10 @@ usage: configure [options] [settings]
   --target=target-alias  the machine that CC will produce code for
 
   --enable-debug         enable debugging
-  --enable-seccomp       enable seccomp
   --enable-static        prepare for static build
 
+       --without-pam          disable pam support
+
   --help, -h             display this help and exit
 EOF
        exit 0
@@ -34,31 +35,32 @@ for x; do
        opt=${x%%=*}
        var=${x#*=}
        case "$opt" in
-       --prefix) PREFIX=$var;;
-       --exec-prefix) EPREFIX=$var;;
-       --bindir) BINDIR=$var;;
-       --datadir) SHAREDIR=$var;;
-       --mandir) MANDIR=$var;;
-       --sysconfdir) SYSCONFDIR=$var;;
-       --pamdir) PAMDIR=$var;;
-       --build) BUILD=$var;;
-       --host) HOST=$var;;
-       --target) TARGET=$var;;
-       --enable-debug) DEBUG=yes;;
-       --enable-seccomp) BUILD_SECCOMP=yes;;
-       --enable-static) BUILD_STATIC=yes;;
-       --help|-h) usage;;
-       *) die "Error: unknown option $opt";;
+       --prefix) PREFIX=$var ;;
+       --exec-prefix) EPREFIX=$var ;;
+       --bindir) BINDIR=$var ;;
+       --datadir) SHAREDIR=$var ;;
+       --mandir) MANDIR=$var ;;
+       --sysconfdir) SYSCONFDIR=$var ;;
+       --pamdir) PAMDIR=$var ;;
+       --build) BUILD=$var ;;
+       --host) HOST=$var ;;
+       --target) TARGET=$var ;;
+       --enable-debug) DEBUG=yes ;;
+       --enable-static) BUILD_STATIC=yes ;;
+       --with-pam) WITHOUT_PAM= ;;
+       --without-pam) WITHOUT_PAM=yes ;;
+       --help|-h) usage ;;
+       *) die "Error: unknown option $opt" ;;
        esac
 done
 
 CONFIG_MK=config.mk
 rm -f "$CONFIG_MK"
 
-: ${VERSION:="$(git describe --dirty --tags --long --always)"}
+# : ${VERSION:="$(git describe --dirty --tags --long --always)"}
+: ${VERSION:="0.3.2"}
 
 cat <<EOF >>$CONFIG_MK
-DESTDIR  ?=    /
 PREFIX   ?=    ${PREFIX:="/usr"}
 EPREFIX  ?=    ${EPREFIX:="${PREFIX}"}
 BINDIR   ?=    ${BINDIR:="${PREFIX}/bin"}
@@ -92,11 +94,14 @@ if [ -z "$OS" ]; then
        KERNEL=${REST%%-*}
 fi
 
+OS_CFLAGS="-D__${OS}__"
+
 case "$OS" in
        linux)
-               OS_CFLAGS="-D_DEFAULT_SOURCE -D_GNU_SOURCE -DUID_MAX=60000 -DGID_MAX=60000"
+               OS_CFLAGS="$OS_CFLAGS -D_DEFAULT_SOURCE -D_GNU_SOURCE -DUID_MAX=60000 -DGID_MAX=60000"
                printf 'CURDIR   :=     .\n' >>$CONFIG_MK
-               printf 'PAM_DOAS  =     pam.d__doas__linux\n' >>$CONFIG_MK
+               [ -z "$WITHOUT_PAM" ] && \
+                       printf 'PAM_DOAS  =     pam.d__doas__linux\n' >>$CONFIG_MK
                ;;
 esac
 
@@ -139,7 +144,7 @@ int main(void) {
        return 0;
 }'
 check_func "explicit_bzero" "$src" || {
-       printf 'OPENBSD  +=     explicit_bzero.c\n' >>$CONFIG_MK
+       printf 'OPENBSD  +=     explicit_bzero.o\n' >>$CONFIG_MK
 }
 
 
@@ -155,7 +160,7 @@ int main(void) {
        return 0;
 }'
 check_func "strlcat" "$src" || {
-       printf 'OPENBSD  +=     strlcat.c\n' >>$CONFIG_MK
+       printf 'OPENBSD  +=     strlcat.o\n' >>$CONFIG_MK
 }
 
 #
@@ -170,7 +175,7 @@ int main(void) {
        return 0;
 }'
 check_func "strlcpy" "$src" || {
-       printf 'OPENBSD  +=     strlcpy.c\n' >>$CONFIG_MK
+       printf 'OPENBSD  +=     strlcpy.o\n' >>$CONFIG_MK
 }
 
 #
@@ -183,7 +188,7 @@ int main(void) {
        return 0;
 }'
 check_func "errc" "$src" || {
-       printf 'OPENBSD  +=     errc.c\n' >>$CONFIG_MK
+       printf 'OPENBSD  +=     errc.o\n' >>$CONFIG_MK
 }
 
 #
@@ -196,7 +201,7 @@ int main(void) {
        return 0;
 }'
 check_func "verrc" "$src" || {
-       printf 'OPENBSD  +=     verrc.c\n' >>$CONFIG_MK
+       printf 'OPENBSD  +=     verrc.o\n' >>$CONFIG_MK
 }
 
 #
@@ -209,7 +214,7 @@ int main(void) {
        return 0;
 }'
 check_func "setprogname" "$src" || {
-       printf 'OPENBSD  +=     progname.c\n' >>$CONFIG_MK
+       printf 'OPENBSD  +=     progname.o\n' >>$CONFIG_MK
 }
 
 #
@@ -223,7 +228,7 @@ int main(void) {
        return 0;
 }'
 check_func "readpassphrase" "$src" || {
-       printf 'OPENBSD  +=     readpassphrase.c\n' >>$CONFIG_MK
+       printf 'OPENBSD  +=     readpassphrase.o\n' >>$CONFIG_MK
 }
 
 #
@@ -237,7 +242,7 @@ int main(void) {
        return 0;
 }'
 check_func "strtonum" "$src" || {
-       printf 'OPENBSD  +=     strtonum.c\n' >>$CONFIG_MK
+       printf 'OPENBSD  +=     strtonum.o\n' >>$CONFIG_MK
 }
 
 #
@@ -250,7 +255,7 @@ int main(void) {
        return 0;
 }'
 check_func "reallocarray" "$src" || {
-       printf 'OPENBSD  +=     reallocarray.c\n' >>$CONFIG_MK
+       printf 'OPENBSD  +=     reallocarray.o\n' >>$CONFIG_MK
 }
 
 #
@@ -272,21 +277,24 @@ src='
 int main(void) {
        return 0;
 }'
-[ -z "$have_bsd_auth_h" ] && \
-       check_func "pam_appl_h" "$src" && {
-               printf 'SRCS     +=     doas_pam.c\n' >>$CONFIG_MK
+check_func "pam_appl_h" "$src" && {
+       [ -z "$WITHOUT_PAM" -a -z "$have_bsd_auth_h" ] && {
+               printf 'SRCS     +=     pam.c\n' >>$CONFIG_MK
+               printf 'LDFLAGS  +=     -lpam\n' >>$CONFIG_MK
        }
+}
 
 #
-# Check for login_cap.h.
+# Check for shadow.h.
 #
 src='
-#include <login_cap.h>
+#include <shadow.h>
 int main(void) {
        return 0;
 }'
-check_func "login_cap_h" "$src" || {
-       printf 'OPENBSD  +=     setusercontext.c\n' >>$CONFIG_MK
+check_func "shadow_h" "$src" && {
+       [ -n "$WITHOUT_PAM" -a -z "$have_bsd_auth_h" ] && \
+               printf 'LDFLAGS  +=     -lcrypt\n' >>$CONFIG_MK
 }
 
 #
@@ -300,7 +308,7 @@ int main(void) {
        return 0;
 }'
 check_func "execvpe" "$src" || {
-       printf 'OPENBSD  +=     execvpe.c\n' >>$CONFIG_MK
+       printf 'OPENBSD  +=     execvpe.o\n' >>$CONFIG_MK
 }
 
 #
@@ -313,7 +321,7 @@ int main(void) {
        return 0;
 }'
 check_func "setresuid" "$src" || {
-       printf 'OPENBSD  +=     setresuid.c\n' >>$CONFIG_MK
+       printf 'OPENBSD  +=     setresuid.o\n' >>$CONFIG_MK
 }
 
 #
@@ -325,27 +333,18 @@ int main(void) {
        pledge("", NULL);
        return 0;
 }'
-check_func "pledge" "$src" && {
-       have_pledge=1
+check_func "pledge" "$src" || {
+       printf 'OPENBSD  +=     pledge-noop.o\n' >>$CONFIG_MK
 }
 
 #
-# Check for seccomp.h
+#
 #
 src='
-#include <linux/seccomp.h>
-#include <sys/prctl.h>
-#include <unistd.h>
-int main(void) {
-       prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL);
-       return 0;
-}'
-[ -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
+#include <stdlib.h>
+int main(void){return 0;}
+__attribute__((__unused__)) static void foo(void){return;}
+'
+check_func "__attribute__" "$src" || {
+       printf 'CFLAGS  +=      -DNO_ATTRIBUTE_ON_RETURN_TYPE=1\n' >>$CONFIG_MK
+}