168 lines · plain
1# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)2# Most of this file is copied from tools/lib/perf/Makefile3 4LIBTHERMAL_VERSION = 05LIBTHERMAL_PATCHLEVEL = 06LIBTHERMAL_EXTRAVERSION = 17 8MAKEFLAGS += --no-print-directory9 10ifeq ($(srctree),)11srctree := $(patsubst %/,%,$(dir $(CURDIR)))12srctree := $(patsubst %/,%,$(dir $(srctree)))13srctree := $(patsubst %/,%,$(dir $(srctree)))14# $(info Determined 'srctree' to be $(srctree))15endif16 17INSTALL = install18 19# Use DESTDIR for installing into a different root directory.20# This is useful for building a package. The program will be21# installed in this directory as if it was the root directory.22# Then the build tool can move it later.23DESTDIR ?=24DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'25 26include $(srctree)/tools/scripts/Makefile.include27include $(srctree)/tools/scripts/Makefile.arch28 29ifeq ($(LP64), 1)30 libdir_relative = lib6431else32 libdir_relative = lib33endif34 35prefix ?=36libdir = $(prefix)/$(libdir_relative)37 38# Shell quotes39libdir_SQ = $(subst ','\'',$(libdir))40libdir_relative_SQ = $(subst ','\'',$(libdir_relative))41 42ifeq ("$(origin V)", "command line")43 VERBOSE = $(V)44endif45ifndef VERBOSE46 VERBOSE = 047endif48 49ifeq ($(VERBOSE),1)50 Q =51else52 Q = @53endif54 55# Set compile option CFLAGS56ifdef EXTRA_CFLAGS57 CFLAGS := $(EXTRA_CFLAGS)58else59 CFLAGS := -g -Wall60endif61 62INCLUDES = \63-I/usr/include/libnl3 \64-I$(srctree)/tools/lib/thermal/include \65-I$(srctree)/tools/lib/ \66-I$(srctree)/tools/include \67-I$(srctree)/tools/arch/$(SRCARCH)/include/ \68-I$(srctree)/tools/arch/$(SRCARCH)/include/uapi \69-I$(srctree)/tools/include/uapi70 71# Append required CFLAGS72override CFLAGS += $(EXTRA_WARNINGS)73override CFLAGS += -Werror -Wall74override CFLAGS += -fPIC75override CFLAGS += $(INCLUDES)76override CFLAGS += -fvisibility=hidden77override CFGLAS += -Wl,-L.78override CFGLAS += -Wl,-lthermal79 80all:81 82export srctree OUTPUT CC LD CFLAGS V83export DESTDIR DESTDIR_SQ84 85include $(srctree)/tools/build/Makefile.include86 87VERSION_SCRIPT := libthermal.map88 89PATCHLEVEL = $(LIBTHERMAL_PATCHLEVEL)90EXTRAVERSION = $(LIBTHERMAL_EXTRAVERSION)91VERSION = $(LIBTHERMAL_VERSION).$(LIBTHERMAL_PATCHLEVEL).$(LIBTHERMAL_EXTRAVERSION)92 93LIBTHERMAL_SO := $(OUTPUT)libthermal.so.$(VERSION)94LIBTHERMAL_A := $(OUTPUT)libthermal.a95LIBTHERMAL_IN := $(OUTPUT)libthermal-in.o96LIBTHERMAL_PC := $(OUTPUT)libthermal.pc97LIBTHERMAL_ALL := $(LIBTHERMAL_A) $(OUTPUT)libthermal.so*98 99THERMAL_UAPI := include/uapi/linux/thermal.h100 101$(THERMAL_UAPI): FORCE102 ln -sf $(srctree)/$@ $(srctree)/tools/$@103 104$(LIBTHERMAL_IN): FORCE105 $(Q)$(MAKE) $(build)=libthermal106 107$(LIBTHERMAL_A): $(LIBTHERMAL_IN)108 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIBTHERMAL_IN)109 110$(LIBTHERMAL_SO): $(LIBTHERMAL_IN)111 $(QUIET_LINK)$(CC) --shared -Wl,-soname,libthermal.so \112 -Wl,--version-script=$(VERSION_SCRIPT) $^ -o $@113 @ln -sf $(@F) $(OUTPUT)libthermal.so114 @ln -sf $(@F) $(OUTPUT)libthermal.so.$(LIBTHERMAL_VERSION)115 116 117libs: $(THERMAL_UAPI) $(LIBTHERMAL_A) $(LIBTHERMAL_SO) $(LIBTHERMAL_PC)118 119all: fixdep120 $(Q)$(MAKE) libs121 122clean:123 $(call QUIET_CLEAN, libthermal) $(RM) $(LIBTHERMAL_A) \124 *.o *~ *.a *.so *.so.$(VERSION) *.so.$(LIBTHERMAL_VERSION) \125 .*.d .*.cmd LIBTHERMAL-CFLAGS $(LIBTHERMAL_PC) \126 $(srctree)/tools/$(THERMAL_UAPI)127 128$(LIBTHERMAL_PC):129 $(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \130 -e "s|@LIBDIR@|$(libdir_SQ)|" \131 -e "s|@VERSION@|$(VERSION)|" \132 < libthermal.pc.template > $@133 134define do_install_mkdir135 if [ ! -d '$(DESTDIR_SQ)$1' ]; then \136 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \137 fi138endef139 140define do_install141 if [ ! -d '$(DESTDIR_SQ)$2' ]; then \142 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \143 fi; \144 $(INSTALL) $1 $(if $3,-m $3,) '$(DESTDIR_SQ)$2'145endef146 147install_lib: libs148 $(call QUIET_INSTALL, $(LIBTHERMAL_ALL)) \149 $(call do_install_mkdir,$(libdir_SQ)); \150 cp -fpR $(LIBTHERMAL_ALL) $(DESTDIR)$(libdir_SQ)151 152install_headers:153 $(call QUIET_INSTALL, headers) \154 $(call do_install,include/thermal.h,$(prefix)/include/thermal,644); \155 156install_pkgconfig: $(LIBTHERMAL_PC)157 $(call QUIET_INSTALL, $(LIBTHERMAL_PC)) \158 $(call do_install,$(LIBTHERMAL_PC),$(libdir_SQ)/pkgconfig,644)159 160install_doc:161 $(Q)$(MAKE) -C Documentation install-man install-html install-examples162 163install: install_lib install_headers install_pkgconfig164 165FORCE:166 167.PHONY: all install clean FORCE168