aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Dokuchaev <danfe@FreeBSD.org>2023-03-24 08:57:52 +0000
committerAlexey Dokuchaev <danfe@FreeBSD.org>2023-03-24 08:57:52 +0000
commit3eeb03bdd42b88a8b366bba07afa567db6722922 (patch)
tree882fc4c60e0439091f33432d306cca7783ba8de0
parentd7b9c1eed7fd2f388171ff323638c0610717a50f (diff)
downloadports-3eeb03bdd42b88a8b366bba07afa567db6722922.tar.gz
ports-3eeb03bdd42b88a8b366bba07afa567db6722922.zip
sysutils/powermon: report modern CPU models (via sysutils/libcpuid)
This program had not seen updates since 2017 and thus cannot report newer CPU models (the list of known ones is hardcoded). Use simple library call instead of manually decoding the CPU code name. While here, simplify the installation recipe in `do-install' target and append to our default {C,LD}FLAGS rather than overwriting them. Requested by: Dmitry Lukhtionov
-rw-r--r--sysutils/powermon/Makefile16
-rw-r--r--sysutils/powermon/files/patch-Makefile15
-rw-r--r--sysutils/powermon/files/patch-src_cpuid.c34
3 files changed, 57 insertions, 8 deletions
diff --git a/sysutils/powermon/Makefile b/sysutils/powermon/Makefile
index 6b5de4c0a31c..b688dfca82bc 100644
--- a/sysutils/powermon/Makefile
+++ b/sysutils/powermon/Makefile
@@ -1,6 +1,7 @@
PORTNAME= powermon
PORTVERSION= 1.0.0
DISTVERSIONPREFIX= v
+PORTREVISION= 1
CATEGORIES= sysutils
MAINTAINER= yamagi@yamagi.org
@@ -13,20 +14,19 @@ LICENSE_FILE= ${WRKSRC}/LICENSE
ONLY_FOR_ARCHS= amd64
ONLY_FOR_ARCHS_REASON= specific to recent x86 processors
-USE_GITHUB= yes
-GH_ACCOUNT= yamagi
+LIB_DEPENDS= libcpuid.so:sysutils/libcpuid
USES= gmake ncurses
+USE_GITHUB= yes
+GH_ACCOUNT= yamagi
+MAKE_ENV= NCURSESLIBS="${NCURSESLIBS}" VERBOSE=1
PLIST_FILES= man/man8/powermon.8.gz sbin/powermon
-post-patch:
- ${REINPLACE_CMD} 's/-lcursesw/${NCURSESLIBS}/g' ${WRKSRC}/Makefile
-
do-install:
- ${INSTALL_PROGRAM} ${WRKDIR}/${PORTNAME}-${PORTVERSION}/release/powermon \
- ${STAGEDIR}${PREFIX}/sbin/powermon
- ${INSTALL_MAN} ${WRKDIR}/${PORTNAME}-${PORTVERSION}/misc/powermon.8 \
+ ${INSTALL_PROGRAM} ${INSTALL_WRKSRC}/release/powermon \
+ ${STAGEDIR}${PREFIX}/sbin
+ ${INSTALL_MAN} ${INSTALL_WRKSRC}/misc/powermon.8 \
${STAGEDIR}${MANPREFIX}/man/man8
.include <bsd.port.mk>
diff --git a/sysutils/powermon/files/patch-Makefile b/sysutils/powermon/files/patch-Makefile
new file mode 100644
index 000000000000..2a1c69684ac5
--- /dev/null
+++ b/sysutils/powermon/files/patch-Makefile
@@ -0,0 +1,15 @@
+--- Makefile.orig 2017-07-03 16:04:31 UTC
++++ Makefile
+@@ -1,9 +1,9 @@
+ # Base CFLAGS
+-CFLAGS := -O2 -fomit-frame-pointer -std=c99 \
+- -pedantic -Wall -Wextra -MMD -pipe
++CFLAGS += -std=c99 -pedantic -Wall -Wextra -MMD \
++ -I$(LOCALBASE)/include -DUSE_LIBCPUID
+
+ # Base LDFLAGS
+-LDFLAGS := -lcursesw -lm
++LDFLAGS += $(NCURSESLIBS) -lm -L$(LOCALBASE)/lib -lcpuid
+
+ # -----------
+
diff --git a/sysutils/powermon/files/patch-src_cpuid.c b/sysutils/powermon/files/patch-src_cpuid.c
new file mode 100644
index 000000000000..8b5dfa2ba38c
--- /dev/null
+++ b/sysutils/powermon/files/patch-src_cpuid.c
@@ -0,0 +1,34 @@
+--- src/cpuid.c.orig 2017-07-03 16:04:31 UTC
++++ src/cpuid.c
+@@ -32,6 +32,9 @@
+ #include <sys/cpuctl.h>
+ #include <sys/errno.h>
+ #include <sys/ioctl.h>
++#ifdef USE_LIBCPUID
++#include <libcpuid/libcpuid.h>
++#endif
+
+ #include "cpuid.h"
+
+@@ -176,6 +179,13 @@ void getcpuvendor(char *vendor, size_t vendor_len) {
+ * Returns the CPU family.
+ */
+ const char *getcpufamily(void) {
++#ifdef USE_LIBCPUID
++ struct cpu_raw_data_t raw;
++ static struct cpu_id_t id;
++
++ return (cpuid_get_raw_data(&raw) == 0 && cpu_identify(&raw, &id) == 0)
++ ? id.cpu_codename : "Unknown";
++#else
+ cpuctl_cpuid_count_args_t cpuid;
+
+ cpuid.level = 0x1;
+@@ -240,6 +250,7 @@ const char *getcpufamily(void) {
+ return "Unknown";
+ break;
+ }
++#endif
+ }
+
+