diff options
Diffstat (limited to 'meta-oe/recipes-kernel/turbostat/turbostat.bb')
-rw-r--r-- | meta-oe/recipes-kernel/turbostat/turbostat.bb | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/meta-oe/recipes-kernel/turbostat/turbostat.bb b/meta-oe/recipes-kernel/turbostat/turbostat.bb new file mode 100644 index 0000000000..f65699865e --- /dev/null +++ b/meta-oe/recipes-kernel/turbostat/turbostat.bb | |||
@@ -0,0 +1,99 @@ | |||
1 | # | ||
2 | # Copyright (C) 2013 Wind River Systems, Inc. | ||
3 | # | ||
4 | # This program is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License version 2 as | ||
6 | # published by the Free Software Foundation. | ||
7 | # | ||
8 | SUMMARY = "Frequency and Idle power monitoring tools for Linux" | ||
9 | |||
10 | DESCRIPTION = "The turbostat tool allows you to determine the actual \ | ||
11 | processor frequency and idle power saving state residency on supported \ | ||
12 | processors." | ||
13 | |||
14 | LICENSE = "GPL-2.0-only" | ||
15 | LIC_FILES_CHKSUM = "file://${UNPACKDIR}/COPYING;md5=bbea815ee2795b2f4230826c0c6b8814" | ||
16 | COMPATIBLE_HOST = '(x86_64.*|i.86.*)-linux' | ||
17 | COMPATIBLE_HOST:libc-musl = "null" | ||
18 | |||
19 | KERNEL_VERSION = "${@get_kernelversion_file("${STAGING_KERNEL_BUILDDIR}")}" | ||
20 | inherit linux-kernel-base | ||
21 | |||
22 | SRC_URI += "\ | ||
23 | file://COPYING \ | ||
24 | " | ||
25 | |||
26 | S = "${UNPACKDIR}" | ||
27 | |||
28 | PACKAGE_ARCH = "${MACHINE_ARCH}" | ||
29 | DEPENDS = "libcap" | ||
30 | |||
31 | # This looks in S, so we better make sure there's | ||
32 | # something in the directory. | ||
33 | # | ||
34 | do_populate_lic[depends] = "${PN}:do_configure" | ||
35 | |||
36 | |||
37 | EXTRA_OEMAKE = '\ | ||
38 | CC="${CC}" 'CFLAGS=-Wall ${LDFLAGS}' \ | ||
39 | ' | ||
40 | |||
41 | # If we build under STAGING_KERNEL_DIR, source will not be put | ||
42 | # into the dbg rpm. STAGING_KERNEL_DIR will exist by the time | ||
43 | # do_configure() is invoked so we can safely copy from it. | ||
44 | # | ||
45 | do_configure[depends] += "virtual/kernel:do_shared_workdir" | ||
46 | do_configure:prepend() { | ||
47 | mkdir -p ${S} | ||
48 | cp -r ${STAGING_KERNEL_DIR}/arch/x86/include/asm/msr-index.h ${S} | ||
49 | cp -r ${STAGING_KERNEL_DIR}/arch/x86/include/asm/intel-family.h ${S} | ||
50 | if [ -f "${STAGING_KERNEL_DIR}/include/vdso/bits.h" ]; then | ||
51 | cp -r ${STAGING_KERNEL_DIR}/include/vdso/bits.h ${S} | ||
52 | cp -r ${STAGING_KERNEL_DIR}/include/vdso/const.h ${S} | ||
53 | else | ||
54 | cp -r ${STAGING_KERNEL_DIR}/include/linux/bits.h ${S} | ||
55 | cp -r ${STAGING_KERNEL_DIR}/include/linux/const.h ${S} | ||
56 | fi | ||
57 | if [ -f "${STAGING_KERNEL_DIR}/tools/include/linux/build_bug.h" ]; then | ||
58 | cp -r ${STAGING_KERNEL_DIR}/tools/include/linux/build_bug.h ${S} | ||
59 | fi | ||
60 | cp -r ${STAGING_KERNEL_DIR}/tools/include/linux/compiler.h ${S} | ||
61 | cp -r ${STAGING_KERNEL_DIR}/tools/include/linux/compiler_types.h ${S} | ||
62 | cp -r ${STAGING_KERNEL_DIR}/tools/include/linux/compiler-gcc.h ${S} | ||
63 | cp -r ${STAGING_KERNEL_DIR}/tools/power/x86/turbostat/* ${S} | ||
64 | } | ||
65 | |||
66 | |||
67 | do_compile() { | ||
68 | sed -i 's#<linux/bits.h>#"bits.h"#' msr-index.h | ||
69 | sed -i 's#<linux/compiler.h>#"compiler.h"#' build_bug.h | ||
70 | sed -i 's#<linux/compiler_types.h>#"compiler_types.h"#' compiler.h | ||
71 | sed -i 's#<linux/compiler-gcc.h>#"compiler-gcc.h"#' compiler_types.h | ||
72 | 'TMPCHECK='grep "<vdso/const.h>" bits.h'' || true | ||
73 | if [ -n $TMPCHECK ]; then | ||
74 | sed -i 's#<vdso/const.h>#"const.h"#' bits.h | ||
75 | sed -i 's#<uapi/linux/const.h>#<linux/const.h>#' const.h | ||
76 | else | ||
77 | sed -i 's#<linux/const.h>#"const.h"#' bits.h | ||
78 | sed -i -e 's#<uapi/linux/const.h>#<linux/const.h>#' -e 's#_LINUX_CONST_H#_LINUX_CONST_H_KERNEL#' const.h | ||
79 | fi | ||
80 | echo '#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))' >> msr-index.h | ||
81 | echo "#define BIT(x) (1 << (x))" > bits.h | ||
82 | echo "#define BIT_ULL(nr) (1ULL << (nr))" >> bits.h | ||
83 | echo "#define GENMASK(h, l) (((~0UL) << (l)) & (~0UL >> (sizeof(long) * 8 - 1 - (h))))" >> bits.h | ||
84 | echo "#define GENMASK_ULL(h, l) (((~0ULL) << (l)) & (~0ULL >> (sizeof(long long) * 8 - 1 - (h))))" >> bits.h | ||
85 | |||
86 | sed -i 's#MSRHEADER#"msr-index.h"#' turbostat.c | ||
87 | sed -i 's#INTEL_FAMILY_HEADER#"intel-family.h"#' turbostat.c | ||
88 | sed -i 's#BUILD_BUG_HEADER#"build_bug.h"#' turbostat.c | ||
89 | sed -i 's#\$(CC) \$(CFLAGS) \$< -o \$(BUILD_OUTPUT)/\$@#\$(CC) \$(CFLAGS) \$(LDFLAGS) \$< -o \$(BUILD_OUTPUT)/\$@#' Makefile | ||
90 | oe_runmake STAGING_KERNEL_DIR=${STAGING_KERNEL_DIR} | ||
91 | } | ||
92 | |||
93 | do_install() { | ||
94 | oe_runmake DESTDIR="${D}" install | ||
95 | } | ||
96 | |||
97 | python do_package:prepend() { | ||
98 | d.setVar('PKGV', d.getVar("KERNEL_VERSION").split("-")[0]) | ||
99 | } | ||