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

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
[portable] Fix up uuid_create() check
To:
gameoftrees@openbsd.org
Date:
Tue, 28 Feb 2023 20:48:37 +0100

Download raw body.

Thread
I'm looking at introducing config.h, which means I'm eyeing all
AC_DEFINE() calls, which made me stumble over this part of
configure.ac:

------------------->
AC_SEARCH_LIBS(uuid_create, , AC_DEFINE(HAVE_BSD_UUID))
AC_SEARCH_LIBS(uuid_create, found_uuid=no, found_uuid=yes)
AC_SEARCH_LIBS(mergesort, , AC_DEFINE(HAVE_BSD_MERGESORT))

# Don't define HAVE_BSD_UUID on darwin (Apple) as this breaks the BSD API.
# Instead, use the UUID implementation wrapper that's in compat/ plus uuid
# ossp
if test "x$found_uuid" = "xyes" -a "x$PLATFORM" != "darwin"; then
        AC_DEFINE(HAVE_BSD_UUID)
else
<-------------------

AC_SEARCH_LIBS() is called twice?  The first call seems to clash
with the subsequent if branch.  The second call has wrong arguments,
AC_SEARCH_LIBS takes libraries as the second parameter.

Also, if we don't specify a lib, why call AC_SEARCH_LIBS in the
first place instead of AC_CHECK_FUNC[S]?

This
* cleans up the confused uuid_create() check;
* adds a template argument to AC_DEFINE() required for config.h;
* moves the mergesort() check into an earlier AC_CHECK_FUNCS().

diff refs/heads/linux refs/heads/uuid
commit - 680b44a7e950277747770bc4302b55d2830e48df
commit + 88e9f2280014e9dfc49f3d281d4bb1644b0443e3
blob - 411a05c09cda3abd712cecf458fd4db2de2cb536
blob + 58d4085c0d7102220664ec9eee5c455beea8b246
--- configure.ac
+++ configure.ac
@@ -168,6 +168,7 @@ AC_CHECK_FUNCS([ \
 	memchr \
 	memmove \
 	memset \
+	mergesort \
 	mkdir \
 	munmap \
 	nl_langinfo \
@@ -482,15 +483,14 @@ AC_SEARCH_LIBS(uuid_create, , AC_DEFINE(HAVE_BSD_UUID)
 	AC_DEFINE(HAVE_LIBCRYPTO)
 fi
 
-AC_SEARCH_LIBS(uuid_create, , AC_DEFINE(HAVE_BSD_UUID))
-AC_SEARCH_LIBS(uuid_create, found_uuid=no, found_uuid=yes)
-AC_SEARCH_LIBS(mergesort, , AC_DEFINE(HAVE_BSD_MERGESORT))
+AC_CHECK_FUNC(uuid_create, found_uuid=yes, found_uuid=no)
 
 # Don't define HAVE_BSD_UUID on darwin (Apple) as this breaks the BSD API.
 # Instead, use the UUID implementation wrapper that's in compat/ plus uuid
 # ossp
 if test "x$found_uuid" = "xyes" -a "x$PLATFORM" != "darwin"; then
-	AC_DEFINE(HAVE_BSD_UUID)
+	AC_DEFINE([HAVE_BSD_UUID], [1],
+		[Define if you have a DCE 1.1 compliant uuid_create() function])
 else
 	PKG_CHECK_MODULES(
 		LIBUUID,
blob - 847c76958d00a869e71be503e43f000280b06cba
blob + 8feed1d64cb2baa5fa54abac69959bc8cfa1677b
--- include/got_compat.h
+++ include/got_compat.h
@@ -421,7 +421,7 @@ int	BSDgetopt(int, char *const *, const char *);
 	((tvp)->tv_sec cmp (uvp)->tv_sec))
 #endif
 
-#ifndef HAVE_BSD_MERGESORT
+#ifndef HAVE_MERGESORT
 /* mergesort.c */
 int mergesort(void *, size_t, size_t, int (*)(const void *, const void *));
 #endif
-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de