From e09feae5f4958bd19082407b115c7f1c0884c9a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Mon, 11 Sep 2023 18:22:35 +0200 Subject: [PATCH 1/3] build: Fix indent --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c94b26b..453d04f 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ LIB_NAME := libgovarnam.so ifeq ($(UNAME), Darwin) SED := sed -i "" - LIB_NAME = libgovarnam.dylib + LIB_NAME = libgovarnam.dylib endif VERSION_STAMP_LDFLAGS := -X 'github.com/varnamproject/govarnam/govarnam.BuildString=${BUILDSTR}' -X 'github.com/varnamproject/govarnam/govarnam.VersionString=${VERSION}' From 5b4cd76ba2fe164c687e140ca4dfcca80b197b6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Mon, 11 Sep 2023 17:45:40 +0200 Subject: [PATCH 2/3] build: Don't strip /lib out of arbitrary paths The current sed expression matches on all paths elements so if one has it's development e.g. in /var/scratch/librem5/ it would truncate the patch to /var/scratchrem5/ which then fails the build. Fix that by only matching at the end of paths to remove /lib from the libdir. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 453d04f..24b5127 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ temp-pc: ${SED} "s#@VERSION@#${VERSION}#g" govarnam.pc ${SED} "s#/include/libgovarnam##g" govarnam.pc - ${SED} "s#/lib##g" govarnam.pc + ${SED} "s#/lib\$$##g" govarnam.pc install-script: cp install.sh.in install.sh From c314a3da4489a90ff94ce299e43ed04f45023838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Mon, 11 Sep 2023 18:12:38 +0200 Subject: [PATCH 3/3] build: Record soname This sets an soname for dynamic linking: $ readelf -a libgovarnam.so | grep SONAME 0x000000000000000e (SONAME) Library soname: [libgovarnam.so.1] This is needed for ABI versioning and dynamlic linking. See e.g. Section 8.1 of Debian's policy. With this one gets properly versioned dependencies e.g. $ readelf -a _build/src/phosh-osk-stub | grep gov 0x0000000000000001 (NEEDED) Shared library: [libgovarnam.so.1.9.0] While without that patch one gets an unversioned dependency which won't allow to handle any ABI changes: $ readelf -a _build/src/phosh-osk-stub | grep libgovarn 0x0000000000000001 (NEEDED) Shared library: [/usr/local/lib/libgovarnam.so] --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 24b5127..b864c1f 100644 --- a/Makefile +++ b/Makefile @@ -16,14 +16,16 @@ UNAME := $(shell uname) SED := sed -i LIB_NAME := libgovarnam.so +SO_NAME := $(shell (echo $(VERSION) | cut -d. -f1)) ifeq ($(UNAME), Darwin) SED := sed -i "" LIB_NAME = libgovarnam.dylib +else + EXT_LDFLAGS = -extldflags -Wl,-soname,$(LIB_NAME).$(SO_NAME) endif -VERSION_STAMP_LDFLAGS := -X 'github.com/varnamproject/govarnam/govarnam.BuildString=${BUILDSTR}' -X 'github.com/varnamproject/govarnam/govarnam.VersionString=${VERSION}' - +VERSION_STAMP_LDFLAGS := -X 'github.com/varnamproject/govarnam/govarnam.BuildString=${BUILDSTR}' -X 'github.com/varnamproject/govarnam/govarnam.VersionString=${VERSION}' $(EXT_LDFLAGS) pc: cp govarnam.pc.in govarnam.pc ${SED} "s#@INSTALL_PREFIX@#${INSTALL_PREFIX}#g" govarnam.pc