Skip to content

Commit 231ce08

Browse files
committed
tools/power turbostat: Add "snapshot:" Makefile target
Kernel developers often need to diagnose remote customer systems with the latest turbostat, yet customers are running binary distros with out-dated turbostat and the customer has no experience cloning linux kernel trees. Add a turbostat "snapshot" makefile target to create a standalone source snapshot from the developer's git tree, appropriately hacked so that the customer can build turbostat without a kernel tree. Include the turbostat binary in the snapshot, for convenience in those situations where the source and destination are trusted, (and have new enough glibc to execute). The snapshot is named with the date it was taken rather than the turbostat VERSION, as it could occur between VERSIONS... Signed-off-by: Len Brown <[email protected]>
1 parent a6189a7 commit 231ce08

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

tools/power/x86/turbostat/Makefile

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ CC = $(CROSS_COMPILE)gcc
33
BUILD_OUTPUT := $(CURDIR)
44
PREFIX ?= /usr
55
DESTDIR ?=
6+
DAY := $(shell date +%Y.%m.%d)
7+
SNAPSHOT = turbostat-$(DAY)
68

79
ifeq ("$(origin O)", "command line")
810
BUILD_OUTPUT := $(O)
@@ -22,9 +24,30 @@ override CFLAGS += -D_FORTIFY_SOURCE=2
2224
.PHONY : clean
2325
clean :
2426
@rm -f $(BUILD_OUTPUT)/turbostat
27+
@rm -f $(SNAPSHOT).tar.gz
2528

2629
install : turbostat
27-
install -d $(DESTDIR)$(PREFIX)/bin
30+
install -d $(DESTDIR)$(PREFIX)/bin
2831
install $(BUILD_OUTPUT)/turbostat $(DESTDIR)$(PREFIX)/bin/turbostat
29-
install -d $(DESTDIR)$(PREFIX)/share/man/man8
32+
install -d $(DESTDIR)$(PREFIX)/share/man/man8
3033
install -m 644 turbostat.8 $(DESTDIR)$(PREFIX)/share/man/man8
34+
35+
snapshot: turbostat
36+
@rm -rf $(SNAPSHOT)
37+
@mkdir $(SNAPSHOT)
38+
@cp turbostat Makefile turbostat.c turbostat.8 ../../../../arch/x86/include/asm/intel-family.h $(SNAPSHOT)
39+
40+
@sed -e 's/^#include <linux\/bits.h>/#include "bits.h"/' ../../../../arch/x86/include/asm/msr-index.h > $(SNAPSHOT)/msr-index.h
41+
@echo '#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))' >> $(SNAPSHOT)/msr-index.h
42+
@echo "#define BIT(x) (1 << (x))" > $(SNAPSHOT)/bits.h
43+
@echo "#define BIT_ULL(nr) (1ULL << (nr))" >> $(SNAPSHOT)/bits.h
44+
@echo "#define GENMASK(h, l) (((~0UL) << (l)) & (~0UL >> (sizeof(long) * 8 - 1 - (h))))" >> $(SNAPSHOT)/bits.h
45+
@echo "#define GENMASK_ULL(h, l) (((~0ULL) << (l)) & (~0ULL >> (sizeof(long long) * 8 - 1 - (h))))" >> $(SNAPSHOT)/bits.h
46+
47+
@echo PWD=. > $(SNAPSHOT)/Makefile
48+
@echo "CFLAGS += -DMSRHEADER='\"msr-index.h\"'" >> $(SNAPSHOT)/Makefile
49+
@echo "CFLAGS += -DINTEL_FAMILY_HEADER='\"intel-family.h\"'" >> $(SNAPSHOT)/Makefile
50+
@sed -e's/.*MSRHEADER.*//' -e's/.*INTEL_FAMILY_HEADER.*//' Makefile >> $(SNAPSHOT)/Makefile
51+
52+
@rm -f $(SNAPSHOT).tar.gz
53+
tar cvzf $(SNAPSHOT).tar.gz $(SNAPSHOT)

0 commit comments

Comments
 (0)