^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) # SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # Makefile for cpupower
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) # Copyright (C) 2005,2006 Dominik Brodowski <linux@dominikbrodowski.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) # Based largely on the Makefile for udev by:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) # Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) OUTPUT=./
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) ifeq ("$(origin O)", "command line")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) OUTPUT := $(O)/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) ifneq ($(OUTPUT),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) # check that the output directory actually exists
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) OUTDIR := $(shell cd $(OUTPUT) && pwd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) $(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) # --- CONFIGURATION BEGIN ---
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) # Set the following to `true' to make a unstripped, unoptimized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) # binary. Leave this set to `false' for production use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) DEBUG ?= true
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) # make the build silent. Set this to something else to make it noisy again.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) V ?= false
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) # Internationalization support (output in different languages).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) # Requires gettext.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) NLS ?= true
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) # Set the following to 'true' to build/install the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) # cpufreq-bench benchmarking tool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) CPUFREQ_BENCH ?= true
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) # Do not build libraries, but build the code in statically
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) # Libraries are still built, otherwise the Makefile code would
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) # be rather ugly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) export STATIC ?= false
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) # Prefix to the directories we're installing to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) DESTDIR ?=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) # --- CONFIGURATION END ---
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) # Package-related definitions. Distributions can modify the version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) # and _should_ modify the PACKAGE_BUGREPORT definition
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) VERSION:= $(shell ./utils/version-gen.sh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) LIB_MAJ= 0.0.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) LIB_MIN= 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) PACKAGE = cpupower
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) PACKAGE_BUGREPORT = linux-pm@vger.kernel.org
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) LANGUAGES = de fr it cs pt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) # Directory definitions. These are default and most probably
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) # do not need to be changed. Please note that DESTDIR is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) # added in front of any of them
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) bindir ?= /usr/bin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) sbindir ?= /usr/sbin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) mandir ?= /usr/man
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) includedir ?= /usr/include
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) localedir ?= /usr/share/locale
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) docdir ?= /usr/share/doc/packages/cpupower
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) confdir ?= /etc/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) bash_completion_dir ?= /usr/share/bash-completion/completions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) # Toolchain: what tools do we use, and what options do they need:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) CP = cp -fpR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) INSTALL = /usr/bin/install -c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) INSTALL_PROGRAM = ${INSTALL}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) INSTALL_DATA = ${INSTALL} -m 644
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #bash completion scripts get sourced and so they should be rw only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) INSTALL_SCRIPT = ${INSTALL} -m 644
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) # If you are running a cross compiler, you may want to set this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) # to something more interesting, like "arm-linux-". If you want
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) # to compile vs uClibc, that can be done here as well.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) CC = $(CROSS)gcc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) LD = $(CROSS)gcc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) AR = $(CROSS)ar
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) STRIP = $(CROSS)strip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) RANLIB = $(CROSS)ranlib
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) HOSTCC = gcc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) MKDIR = mkdir
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) # 64bit library detection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) include ../../scripts/Makefile.arch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) ifeq ($(IS_64_BIT), 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) libdir ?= /usr/lib64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) libdir ?= /usr/lib
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) # Now we set up the build system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) GMO_FILES = ${shell for HLANG in ${LANGUAGES}; do echo $(OUTPUT)po/$$HLANG.gmo; done;}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) # check if compiler option is supported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) cc-supports = ${shell if $(CC) ${1} -S -o /dev/null -x c /dev/null > /dev/null 2>&1; then echo "$(1)"; fi;}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) # use '-Os' optimization if available, else use -O2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) OPTIMIZATION := $(call cc-supports,-Os,-O2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) WARNINGS := -Wall -Wchar-subscripts -Wpointer-arith -Wsign-compare
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) WARNINGS += $(call cc-supports,-Wno-pointer-sign)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) WARNINGS += $(call cc-supports,-Wdeclaration-after-statement)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) WARNINGS += -Wshadow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) override CFLAGS += -DVERSION=\"$(VERSION)\" -DPACKAGE=\"$(PACKAGE)\" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) -DPACKAGE_BUGREPORT=\"$(PACKAGE_BUGREPORT)\" -D_GNU_SOURCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) UTIL_OBJS = utils/helpers/amd.o utils/helpers/msr.o \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) utils/helpers/sysfs.o utils/helpers/misc.o utils/helpers/cpuid.o \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) utils/helpers/pci.o utils/helpers/bitmask.o \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) utils/idle_monitor/nhm_idle.o utils/idle_monitor/snb_idle.o \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) utils/idle_monitor/hsw_ext_idle.o \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) utils/idle_monitor/amd_fam14h_idle.o utils/idle_monitor/cpuidle_sysfs.o \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) utils/idle_monitor/mperf_monitor.o utils/idle_monitor/cpupower-monitor.o \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) utils/cpupower.o utils/cpufreq-info.o utils/cpufreq-set.o \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) utils/cpupower-set.o utils/cpupower-info.o utils/cpuidle-info.o \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) utils/cpuidle-set.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) UTIL_SRC := $(UTIL_OBJS:.o=.c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) UTIL_OBJS := $(addprefix $(OUTPUT),$(UTIL_OBJS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) UTIL_HEADERS = utils/helpers/helpers.h utils/idle_monitor/cpupower-monitor.h \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) utils/helpers/bitmask.h \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) utils/idle_monitor/idle_monitors.h utils/idle_monitor/idle_monitors.def
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) LIB_HEADERS = lib/cpufreq.h lib/cpupower.h lib/cpuidle.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) LIB_SRC = lib/cpufreq.c lib/cpupower.c lib/cpuidle.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) LIB_OBJS = lib/cpufreq.o lib/cpupower.o lib/cpuidle.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) LIB_OBJS := $(addprefix $(OUTPUT),$(LIB_OBJS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) override CFLAGS += -pipe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) ifeq ($(strip $(NLS)),true)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) INSTALL_NLS += install-gmo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) COMPILE_NLS += create-gmo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) override CFLAGS += -DNLS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) ifeq ($(strip $(CPUFREQ_BENCH)),true)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) INSTALL_BENCH += install-bench
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) COMPILE_BENCH += compile-bench
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) ifeq ($(strip $(STATIC)),true)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) UTIL_OBJS += $(LIB_OBJS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) UTIL_HEADERS += $(LIB_HEADERS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) UTIL_SRC += $(LIB_SRC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) override CFLAGS += $(WARNINGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) ifeq ($(strip $(V)),false)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) QUIET=@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) ECHO=@echo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) QUIET=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) ECHO=@\#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) export QUIET ECHO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) # if DEBUG is enabled, then we do not strip or optimize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) ifeq ($(strip $(DEBUG)),true)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) override CFLAGS += -O1 -g -DDEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) STRIPCMD = /bin/true -Since_we_are_debugging
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) override CFLAGS += $(OPTIMIZATION) -fomit-frame-pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) # the actual make rules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) all: libcpupower $(OUTPUT)cpupower $(COMPILE_NLS) $(COMPILE_BENCH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) $(OUTPUT)lib/%.o: $(LIB_SRC) $(LIB_HEADERS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) $(ECHO) " CC " $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) $(QUIET) $(CC) $(CFLAGS) -fPIC -o $@ -c lib/$*.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) $(OUTPUT)libcpupower.so.$(LIB_MAJ): $(LIB_OBJS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) $(ECHO) " LD " $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) $(QUIET) $(CC) -shared $(CFLAGS) $(LDFLAGS) -o $@ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) -Wl,-soname,libcpupower.so.$(LIB_MIN) $(LIB_OBJS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) @ln -sf $(@F) $(OUTPUT)libcpupower.so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) @ln -sf $(@F) $(OUTPUT)libcpupower.so.$(LIB_MIN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) libcpupower: $(OUTPUT)libcpupower.so.$(LIB_MAJ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) # Let all .o files depend on its .c file and all headers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) # Might be worth to put this into utils/Makefile at some point of time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) $(UTIL_OBJS): $(UTIL_HEADERS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) $(OUTPUT)%.o: %.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) $(ECHO) " CC " $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) $(QUIET) $(CC) $(CFLAGS) -I./lib -I ./utils -o $@ -c $*.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) $(OUTPUT)cpupower: $(UTIL_OBJS) $(OUTPUT)libcpupower.so.$(LIB_MAJ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) $(ECHO) " CC " $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) ifeq ($(strip $(STATIC)),true)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) $(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) $(UTIL_OBJS) -lrt -lpci -L$(OUTPUT) -o $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) $(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) $(UTIL_OBJS) -lcpupower -lrt -lpci -L$(OUTPUT) -o $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) $(QUIET) $(STRIPCMD) $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) $(OUTPUT)po/$(PACKAGE).pot: $(UTIL_SRC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) $(ECHO) " GETTEXT " $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) $(QUIET) xgettext --default-domain=$(PACKAGE) --add-comments \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) --keyword=_ --keyword=N_ $(UTIL_SRC) -p $(@D) -o $(@F)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) $(OUTPUT)po/%.gmo: po/%.po
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) $(ECHO) " MSGFMT " $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) $(QUIET) msgfmt -o $@ po/$*.po
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) create-gmo: ${GMO_FILES}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) update-po: $(OUTPUT)po/$(PACKAGE).pot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) $(ECHO) " MSGMRG " $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) $(QUIET) @for HLANG in $(LANGUAGES); do \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) echo -n "Updating $$HLANG "; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) if msgmerge po/$$HLANG.po $< -o \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) $(OUTPUT)po/$$HLANG.new.po; then \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) mv -f $(OUTPUT)po/$$HLANG.new.po $(OUTPUT)po/$$HLANG.po; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) else \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) echo "msgmerge for $$HLANG failed!"; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) rm -f $(OUTPUT)po/$$HLANG.new.po; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) fi; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) compile-bench: $(OUTPUT)libcpupower.so.$(LIB_MAJ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) @V=$(V) confdir=$(confdir) $(MAKE) -C bench O=$(OUTPUT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) # we compile into subdirectories. if the target directory is not the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) # source directory, they might not exists. So we depend the various
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) # files onto their directories.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) DIRECTORY_DEPS = $(LIB_OBJS) $(UTIL_OBJS) $(GMO_FILES)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) $(DIRECTORY_DEPS): | $(sort $(dir $(DIRECTORY_DEPS)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) # In the second step, we make a rule to actually create these directories
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) $(sort $(dir $(DIRECTORY_DEPS))):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) $(ECHO) " MKDIR " $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) $(QUIET) $(MKDIR) -p $@ 2>/dev/null
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) clean:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) -find $(OUTPUT) \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) | xargs rm -f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) -rm -f $(OUTPUT)cpupower
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) -rm -f $(OUTPUT)libcpupower.so*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) -rm -rf $(OUTPUT)po/*.gmo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) -rm -rf $(OUTPUT)po/*.pot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) $(MAKE) -C bench O=$(OUTPUT) clean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) install-lib:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) $(INSTALL) -d $(DESTDIR)${libdir}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) $(CP) $(OUTPUT)libcpupower.so* $(DESTDIR)${libdir}/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) $(INSTALL) -d $(DESTDIR)${includedir}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) $(INSTALL_DATA) lib/cpufreq.h $(DESTDIR)${includedir}/cpufreq.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) $(INSTALL_DATA) lib/cpuidle.h $(DESTDIR)${includedir}/cpuidle.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) install-tools:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) $(INSTALL) -d $(DESTDIR)${bindir}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) $(INSTALL_PROGRAM) $(OUTPUT)cpupower $(DESTDIR)${bindir}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) $(INSTALL) -d $(DESTDIR)${bash_completion_dir}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) $(INSTALL_SCRIPT) cpupower-completion.sh '$(DESTDIR)${bash_completion_dir}/cpupower'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) install-man:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) $(INSTALL_DATA) -D man/cpupower.1 $(DESTDIR)${mandir}/man1/cpupower.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) $(INSTALL_DATA) -D man/cpupower-frequency-set.1 $(DESTDIR)${mandir}/man1/cpupower-frequency-set.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) $(INSTALL_DATA) -D man/cpupower-frequency-info.1 $(DESTDIR)${mandir}/man1/cpupower-frequency-info.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) $(INSTALL_DATA) -D man/cpupower-idle-set.1 $(DESTDIR)${mandir}/man1/cpupower-idle-set.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) $(INSTALL_DATA) -D man/cpupower-idle-info.1 $(DESTDIR)${mandir}/man1/cpupower-idle-info.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) $(INSTALL_DATA) -D man/cpupower-set.1 $(DESTDIR)${mandir}/man1/cpupower-set.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) $(INSTALL_DATA) -D man/cpupower-info.1 $(DESTDIR)${mandir}/man1/cpupower-info.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) $(INSTALL_DATA) -D man/cpupower-monitor.1 $(DESTDIR)${mandir}/man1/cpupower-monitor.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) install-gmo:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) $(INSTALL) -d $(DESTDIR)${localedir}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) for HLANG in $(LANGUAGES); do \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) echo '$(INSTALL_DATA) -D $(OUTPUT)po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo'; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) $(INSTALL_DATA) -D $(OUTPUT)po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) install-bench:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) @#DESTDIR must be set from outside to survive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) @sbindir=$(sbindir) bindir=$(bindir) docdir=$(docdir) confdir=$(confdir) $(MAKE) -C bench O=$(OUTPUT) install
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) ifeq ($(strip $(STATIC)),true)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) install: all install-tools install-man $(INSTALL_NLS) $(INSTALL_BENCH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) install: all install-lib install-tools install-man $(INSTALL_NLS) $(INSTALL_BENCH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) uninstall:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) - rm -f $(DESTDIR)${libdir}/libcpupower.*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) - rm -f $(DESTDIR)${includedir}/cpufreq.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) - rm -f $(DESTDIR)${includedir}/cpuidle.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) - rm -f $(DESTDIR)${bindir}/utils/cpupower
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) - rm -f $(DESTDIR)${mandir}/man1/cpupower.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) - rm -f $(DESTDIR)${mandir}/man1/cpupower-frequency-set.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) - rm -f $(DESTDIR)${mandir}/man1/cpupower-frequency-info.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) - rm -f $(DESTDIR)${mandir}/man1/cpupower-set.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) - rm -f $(DESTDIR)${mandir}/man1/cpupower-info.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) - rm -f $(DESTDIR)${mandir}/man1/cpupower-monitor.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) - for HLANG in $(LANGUAGES); do \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) rm -f $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) .PHONY: all utils libcpupower update-po create-gmo install-lib install-tools install-man install-gmo install uninstall clean