]> git.armaanb.net Git - opendoas.git/blobdiff - configure
configure: use LDLIBS instead of setting LDFLAGS
[opendoas.git] / configure
index 632c74afff96c96218522059ef611accc8a6eca0..9592a30f2b781d896652a975aecaa34ea7fcf6a7 100755 (executable)
--- a/configure
+++ b/configure
@@ -116,7 +116,14 @@ 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 'LDLIBS +=       -lutil\n' >>$CONFIG_MK
+               : ${BINGRP:=wheel}
+               ;;
+       darwin)
                : ${BINGRP:=wheel}
                ;;
 esac
@@ -154,10 +161,14 @@ 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.
-XCC="$XCC -Wl,--no-as-needed"
+
+case "$OS" in
+       darwin) ;;
+       *) XCC="$XCC -Wl,--no-as-needed" ;;
+esac
 
 check_func() {
        func="$1"; src="$2"; shift 2
@@ -189,7 +200,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 'LDLIBS +=       -lpam\n' >>$CONFIG_MK
                printf '#define USE_PAM\n' >>$CONFIG_H
                printf 'pam\n'
 
@@ -208,7 +219,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
@@ -287,9 +298,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" || {
@@ -360,7 +372,9 @@ int main(void) {
        execvpe("", p, p);
        return 0;
 }'
-check_func "execvpe" "$src" || die "system has no execvpe(3): not supported"
+check_func "execvpe" "$src" || {
+       printf 'SRCS += libopenbsd/execvpe.c\n' >>$CONFIG_MK
+}
 
 #
 # Check for setresuid().
@@ -371,9 +385,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().