From 1aa1f0ab927e8e2e83fcbcdbcf8a1f5ae31ac153 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 8 Jan 2020 17:48:35 -0500 Subject: Makefile: strip prefixed v from version.h We also no longer do anything dynamic with dkms.conf, and we don't rewrite any files at all, but rather pass this through as a cflag to the compiler optionally. Signed-off-by: Jason A. Donenfeld Reported-by: Egbert Verhage --- src/Kbuild | 1 + src/Makefile | 31 +++++++++---------------------- src/version.h | 2 ++ 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/Kbuild b/src/Kbuild index 920797e..f1b4ad7 100644 --- a/src/Kbuild +++ b/src/Kbuild @@ -6,6 +6,7 @@ ccflags-y := -O3 -fvisibility=hidden ccflags-$(CONFIG_WIREGUARD_DEBUG) += -DDEBUG -g ccflags-y += -D'pr_fmt(fmt)=KBUILD_MODNAME ": " fmt' ccflags-y += -Wframe-larger-than=2048 +ccflags-$(if $(WIREGUARD_VERSION),y,) += -D'WIREGUARD_VERSION="$(WIREGUARD_VERSION)"' wireguard-y := main.o noise.o device.o peer.o timers.o queueing.o send.o receive.o socket.o peerlookup.o allowedips.o ratelimiter.o cookie.o netlink.o diff --git a/src/Makefile b/src/Makefile index 9899a73..c20bfd3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -19,32 +19,19 @@ ifneq ($(V),1) MAKEFLAGS += --no-print-directory endif -version.h: - @export GIT_CEILING_DIRECTORIES="$$(readlink -f ../..)" && \ - ver="#define WIREGUARD_VERSION \"$$(git describe --dirty 2>/dev/null)\"" && \ - [ "$$(cat version.h 2>/dev/null)" != "$$ver" ] && \ - echo "$$ver" > version.h && \ - git update-index --assume-unchanged version.h || true - -dkms.conf: - @export GIT_CEILING_DIRECTORIES="$$(readlink -f ../..)" && \ - ver="$$(git describe --dirty 2>/dev/null)" && \ - . ./dkms.conf && \ - [ "$$PACKAGE_VERSION" != "$$ver" ] && \ - sed -i "s/PACKAGE_VERSION=.*/PACKAGE_VERSION=\"$$ver\"/" dkms.conf && \ - git update-index --assume-unchanged dkms.conf || true - -module: version.h - @$(MAKE) -C $(KERNELDIR) M=$(PWD) modules - -module-debug: version.h - @$(MAKE) -C $(KERNELDIR) M=$(PWD) V=1 CONFIG_WIREGUARD_DEBUG=y modules +WIREGUARD_VERSION = $(patsubst v%,%,$(shell GIT_CEILING_DIRECTORIES="$(PWD)/../.." git describe --dirty 2>/dev/null)) + +module: + @$(MAKE) -C $(KERNELDIR) M=$(PWD) WIREGUARD_VERSION="$(WIREGUARD_VERSION)" modules + +module-debug: + @$(MAKE) -C $(KERNELDIR) M=$(PWD) V=1 CONFIG_WIREGUARD_DEBUG=y WIREGUARD_VERSION="$(WIREGUARD_VERSION)" modules clean: @$(MAKE) -C $(KERNELDIR) M=$(PWD) clean module-install: - @$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install + @$(MAKE) -C $(KERNELDIR) M=$(PWD) WIREGUARD_VERSION="$(WIREGUARD_VERSION)" modules_install $(DEPMOD) -a $(KERNELRELEASE) install: module-install @@ -68,4 +55,4 @@ cloc: -include tests/debug.mk -.PHONY: all module module-debug module-install install dkms-install clean cloc check style version.h dkms.conf +.PHONY: all module module-debug module-install install dkms-install clean cloc check style diff --git a/src/version.h b/src/version.h index 07d1c2d..e42c50d 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1,3 @@ +#ifndef WIREGUARD_VERSION #define WIREGUARD_VERSION "0.0.20200105" +#endif -- cgit v1.2.3-59-g8ed1b