18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ciinclude ../../../scripts/Makefile.include
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_cibindir ?= /usr/bin
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ciifeq ($(srctree),)
78c2ecf20Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(CURDIR)))
88c2ecf20Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(srctree)))
98c2ecf20Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(srctree)))
108c2ecf20Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(srctree)))
118c2ecf20Sopenharmony_ciendif
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci# Do not use make's built-in rules
148c2ecf20Sopenharmony_ci# (this improves performance and avoids hard-to-debug behaviour);
158c2ecf20Sopenharmony_ciMAKEFLAGS += -r
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cioverride CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ciALL_TARGETS := intel-speed-select
208c2ecf20Sopenharmony_ciALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ciall: $(ALL_PROGRAMS)
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ciexport srctree OUTPUT CC LD CFLAGS
258c2ecf20Sopenharmony_ciinclude $(srctree)/tools/build/Makefile.include
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#
288c2ecf20Sopenharmony_ci# We need the following to be outside of kernel tree
298c2ecf20Sopenharmony_ci#
308c2ecf20Sopenharmony_ci$(OUTPUT)include/linux/isst_if.h: ../../../../include/uapi/linux/isst_if.h
318c2ecf20Sopenharmony_ci	mkdir -p $(OUTPUT)include/linux 2>&1 || true
328c2ecf20Sopenharmony_ci	ln -sf $(CURDIR)/../../../../include/uapi/linux/isst_if.h $@
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ciprepare: $(OUTPUT)include/linux/isst_if.h
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ciISST_IN := $(OUTPUT)intel-speed-select-in.o
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci$(ISST_IN): prepare FORCE
398c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=intel-speed-select
408c2ecf20Sopenharmony_ci$(OUTPUT)intel-speed-select: $(ISST_IN)
418c2ecf20Sopenharmony_ci	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ciclean:
448c2ecf20Sopenharmony_ci	rm -f $(ALL_PROGRAMS)
458c2ecf20Sopenharmony_ci	rm -rf $(OUTPUT)include/linux/isst_if.h
468c2ecf20Sopenharmony_ci	find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ciinstall: $(ALL_PROGRAMS)
498c2ecf20Sopenharmony_ci	install -d -m 755 $(DESTDIR)$(bindir);		\
508c2ecf20Sopenharmony_ci	for program in $(ALL_PROGRAMS); do		\
518c2ecf20Sopenharmony_ci		install $$program $(DESTDIR)$(bindir);	\
528c2ecf20Sopenharmony_ci	done
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ciFORCE:
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci.PHONY: all install clean FORCE prepare
57