aboutsummaryrefslogtreecommitdiffstats
path: root/tools/power
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2011-04-20 14:01:39 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2011-07-29 12:35:39 -0400
commitaf594f0ceb73c5bd984c89f3386bd7e8ecc471f5 (patch)
tree9960b1ff6d27cf096961f0c8012ec0489bc6301e /tools/power
parenta1ce5ba2b7d08ab6347dc254f86f70e91c5f1a44 (diff)
cpupowerutils: use kernel version-derived version string
As cpupowerutils is intended to be included into the kernel sources, use the kernel versioning instead of a custom version. The script utils/version-gen.sh is largely based on the script already found in tools/perf/util/PERF-VERSION-GEN . Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'tools/power')
-rw-r--r--tools/power/cpupower/Makefile13
-rwxr-xr-xtools/power/cpupower/utils/version-gen.sh35
2 files changed, 41 insertions, 7 deletions
diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile
index 62c2716a9588..90d079e0e48d 100644
--- a/tools/power/cpupower/Makefile
+++ b/tools/power/cpupower/Makefile
@@ -47,7 +47,7 @@ DESTDIR ?=
47# Package-related definitions. Distributions can modify the version 47# Package-related definitions. Distributions can modify the version
48# and _should_ modify the PACKAGE_BUGREPORT definition 48# and _should_ modify the PACKAGE_BUGREPORT definition
49 49
50VERSION = 009p1 50VERSION= $(shell ./utils/version-gen.sh)
51LIB_MAJ= 0.0.0 51LIB_MAJ= 0.0.0
52LIB_MIN= 0 52LIB_MIN= 0
53 53
@@ -110,7 +110,7 @@ WARNINGS += $(call cc-supports,-Wno-pointer-sign)
110WARNINGS += $(call cc-supports,-Wdeclaration-after-statement) 110WARNINGS += $(call cc-supports,-Wdeclaration-after-statement)
111WARNINGS += -Wshadow 111WARNINGS += -Wshadow
112 112
113CPPFLAGS += -DVERSION=\"$(VERSION)\" -DPACKAGE=\"$(PACKAGE)\" \ 113CFLAGS += -DVERSION=\"$(VERSION)\" -DPACKAGE=\"$(PACKAGE)\" \
114 -DPACKAGE_BUGREPORT=\"$(PACKAGE_BUGREPORT)\" -D_GNU_SOURCE 114 -DPACKAGE_BUGREPORT=\"$(PACKAGE_BUGREPORT)\" -D_GNU_SOURCE
115 115
116UTIL_OBJS = utils/helpers/amd.o utils/helpers/topology.o utils/helpers/msr.o \ 116UTIL_OBJS = utils/helpers/amd.o utils/helpers/topology.o utils/helpers/msr.o \
@@ -157,8 +157,7 @@ export QUIET ECHO
157 157
158# if DEBUG is enabled, then we do not strip or optimize 158# if DEBUG is enabled, then we do not strip or optimize
159ifeq ($(strip $(DEBUG)),true) 159ifeq ($(strip $(DEBUG)),true)
160 CFLAGS += -O1 -g 160 CFLAGS += -O1 -g -DDEBUG
161 CPPFLAGS += -DDEBUG
162 STRIPCMD = /bin/true -Since_we_are_debugging 161 STRIPCMD = /bin/true -Since_we_are_debugging
163else 162else
164 CFLAGS += $(OPTIMIZATION) -fomit-frame-pointer 163 CFLAGS += $(OPTIMIZATION) -fomit-frame-pointer
@@ -172,11 +171,11 @@ all: libcpufreq cpupower $(COMPILE_NLS) $(COMPILE_BENCH)
172 171
173lib/%.o: $(LIB_SRC) $(LIB_HEADERS) 172lib/%.o: $(LIB_SRC) $(LIB_HEADERS)
174 $(ECHO) " CC " $@ 173 $(ECHO) " CC " $@
175 $(QUIET) $(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -o $@ -c lib/$*.c 174 $(QUIET) $(CC) $(CFLAGS) -fPIC -o $@ -c lib/$*.c
176 175
177libcpufreq.so.$(LIB_MAJ): $(LIB_OBJS) 176libcpufreq.so.$(LIB_MAJ): $(LIB_OBJS)
178 $(ECHO) " LD " $@ 177 $(ECHO) " LD " $@
179 $(QUIET) $(CC) -shared $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ \ 178 $(QUIET) $(CC) -shared $(CFLAGS) $(LDFLAGS) -o $@ \
180 -Wl,-soname,libcpufreq.so.$(LIB_MIN) $(LIB_OBJS) 179 -Wl,-soname,libcpufreq.so.$(LIB_MIN) $(LIB_OBJS)
181 @ln -sf $@ libcpufreq.so 180 @ln -sf $@ libcpufreq.so
182 @ln -sf $@ libcpufreq.so.$(LIB_MIN) 181 @ln -sf $@ libcpufreq.so.$(LIB_MIN)
@@ -189,7 +188,7 @@ $(UTIL_OBJS): $(UTIL_HEADERS)
189 188
190.c.o: 189.c.o:
191 $(ECHO) " CC " $@ 190 $(ECHO) " CC " $@
192 $(QUIET) $(CC) $(CFLAGS) $(CPPFLAGS) -I./lib -I ./utils -o $@ -c $*.c 191 $(QUIET) $(CC) $(CFLAGS) -I./lib -I ./utils -o $@ -c $*.c
193 192
194cpupower: $(UTIL_OBJS) libcpufreq.so.$(LIB_MAJ) 193cpupower: $(UTIL_OBJS) libcpufreq.so.$(LIB_MAJ)
195 $(ECHO) " CC " $@ 194 $(ECHO) " CC " $@
diff --git a/tools/power/cpupower/utils/version-gen.sh b/tools/power/cpupower/utils/version-gen.sh
new file mode 100755
index 000000000000..5ec41c556992
--- /dev/null
+++ b/tools/power/cpupower/utils/version-gen.sh
@@ -0,0 +1,35 @@
1#!/bin/sh
2#
3# Script which prints out the version to use for building cpupowerutils.
4# Must be called from tools/power/cpupower/
5#
6# Heavily based on tools/perf/util/PERF-VERSION-GEN .
7
8LF='
9'
10
11# First check if there is a .git to get the version from git describe
12# otherwise try to get the version from the kernel makefile
13if test -d ../../../.git -o -f ../../../.git &&
14 VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
15 case "$VN" in
16 *$LF*) (exit 1) ;;
17 v[0-9]*)
18 git update-index -q --refresh
19 test -z "$(git diff-index --name-only HEAD --)" ||
20 VN="$VN-dirty" ;;
21 esac
22then
23 VN=$(echo "$VN" | sed -e 's/-/./g');
24else
25 eval $(grep '^VERSION[[:space:]]*=' ../../../Makefile|tr -d ' ')
26 eval $(grep '^PATCHLEVEL[[:space:]]*=' ../../../Makefile|tr -d ' ')
27 eval $(grep '^SUBLEVEL[[:space:]]*=' ../../../Makefile|tr -d ' ')
28 eval $(grep '^EXTRAVERSION[[:space:]]*=' ../../../Makefile|tr -d ' ')
29
30 VN="${VERSION}.${PATCHLEVEL}.${SUBLEVEL}${EXTRAVERSION}"
31fi
32
33VN=$(expr "$VN" : v*'\(.*\)')
34
35echo $VN