hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/tools/power/cpupower/Makefile
....@@ -1,3 +1,4 @@
1
+# SPDX-License-Identifier: GPL-2.0-only
12 # Makefile for cpupower
23 #
34 # Copyright (C) 2005,2006 Dominik Brodowski <linux@dominikbrodowski.net>
....@@ -5,19 +6,6 @@
56 # Based largely on the Makefile for udev by:
67 #
78 # 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
219 #
2210 OUTPUT=./
2311 ifeq ("$(origin O)", "command line")
....@@ -30,7 +18,6 @@
3018 $(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist))
3119 endif
3220
33
-include ../../scripts/Makefile.arch
3421
3522 # --- CONFIGURATION BEGIN ---
3623
....@@ -64,7 +51,7 @@
6451 # Package-related definitions. Distributions can modify the version
6552 # and _should_ modify the PACKAGE_BUGREPORT definition
6653
67
-VERSION= $(shell ./utils/version-gen.sh)
54
+VERSION:= $(shell ./utils/version-gen.sh)
6855 LIB_MAJ= 0.0.1
6956 LIB_MIN= 0
7057
....@@ -81,14 +68,10 @@
8168 sbindir ?= /usr/sbin
8269 mandir ?= /usr/man
8370 includedir ?= /usr/include
84
-ifeq ($(IS_64_BIT), 1)
85
-libdir ?= /usr/lib64
86
-else
87
-libdir ?= /usr/lib
88
-endif
8971 localedir ?= /usr/share/locale
9072 docdir ?= /usr/share/doc/packages/cpupower
9173 confdir ?= /etc/
74
+bash_completion_dir ?= /usr/share/bash-completion/completions
9275
9376 # Toolchain: what tools do we use, and what options do they need:
9477
....@@ -96,7 +79,8 @@
9679 INSTALL = /usr/bin/install -c
9780 INSTALL_PROGRAM = ${INSTALL}
9881 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
10084
10185 # If you are running a cross compiler, you may want to set this
10286 # to something more interesting, like "arm-linux-". If you want
....@@ -110,6 +94,14 @@
11094 HOSTCC = gcc
11195 MKDIR = mkdir
11296
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
113105
114106 # Now we set up the build system
115107 #
....@@ -129,7 +121,7 @@
129121 WARNINGS += $(call cc-supports,-Wdeclaration-after-statement)
130122 WARNINGS += -Wshadow
131123
132
-CFLAGS += -DVERSION=\"$(VERSION)\" -DPACKAGE=\"$(PACKAGE)\" \
124
+override CFLAGS += -DVERSION=\"$(VERSION)\" -DPACKAGE=\"$(PACKAGE)\" \
133125 -DPACKAGE_BUGREPORT=\"$(PACKAGE_BUGREPORT)\" -D_GNU_SOURCE
134126
135127 UTIL_OBJS = utils/helpers/amd.o utils/helpers/msr.o \
....@@ -156,12 +148,12 @@
156148 LIB_OBJS = lib/cpufreq.o lib/cpupower.o lib/cpuidle.o
157149 LIB_OBJS := $(addprefix $(OUTPUT),$(LIB_OBJS))
158150
159
-CFLAGS += -pipe
151
+override CFLAGS += -pipe
160152
161153 ifeq ($(strip $(NLS)),true)
162154 INSTALL_NLS += install-gmo
163155 COMPILE_NLS += create-gmo
164
- CFLAGS += -DNLS
156
+ override CFLAGS += -DNLS
165157 endif
166158
167159 ifeq ($(strip $(CPUFREQ_BENCH)),true)
....@@ -175,7 +167,7 @@
175167 UTIL_SRC += $(LIB_SRC)
176168 endif
177169
178
-CFLAGS += $(WARNINGS)
170
+override CFLAGS += $(WARNINGS)
179171
180172 ifeq ($(strip $(V)),false)
181173 QUIET=@
....@@ -188,10 +180,10 @@
188180
189181 # if DEBUG is enabled, then we do not strip or optimize
190182 ifeq ($(strip $(DEBUG)),true)
191
- CFLAGS += -O1 -g -DDEBUG
183
+ override CFLAGS += -O1 -g -DDEBUG
192184 STRIPCMD = /bin/true -Since_we_are_debugging
193185 else
194
- CFLAGS += $(OPTIMIZATION) -fomit-frame-pointer
186
+ override CFLAGS += $(OPTIMIZATION) -fomit-frame-pointer
195187 STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
196188 endif
197189
....@@ -278,16 +270,18 @@
278270 $(MAKE) -C bench O=$(OUTPUT) clean
279271
280272
281
-install-lib:
273
+install-lib: libcpupower
282274 $(INSTALL) -d $(DESTDIR)${libdir}
283275 $(CP) $(OUTPUT)libcpupower.so* $(DESTDIR)${libdir}/
284276 $(INSTALL) -d $(DESTDIR)${includedir}
285277 $(INSTALL_DATA) lib/cpufreq.h $(DESTDIR)${includedir}/cpufreq.h
286278 $(INSTALL_DATA) lib/cpuidle.h $(DESTDIR)${includedir}/cpuidle.h
287279
288
-install-tools:
280
+install-tools: $(OUTPUT)cpupower
289281 $(INSTALL) -d $(DESTDIR)${bindir}
290282 $(INSTALL_PROGRAM) $(OUTPUT)cpupower $(DESTDIR)${bindir}
283
+ $(INSTALL) -d $(DESTDIR)${bash_completion_dir}
284
+ $(INSTALL_SCRIPT) cpupower-completion.sh '$(DESTDIR)${bash_completion_dir}/cpupower'
291285
292286 install-man:
293287 $(INSTALL_DATA) -D man/cpupower.1 $(DESTDIR)${mandir}/man1/cpupower.1
....@@ -299,14 +293,14 @@
299293 $(INSTALL_DATA) -D man/cpupower-info.1 $(DESTDIR)${mandir}/man1/cpupower-info.1
300294 $(INSTALL_DATA) -D man/cpupower-monitor.1 $(DESTDIR)${mandir}/man1/cpupower-monitor.1
301295
302
-install-gmo:
296
+install-gmo: create-gmo
303297 $(INSTALL) -d $(DESTDIR)${localedir}
304298 for HLANG in $(LANGUAGES); do \
305299 echo '$(INSTALL_DATA) -D $(OUTPUT)po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo'; \
306300 $(INSTALL_DATA) -D $(OUTPUT)po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo; \
307301 done;
308302
309
-install-bench:
303
+install-bench: compile-bench
310304 @#DESTDIR must be set from outside to survive
311305 @sbindir=$(sbindir) bindir=$(bindir) docdir=$(docdir) confdir=$(confdir) $(MAKE) -C bench O=$(OUTPUT) install
312306