| .. | .. |
|---|
| 1 | +# SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | # Makefile for cpupower |
|---|
| 2 | 3 | # |
|---|
| 3 | 4 | # Copyright (C) 2005,2006 Dominik Brodowski <linux@dominikbrodowski.net> |
|---|
| .. | .. |
|---|
| 5 | 6 | # Based largely on the Makefile for udev by: |
|---|
| 6 | 7 | # |
|---|
| 7 | 8 | # Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com> |
|---|
| 8 | | -# |
|---|
| 9 | | -# This program is free software; you can redistribute it and/or modify |
|---|
| 10 | | -# it under the terms of the GNU General Public License as published by |
|---|
| 11 | | -# the Free Software Foundation; version 2 of the License. |
|---|
| 12 | | -# |
|---|
| 13 | | -# This program is distributed in the hope that it will be useful, |
|---|
| 14 | | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 16 | | -# General Public License for more details. |
|---|
| 17 | | -# |
|---|
| 18 | | -# You should have received a copy of the GNU General Public License |
|---|
| 19 | | -# along with this program; if not, write to the Free Software |
|---|
| 20 | | -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 21 | 9 | # |
|---|
| 22 | 10 | OUTPUT=./ |
|---|
| 23 | 11 | ifeq ("$(origin O)", "command line") |
|---|
| .. | .. |
|---|
| 30 | 18 | $(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist)) |
|---|
| 31 | 19 | endif |
|---|
| 32 | 20 | |
|---|
| 33 | | -include ../../scripts/Makefile.arch |
|---|
| 34 | 21 | |
|---|
| 35 | 22 | # --- CONFIGURATION BEGIN --- |
|---|
| 36 | 23 | |
|---|
| .. | .. |
|---|
| 64 | 51 | # Package-related definitions. Distributions can modify the version |
|---|
| 65 | 52 | # and _should_ modify the PACKAGE_BUGREPORT definition |
|---|
| 66 | 53 | |
|---|
| 67 | | -VERSION= $(shell ./utils/version-gen.sh) |
|---|
| 54 | +VERSION:= $(shell ./utils/version-gen.sh) |
|---|
| 68 | 55 | LIB_MAJ= 0.0.1 |
|---|
| 69 | 56 | LIB_MIN= 0 |
|---|
| 70 | 57 | |
|---|
| .. | .. |
|---|
| 81 | 68 | sbindir ?= /usr/sbin |
|---|
| 82 | 69 | mandir ?= /usr/man |
|---|
| 83 | 70 | includedir ?= /usr/include |
|---|
| 84 | | -ifeq ($(IS_64_BIT), 1) |
|---|
| 85 | | -libdir ?= /usr/lib64 |
|---|
| 86 | | -else |
|---|
| 87 | | -libdir ?= /usr/lib |
|---|
| 88 | | -endif |
|---|
| 89 | 71 | localedir ?= /usr/share/locale |
|---|
| 90 | 72 | docdir ?= /usr/share/doc/packages/cpupower |
|---|
| 91 | 73 | confdir ?= /etc/ |
|---|
| 74 | +bash_completion_dir ?= /usr/share/bash-completion/completions |
|---|
| 92 | 75 | |
|---|
| 93 | 76 | # Toolchain: what tools do we use, and what options do they need: |
|---|
| 94 | 77 | |
|---|
| .. | .. |
|---|
| 96 | 79 | INSTALL = /usr/bin/install -c |
|---|
| 97 | 80 | INSTALL_PROGRAM = ${INSTALL} |
|---|
| 98 | 81 | INSTALL_DATA = ${INSTALL} -m 644 |
|---|
| 99 | | -INSTALL_SCRIPT = ${INSTALL_PROGRAM} |
|---|
| 82 | +#bash completion scripts get sourced and so they should be rw only. |
|---|
| 83 | +INSTALL_SCRIPT = ${INSTALL} -m 644 |
|---|
| 100 | 84 | |
|---|
| 101 | 85 | # If you are running a cross compiler, you may want to set this |
|---|
| 102 | 86 | # to something more interesting, like "arm-linux-". If you want |
|---|
| .. | .. |
|---|
| 110 | 94 | HOSTCC = gcc |
|---|
| 111 | 95 | MKDIR = mkdir |
|---|
| 112 | 96 | |
|---|
| 97 | +# 64bit library detection |
|---|
| 98 | +include ../../scripts/Makefile.arch |
|---|
| 99 | + |
|---|
| 100 | +ifeq ($(IS_64_BIT), 1) |
|---|
| 101 | +libdir ?= /usr/lib64 |
|---|
| 102 | +else |
|---|
| 103 | +libdir ?= /usr/lib |
|---|
| 104 | +endif |
|---|
| 113 | 105 | |
|---|
| 114 | 106 | # Now we set up the build system |
|---|
| 115 | 107 | # |
|---|
| .. | .. |
|---|
| 129 | 121 | WARNINGS += $(call cc-supports,-Wdeclaration-after-statement) |
|---|
| 130 | 122 | WARNINGS += -Wshadow |
|---|
| 131 | 123 | |
|---|
| 132 | | -CFLAGS += -DVERSION=\"$(VERSION)\" -DPACKAGE=\"$(PACKAGE)\" \ |
|---|
| 124 | +override CFLAGS += -DVERSION=\"$(VERSION)\" -DPACKAGE=\"$(PACKAGE)\" \ |
|---|
| 133 | 125 | -DPACKAGE_BUGREPORT=\"$(PACKAGE_BUGREPORT)\" -D_GNU_SOURCE |
|---|
| 134 | 126 | |
|---|
| 135 | 127 | UTIL_OBJS = utils/helpers/amd.o utils/helpers/msr.o \ |
|---|
| .. | .. |
|---|
| 156 | 148 | LIB_OBJS = lib/cpufreq.o lib/cpupower.o lib/cpuidle.o |
|---|
| 157 | 149 | LIB_OBJS := $(addprefix $(OUTPUT),$(LIB_OBJS)) |
|---|
| 158 | 150 | |
|---|
| 159 | | -CFLAGS += -pipe |
|---|
| 151 | +override CFLAGS += -pipe |
|---|
| 160 | 152 | |
|---|
| 161 | 153 | ifeq ($(strip $(NLS)),true) |
|---|
| 162 | 154 | INSTALL_NLS += install-gmo |
|---|
| 163 | 155 | COMPILE_NLS += create-gmo |
|---|
| 164 | | - CFLAGS += -DNLS |
|---|
| 156 | + override CFLAGS += -DNLS |
|---|
| 165 | 157 | endif |
|---|
| 166 | 158 | |
|---|
| 167 | 159 | ifeq ($(strip $(CPUFREQ_BENCH)),true) |
|---|
| .. | .. |
|---|
| 175 | 167 | UTIL_SRC += $(LIB_SRC) |
|---|
| 176 | 168 | endif |
|---|
| 177 | 169 | |
|---|
| 178 | | -CFLAGS += $(WARNINGS) |
|---|
| 170 | +override CFLAGS += $(WARNINGS) |
|---|
| 179 | 171 | |
|---|
| 180 | 172 | ifeq ($(strip $(V)),false) |
|---|
| 181 | 173 | QUIET=@ |
|---|
| .. | .. |
|---|
| 188 | 180 | |
|---|
| 189 | 181 | # if DEBUG is enabled, then we do not strip or optimize |
|---|
| 190 | 182 | ifeq ($(strip $(DEBUG)),true) |
|---|
| 191 | | - CFLAGS += -O1 -g -DDEBUG |
|---|
| 183 | + override CFLAGS += -O1 -g -DDEBUG |
|---|
| 192 | 184 | STRIPCMD = /bin/true -Since_we_are_debugging |
|---|
| 193 | 185 | else |
|---|
| 194 | | - CFLAGS += $(OPTIMIZATION) -fomit-frame-pointer |
|---|
| 186 | + override CFLAGS += $(OPTIMIZATION) -fomit-frame-pointer |
|---|
| 195 | 187 | STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment |
|---|
| 196 | 188 | endif |
|---|
| 197 | 189 | |
|---|
| .. | .. |
|---|
| 278 | 270 | $(MAKE) -C bench O=$(OUTPUT) clean |
|---|
| 279 | 271 | |
|---|
| 280 | 272 | |
|---|
| 281 | | -install-lib: |
|---|
| 273 | +install-lib: libcpupower |
|---|
| 282 | 274 | $(INSTALL) -d $(DESTDIR)${libdir} |
|---|
| 283 | 275 | $(CP) $(OUTPUT)libcpupower.so* $(DESTDIR)${libdir}/ |
|---|
| 284 | 276 | $(INSTALL) -d $(DESTDIR)${includedir} |
|---|
| 285 | 277 | $(INSTALL_DATA) lib/cpufreq.h $(DESTDIR)${includedir}/cpufreq.h |
|---|
| 286 | 278 | $(INSTALL_DATA) lib/cpuidle.h $(DESTDIR)${includedir}/cpuidle.h |
|---|
| 287 | 279 | |
|---|
| 288 | | -install-tools: |
|---|
| 280 | +install-tools: $(OUTPUT)cpupower |
|---|
| 289 | 281 | $(INSTALL) -d $(DESTDIR)${bindir} |
|---|
| 290 | 282 | $(INSTALL_PROGRAM) $(OUTPUT)cpupower $(DESTDIR)${bindir} |
|---|
| 283 | + $(INSTALL) -d $(DESTDIR)${bash_completion_dir} |
|---|
| 284 | + $(INSTALL_SCRIPT) cpupower-completion.sh '$(DESTDIR)${bash_completion_dir}/cpupower' |
|---|
| 291 | 285 | |
|---|
| 292 | 286 | install-man: |
|---|
| 293 | 287 | $(INSTALL_DATA) -D man/cpupower.1 $(DESTDIR)${mandir}/man1/cpupower.1 |
|---|
| .. | .. |
|---|
| 299 | 293 | $(INSTALL_DATA) -D man/cpupower-info.1 $(DESTDIR)${mandir}/man1/cpupower-info.1 |
|---|
| 300 | 294 | $(INSTALL_DATA) -D man/cpupower-monitor.1 $(DESTDIR)${mandir}/man1/cpupower-monitor.1 |
|---|
| 301 | 295 | |
|---|
| 302 | | -install-gmo: |
|---|
| 296 | +install-gmo: create-gmo |
|---|
| 303 | 297 | $(INSTALL) -d $(DESTDIR)${localedir} |
|---|
| 304 | 298 | for HLANG in $(LANGUAGES); do \ |
|---|
| 305 | 299 | echo '$(INSTALL_DATA) -D $(OUTPUT)po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo'; \ |
|---|
| 306 | 300 | $(INSTALL_DATA) -D $(OUTPUT)po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo; \ |
|---|
| 307 | 301 | done; |
|---|
| 308 | 302 | |
|---|
| 309 | | -install-bench: |
|---|
| 303 | +install-bench: compile-bench |
|---|
| 310 | 304 | @#DESTDIR must be set from outside to survive |
|---|
| 311 | 305 | @sbindir=$(sbindir) bindir=$(bindir) docdir=$(docdir) confdir=$(confdir) $(MAKE) -C bench O=$(OUTPUT) install |
|---|
| 312 | 306 | |
|---|