162306a36Sopenharmony_ci# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) 262306a36Sopenharmony_ci# Most of this file is copied from tools/lib/perf/Makefile 362306a36Sopenharmony_ci 462306a36Sopenharmony_ciLIBTHERMAL_TOOLS_VERSION = 0 562306a36Sopenharmony_ciLIBTHERMAL_TOOLS_PATCHLEVEL = 0 662306a36Sopenharmony_ciLIBTHERMAL_TOOLS_EXTRAVERSION = 1 762306a36Sopenharmony_ci 862306a36Sopenharmony_ciMAKEFLAGS += --no-print-directory 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ciifeq ($(srctree),) 1162306a36Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(CURDIR))) 1262306a36Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(srctree))) 1362306a36Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(srctree))) 1462306a36Sopenharmony_ci# $(info Determined 'srctree' to be $(srctree)) 1562306a36Sopenharmony_ciendif 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ciINSTALL = install 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci# Use DESTDIR for installing into a different root directory. 2062306a36Sopenharmony_ci# This is useful for building a package. The program will be 2162306a36Sopenharmony_ci# installed in this directory as if it was the root directory. 2262306a36Sopenharmony_ci# Then the build tool can move it later. 2362306a36Sopenharmony_ciDESTDIR ?= 2462306a36Sopenharmony_ciDESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ciinclude $(srctree)/tools/scripts/Makefile.include 2762306a36Sopenharmony_ciinclude $(srctree)/tools/scripts/Makefile.arch 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ciifeq ($(LP64), 1) 3062306a36Sopenharmony_ci libdir_relative = lib64 3162306a36Sopenharmony_cielse 3262306a36Sopenharmony_ci libdir_relative = lib 3362306a36Sopenharmony_ciendif 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ciprefix ?= 3662306a36Sopenharmony_cilibdir = $(prefix)/$(libdir_relative) 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci# Shell quotes 3962306a36Sopenharmony_cilibdir_SQ = $(subst ','\'',$(libdir)) 4062306a36Sopenharmony_cilibdir_relative_SQ = $(subst ','\'',$(libdir_relative)) 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ciifeq ("$(origin V)", "command line") 4362306a36Sopenharmony_ci VERBOSE = $(V) 4462306a36Sopenharmony_ciendif 4562306a36Sopenharmony_ciifndef VERBOSE 4662306a36Sopenharmony_ci VERBOSE = 0 4762306a36Sopenharmony_ciendif 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ciifeq ($(VERBOSE),1) 5062306a36Sopenharmony_ci Q = 5162306a36Sopenharmony_cielse 5262306a36Sopenharmony_ci Q = @ 5362306a36Sopenharmony_ciendif 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci# Set compile option CFLAGS 5662306a36Sopenharmony_ciifdef EXTRA_CFLAGS 5762306a36Sopenharmony_ci CFLAGS := $(EXTRA_CFLAGS) 5862306a36Sopenharmony_cielse 5962306a36Sopenharmony_ci CFLAGS := -g -Wall 6062306a36Sopenharmony_ciendif 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ciINCLUDES = \ 6362306a36Sopenharmony_ci-I/usr/include/libnl3 \ 6462306a36Sopenharmony_ci-I$(srctree)/tools/lib/thermal/include \ 6562306a36Sopenharmony_ci-I$(srctree)/tools/lib/ \ 6662306a36Sopenharmony_ci-I$(srctree)/tools/include \ 6762306a36Sopenharmony_ci-I$(srctree)/tools/arch/$(SRCARCH)/include/ \ 6862306a36Sopenharmony_ci-I$(srctree)/tools/arch/$(SRCARCH)/include/uapi \ 6962306a36Sopenharmony_ci-I$(srctree)/tools/include/uapi 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci# Append required CFLAGS 7262306a36Sopenharmony_cioverride CFLAGS += $(EXTRA_WARNINGS) 7362306a36Sopenharmony_cioverride CFLAGS += -Werror -Wall 7462306a36Sopenharmony_cioverride CFLAGS += -fPIC 7562306a36Sopenharmony_cioverride CFLAGS += $(INCLUDES) 7662306a36Sopenharmony_cioverride CFGLAS += -Wl,-L. 7762306a36Sopenharmony_cioverride CFGLAS += -Wl,-lthermal 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ciall: 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ciexport srctree OUTPUT CC LD CFLAGS V 8262306a36Sopenharmony_ciexport DESTDIR DESTDIR_SQ 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ciinclude $(srctree)/tools/build/Makefile.include 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ciPATCHLEVEL = $(LIBTHERMAL_TOOLS_PATCHLEVEL) 8762306a36Sopenharmony_ciEXTRAVERSION = $(LIBTHERMAL_TOOLS_EXTRAVERSION) 8862306a36Sopenharmony_ciVERSION = $(LIBTHERMAL_TOOLS_VERSION).$(LIBTHERMAL_TOOLS_PATCHLEVEL).$(LIBTHERMAL_TOOLS_EXTRAVERSION) 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ciLIBTHERMAL_TOOLS_SO := $(OUTPUT)libthermal_tools.so.$(VERSION) 9162306a36Sopenharmony_ciLIBTHERMAL_TOOLS_A := $(OUTPUT)libthermal_tools.a 9262306a36Sopenharmony_ciLIBTHERMAL_TOOLS_IN := $(OUTPUT)libthermal_tools-in.o 9362306a36Sopenharmony_ciLIBTHERMAL_TOOLS_PC := $(OUTPUT)libthermal_tools.pc 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ciLIBTHERMAL_TOOLS_ALL := $(LIBTHERMAL_TOOLS_A) $(OUTPUT)libthermal_tools.so* 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci$(LIBTHERMAL_TOOLS_IN): FORCE 9862306a36Sopenharmony_ci $(Q)$(MAKE) $(build)=libthermal_tools 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci$(LIBTHERMAL_TOOLS_A): $(LIBTHERMAL_TOOLS_IN) 10162306a36Sopenharmony_ci $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIBTHERMAL_TOOLS_IN) 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci$(LIBTHERMAL_TOOLS_SO): $(LIBTHERMAL_TOOLS_IN) 10462306a36Sopenharmony_ci $(QUIET_LINK)$(CC) --shared -Wl,-soname,libthermal_tools.so $^ -o $@ 10562306a36Sopenharmony_ci @ln -sf $(@F) $(OUTPUT)libthermal_tools.so 10662306a36Sopenharmony_ci @ln -sf $(@F) $(OUTPUT)libthermal_tools.so.$(LIBTHERMAL_TOOLS_VERSION) 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_cilibs: $(LIBTHERMAL_TOOLS_A) $(LIBTHERMAL_TOOLS_SO) $(LIBTHERMAL_TOOLS_PC) 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ciall: fixdep 11262306a36Sopenharmony_ci $(Q)$(MAKE) libs 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ciclean: 11562306a36Sopenharmony_ci $(call QUIET_CLEAN, libthermal_tools) $(RM) $(LIBTHERMAL_TOOLS_A) \ 11662306a36Sopenharmony_ci *.o *~ *.a *.so *.so.$(VERSION) *.so.$(LIBTHERMAL_TOOLS_VERSION) .*.d .*.cmd LIBTHERMAL_TOOLS-CFLAGS $(LIBTHERMAL_TOOLS_PC) 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_ci$(LIBTHERMAL_TOOLS_PC): 11962306a36Sopenharmony_ci $(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \ 12062306a36Sopenharmony_ci -e "s|@LIBDIR@|$(libdir_SQ)|" \ 12162306a36Sopenharmony_ci -e "s|@VERSION@|$(VERSION)|" \ 12262306a36Sopenharmony_ci < libthermal_tools.pc.template > $@ 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_cidefine do_install_mkdir 12562306a36Sopenharmony_ci if [ ! -d '$(DESTDIR_SQ)$1' ]; then \ 12662306a36Sopenharmony_ci $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \ 12762306a36Sopenharmony_ci fi 12862306a36Sopenharmony_ciendef 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_cidefine do_install 13162306a36Sopenharmony_ci if [ ! -d '$(DESTDIR_SQ)$2' ]; then \ 13262306a36Sopenharmony_ci $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \ 13362306a36Sopenharmony_ci fi; \ 13462306a36Sopenharmony_ci $(INSTALL) $1 $(if $3,-m $3,) '$(DESTDIR_SQ)$2' 13562306a36Sopenharmony_ciendef 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ciinstall_lib: libs 13862306a36Sopenharmony_ci $(call QUIET_INSTALL, $(LIBTHERMAL_TOOLS_ALL)) \ 13962306a36Sopenharmony_ci $(call do_install_mkdir,$(libdir_SQ)); \ 14062306a36Sopenharmony_ci cp -fpR $(LIBTHERMAL_TOOLS_ALL) $(DESTDIR)$(libdir_SQ) 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_ciinstall_headers: 14362306a36Sopenharmony_ci $(call QUIET_INSTALL, headers) \ 14462306a36Sopenharmony_ci $(call do_install,include/thermal.h,$(prefix)/include/thermal,644); \ 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_ciinstall_pkgconfig: $(LIBTHERMAL_TOOLS_PC) 14762306a36Sopenharmony_ci $(call QUIET_INSTALL, $(LIBTHERMAL_TOOLS_PC)) \ 14862306a36Sopenharmony_ci $(call do_install,$(LIBTHERMAL_TOOLS_PC),$(libdir_SQ)/pkgconfig,644) 14962306a36Sopenharmony_ci 15062306a36Sopenharmony_ciinstall_doc: 15162306a36Sopenharmony_ci $(Q)$(MAKE) -C Documentation install-man install-html install-examples 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ci#install: install_lib install_headers install_pkgconfig install_doc 15462306a36Sopenharmony_ciinstall: install_lib install_headers install_pkgconfig 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_ciFORCE: 15762306a36Sopenharmony_ci 15862306a36Sopenharmony_ci.PHONY: all install clean FORCE 159