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