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