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

From:
Omar Polo <op@omarpolo.com>
Subject:
[portable] fix cross-compilation and libbsd detection
To:
gameoftrees@openbsd.org
Date:
Fri, 24 Feb 2023 11:29:32 +0100

Download raw body.

Thread
Trying to update the void linux package I noticed two issues:

 - template/configure don't pick up libbsd and fails the sys/queue.h
   test.  Even if the template is not built because the pre-assembled
   file is bundled, the configure is still ran and failure here stops
   everything.

 - replace AC_RUN_IFELSE with AC_COMPILE_IFELSE to have
   cross-compilation working again.  We're not interested in running
   the produced binary, only in seeing which header provides
   SHA1_DIGEST_LENGTH.  I guess these could be further simplified to
   AC_CHECK_DECL

I've built a tarball with this applied (plus version changed) at
https://ftp.omarpolo.com/got-portable-0.84a.tar.gz and tested on void
linux.  I can successfully build a package for amd64-musl and cross
compile for aarch64-musl and aarch64 (glibc.)

diff /home/op/w/got-portable
commit - e81f6f1a0b51a5565d284b8930b6c93c25fa288e
path + /home/op/w/got-portable
blob - 5ecb1e0be7519f3c6ebc7ef010454baac4c9b649
file + configure.ac
--- configure.ac
+++ configure.ac
@@ -88,23 +88,17 @@ if test "x$ac_cv_header_sha_h" = xyes; then
 # Check for SHA1_DIGEST_LENGTH
 have_sha1_digest_length=no
 if test "x$ac_cv_header_sha_h" = xyes; then
-	AC_RUN_IFELSE([AC_LANG_PROGRAM(
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
 	    [#include <sha.h>],
-	    [#if !defined(SHA1_DIGEST_LENGTH) && defined (SHA_DIGEST_LENGTH)
-		exit(1);
-	     #endif
-	    ])],
+	    [return SHA1_DIGEST_LENGTH])],
 	[have_sha1_digest_length=yes])
 	AC_DEFINE(HAVE_SHA_AS_SHA1)
 fi
 
 if test "x$ac_cv_header_sha1_h" = xyes; then
-	AC_RUN_IFELSE([AC_LANG_PROGRAM(
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
 	    [#include <sha1.h>],
-	    [#if !defined(SHA1_DIGEST_LENGTH) && defined(SHA_DIGEST_LENGTH)
-		exit(1);
-	     #endif
-	]    )],
+	    [return SHA1_DIGEST_LENGTH])],
 	[have_sha1_digest_length=yes])
 	AC_DEFINE(HAVE_SHA1_AS_SHA1)
 fi
blob - bd7a2184fd73cfb5a1ece5f92428ce2c6d7c726e
file + template/configure.ac
--- template/configure.ac
+++ template/configure.ac
@@ -20,7 +20,15 @@ AC_PROG_YACC
 
 AC_PROG_CC
 AC_PROG_YACC
+PKG_PROG_PKG_CONFIG
 
+PKG_CHECK_MODULES(LIBBSD, libbsd-overlay, [
+	AM_CFLAGS="$LIBBSD_CFLAGS $AM_CFLAGS"
+	CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
+	LIBS="$LIBBSD_LIBS $LIBS"
+	AC_DEFINE(HAVE_LIBBSD)
+], [AC_MSG_NOTICE([libbisd not found])])
+
 AM_CPPFLAGS="$CFLAGS"
 
 AC_REPLACE_FUNCS([ \