]> git.armaanb.net Git - opendoas.git/blobdiff - configure
Replace build/installation instructions with discouragements
[opendoas.git] / configure
index d6c85af1de06c2b6139c4beb31a08b41593001fd..1f92f0175d6613e7ba8359a3c17bf14d4e3c4e43 100755 (executable)
--- a/configure
+++ b/configure
@@ -15,7 +15,6 @@ usage: configure [options]
   --datadir=DIR          architecture-independent data files [PREFIX/share]
   --mandir=DIR           manual pages [DATADIR/man]
   --sysconfdir=DIR       directory for configuration files [/etc]
-  --pamdir=DIR           PAM directory [SYSCONFDIR/pam.d]
 
   --build=build-alias    a cpu-vendor-opsys for the system where the application will be built
   --host=host-alias      a cpu-vendor-opsys for the system where the application will run
@@ -52,7 +51,6 @@ for x; do
        --datadir) SHAREDIR=$var ;;
        --mandir) MANDIR=$var ;;
        --sysconfdir) SYSCONFDIR=$var ;;
-       --pamdir) PAMDIR=$var ;;
        --build) BUILD=$var ;;
        --host) HOST=$var ;;
        --target) TARGET=$var ;;
@@ -116,11 +114,11 @@ case "$OS" in
                ;;
        netbsd)
                OS_CFLAGS="$OS_CFLAGS -D_OPENBSD_SOURCE"
-               printf 'LDFLAGS  +=     -lutil\n' >>$CONFIG_MK
+               printf 'LDLIBS +=       -lutil\n' >>$CONFIG_MK
                : ${BINGRP:=wheel}
                ;;
        freebsd)
-               printf 'LDFLAGS  +=     -lutil\n' >>$CONFIG_MK
+               printf 'LDLIBS +=       -lutil\n' >>$CONFIG_MK
                : ${BINGRP:=wheel}
                ;;
        darwin)
@@ -134,7 +132,6 @@ esac
 : ${SHAREDIR:=${PREFIX}/share}
 : ${MANDIR:=${SHAREDIR}/man}
 : ${SYSCONFDIR:=/etc}
-: ${PAMDIR:=${SYSCONFDIR}/pam.d}
 : ${BINMODE:=4755}
 : ${BINOWN:=root}
 : ${BINGRP:=root}
@@ -146,14 +143,13 @@ BINDIR   ?=       ${BINDIR}
 SHAREDIR ?=    ${SHAREDIR}
 MANDIR   ?=    ${MANDIR}
 SYSCONFDIR?=   ${SYSCONFDIR}
-PAMDIR   ?=    ${PAMDIR}
 BINMODE  ?=    ${BINMODE}
 BINOWN  ?=     ${BINOWN}
 BINGRP  ?=     ${BINGRP}
 EOF
 
 [ -n "$OS_CFLAGS" ] && \
-       printf 'CFLAGS   +=     %s\n' "$OS_CFLAGS" >>$CONFIG_MK
+       printf 'OS_CFLAGS   +=  %s\n' "$OS_CFLAGS" >>$CONFIG_MK
 
 [ -n "$DEBUG" ] && \
        printf 'CFLAGS   +=     -O0 -g\n' >>$CONFIG_MK
@@ -161,8 +157,8 @@ EOF
 [ -n "$BUILD_STATIC" ] && \
        printf 'CFLAGS   +=     -static\n' >>$CONFIG_MK
 
-# Add CPPFLAGS/CFLAGS/LDFLAGS to CC for testing features
-XCC="${CC:=cc} $CFLAGS $OS_CFLAGS $CPPFLAGS $LDFLAGS"
+# Add CPPFLAGS/CFLAGS/LDFLAGS/LDLIBS to CC for testing features
+XCC="${CC:=cc} $CFLAGS $OS_CFLAGS $CPPFLAGS $LDFLAGS $LDLIBS"
 # Make sure to disable --as-needed for CC tests.
 
 case "$OS" in
@@ -200,12 +196,9 @@ 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 'LDLIBS +=       -lpam\n' >>$CONFIG_MK
                printf '#define USE_PAM\n' >>$CONFIG_H
                printf 'pam\n'
-
-               pam_file="pam.d__doas__${OS}"
-               [ -e "$pam_file" ] && printf 'PAM_DOAS  =       %s\n' "$pam_file" >>$CONFIG_MK
                return 0
        }
 
@@ -219,7 +212,7 @@ int main(void) {
 }'
        [ -z "$WITHOUT_SHADOW" ] && check_func "shadow_h" "$src" && {
                printf 'SRCS     +=     shadow.c\n' >>$CONFIG_MK
-               printf 'LDFLAGS  +=     -lcrypt\n' >>$CONFIG_MK
+               printf 'LDLIBS +=       -lcrypt\n' >>$CONFIG_MK
                printf '#define USE_SHADOW\n' >>$CONFIG_H
                printf 'shadow\n'
                return 0
@@ -298,9 +291,10 @@ check_func "errc" "$src" || {
 # Check for verrc().
 #
 src='
+#include <stddef.h>
 #include <err.h>
 int main(void) {
-       verrc(0, 0, "");
+       verrc(0, 0, "x", NULL);
        return 0;
 }'
 check_func "verrc" "$src" || {
@@ -384,9 +378,47 @@ int main(void) {
        setresuid(0, 0, 0);
        return 0;
 }'
-check_func "setresuid" "$src" || {
+check_func "setresuid" "$src"
+have_setresuid=$?
+
+#
+# Check for setresgid().
+#
+src='
+#include <unistd.h>
+int main(void) {
+       setresgid(0, 0, 0);
+       return 0;
+}'
+check_func "setresgid" "$src"
+have_setresgid=$?
+
+if [ $have_setresuid -eq 1 -o $have_setresgid -eq 1 ]; then
        printf 'SRCS += libopenbsd/bsd-setres_id.c\n' >>$CONFIG_MK
-}
+fi
+
+#
+# Check for setreuid().
+#
+src='
+#include <unistd.h>
+int main(void) {
+       setreuid(0, 0);
+       return 0;
+}'
+check_func "setreuid" "$src"
+
+
+#
+# Check for setregid().
+#
+src='
+#include <unistd.h>
+int main(void) {
+       setregid(0, 0);
+       return 0;
+}'
+check_func "setregid" "$src"
 
 #
 # Check for closefrom().
@@ -506,7 +538,7 @@ 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
+       printf 'OS_CFLAGS       +=      -DNO_ATTRIBUTE_ON_RETURN_TYPE=1\n' >>$CONFIG_MK
 }
 
 auth=$(authmethod)