From: Christian Storm <[email protected]>

Adapt the build system to build a shared library
libebgenv-${EBG_VERSION}.so symlinked to by a
libebgenv.so in addition to the static libebgenv.a.

This shared library may be used by external software
such as SWUpdate [1] wanting to modify EFI Boot Guard's
environment without having to statically link against
libebgenv.a, following the pattern of libubootenv [2].

Note that the bg_setenv utility deliberately remains
statically linked against libebgenv.a. for easy
inclusion in initramfs or rescue media and to not
break existing deployments. Alike, libebgenv.a is
still installed via make install (though distributions
may decide to not package it).
This may be deprecated and removed in future versions.

[1] https://github.com/sbabic/swupdate
[2] https://github.com/sbabic/libubootenv

Signed-off-by: Christian Storm <[email protected]>
---
 .gitignore   | 5 +++++
 Makefile.am  | 9 +++++++++
 configure.ac | 4 +++-
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 6433560..c8cb496 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,7 @@
 *.so
 *.so.*
 *.dylib
+*.lai
 
 # EFI
 *.efi
@@ -70,6 +71,7 @@ Makefile.in
 /config.status
 /config.sub
 /configure
+/configure~
 /configure.scan
 /depcomp
 /install-sh
@@ -78,4 +80,7 @@ Makefile.in
 /Makefile
 /tools/tests/Makefile
 .deps/
+m4/libtool.m4
+m4/lt*
 version.h
+libtool
diff --git a/Makefile.am b/Makefile.am
index ee142d1..f000d73 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -90,6 +90,14 @@ libebgenv_a_CFLAGS = \
 pkginclude_HEADERS = \
        include/ebgenv.h
 
+#
+# Shared libraries
+#
+LIBEBGENV_SO_VERSION = $(shell $(EGREP) -o '[0-9]+\.[0-9]+' 
$(top_srcdir)/VERSION)
+lib_LTLIBRARIES = libebgenv.la
+libebgenv_la_SOURCES = $(libebgenv_a_SOURCES)
+libebgenv_la_LDFLAGS = -release $(LIBEBGENV_SO_VERSION).0
+
 #
 # bg_setenv binary
 #
@@ -111,6 +119,7 @@ bg_setenv_DEPENDENCIES = \
 install-exec-hook:
        $(LN_S) -f bg_setenv$(EXEEXT) \
                $(DESTDIR)$(bindir)/bg_printenv$(EXEEXT)
+       $(RM) $(DESTDIR)$(libdir)/$(lib_LTLIBRARIES)
 
 #
 # EFI compilation
diff --git a/configure.ac b/configure.ac
index fd75cb8..6dcd386 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,8 @@ AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_AUX_DIR([build-aux])
 AC_PREFIX_DEFAULT([/usr])
 
+LT_INIT
+
 AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability silent-rules tar-pax 
no-dist-gzip dist-xz subdir-objects])
 AM_SILENT_RULES([yes])
 
@@ -47,8 +49,8 @@ AM_PROG_CC_C_O
 AC_PROG_GCC_TRADITIONAL
 
 AC_PROG_MKDIR_P
-AC_PROG_RANLIB
 AC_PROG_LN_S
+AC_PROG_EGREP
 
 AC_ARG_WITH([gnuefi-sys-dir],
            AS_HELP_STRING([--with-gnuefi-sys-dir=DIRECTORY],
-- 
2.33.0

-- 
You received this message because you are subscribed to the Google Groups "EFI 
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/efibootguard-dev/20210826082255.44810-1-christian.storm%40siemens.com.

Reply via email to