From 053622b9022f0a91333f58646128fa7c00490c04 Mon Sep 17 00:00:00 2001 From: Chris J Arges Date: Mon, 11 Jan 2016 14:21:38 -0600 Subject: [PATCH 1/4] kpatch-build: allow external LDFLAGS When building binaries such as create-diff-object it would be useful to be able to pass LDFLAGS when running make from the command line. --- kpatch-build/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kpatch-build/Makefile b/kpatch-build/Makefile index 739aa0e..58d5ede 100644 --- a/kpatch-build/Makefile +++ b/kpatch-build/Makefile @@ -1,7 +1,7 @@ include ../Makefile.inc CFLAGS += -I../kmod/patch -Iinsn -Wall -g -Werror -LDFLAGS = -lelf +LDFLAGS += -lelf TARGETS = create-diff-object OBJS = create-diff-object.o lookup.o insn/insn.o insn/inat.o From 06ad01b784e27d4f9cc52510de8d72eca0b6a407 Mon Sep 17 00:00:00 2001 From: Chris J Arges Date: Tue, 12 Jan 2016 20:12:59 -0600 Subject: [PATCH 2/4] Makefile: make libexec a parameter Some distributions prefer not to use /usr/libexec. To make things easier for packaging, allow this directory to be set easily via environment variables. Signed-off-by: Chris J Arges --- Makefile.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.inc b/Makefile.inc index 4ea73cb..241f742 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -5,10 +5,11 @@ INSTALL = /usr/bin/install PREFIX ?= /usr/local LIBDIR ?= lib +LIBEXEC ?= libexec BINDIR = $(DESTDIR)$(PREFIX)/bin SBINDIR = $(DESTDIR)$(PREFIX)/sbin MODULESDIR = $(DESTDIR)$(PREFIX)/$(LIBDIR)/kpatch -LIBEXECDIR = $(DESTDIR)$(PREFIX)/libexec/kpatch +LIBEXECDIR = $(DESTDIR)$(PREFIX)/$(LIBEXEC)/kpatch DATADIR = $(DESTDIR)$(PREFIX)/share/kpatch MANDIR = $(DESTDIR)$(PREFIX)/share/man/man1 SYSTEMDDIR = $(DESTDIR)$(PREFIX)/lib/systemd/system From 3c8f5f7bfaad2ca955c600ea1ee8d4df5b4d8a27 Mon Sep 17 00:00:00 2001 From: Chris J Arges Date: Mon, 8 Feb 2016 10:46:06 -0600 Subject: [PATCH 3/4] Makefile: determine kernel release in Makefile Don't assume we are building for the current kernel. In addition print out a proper package necessary for building the module. Signed-off-by: Chris J Arges --- kmod/core/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kmod/core/Makefile b/kmod/core/Makefile index 53ad8e4..3a01339 100644 --- a/kmod/core/Makefile +++ b/kmod/core/Makefile @@ -1,9 +1,10 @@ # make rules KPATCH_BUILD ?= /lib/modules/$(shell uname -r)/build +KERNELRELEASE := $(lastword $(subst /, , $(dir $(KPATCH_BUILD)))) THISDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) ifeq ($(wildcard $(KPATCH_BUILD)),) -$(error $(KPATCH_BUILD) doesn\'t exist. Try installing the kernel-devel-$(shell uname -r) RPM or linux-image-$(shell uname -r)-dbg DEB.) +$(error $(KPATCH_BUILD) doesn\'t exist. Try installing the kernel-devel-$(KERNELRELEASE) RPM or linux-headers-$(KERNELRELEASE) DEB.) endif KPATCH_MAKE = $(MAKE) -C $(KPATCH_BUILD) M=$(THISDIR) From e9b96546025777b9512525cd72dfc6debbb52789 Mon Sep 17 00:00:00 2001 From: Chris J Arges Date: Wed, 10 Feb 2016 09:55:45 -0600 Subject: [PATCH 4/4] Makefile: add BUILDMOD parameter to select building kmod core In some cases when packaging it may not be useful to build kmod/core at package build time (for example if using DKMS). Add a parameter 'BUILDMOD' that when set to 'yes' will build kmod/core. Signed-off-by: Chris J Arges --- Makefile.inc | 1 + kmod/Makefile | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/Makefile.inc b/Makefile.inc index 241f742..4828619 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -13,6 +13,7 @@ LIBEXECDIR = $(DESTDIR)$(PREFIX)/$(LIBEXEC)/kpatch DATADIR = $(DESTDIR)$(PREFIX)/share/kpatch MANDIR = $(DESTDIR)$(PREFIX)/share/man/man1 SYSTEMDDIR = $(DESTDIR)$(PREFIX)/lib/systemd/system +BUILDMOD ?= yes .PHONY: all install clean .DEFAULT: all diff --git a/kmod/Makefile b/kmod/Makefile index 2cbd2a1..61b0321 100644 --- a/kmod/Makefile +++ b/kmod/Makefile @@ -1,18 +1,26 @@ include ../Makefile.inc all: clean +ifeq ($(BUILDMOD),yes) $(MAKE) -C core +endif install: +ifeq ($(BUILDMOD),yes) $(INSTALL) -d $(MODULESDIR)/$(shell uname -r) $(INSTALL) -m 644 core/kpatch.ko $(MODULESDIR)/$(shell uname -r) $(INSTALL) -m 644 core/Module.symvers $(MODULESDIR)/$(shell uname -r) +endif $(INSTALL) -d $(DATADIR)/patch $(INSTALL) -m 644 patch/* $(DATADIR)/patch uninstall: +ifeq ($(BUILDMOD),yes) $(RM) -R $(MODULESDIR) +endif $(RM) -R $(DATADIR) clean: +ifeq ($(BUILDMOD),yes) $(MAKE) -C core clean +endif