1 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2- 1 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) 2 # Most of this file is copied from tools/lib/p 2 # Most of this file is copied from tools/lib/perf/Makefile 3 3 4 LIBTHERMAL_VERSION = 0 4 LIBTHERMAL_VERSION = 0 5 LIBTHERMAL_PATCHLEVEL = 0 5 LIBTHERMAL_PATCHLEVEL = 0 6 LIBTHERMAL_EXTRAVERSION = 1 6 LIBTHERMAL_EXTRAVERSION = 1 7 7 8 MAKEFLAGS += --no-print-directory 8 MAKEFLAGS += --no-print-directory 9 9 10 ifeq ($(srctree),) 10 ifeq ($(srctree),) 11 srctree := $(patsubst %/,%,$(dir $(CURDIR))) 11 srctree := $(patsubst %/,%,$(dir $(CURDIR))) 12 srctree := $(patsubst %/,%,$(dir $(srctree))) 12 srctree := $(patsubst %/,%,$(dir $(srctree))) 13 srctree := $(patsubst %/,%,$(dir $(srctree))) 13 srctree := $(patsubst %/,%,$(dir $(srctree))) 14 # $(info Determined 'srctree' to be $(srctree) 14 # $(info Determined 'srctree' to be $(srctree)) 15 endif 15 endif 16 16 17 INSTALL = install 17 INSTALL = install 18 18 19 # Use DESTDIR for installing into a different 19 # Use DESTDIR for installing into a different root directory. 20 # This is useful for building a package. The p 20 # This is useful for building a package. The program will be 21 # installed in this directory as if it was the 21 # installed in this directory as if it was the root directory. 22 # Then the build tool can move it later. 22 # Then the build tool can move it later. 23 DESTDIR ?= 23 DESTDIR ?= 24 DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' 24 DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' 25 25 26 include $(srctree)/tools/scripts/Makefile.incl 26 include $(srctree)/tools/scripts/Makefile.include 27 include $(srctree)/tools/scripts/Makefile.arch 27 include $(srctree)/tools/scripts/Makefile.arch 28 28 29 ifeq ($(LP64), 1) 29 ifeq ($(LP64), 1) 30 libdir_relative = lib64 30 libdir_relative = lib64 31 else 31 else 32 libdir_relative = lib 32 libdir_relative = lib 33 endif 33 endif 34 34 35 prefix ?= 35 prefix ?= 36 libdir = $(prefix)/$(libdir_relative) 36 libdir = $(prefix)/$(libdir_relative) 37 37 38 # Shell quotes 38 # Shell quotes 39 libdir_SQ = $(subst ','\'',$(libdir)) 39 libdir_SQ = $(subst ','\'',$(libdir)) 40 libdir_relative_SQ = $(subst ','\'',$(libdir_r 40 libdir_relative_SQ = $(subst ','\'',$(libdir_relative)) 41 41 42 ifeq ("$(origin V)", "command line") 42 ifeq ("$(origin V)", "command line") 43 VERBOSE = $(V) 43 VERBOSE = $(V) 44 endif 44 endif 45 ifndef VERBOSE 45 ifndef VERBOSE 46 VERBOSE = 0 46 VERBOSE = 0 47 endif 47 endif 48 48 49 ifeq ($(VERBOSE),1) 49 ifeq ($(VERBOSE),1) 50 Q = 50 Q = 51 else 51 else 52 Q = @ 52 Q = @ 53 endif 53 endif 54 54 55 # Set compile option CFLAGS 55 # Set compile option CFLAGS 56 ifdef EXTRA_CFLAGS 56 ifdef EXTRA_CFLAGS 57 CFLAGS := $(EXTRA_CFLAGS) 57 CFLAGS := $(EXTRA_CFLAGS) 58 else 58 else 59 CFLAGS := -g -Wall 59 CFLAGS := -g -Wall 60 endif 60 endif 61 61 62 INCLUDES = \ 62 INCLUDES = \ 63 -I/usr/include/libnl3 \ 63 -I/usr/include/libnl3 \ 64 -I$(srctree)/tools/lib/thermal/include \ 64 -I$(srctree)/tools/lib/thermal/include \ 65 -I$(srctree)/tools/lib/ \ 65 -I$(srctree)/tools/lib/ \ 66 -I$(srctree)/tools/include \ 66 -I$(srctree)/tools/include \ 67 -I$(srctree)/tools/arch/$(SRCARCH)/include/ \ 67 -I$(srctree)/tools/arch/$(SRCARCH)/include/ \ 68 -I$(srctree)/tools/arch/$(SRCARCH)/include/uap 68 -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi \ 69 -I$(srctree)/tools/include/uapi 69 -I$(srctree)/tools/include/uapi 70 70 71 # Append required CFLAGS 71 # Append required CFLAGS 72 override CFLAGS += $(EXTRA_WARNINGS) 72 override CFLAGS += $(EXTRA_WARNINGS) 73 override CFLAGS += -Werror -Wall 73 override CFLAGS += -Werror -Wall 74 override CFLAGS += -fPIC 74 override CFLAGS += -fPIC 75 override CFLAGS += $(INCLUDES) 75 override CFLAGS += $(INCLUDES) 76 override CFLAGS += -fvisibility=hidden 76 override CFLAGS += -fvisibility=hidden 77 override CFGLAS += -Wl,-L. 77 override CFGLAS += -Wl,-L. 78 override CFGLAS += -Wl,-lthermal 78 override CFGLAS += -Wl,-lthermal 79 79 80 all: 80 all: 81 81 82 export srctree OUTPUT CC LD CFLAGS V 82 export srctree OUTPUT CC LD CFLAGS V 83 export DESTDIR DESTDIR_SQ 83 export DESTDIR DESTDIR_SQ 84 84 85 include $(srctree)/tools/build/Makefile.includ 85 include $(srctree)/tools/build/Makefile.include 86 86 87 VERSION_SCRIPT := libthermal.map 87 VERSION_SCRIPT := libthermal.map 88 88 89 PATCHLEVEL = $(LIBTHERMAL_PATCHLEVEL) 89 PATCHLEVEL = $(LIBTHERMAL_PATCHLEVEL) 90 EXTRAVERSION = $(LIBTHERMAL_EXTRAVERSION) 90 EXTRAVERSION = $(LIBTHERMAL_EXTRAVERSION) 91 VERSION = $(LIBTHERMAL_VERSION).$(LIBTHE 91 VERSION = $(LIBTHERMAL_VERSION).$(LIBTHERMAL_PATCHLEVEL).$(LIBTHERMAL_EXTRAVERSION) 92 92 93 LIBTHERMAL_SO := $(OUTPUT)libthermal.so.$(VERS 93 LIBTHERMAL_SO := $(OUTPUT)libthermal.so.$(VERSION) 94 LIBTHERMAL_A := $(OUTPUT)libthermal.a 94 LIBTHERMAL_A := $(OUTPUT)libthermal.a 95 LIBTHERMAL_IN := $(OUTPUT)libthermal-in.o 95 LIBTHERMAL_IN := $(OUTPUT)libthermal-in.o 96 LIBTHERMAL_PC := $(OUTPUT)libthermal.pc 96 LIBTHERMAL_PC := $(OUTPUT)libthermal.pc 97 LIBTHERMAL_ALL := $(LIBTHERMAL_A) $(OUTPUT)lib 97 LIBTHERMAL_ALL := $(LIBTHERMAL_A) $(OUTPUT)libthermal.so* 98 98 99 THERMAL_UAPI := include/uapi/linux/thermal.h 99 THERMAL_UAPI := include/uapi/linux/thermal.h 100 100 101 $(THERMAL_UAPI): FORCE 101 $(THERMAL_UAPI): FORCE 102 ln -sf $(srctree)/$@ $(srctree)/tools/ 102 ln -sf $(srctree)/$@ $(srctree)/tools/$@ 103 103 104 $(LIBTHERMAL_IN): FORCE 104 $(LIBTHERMAL_IN): FORCE 105 $(Q)$(MAKE) $(build)=libthermal 105 $(Q)$(MAKE) $(build)=libthermal 106 106 107 $(LIBTHERMAL_A): $(LIBTHERMAL_IN) 107 $(LIBTHERMAL_A): $(LIBTHERMAL_IN) 108 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $( 108 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIBTHERMAL_IN) 109 109 110 $(LIBTHERMAL_SO): $(LIBTHERMAL_IN) 110 $(LIBTHERMAL_SO): $(LIBTHERMAL_IN) 111 $(QUIET_LINK)$(CC) --shared -Wl,-sonam 111 $(QUIET_LINK)$(CC) --shared -Wl,-soname,libthermal.so \ 112 -Wl,--vers 112 -Wl,--version-script=$(VERSION_SCRIPT) $^ -o $@ 113 @ln -sf $(@F) $(OUTPUT)libthermal.so 113 @ln -sf $(@F) $(OUTPUT)libthermal.so 114 @ln -sf $(@F) $(OUTPUT)libthermal.so.$ 114 @ln -sf $(@F) $(OUTPUT)libthermal.so.$(LIBTHERMAL_VERSION) 115 115 116 116 117 libs: $(THERMAL_UAPI) $(LIBTHERMAL_A) $(LIBTHE 117 libs: $(THERMAL_UAPI) $(LIBTHERMAL_A) $(LIBTHERMAL_SO) $(LIBTHERMAL_PC) 118 118 119 all: fixdep 119 all: fixdep 120 $(Q)$(MAKE) libs 120 $(Q)$(MAKE) libs 121 121 122 clean: 122 clean: 123 $(call QUIET_CLEAN, libthermal) $(RM) 123 $(call QUIET_CLEAN, libthermal) $(RM) $(LIBTHERMAL_A) \ 124 *.o *~ *.a *.so *.so.$(VERSION !! 124 *.o *~ *.a *.so *.so.$(VERSION) *.so.$(LIBTHERMAL_VERSION) .*.d .*.cmd LIBTHERMAL-CFLAGS $(LIBTHERMAL_PC) 125 .*.d .*.cmd LIBTHERMAL-CFLAGS << 126 $(srctree)/tools/$(THERMAL_UAP << 127 125 128 $(LIBTHERMAL_PC): 126 $(LIBTHERMAL_PC): 129 $(QUIET_GEN)sed -e "s|@PREFIX@|$(prefi 127 $(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \ 130 -e "s|@LIBDIR@|$(libdir_SQ)|" 128 -e "s|@LIBDIR@|$(libdir_SQ)|" \ 131 -e "s|@VERSION@|$(VERSION)|" \ 129 -e "s|@VERSION@|$(VERSION)|" \ 132 < libthermal.pc.template > $@ 130 < libthermal.pc.template > $@ 133 131 134 define do_install_mkdir 132 define do_install_mkdir 135 if [ ! -d '$(DESTDIR_SQ)$1' ]; then 133 if [ ! -d '$(DESTDIR_SQ)$1' ]; then \ 136 $(INSTALL) -d -m 755 '$(DESTDI 134 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \ 137 fi 135 fi 138 endef 136 endef 139 137 140 define do_install 138 define do_install 141 if [ ! -d '$(DESTDIR_SQ)$2' ]; then 139 if [ ! -d '$(DESTDIR_SQ)$2' ]; then \ 142 $(INSTALL) -d -m 755 '$(DESTDI 140 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \ 143 fi; 141 fi; \ 144 $(INSTALL) $1 $(if $3,-m $3,) '$(DESTD 142 $(INSTALL) $1 $(if $3,-m $3,) '$(DESTDIR_SQ)$2' 145 endef 143 endef 146 144 147 install_lib: libs 145 install_lib: libs 148 $(call QUIET_INSTALL, $(LIBTHERMAL_ALL 146 $(call QUIET_INSTALL, $(LIBTHERMAL_ALL)) \ 149 $(call do_install_mkdir,$(libd 147 $(call do_install_mkdir,$(libdir_SQ)); \ 150 cp -fpR $(LIBTHERMAL_ALL) $(DE 148 cp -fpR $(LIBTHERMAL_ALL) $(DESTDIR)$(libdir_SQ) 151 149 152 install_headers: 150 install_headers: 153 $(call QUIET_INSTALL, headers) \ 151 $(call QUIET_INSTALL, headers) \ 154 $(call do_install,include/ther 152 $(call do_install,include/thermal.h,$(prefix)/include/thermal,644); \ 155 153 156 install_pkgconfig: $(LIBTHERMAL_PC) 154 install_pkgconfig: $(LIBTHERMAL_PC) 157 $(call QUIET_INSTALL, $(LIBTHERMAL_PC) 155 $(call QUIET_INSTALL, $(LIBTHERMAL_PC)) \ 158 $(call do_install,$(LIBTHERMAL 156 $(call do_install,$(LIBTHERMAL_PC),$(libdir_SQ)/pkgconfig,644) 159 157 160 install_doc: 158 install_doc: 161 $(Q)$(MAKE) -C Documentation install-m 159 $(Q)$(MAKE) -C Documentation install-man install-html install-examples 162 160 163 install: install_lib install_headers install_p 161 install: install_lib install_headers install_pkgconfig 164 162 165 FORCE: 163 FORCE: 166 164 167 .PHONY: all install clean FORCE 165 .PHONY: all install clean FORCE
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.