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