"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Anna Vyalkova <cyber+misc@sysrq.in>
Subject:
[PATCH 1/4] portable: check for libbsd earlier
To:
gameoftrees@openbsd.org
Date:
Wed, 22 Mar 2023 21:58:34 +0500

Download raw body.

Thread
That allows to use libbsd instead of own compat funcs.
---
 configure.ac | 128 +++++++++++++++++++++++++--------------------------
 1 file changed, 64 insertions(+), 64 deletions(-)

diff --git a/configure.ac b/configure.ac
index 86591a8da..dd33ca1d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,6 +55,70 @@ if test "$YACC_OVERRIDE" = "yes"; then
 	AC_MSG_NOTICE("Using YACC set from environment: $YACC")
 fi
 
+# Check the platform we're compiling on.
+AC_MSG_CHECKING(platform)
+case "$host_os" in
+	*linux*)
+		AC_MSG_RESULT(linux)
+		PLATFORM=linux
+		;;
+	*freebsd*)
+		AC_MSG_RESULT(freebsd)
+		PLATFORM=freebsd
+		;;
+	*darwin*)
+		AC_MSG_RESULT(darwin)
+		PLATFORM=darwin
+		;;
+	*netbsd*)
+		AC_MSG_RESULT(netbsd)
+		PLATFORM=netbsd
+		;;
+	*openbsd*)
+		AC_MSG_RESULT(openbsd)
+		PLATFORM=openbsd
+		;;
+	*dragonfly*)
+		AC_MSG_RESULT(dragonfly)
+		PLATFORM=dragonflybsd
+		;;
+	*)
+		AC_MSG_RESULT(unknown)
+		PLATFORM=unknown
+		;;
+esac
+AC_SUBST(PLATFORM)
+AM_CONDITIONAL([HOST_FREEBSD], [test "$PLATFORM" = "freebsd"])
+AM_CONDITIONAL([HOST_LINUX], [test "$PLATFORM" = "linux"])
+AM_CONDITIONAL([HOST_DARWIN], [test "$PLATFORM" = "darwin"])
+AM_CONDITIONAL([HOST_NETBSD], [test "$PLATFORM" = "netbsd"])
+AM_CONDITIONAL([HOST_OPENBSD], [test "$PLATFORM" = "openbsd"])
+AM_CONDITIONAL([HOST_DRAGONFLYBSD], [test "$PLATFORM" = "dragonflybsd"])
+
+if test "$PLATFORM" = "linux"; then
+	PKG_CHECK_MODULES(
+		LIBBSD,
+		libbsd-overlay,
+		[
+		 	libbsd_CFLAGS="$LIBBSD_CFLAGS"
+			libbsd_LIBS="$LIBBSD_LIBS"
+			AC_SUBST(libbsd_CFLAGS)
+			AC_SUBST(libbsd_LIBS)
+			AC_DEFINE([HAVE_LIBBSD], [1], [BSD UUID])
+		],
+		[
+			AC_MSG_ERROR("*** couldn't find libbsd-overlay via pkg-config")
+		]
+
+	)
+
+	# Add LIBBSD_{CFLAGS,LIBS} to the environment here, as libbsd puts its
+	# header files in a non-standard location, which means the overlay for
+	# <sys/tree.h> and <sys/queue.h> won't be found.
+	CFLAGS="$CFLAGS $LIBBSD_CFLAGS"
+	LIBS="$LIBS $LIBBSD_LIBS"
+fi
+
 # Checks for header files.
 AC_CHECK_HEADERS([ \
 	fcntl.h \
@@ -348,46 +412,6 @@ else
 	AC_LIBOBJ(base64)
 fi
 
-# Check the platform we're compiling on.
-AC_MSG_CHECKING(platform)
-case "$host_os" in
-	*linux*)
-		AC_MSG_RESULT(linux)
-		PLATFORM=linux
-		;;
-	*freebsd*)
-		AC_MSG_RESULT(freebsd)
-		PLATFORM=freebsd
-		;;
-	*darwin*)
-		AC_MSG_RESULT(darwin)
-		PLATFORM=darwin
-		;;
-	*netbsd*)
-		AC_MSG_RESULT(netbsd)
-		PLATFORM=netbsd
-		;;
-	*openbsd*)
-		AC_MSG_RESULT(openbsd)
-		PLATFORM=openbsd
-		;;
-	*dragonfly*)
-		AC_MSG_RESULT(dragonfly)
-		PLATFORM=dragonflybsd
-		;;
-	*)
-		AC_MSG_RESULT(unknown)
-		PLATFORM=unknown
-		;;
-esac
-AC_SUBST(PLATFORM)
-AM_CONDITIONAL([HOST_FREEBSD], [test "$PLATFORM" = "freebsd"])
-AM_CONDITIONAL([HOST_LINUX], [test "$PLATFORM" = "linux"])
-AM_CONDITIONAL([HOST_DARWIN], [test "$PLATFORM" = "darwin"])
-AM_CONDITIONAL([HOST_NETBSD], [test "$PLATFORM" = "netbsd"])
-AM_CONDITIONAL([HOST_OPENBSD], [test "$PLATFORM" = "openbsd"])
-AM_CONDITIONAL([HOST_DRAGONFLYBSD], [test "$PLATFORM" = "dragonflybsd"])
-
 # On OpenBSD, these functions are already defined, yet looking for them in
 # this way on OpenBSD breaks <sha2.h> inclusion.
 # FIXME: this needs addressing.
@@ -668,30 +692,6 @@ if test "x$found_zlib" = "xno"; then
 	AC_MSG_ERROR("*** couldn't find zlib ***")
 fi
 
-if test "$PLATFORM" = "linux"; then
-	PKG_CHECK_MODULES(
-		LIBBSD,
-		libbsd-overlay,
-		[
-		 	libbsd_CFLAGS="$LIBBSD_CFLAGS"
-			libbsd_LIBS="$LIBBSD_LIBS"
-			AC_SUBST(libbsd_CFLAGS)
-			AC_SUBST(libbsd_LIBS)
-			AC_DEFINE([HAVE_LIBBSD], [1], [BSD UUID])
-		],
-		[
-			AC_MSG_ERROR("*** couldn't find libbsd-overlay via pkg-config")
-		]
-
-	)
-
-	# Add LIBBSD_{CFLAGS,LIBS} to the environment here, as libbsd puts its
-	# header files in a non-standard location, which means the overlay for
-	# <sys/tree.h> and <sys/queue.h> won't be found.
-	CFLAGS="$CFLAGS $LIBBSD_CFLAGS"
-	LIBS="$LIBS $LIBBSD_LIBS"
-fi
-
 # Look for a suitable queue.h.  We hope libbsd is enough, but that is missing
 # some declarations.
 AC_CHECK_DECL(
-- 
2.40.0