xref: /linux/tools/power/x86/intel-speed-select/Makefile (revision c17ee635fd3a482b2ad2bf5e269755c2eae5f25e)
1# SPDX-License-Identifier: GPL-2.0
2include ../../../scripts/Makefile.include
3
4bindir ?= /usr/bin
5
6ifeq ($(srctree),)
7srctree := $(patsubst %/,%,$(dir $(CURDIR)))
8srctree := $(patsubst %/,%,$(dir $(srctree)))
9srctree := $(patsubst %/,%,$(dir $(srctree)))
10srctree := $(patsubst %/,%,$(dir $(srctree)))
11endif
12
13# Do not use make's built-in rules
14# (this improves performance and avoids hard-to-debug behaviour);
15MAKEFLAGS += -r
16
17NL3_CFLAGS = $(shell pkg-config --cflags libnl-3.0 2>/dev/null)
18ifeq ($(NL3_CFLAGS),)
19NL3_CFLAGS = -I/usr/include/libnl3
20endif
21
22override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include $(NL3_CFLAGS)
23override LDFLAGS += -lnl-genl-3 -lnl-3
24
25ALL_TARGETS := intel-speed-select
26ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
27
28all: $(ALL_PROGRAMS)
29
30export srctree OUTPUT CC LD CFLAGS
31include $(srctree)/tools/build/Makefile.include
32
33#
34# We need the following to be outside of kernel tree
35#
36$(OUTPUT)include/linux/isst_if.h: ../../../../include/uapi/linux/isst_if.h
37	mkdir -p $(OUTPUT)include/linux 2>&1 || true
38	ln -sf $(CURDIR)/../../../../include/uapi/linux/isst_if.h $@
39
40$(OUTPUT)include/linux/thermal.h: ../../../../include/uapi/linux/thermal.h
41	mkdir -p $(OUTPUT)include/linux 2>&1 || true
42	ln -sf $(CURDIR)/../../../../include/uapi/linux/thermal.h $@
43
44prepare: $(OUTPUT)include/linux/isst_if.h $(OUTPUT)include/linux/thermal.h
45
46ISST_IN := $(OUTPUT)intel-speed-select-in.o
47
48$(ISST_IN): prepare FORCE
49	$(Q)$(MAKE) $(build)=intel-speed-select
50$(OUTPUT)intel-speed-select: $(ISST_IN)
51	$(QUIET_LINK)$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
52
53clean:
54	rm -f $(ALL_PROGRAMS)
55	rm -rf $(OUTPUT)include/linux/isst_if.h
56	find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
57
58install: $(ALL_PROGRAMS)
59	install -d -m 755 $(DESTDIR)$(bindir);		\
60	for program in $(ALL_PROGRAMS); do		\
61		install $$program $(DESTDIR)$(bindir);	\
62	done
63
64FORCE:
65
66.PHONY: all install clean FORCE prepare
67