Skip to content

Commit a648e08

Browse files
committed
tools/power x86_energy_perf_policy: Add make snapshot target
$ make snapshot creates x86_energy_perf_policy-$(DATE).tar.gz Which can be transported to a target machine without needing a kernel tree to build on the target. Useful for creating debug versions. Signed-off-by: Len Brown <len.brown@intel.com>
1 parent 2734fdb commit a648e08

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

  • tools/power/x86/x86_energy_perf_policy

tools/power/x86/x86_energy_perf_policy/Makefile

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# SPDX-License-Identifier: GPL-2.0
22
CC = $(CROSS_COMPILE)gcc
3-
BUILD_OUTPUT := $(CURDIR)
3+
BUILD_OUTPUT := $(CURDIR)
44
PREFIX := /usr
55
DESTDIR :=
6+
DAY := $(shell date +%Y.%m.%d)
7+
SNAPSHOT = x86_energy_perf_policy-$(DAY)
8+
9+
610

711
ifeq ("$(origin O)", "command line")
812
BUILD_OUTPUT := $(O)
@@ -27,3 +31,26 @@ install : x86_energy_perf_policy
2731
install -d $(DESTDIR)$(PREFIX)/share/man/man8
2832
install -m 644 x86_energy_perf_policy.8 $(DESTDIR)$(PREFIX)/share/man/man8
2933

34+
snapshot: x86_energy_perf_policy
35+
@rm -rf $(SNAPSHOT)
36+
@mkdir $(SNAPSHOT)
37+
@cp x86_energy_perf_policy Makefile x86_energy_perf_policy.c x86_energy_perf_policy.8 $(SNAPSHOT)
38+
39+
@sed -e 's/^#include <linux\/bits.h>/#include "bits.h"/' -e 's/u64/unsigned long long/' ../../../../arch/x86/include/asm/msr-index.h > $(SNAPSHOT)/msr-index.h
40+
@echo '#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))' >> $(SNAPSHOT)/msr-index.h
41+
@echo "#define BIT(x) (1 << (x))" > $(SNAPSHOT)/bits.h
42+
@echo "#define BIT_ULL(nr) (1ULL << (nr))" >> $(SNAPSHOT)/bits.h
43+
@echo "#define GENMASK(h, l) (((~0UL) << (l)) & (~0UL >> (sizeof(long) * 8 - 1 - (h))))" >> $(SNAPSHOT)/bits.h
44+
@echo "#define GENMASK_ULL(h, l) (((~0ULL) << (l)) & (~0ULL >> (sizeof(long long) * 8 - 1 - (h))))" >> $(SNAPSHOT)/bits.h
45+
46+
@echo '#define BUILD_BUG_ON(cond) do { enum { compile_time_check ## __COUNTER__ = 1/(!(cond)) }; } while (0)' > $(SNAPSHOT)/build_bug.h
47+
@echo '#define __must_be_array(arr) 0' >> $(SNAPSHOT)/build_bug.h
48+
49+
@echo PWD=. > $(SNAPSHOT)/Makefile
50+
@echo "CFLAGS += -DMSRHEADER='\"msr-index.h\"'" >> $(SNAPSHOT)/Makefile
51+
@echo "CFLAGS += -DBUILD_BUG_HEADER='\"build_bug.h\"'" >> $(SNAPSHOT)/Makefile
52+
@sed -e's/.*MSRHEADER.*//' Makefile >> $(SNAPSHOT)/Makefile
53+
54+
@rm -f $(SNAPSHOT).tar.gz
55+
tar cvzf $(SNAPSHOT).tar.gz $(SNAPSHOT)
56+

0 commit comments

Comments
 (0)