0001
0002
0003
0004 LIBTHERMAL_TOOLS_VERSION = 0
0005 LIBTHERMAL_TOOLS_PATCHLEVEL = 0
0006 LIBTHERMAL_TOOLS_EXTRAVERSION = 1
0007
0008 MAKEFLAGS += --no-print-directory
0009
0010 ifeq ($(srctree),)
0011 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
0012 srctree := $(patsubst %/,%,$(dir $(srctree)))
0013 srctree := $(patsubst %/,%,$(dir $(srctree)))
0014
0015 endif
0016
0017 INSTALL = install
0018
0019
0020
0021
0022
0023 DESTDIR ?=
0024 DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
0025
0026 include $(srctree)/tools/scripts/Makefile.include
0027 include $(srctree)/tools/scripts/Makefile.arch
0028
0029 ifeq ($(LP64), 1)
0030 libdir_relative = lib64
0031 else
0032 libdir_relative = lib
0033 endif
0034
0035 prefix ?=
0036 libdir = $(prefix)/$(libdir_relative)
0037
0038
0039 libdir_SQ = $(subst ','\'',$(libdir))
0040 libdir_relative_SQ = $(subst ','\'',$(libdir_relative))
0041
0042 ifeq ("$(origin V)", "command line")
0043 VERBOSE = $(V)
0044 endif
0045 ifndef VERBOSE
0046 VERBOSE = 0
0047 endif
0048
0049 ifeq ($(VERBOSE),1)
0050 Q =
0051 else
0052 Q = @
0053 endif
0054
0055
0056 ifdef EXTRA_CFLAGS
0057 CFLAGS := $(EXTRA_CFLAGS)
0058 else
0059 CFLAGS := -g -Wall
0060 endif
0061
0062 INCLUDES = \
0063 -I/usr/include/libnl3 \
0064 -I$(srctree)/tools/lib/thermal/include \
0065 -I$(srctree)/tools/lib/ \
0066 -I$(srctree)/tools/include \
0067 -I$(srctree)/tools/arch/$(SRCARCH)/include/ \
0068 -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi \
0069 -I$(srctree)/tools/include/uapi
0070
0071
0072 override CFLAGS += $(EXTRA_WARNINGS)
0073 override CFLAGS += -Werror -Wall
0074 override CFLAGS += -fPIC
0075 override CFLAGS += $(INCLUDES)
0076 override CFGLAS += -Wl,-L.
0077 override CFGLAS += -Wl,-lthermal
0078
0079 all:
0080
0081 export srctree OUTPUT CC LD CFLAGS V
0082 export DESTDIR DESTDIR_SQ
0083
0084 include $(srctree)/tools/build/Makefile.include
0085
0086 PATCHLEVEL = $(LIBTHERMAL_TOOLS_PATCHLEVEL)
0087 EXTRAVERSION = $(LIBTHERMAL_TOOLS_EXTRAVERSION)
0088 VERSION = $(LIBTHERMAL_TOOLS_VERSION).$(LIBTHERMAL_TOOLS_PATCHLEVEL).$(LIBTHERMAL_TOOLS_EXTRAVERSION)
0089
0090 LIBTHERMAL_TOOLS_SO := $(OUTPUT)libthermal_tools.so.$(VERSION)
0091 LIBTHERMAL_TOOLS_A := $(OUTPUT)libthermal_tools.a
0092 LIBTHERMAL_TOOLS_IN := $(OUTPUT)libthermal_tools-in.o
0093 LIBTHERMAL_TOOLS_PC := $(OUTPUT)libthermal_tools.pc
0094
0095 LIBTHERMAL_TOOLS_ALL := $(LIBTHERMAL_TOOLS_A) $(OUTPUT)libthermal_tools.so*
0096
0097 $(LIBTHERMAL_TOOLS_IN): FORCE
0098 $(Q)$(MAKE) $(build)=libthermal_tools
0099
0100 $(LIBTHERMAL_TOOLS_A): $(LIBTHERMAL_TOOLS_IN)
0101 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIBTHERMAL_TOOLS_IN)
0102
0103 $(LIBTHERMAL_TOOLS_SO): $(LIBTHERMAL_TOOLS_IN)
0104 $(QUIET_LINK)$(CC) --shared -Wl,-soname,libthermal_tools.so $^ -o $@
0105 @ln -sf $(@F) $(OUTPUT)libthermal_tools.so
0106 @ln -sf $(@F) $(OUTPUT)libthermal_tools.so.$(LIBTHERMAL_TOOLS_VERSION)
0107
0108
0109 libs: $(LIBTHERMAL_TOOLS_A) $(LIBTHERMAL_TOOLS_SO) $(LIBTHERMAL_TOOLS_PC)
0110
0111 all: fixdep
0112 $(Q)$(MAKE) libs
0113
0114 clean:
0115 $(call QUIET_CLEAN, libthermal_tools) $(RM) $(LIBTHERMAL_TOOLS_A) \
0116 *.o *~ *.a *.so *.so.$(VERSION) *.so.$(LIBTHERMAL_TOOLS_VERSION) .*.d .*.cmd LIBTHERMAL_TOOLS-CFLAGS $(LIBTHERMAL_TOOLS_PC)
0117
0118 $(LIBTHERMAL_TOOLS_PC):
0119 $(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \
0120 -e "s|@LIBDIR@|$(libdir_SQ)|" \
0121 -e "s|@VERSION@|$(VERSION)|" \
0122 < libthermal_tools.pc.template > $@
0123
0124 define do_install_mkdir
0125 if [ ! -d '$(DESTDIR_SQ)$1' ]; then \
0126 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \
0127 fi
0128 endef
0129
0130 define do_install
0131 if [ ! -d '$(DESTDIR_SQ)$2' ]; then \
0132 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \
0133 fi; \
0134 $(INSTALL) $1 $(if $3,-m $3,) '$(DESTDIR_SQ)$2'
0135 endef
0136
0137 install_lib: libs
0138 $(call QUIET_INSTALL, $(LIBTHERMAL_TOOLS_ALL)) \
0139 $(call do_install_mkdir,$(libdir_SQ)); \
0140 cp -fpR $(LIBTHERMAL_TOOLS_ALL) $(DESTDIR)$(libdir_SQ)
0141
0142 install_headers:
0143 $(call QUIET_INSTALL, headers) \
0144 $(call do_install,include/thermal.h,$(prefix)/include/thermal,644); \
0145
0146 install_pkgconfig: $(LIBTHERMAL_TOOLS_PC)
0147 $(call QUIET_INSTALL, $(LIBTHERMAL_TOOLS_PC)) \
0148 $(call do_install,$(LIBTHERMAL_TOOLS_PC),$(libdir_SQ)/pkgconfig,644)
0149
0150 install_doc:
0151 $(Q)$(MAKE) -C Documentation install-man install-html install-examples
0152
0153
0154 install: install_lib install_headers install_pkgconfig
0155
0156 FORCE:
0157
0158 .PHONY: all install clean FORCE