13b7c5e8aSDaniel Lezcano# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) 23b7c5e8aSDaniel Lezcano# Most of this file is copied from tools/lib/perf/Makefile 33b7c5e8aSDaniel Lezcano 43b7c5e8aSDaniel LezcanoLIBTHERMAL_TOOLS_VERSION = 0 53b7c5e8aSDaniel LezcanoLIBTHERMAL_TOOLS_PATCHLEVEL = 0 6*a2626724SDaniel LezcanoLIBTHERMAL_TOOLS_EXTRAVERSION = 2 73b7c5e8aSDaniel Lezcano 83b7c5e8aSDaniel LezcanoMAKEFLAGS += --no-print-directory 93b7c5e8aSDaniel Lezcano 103b7c5e8aSDaniel Lezcanoifeq ($(srctree),) 113b7c5e8aSDaniel Lezcanosrctree := $(patsubst %/,%,$(dir $(CURDIR))) 123b7c5e8aSDaniel Lezcanosrctree := $(patsubst %/,%,$(dir $(srctree))) 133b7c5e8aSDaniel Lezcanosrctree := $(patsubst %/,%,$(dir $(srctree))) 143b7c5e8aSDaniel Lezcano# $(info Determined 'srctree' to be $(srctree)) 153b7c5e8aSDaniel Lezcanoendif 163b7c5e8aSDaniel Lezcano 173b7c5e8aSDaniel LezcanoINSTALL = install 183b7c5e8aSDaniel Lezcano 193b7c5e8aSDaniel Lezcano# Use DESTDIR for installing into a different root directory. 203b7c5e8aSDaniel Lezcano# This is useful for building a package. The program will be 213b7c5e8aSDaniel Lezcano# installed in this directory as if it was the root directory. 223b7c5e8aSDaniel Lezcano# Then the build tool can move it later. 233b7c5e8aSDaniel LezcanoDESTDIR ?= 243b7c5e8aSDaniel LezcanoDESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' 253b7c5e8aSDaniel Lezcano 263b7c5e8aSDaniel Lezcanoinclude $(srctree)/tools/scripts/Makefile.include 273b7c5e8aSDaniel Lezcanoinclude $(srctree)/tools/scripts/Makefile.arch 283b7c5e8aSDaniel Lezcano 293b7c5e8aSDaniel Lezcanoifeq ($(LP64), 1) 303b7c5e8aSDaniel Lezcano libdir_relative = lib64 313b7c5e8aSDaniel Lezcanoelse 323b7c5e8aSDaniel Lezcano libdir_relative = lib 333b7c5e8aSDaniel Lezcanoendif 343b7c5e8aSDaniel Lezcano 353b7c5e8aSDaniel Lezcanoprefix ?= 363b7c5e8aSDaniel Lezcanolibdir = $(prefix)/$(libdir_relative) 373b7c5e8aSDaniel Lezcano 383b7c5e8aSDaniel Lezcano# Shell quotes 393b7c5e8aSDaniel Lezcanolibdir_SQ = $(subst ','\'',$(libdir)) 403b7c5e8aSDaniel Lezcanolibdir_relative_SQ = $(subst ','\'',$(libdir_relative)) 413b7c5e8aSDaniel Lezcano 423b7c5e8aSDaniel Lezcano# Set compile option CFLAGS 433b7c5e8aSDaniel Lezcanoifdef EXTRA_CFLAGS 443b7c5e8aSDaniel Lezcano CFLAGS := $(EXTRA_CFLAGS) 453b7c5e8aSDaniel Lezcanoelse 463b7c5e8aSDaniel Lezcano CFLAGS := -g -Wall 473b7c5e8aSDaniel Lezcanoendif 483b7c5e8aSDaniel Lezcano 493b7c5e8aSDaniel LezcanoINCLUDES = \ 503b7c5e8aSDaniel Lezcano-I/usr/include/libnl3 \ 513b7c5e8aSDaniel Lezcano-I$(srctree)/tools/lib/thermal/include \ 523b7c5e8aSDaniel Lezcano-I$(srctree)/tools/lib/ \ 533b7c5e8aSDaniel Lezcano-I$(srctree)/tools/include \ 543b7c5e8aSDaniel Lezcano-I$(srctree)/tools/arch/$(SRCARCH)/include/ \ 553b7c5e8aSDaniel Lezcano-I$(srctree)/tools/arch/$(SRCARCH)/include/uapi \ 563b7c5e8aSDaniel Lezcano-I$(srctree)/tools/include/uapi 573b7c5e8aSDaniel Lezcano 583b7c5e8aSDaniel Lezcano# Append required CFLAGS 593b7c5e8aSDaniel Lezcanooverride CFLAGS += $(EXTRA_WARNINGS) 603b7c5e8aSDaniel Lezcanooverride CFLAGS += -Werror -Wall 613b7c5e8aSDaniel Lezcanooverride CFLAGS += -fPIC 623b7c5e8aSDaniel Lezcanooverride CFLAGS += $(INCLUDES) 633b7c5e8aSDaniel Lezcanooverride CFGLAS += -Wl,-L. 643b7c5e8aSDaniel Lezcanooverride CFGLAS += -Wl,-lthermal 653b7c5e8aSDaniel Lezcano 663b7c5e8aSDaniel Lezcanoall: 673b7c5e8aSDaniel Lezcano 683b7c5e8aSDaniel Lezcanoexport srctree OUTPUT CC LD CFLAGS V 693b7c5e8aSDaniel Lezcanoexport DESTDIR DESTDIR_SQ 703b7c5e8aSDaniel Lezcano 713b7c5e8aSDaniel Lezcanoinclude $(srctree)/tools/build/Makefile.include 723b7c5e8aSDaniel Lezcano 733b7c5e8aSDaniel LezcanoPATCHLEVEL = $(LIBTHERMAL_TOOLS_PATCHLEVEL) 743b7c5e8aSDaniel LezcanoEXTRAVERSION = $(LIBTHERMAL_TOOLS_EXTRAVERSION) 753b7c5e8aSDaniel LezcanoVERSION = $(LIBTHERMAL_TOOLS_VERSION).$(LIBTHERMAL_TOOLS_PATCHLEVEL).$(LIBTHERMAL_TOOLS_EXTRAVERSION) 763b7c5e8aSDaniel Lezcano 773b7c5e8aSDaniel LezcanoLIBTHERMAL_TOOLS_SO := $(OUTPUT)libthermal_tools.so.$(VERSION) 783b7c5e8aSDaniel LezcanoLIBTHERMAL_TOOLS_A := $(OUTPUT)libthermal_tools.a 793b7c5e8aSDaniel LezcanoLIBTHERMAL_TOOLS_IN := $(OUTPUT)libthermal_tools-in.o 803b7c5e8aSDaniel LezcanoLIBTHERMAL_TOOLS_PC := $(OUTPUT)libthermal_tools.pc 813b7c5e8aSDaniel Lezcano 823b7c5e8aSDaniel LezcanoLIBTHERMAL_TOOLS_ALL := $(LIBTHERMAL_TOOLS_A) $(OUTPUT)libthermal_tools.so* 833b7c5e8aSDaniel Lezcano 843b7c5e8aSDaniel Lezcano$(LIBTHERMAL_TOOLS_IN): FORCE 853b7c5e8aSDaniel Lezcano $(Q)$(MAKE) $(build)=libthermal_tools 863b7c5e8aSDaniel Lezcano 873b7c5e8aSDaniel Lezcano$(LIBTHERMAL_TOOLS_A): $(LIBTHERMAL_TOOLS_IN) 883b7c5e8aSDaniel Lezcano $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIBTHERMAL_TOOLS_IN) 893b7c5e8aSDaniel Lezcano 903b7c5e8aSDaniel Lezcano$(LIBTHERMAL_TOOLS_SO): $(LIBTHERMAL_TOOLS_IN) 913b7c5e8aSDaniel Lezcano $(QUIET_LINK)$(CC) --shared -Wl,-soname,libthermal_tools.so $^ -o $@ 923b7c5e8aSDaniel Lezcano @ln -sf $(@F) $(OUTPUT)libthermal_tools.so 933b7c5e8aSDaniel Lezcano @ln -sf $(@F) $(OUTPUT)libthermal_tools.so.$(LIBTHERMAL_TOOLS_VERSION) 943b7c5e8aSDaniel Lezcano 953b7c5e8aSDaniel Lezcano 963b7c5e8aSDaniel Lezcanolibs: $(LIBTHERMAL_TOOLS_A) $(LIBTHERMAL_TOOLS_SO) $(LIBTHERMAL_TOOLS_PC) 973b7c5e8aSDaniel Lezcano 983b7c5e8aSDaniel Lezcanoall: fixdep 993b7c5e8aSDaniel Lezcano $(Q)$(MAKE) libs 1003b7c5e8aSDaniel Lezcano 1013b7c5e8aSDaniel Lezcanoclean: 1023b7c5e8aSDaniel Lezcano $(call QUIET_CLEAN, libthermal_tools) $(RM) $(LIBTHERMAL_TOOLS_A) \ 1033b7c5e8aSDaniel Lezcano *.o *~ *.a *.so *.so.$(VERSION) *.so.$(LIBTHERMAL_TOOLS_VERSION) .*.d .*.cmd LIBTHERMAL_TOOLS-CFLAGS $(LIBTHERMAL_TOOLS_PC) 1043b7c5e8aSDaniel Lezcano 1053b7c5e8aSDaniel Lezcano$(LIBTHERMAL_TOOLS_PC): 1063b7c5e8aSDaniel Lezcano $(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \ 1073b7c5e8aSDaniel Lezcano -e "s|@LIBDIR@|$(libdir_SQ)|" \ 1083b7c5e8aSDaniel Lezcano -e "s|@VERSION@|$(VERSION)|" \ 1093b7c5e8aSDaniel Lezcano < libthermal_tools.pc.template > $@ 1103b7c5e8aSDaniel Lezcano 1113b7c5e8aSDaniel Lezcanodefine do_install_mkdir 1123b7c5e8aSDaniel Lezcano if [ ! -d '$(DESTDIR_SQ)$1' ]; then \ 1133b7c5e8aSDaniel Lezcano $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \ 1143b7c5e8aSDaniel Lezcano fi 1153b7c5e8aSDaniel Lezcanoendef 1163b7c5e8aSDaniel Lezcano 1173b7c5e8aSDaniel Lezcanodefine do_install 1183b7c5e8aSDaniel Lezcano if [ ! -d '$(DESTDIR_SQ)$2' ]; then \ 1193b7c5e8aSDaniel Lezcano $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \ 1203b7c5e8aSDaniel Lezcano fi; \ 1213b7c5e8aSDaniel Lezcano $(INSTALL) $1 $(if $3,-m $3,) '$(DESTDIR_SQ)$2' 1223b7c5e8aSDaniel Lezcanoendef 1233b7c5e8aSDaniel Lezcano 1243b7c5e8aSDaniel Lezcanoinstall_lib: libs 1253b7c5e8aSDaniel Lezcano $(call QUIET_INSTALL, $(LIBTHERMAL_TOOLS_ALL)) \ 1263b7c5e8aSDaniel Lezcano $(call do_install_mkdir,$(libdir_SQ)); \ 1273b7c5e8aSDaniel Lezcano cp -fpR $(LIBTHERMAL_TOOLS_ALL) $(DESTDIR)$(libdir_SQ) 1283b7c5e8aSDaniel Lezcano 1293b7c5e8aSDaniel Lezcanoinstall_headers: 1303b7c5e8aSDaniel Lezcano $(call QUIET_INSTALL, headers) \ 1313b7c5e8aSDaniel Lezcano $(call do_install,include/thermal.h,$(prefix)/include/thermal,644); \ 1323b7c5e8aSDaniel Lezcano 1333b7c5e8aSDaniel Lezcanoinstall_pkgconfig: $(LIBTHERMAL_TOOLS_PC) 1343b7c5e8aSDaniel Lezcano $(call QUIET_INSTALL, $(LIBTHERMAL_TOOLS_PC)) \ 1353b7c5e8aSDaniel Lezcano $(call do_install,$(LIBTHERMAL_TOOLS_PC),$(libdir_SQ)/pkgconfig,644) 1363b7c5e8aSDaniel Lezcano 1373b7c5e8aSDaniel Lezcanoinstall_doc: 1383b7c5e8aSDaniel Lezcano $(Q)$(MAKE) -C Documentation install-man install-html install-examples 1393b7c5e8aSDaniel Lezcano 1403b7c5e8aSDaniel Lezcano#install: install_lib install_headers install_pkgconfig install_doc 1413b7c5e8aSDaniel Lezcanoinstall: install_lib install_headers install_pkgconfig 1423b7c5e8aSDaniel Lezcano 1433b7c5e8aSDaniel LezcanoFORCE: 1443b7c5e8aSDaniel Lezcano 1453b7c5e8aSDaniel Lezcano.PHONY: all install clean FORCE 146