drm/bridge: adv7511: Switch to atomic operations
[drm/drm-misc.git] / tools / power / x86 / turbostat / Makefile
blob3946d5254a1fd728096fc8432e8f7f5c5f335765
1 # SPDX-License-Identifier: GPL-2.0
2 CC = $(CROSS_COMPILE)gcc
3 BUILD_OUTPUT := $(CURDIR)
4 PREFIX ?= /usr
5 DESTDIR ?=
6 DAY := $(shell date +%Y.%m.%d)
7 SNAPSHOT = turbostat-$(DAY)
9 ifeq ("$(origin O)", "command line")
10 BUILD_OUTPUT := $(O)
11 endif
13 turbostat : turbostat.c
14 override CFLAGS += -O2 -Wall -Wextra -I../../../include
15 override CFLAGS += -DMSRHEADER='"../../../../arch/x86/include/asm/msr-index.h"'
16 override CFLAGS += -DINTEL_FAMILY_HEADER='"../../../../arch/x86/include/asm/intel-family.h"'
17 override CFLAGS += -DBUILD_BUG_HEADER='"../../../../include/linux/build_bug.h"'
18 override CFLAGS += -D_FILE_OFFSET_BITS=64
19 override CFLAGS += -D_FORTIFY_SOURCE=2
21 %: %.c
22 @mkdir -p $(BUILD_OUTPUT)
23 $(CC) $(CFLAGS) $< -o $(BUILD_OUTPUT)/$@ $(LDFLAGS) -lcap -lrt
25 .PHONY : clean
26 clean :
27 @rm -f $(BUILD_OUTPUT)/turbostat
28 @rm -f $(SNAPSHOT).tar.gz
30 install : turbostat
31 install -d $(DESTDIR)$(PREFIX)/bin
32 install $(BUILD_OUTPUT)/turbostat $(DESTDIR)$(PREFIX)/bin/turbostat
33 install -d $(DESTDIR)$(PREFIX)/share/man/man8
34 install -m 644 turbostat.8 $(DESTDIR)$(PREFIX)/share/man/man8
36 snapshot: turbostat
37 @rm -rf $(SNAPSHOT)
38 @mkdir $(SNAPSHOT)
39 @cp turbostat Makefile turbostat.c turbostat.8 ../../../../arch/x86/include/asm/intel-family.h $(SNAPSHOT)
41 @sed -e 's/^#include <linux\/bits.h>/#include "bits.h"/' ../../../../arch/x86/include/asm/msr-index.h > $(SNAPSHOT)/msr-index.h
42 @echo '#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))' >> $(SNAPSHOT)/msr-index.h
43 @echo "#define BIT(x) (1 << (x))" > $(SNAPSHOT)/bits.h
44 @echo "#define BIT_ULL(nr) (1ULL << (nr))" >> $(SNAPSHOT)/bits.h
45 @echo "#define GENMASK(h, l) (((~0UL) << (l)) & (~0UL >> (sizeof(long) * 8 - 1 - (h))))" >> $(SNAPSHOT)/bits.h
46 @echo "#define GENMASK_ULL(h, l) (((~0ULL) << (l)) & (~0ULL >> (sizeof(long long) * 8 - 1 - (h))))" >> $(SNAPSHOT)/bits.h
48 @echo '#define BUILD_BUG_ON(cond) do { enum { compile_time_check ## __COUNTER__ = 1/(!(cond)) }; } while (0)' > $(SNAPSHOT)/build_bug.h
49 @echo '#define __must_be_array(arr) 0' >> $(SNAPSHOT)/build_bug.h
51 @echo PWD=. > $(SNAPSHOT)/Makefile
52 @echo "CFLAGS += -DMSRHEADER='\"msr-index.h\"'" >> $(SNAPSHOT)/Makefile
53 @echo "CFLAGS += -DINTEL_FAMILY_HEADER='\"intel-family.h\"'" >> $(SNAPSHOT)/Makefile
54 @echo "CFLAGS += -DBUILD_BUG_HEADER='\"build_bug.h\"'" >> $(SNAPSHOT)/Makefile
55 @sed -e's/.*MSRHEADER.*//' -e's/.*INTEL_FAMILY_HEADER.*//' -e's/.*BUILD_BUG_HEADER.*//' Makefile >> $(SNAPSHOT)/Makefile
57 @rm -f $(SNAPSHOT).tar.gz
58 tar cvzf $(SNAPSHOT).tar.gz $(SNAPSHOT)