From e14f3ae39662350be7cb4549fc5e3193ab2f28b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sat, 23 Sep 2023 14:10:36 +0200 Subject: [PATCH] build: Allow to set libddir Needed for multiarch installations --- Makefile | 37 +++++++++++++++++++++---------------- govarnam.pc.in | 2 +- install.sh.in | 12 ++++++------ 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 4f57940..e0eb8fc 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ default: build ; CLI_BIN := varnamcli INSTALL_PREFIX := $(or ${PREFIX},${PREFIX},/usr/local) +LIBDIR := /lib # Try to get the commit hash from git LAST_COMMIT := $(or $(shell git rev-parse --short HEAD 2> /dev/null),"UNKNOWN") @@ -14,13 +15,12 @@ BUILDSTR := ${VERSION} (\#${LAST_COMMIT} $(shell date -u +"%Y-%m-%dT%H:%M:%S%z") RELEASE_NAME := govarnam-${VERSION}-${shell uname -m} UNAME := $(shell uname) -SED := sed -i +SED := sed LIB_NAME := libgovarnam.so SO_NAME := $(shell (echo $(VERSION) | cut -d. -f1)) CURDIR := $(shell pwd) ifeq ($(UNAME), Darwin) - SED := sed -i "" LIB_NAME = libgovarnam.dylib else EXT_LDFLAGS = -extldflags "-Wl,-soname,$(LIB_NAME).$(SO_NAME),--version-script,$(CURDIR)/govarnam.syms" @@ -28,25 +28,30 @@ endif 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 - ${SED} "s#@VERSION@#${VERSION}#g" govarnam.pc + ${SED} -e "s#@INSTALL_PREFIX@#${INSTALL_PREFIX}#g" \ + -e "s#@VERSION@#${VERSION}#g" \ + -e "s#@LIBDIR@#${LIBDIR}#g" \ + govarnam.pc.in > govarnam.pc.tmp + mv govarnam.pc.tmp govarnam.pc # Used only for building the CLI temp-pc: - cp govarnam.pc.in govarnam.pc - ${SED} "s#@INSTALL_PREFIX@#$(realpath .)#g" govarnam.pc - ${SED} "s#@VERSION@#${VERSION}#g" govarnam.pc - - ${SED} "s#/include/libgovarnam##g" govarnam.pc - ${SED} "s#/lib\$$##g" govarnam.pc + ${SED} -e "s#@INSTALL_PREFIX@#$(realpath .)#g" \ + -e "s#@VERSION@#${VERSION}#g" \ + -e "s#@LIBDIR@#${LIBDIR}#g" \ + -e "s#/include/libgovarnam##g" \ + -e "s#/lib\$$##g" \ + govarnam.pc.in > govarnam.pc.tmp + mv govarnam.pc.tmp govarnam.pc install.sh: install.sh.in - cp install.sh.in install.sh - ${SED} "s#@INSTALL_PREFIX@#${INSTALL_PREFIX}#g" install.sh - ${SED} "s#@VERSION@#${VERSION}#g" install.sh - ${SED} "s#@LIB_NAME@#${LIB_NAME}#g" install.sh - ${SED} "s#@SO_NAME@#${SO_NAME}#g" install.sh + ${SED} -e "s#@INSTALL_PREFIX@#${INSTALL_PREFIX}#g" \ + -e "s#@VERSION@#${VERSION}#g" \ + -e "s#@LIBDIR@#${LIBDIR}#g" \ + -e "s#@LIB_NAME@#${LIB_NAME}#g" \ + -e "s#@SO_NAME@#${SO_NAME}#g" \ + install.sh.in > install.sh.tmp + mv install.sh.tmp install.sh chmod +x install.sh .PHONY: install diff --git a/govarnam.pc.in b/govarnam.pc.in index af00678..cd1e1df 100644 --- a/govarnam.pc.in +++ b/govarnam.pc.in @@ -1,6 +1,6 @@ prefix=@INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib +libdir=${prefix}@LIBDIR@ includedir=${prefix}/include/libgovarnam Name: GoVarnam diff --git a/install.sh.in b/install.sh.in index d5381ba..7415fc2 100755 --- a/install.sh.in +++ b/install.sh.in @@ -11,11 +11,11 @@ if [ "$ARG1" == "install" ]; then "${SUDO}" mkdir -p "/usr/local/bin/" "${SUDO}" cp "$SCRIPT_DIR/varnamcli" "${DESTDIR}@INSTALL_PREFIX@/bin/varnamcli" - "${SUDO}" mkdir -p "${DESTDIR}@INSTALL_PREFIX@/lib/pkgconfig" - "${SUDO}" cp "$SCRIPT_DIR/@LIB_NAME@" "${DESTDIR}@INSTALL_PREFIX@/lib/@LIB_NAME@.@VERSION@" - "${SUDO}" ln -sf "${DESTDIR}@INSTALL_PREFIX@/lib/@LIB_NAME@.@VERSION@" "${DESTDIR}@INSTALL_PREFIX@/lib/@LIB_NAME@" - "${SUDO}" ln -sf "${DESTDIR}@INSTALL_PREFIX@/lib/@LIB_NAME@.@VERSION@" "${DESTDIR}@INSTALL_PREFIX@/lib/@LIB_NAME@.@SO_NAME@" - "${SUDO}" cp "$SCRIPT_DIR/govarnam.pc" "${DESTDIR}@INSTALL_PREFIX@/lib/pkgconfig/" + "${SUDO}" mkdir -p "${DESTDIR}@INSTALL_PREFIX@@LIBDIR@/pkgconfig" + "${SUDO}" cp "$SCRIPT_DIR/@LIB_NAME@" "${DESTDIR}@INSTALL_PREFIX@@LIBDIR@/@LIB_NAME@.@VERSION@" + "${SUDO}" ln -s "@INSTALL_PREFIX@@LIBDIR@/@LIB_NAME@.@VERSION@" "${DESTDIR}@INSTALL_PREFIX@@LIBDIR@/@LIB_NAME@" + "${SUDO}" ln -s "@INSTALL_PREFIX@@LIBDIR@/@LIB_NAME@.@VERSION@" "${DESTDIR}@INSTALL_PREFIX@@LIBDIR@/@LIB_NAME@.@SO_NAME@" + "${SUDO}" cp "$SCRIPT_DIR/govarnam.pc" "${DESTDIR}@INSTALL_PREFIX@@LIBDIR@/pkgconfig/" "${SUDO}" mkdir -p "${DESTDIR}@INSTALL_PREFIX@/include/libgovarnam" "${SUDO}" cp "$SCRIPT_DIR/"*.h "${DESTDIR}@INSTALL_PREFIX@/include/libgovarnam/" @@ -28,7 +28,7 @@ if [ "$ARG1" == "install" ]; then notify-send "$msg" &> /dev/null || true elif [ "$ARG1" == "uninstall" ]; then - "${SUDO}" rm -f "${DESTDIR}@INSTALL_PREFIX@/bin/varnamcli" "${DESTDIR}@INSTALL_PREFIX@/lib/@LIB_NAME@.@VERSION@" "${DESTDIR}@INSTALL_PREFIX@/lib/@LIB_NAME@" "${DESTDIR}@INSTALL_PREFIX@/lib/pkgconfig/govarnam.pc" + "${SUDO}" rm -f "${DESTDIR}@INSTALL_PREFIX@/bin/varnamcli" "${DESTDIR}@INSTALL_PREFIX@@LIBDIR@/@LIB_NAME@.@VERSION@" "${DESTDIR}@INSTALL_PREFIX@@LIBDIR@/@LIB_NAME@" "${DESTDIR}@INSTALL_PREFIX@@LIBDIR@/pkgconfig/govarnam.pc" "${SUDO}" rm -f "${DESTDIR}@INSTALL_PREFIX@/include/libgovarnam/"* "${SUDO}" rmdir "${DESTDIR}@INSTALL_PREFIX@/include/libgovarnam" || true "${SUDO}" rm -f "${DESTDIR}@INSTALL_PREFIX@/share/varnam/schemes/"*