[sandbox] configure: check for static libc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Missing static libc doesn't really prevent the build to finish, but it
would cause errors when running qemu sandboxes. Checking in configure
will save time for new developers.
---
 configure.ac      |  2 ++
 m4/virt-static.m4 | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)
 create mode 100644 m4/virt-static.m4

diff --git a/configure.ac b/configure.ac
index 0e49a0a..ba5247a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -87,6 +87,8 @@ LIBVIRT_SANDBOX_COVERAGE
 LIBVIRT_SANDBOX_RPCGEN
 LIBVIRT_SANDBOX_SELINUX
 
+LIBVIRT_SANDBOX_STATIC_LIBC
+
 GOBJECT_INTROSPECTION_CHECK([$GOBJECT_INTROSPECTION_REQUIRED])
 
 dnl Should be in m4/virt-gettext.m4 but intltoolize is too
diff --git a/m4/virt-static.m4 b/m4/virt-static.m4
new file mode 100644
index 0000000..8a40351
--- /dev/null
+++ b/m4/virt-static.m4
@@ -0,0 +1,33 @@
+# LIBVIRT_SANDBOX_STATIC_LIB(NAME, CFLAGS, LDFLAGS, PROLOG, PROGRAM)
+# ------------------------------------------------------------------
+# Check if the program can be linked with static libraries only.
+#
+AC_DEFUN([LIBVIRT_SANDBOX_STATIC_LIB], [
+    AC_MSG_CHECKING([for static $1])
+
+    SAVED_LDFLAGS=$LDFLAGS
+    SAVED_CFLAGS=$CFLAGS
+    CFLAGS="$2"
+    LDFLAGS="-static $3"
+    AC_LINK_IFELSE(
+        [AC_LANG_PROGRAM([$4],
+                         [$5])],
+        [],
+        [AC_MSG_RESULT([no])]
+        [AC_MSG_ERROR([static $1 is required in order to build virt-sandbox-init-qemu])]
+    )
+    LDFLAGS=$SAVED_LDFLAGS
+    CFLAGS=$SAVED_CFLAGS
+
+    AC_MSG_RESULT([yes])
+])
+
+AC_DEFUN([LIBVIRT_SANDBOX_STATIC_LIBC], [
+    LIBVIRT_SANDBOX_STATIC_LIB(
+         [LIBC],
+         [],
+         [],
+         [#include <stdio.h>],
+         [printf("bar");])
+])
+
-- 
2.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]