Bug 275141 - [NEW PORT] x11/wlopm
Summary: [NEW PORT] x11/wlopm
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Robert Clausecker
URL: https://git.sr.ht/~leon_plickat/wlopm
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-16 21:34 UTC by Tino Engel
Modified: 2023-11-19 06:55 UTC (History)
3 users (show)

See Also:
tino.engel: maintainer-feedback+


Attachments
result of 'git format-patch origin/main' (2.21 KB, patch)
2023-11-16 21:34 UTC, Tino Engel
no flags Details | Diff
result of 'git format-patch origin/main' after fixes (4.48 KB, patch)
2023-11-17 16:51 UTC, Tino Engel
no flags Details | Diff
patch I plan to commit (3.52 KB, patch)
2023-11-18 08:40 UTC, Robert Clausecker
tino.engel: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tino Engel 2023-11-16 21:34:09 UTC
Created attachment 246362 [details]
result of 'git format-patch origin/main'

Attached is a patch which introduces a new port, wlopm (Wayland output power management).
Upstream description: Simple client implementing zwlr-output-power-management-v1.
Project page: https://git.sr.ht/~leon_plickat/wlopm

NOTE: 2 warnings stay in portlint. The structure of the upstream make procedure required the use of DISTFILES.
Comment 1 Oleh Vinichenko 2023-11-17 06:54:56 UTC
thanks for the port. i had brief talk with wlomp author about clang compilation. indeed, by default wlomp wouldn't compile with clang but adding "-Wno-strict-prototypes" to CFLAGS would be sufficient for successfull compilation. This, then, avoids having gcc as compiler. I am not sure about gmake.
Comment 2 Tino Engel 2023-11-17 07:54:07 UTC
I tried "-Wno-strict-prototypes", but compilation still fails with error
wlopm.c:96:18: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
Adding -Werror,-Wstrict-prototypes as mentioned in the error message also does not fix the problem.

Trying to use make instead of gmake I also end up with errors.

I am unsure how to proceed, since using clang (and non-g-make) would be the better variant, but I am not able at the moment to make it compile then.
Comment 3 Oleh Vinichenko 2023-11-17 08:10:54 UTC
can you, please, add full error.
Comment 4 Tino Engel 2023-11-17 08:16:47 UTC
Below the error without USE_GCC but with -Wno-strict-prototypes:
=================

lgrande@elfreebsdo1:~/git/PERSONAL/freebsd-ports/x11/wlopm % cat Makefile
PORTNAME=	wlopm
PORTVERSION=	0.1.0
DISTVERSIONPREFIX=	v
CATEGORIES=	x11 wayland
MASTER_SITES=	https://git.sr.ht/~leon_plickat/${PORTNAME}/archive/
DISTFILES=	${DISTVERSIONFULL}${EXTRACT_SUFX}
DIST_SUBDIR=	wlopm

MAINTAINER=	tino.engel@mail.de
COMMENT=	Wayland output power management
WWW=		https://git.sr.ht/~leon_plickat/wlopm

LICENSE=	GPLv3
LICENSE_FILE=	${WRKSRC}/LICENSE

BUILD_DEPENDS=	wayland-scanner:graphics/wayland
LIB_DEPENDS=	libwayland-client.so:graphics/wayland

USES=		gmake
#USE_GCC=	yes

ALL_TARGET=	wlopm

CFLAGS+=	-Wall -Werror -Wextra -Wpedantic -Wno-unused-parameter \
		-Wconversion -Wformat-security -Wformat -Wsign-conversion \
		-Wfloat-conversion -Wunused-result -I${LOCALBASE}/include \
		-Wno-strict-prototypes
LDFLAGS+=	-L${LOCALBASE}/lib

LIBS=		-lwayland-client

PLIST_FILES=	bin/wlopm \
		share/man/man1/wlopm.1.gz

do-install:
	${INSTALL} ${WRKSRC}/wlopm ${STAGEDIR}${PREFIX}/bin/wlopm
	${INSTALL_DATA} ${WRKSRC}/wlopm.1 ${STAGEDIR}${PREFIX}/share/man/man1/wlopm.1

.include <bsd.port.mk>
elgrande@elfreebsdo1:~/git/PERSONAL/freebsd-ports/x11/wlopm % make
===>  License GPLv3 accepted by the user
===>   wlopm-0.1.0 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by wlopm-0.1.0 for building
===>  Extracting for wlopm-0.1.0
=> SHA256 Checksum OK for wlopm/v0.1.0.tar.gz.
===>  Patching for wlopm-0.1.0
===>   wlopm-0.1.0 depends on executable: wayland-scanner - found
===>   wlopm-0.1.0 depends on package: gmake>=4.3 - found
===>   wlopm-0.1.0 depends on shared library: libwayland-client.so - found (/usr/local/lib/libwayland-client.so)
===>  Configuring for wlopm-0.1.0
===>  Building for wlopm-0.1.0
gmake[1]: Entering directory '/usr/home/elgrande/git/PERSONAL/freebsd-ports/x11/wlopm/work/wlopm-v0.1.0'
wayland-scanner private-code < wlr-output-power-management-unstable-v1.xml > wlr-output-power-management-unstable-v1.c
wayland-scanner client-header < wlr-output-power-management-unstable-v1.xml > wlr-output-power-management-unstable-v1.h
cc -O2 -pipe  -Wall -Werror -Wextra -Wpedantic -Wno-unused-parameter -Wconversion -Wformat-security -Wformat -Wsign-conversion -Wfloat-conversion -Wunused-result -I/usr/local/include -Wno-strict-prototypes -fstack-protector-strong -fno-strict-aliasing  -Wall -Werror -Wextra -Wpedantic -Wno-unused-parameter -Wconversion -Wformat-security -Wformat -Wsign-conversion -Wfloat-conversion -Wunused-result   -c -o wlopm.o wlopm.c
cc -O2 -pipe  -Wall -Werror -Wextra -Wpedantic -Wno-unused-parameter -Wconversion -Wformat-security -Wformat -Wsign-conversion -Wfloat-conversion -Wunused-result -I/usr/local/include -Wno-strict-prototypes -fstack-protector-strong -fno-strict-aliasing  -Wall -Werror -Wextra -Wpedantic -Wno-unused-parameter -Wconversion -Wformat-security -Wformat -Wsign-conversion -Wfloat-conversion -Wunused-result   -c -o wlr-output-power-management-unstable-v1.o wlr-output-power-management-unstable-v1.c
wlopm.c:96:18: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
static void noop () {}
                 ^
                  void
1 error generated.
gmake[1]: *** [<builtin>: wlopm.o] Error 1
gmake[1]: Leaving directory '/usr/home/elgrande/git/PERSONAL/freebsd-ports/x11/wlopm/work/wlopm-v0.1.0'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make: stopped in /usr/home/elgrande/git/PERSONAL/freebsd-ports/x11/wlopm
elgrande@elfreebsdo1:~/git/PERSONAL/freebsd-ports/x11/wlopm %
Comment 5 Oleh Vinichenko 2023-11-17 11:45:25 UTC
it maybe that flag is slightly incorrect. Please, try:
-Wno-error=strict-prototypes
Comment 6 Tino Engel 2023-11-17 11:49:43 UTC
Also with -Werror=strict-prototypes the same error occurs:

gmake[1]: Entering directory '/usr/home/elgrande/git/PERSONAL/freebsd-ports/x11/wlopm/work/wlopm-v0.1.0'
cc -O2 -pipe  -Wall -Werror -Wextra -Wpedantic -Wno-unused-parameter -Wconversion -Wformat-security -Wformat -Wsign-conversion -Wfloat-conversion -Wunused-result -I/usr/local/include -Werror=strict-prototypes -fstack-protector-strong -fno-strict-aliasing  -Wall -Werror -Wextra -Wpedantic -Wno-unused-parameter -Wconversion -Wformat-security -Wformat -Wsign-conversion -Wfloat-conversion -Wunused-result   -c -o wlopm.o wlopm.c
wlopm.c:96:18: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
static void noop () {}
                 ^
                  void
1 error generated.
Comment 7 Tino Engel 2023-11-17 13:10:40 UTC
Info:
I am currently digging into this.
What I see: when I build the port using 'make' and the go to work subdir, I can compile with clang issuing:
clang -c -v -I/usr/local/include wlopm.c -o wlopm.o
I skipped linking for convenience, it is just about proving clang can actually compile this. Well it can, but somehow not yet via the port Makefile.
Comment 8 Oleh Vinichenko 2023-11-17 13:21:47 UTC
maybe it is worth removing all the CFLAGS and linking part for the start and then selectively add what is needed.
Comment 9 Tino Engel 2023-11-17 15:50:42 UTC
tried that in various ways.
it somehow seems as if clang ignores "-Wno-strict-prototypes" completely. I can see in the terminal, that the argument is passed to cc. anyhow it still complains about missing strict prototypes.
maybe clang is behaving strange here?
Comment 10 Tino Engel 2023-11-17 16:34:45 UTC
ok, got it working.
the problem was: the upstream Makefile explicitly sets "-Werror" which undoes the required "-Wno-error".
you can see the current status at https://github.com/elgithubo/freebsd-ports/tree/main/x11/wlopm .

Shall I/we also investigate if gmake can be substituted by make?
Comment 11 Tino Engel 2023-11-17 16:51:06 UTC
Created attachment 246374 [details]
result of 'git format-patch origin/main'  after fixes

Seems at a first glance, substituting gmake by make would require further patches.

I have created a second patch for the current version, it can be added to the ports tree, if this state is sufficient.
Comment 12 Robert Clausecker freebsd_committer freebsd_triage 2023-11-18 07:03:14 UTC
I strongly recommend patching out -Werror out of any Makefiles for FreeBSD ports.  Compiler warnings change all the time; with -Werror, that means perfectly fine ports break randomly and need to be fixed.  This just causes a bunch of needless churn.
Comment 13 Tino Engel 2023-11-18 07:18:53 UTC
I also have a bad feeling about removing -Werror.
Anyhow we need to decide if we want either
- remove -Werror from upstream Makefile
or
- use gcc instead of clang.
I double checked, it definitely is the -Werror in the upstream Makefile, that causes the compilation error with clang. This is also indicated by the error message 
"wlopm.c:96:18: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]", I need to switch _both_ mentioned parameters to "no-*" otherwise compilation fails.
Comment 14 Oleh Vinichenko 2023-11-18 07:35:10 UTC
filtering out -Werror is a common practice in downstream maintenance. it should not be too worrying. My personal take is to stick with default compiler that is clang.
Comment 15 Tino Engel 2023-11-18 08:01:58 UTC
I am open for both variants, but I actually also would prefer to use clang as default compiler.
The final decision/approval  needs to be made by the person who commits this to the freebsd ports tree.
Comment 16 Robert Clausecker freebsd_committer freebsd_triage 2023-11-18 08:16:02 UTC
As a committer, I strongly preferred if you went the route of disabling -Werror.  It's just less of a headache down the road.

We prefer if people only used non-default compilers when the default compiler doesn't do.

If you submit a patch with a change to remove -Werror, I can commit it this weekend.
Comment 17 Tino Engel 2023-11-18 08:21:24 UTC
oh, i misread your previous reply as "I strongly recommend NOT patching out -Werror out of any Makefiles for FreeBSD ports". sorry for the confusion.

I already have created 2 patches as attachments to this ticket. if you apply 0001 and then 0002, there is a port version which patches out the -Werror and uses clang.

Is that okay, or do you need a single patch?
Comment 18 Robert Clausecker freebsd_committer freebsd_triage 2023-11-18 08:40:35 UTC
Created attachment 246384 [details]
patch I plan to commit

I've reviewed your patch and copy-edited it a little bit to make it confirm to our conventions.

Most importantly, I removed all the extra warning flags.  We do not add extra flags to the compilation unless they are needed to make the build work.

Please check the result and let me know if it is ok by setting the "maintainer-approval" flag to "+" on the patch.  If not, please submit a revised patch or let me know what to change.

I also noticed that pkg-descr is a bit short and very technical.  If you have no experience with Wayland internals, it sounds very cryptic.  Perhaps you could extend it a little and explain how a user could benefit from installing the port.
Comment 19 Tino Engel 2023-11-18 08:48:18 UTC
Comment on attachment 246384 [details]
patch I plan to commit

>From 1a80b4c2ef62410f2b979b0b639522a49d55e0c5 Mon Sep 17 00:00:00 2001
>From: Tino Engel <tino.engel@mail.de>
>Date: Thu, 16 Nov 2023 22:27:12 +0100
>Subject: [PATCH] x11/wlopm: Wayland output power management
>
>wlopm - Wayland output power management
>
>Simple client implementing zwlr-output-power-management-v1.
>
>WWW: https://git.sr.ht/~leon_plickat/wlopm
>
>PR:		275141
>---
> x11/Makefile                   |  1 +
> x11/wlopm/Makefile             | 33 +++++++++++++++++++++++++++++++++
> x11/wlopm/distinfo             |  3 +++
> x11/wlopm/files/patch-Makefile | 11 +++++++++++
> x11/wlopm/pkg-descr            |  3 +++
> 5 files changed, 51 insertions(+)
> create mode 100644 x11/wlopm/Makefile
> create mode 100644 x11/wlopm/distinfo
> create mode 100644 x11/wlopm/files/patch-Makefile
> create mode 100644 x11/wlopm/pkg-descr
>
>diff --git a/x11/Makefile b/x11/Makefile
>index f66a95f17840..6d34b41222d2 100644
>--- a/x11/Makefile
>+++ b/x11/Makefile
>@@ -431,6 +431,7 @@
>     SUBDIR += wl-clipboard
>     SUBDIR += wl-mirror
>     SUBDIR += wlogout
>+    SUBDIR += wlopm
>     SUBDIR += wlr-randr
>     SUBDIR += wlr-which-key
>     SUBDIR += wlrctl
>diff --git a/x11/wlopm/Makefile b/x11/wlopm/Makefile
>new file mode 100644
>index 000000000000..eaf77f6e9011
>--- /dev/null
>+++ b/x11/wlopm/Makefile
>@@ -0,0 +1,33 @@
>+PORTNAME=	wlopm
>+DISTVERSIONPREFIX=	v
>+DISTVERSION=	0.1.0
>+CATEGORIES=	x11 wayland
>+MASTER_SITES=	https://git.sr.ht/~leon_plickat/${PORTNAME}/archive/
>+DISTNAME=	${DISTVERSIONFULL}
>+DIST_SUBDIR=	${PORTNAME}
>+
>+MAINTAINER=	tino.engel@mail.de
>+COMMENT=	Wayland output power management
>+WWW=		https://git.sr.ht/~leon_plickat/wlopm
>+
>+LICENSE=	GPLv3
>+LICENSE_FILE=	${WRKSRC}/LICENSE
>+
>+BUILD_DEPENDS=	wayland-scanner:graphics/wayland
>+LIB_DEPENDS=	libwayland-client.so:graphics/wayland
>+
>+USES=		gmake localbase:ldflags
>+
>+ALL_TARGET=	wlopm
>+CFLAGS+=	-Wno-strict-prototypes
>+LIBS=		-lwayland-client
>+WRKSRC=		${WRKDIR}/${PORTNAME}-${DISTVERSIONFULL}
>+
>+PLIST_FILES=	bin/wlopm \
>+		share/man/man1/wlopm.1.gz
>+
>+do-install:
>+	${INSTALL_PROGRAM} ${WRKSRC}/wlopm ${STAGEDIR}${PREFIX}/bin/wlopm
>+	${INSTALL_DATA} ${WRKSRC}/wlopm.1 ${STAGEDIR}${PREFIX}/share/man/man1/wlopm.1
>+
>+.include <bsd.port.mk>
>diff --git a/x11/wlopm/distinfo b/x11/wlopm/distinfo
>new file mode 100644
>index 000000000000..fbeda9111949
>--- /dev/null
>+++ b/x11/wlopm/distinfo
>@@ -0,0 +1,3 @@
>+TIMESTAMP = 1700117590
>+SHA256 (wlopm/v0.1.0.tar.gz) = f9a7ec03a412e602420ab11d0eea872f6d30dfe5cfee93cd3d0289e4fbbb3aa1
>+SIZE (wlopm/v0.1.0.tar.gz) = 19004
>diff --git a/x11/wlopm/files/patch-Makefile b/x11/wlopm/files/patch-Makefile
>new file mode 100644
>index 000000000000..b98b847e0173
>--- /dev/null
>+++ b/x11/wlopm/files/patch-Makefile
>@@ -0,0 +1,11 @@
>+--- Makefile.orig	2023-11-18 08:35:21 UTC
>++++ Makefile
>+@@ -4,7 +4,7 @@ PREFIX=/usr/local
>+ BINDIR=$(PREFIX)/bin
>+ MANDIR=$(PREFIX)/share/man
>+ 
>+-CFLAGS+=-Wall -Werror -Wextra -Wpedantic -Wno-unused-parameter -Wconversion -Wformat-security -Wformat -Wsign-conversion -Wfloat-conversion -Wunused-result
>++CFLAGS+=-Wall -Wextra -Wpedantic -Wno-unused-parameter -Wconversion -Wformat-security -Wformat -Wsign-conversion -Wfloat-conversion -Wunused-result
>+ LIBS=-lwayland-client
>+ OBJ=wlopm.o wlr-output-power-management-unstable-v1.o
>+ GEN=wlr-output-power-management-unstable-v1.c wlr-output-power-management-unstable-v1.h
>diff --git a/x11/wlopm/pkg-descr b/x11/wlopm/pkg-descr
>new file mode 100644
>index 000000000000..79f99f28dcea
>--- /dev/null
>+++ b/x11/wlopm/pkg-descr
>@@ -0,0 +1,3 @@
>+wlopm - Wayland output power management
>+
>+Simple client for switching displays in Wayland on and off.
>-- 
>2.42.0
>
Comment 20 Tino Engel 2023-11-18 08:52:02 UTC
I have edited your patch using a Bugzilla function "Edit as comment", what did not do exactly what I expected. 
Anyhow: I think your patch is good to go except one change (as requested by you):
pkg-descr should contain:
Simple client for switching displays in Wayland on and off.
Comment 21 Robert Clausecker freebsd_committer freebsd_triage 2023-11-18 08:54:55 UTC
Great!
Comment 22 commit-hook freebsd_committer freebsd_triage 2023-11-18 20:24:06 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e167afd981bb3bc9dfc22add54e1e301bfe30394

commit e167afd981bb3bc9dfc22add54e1e301bfe30394
Author:     Tino Engel <tino.engel@mail.de>
AuthorDate: 2023-11-16 21:27:12 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-11-18 20:20:44 +0000

    x11/wlopm: Wayland output power management

    wlopm - Wayland output power management

    Simple client implementing zwlr-output-power-management-v1.

    WWW: https://git.sr.ht/~leon_plickat/wlopm

    PR:             275141

 x11/Makefile                         |  1 +
 x11/wlopm/Makefile (new)             | 33 +++++++++++++++++++++++++++++++++
 x11/wlopm/distinfo (new)             |  3 +++
 x11/wlopm/files/patch-Makefile (new) | 11 +++++++++++
 x11/wlopm/pkg-descr (new)            |  3 +++
 5 files changed, 51 insertions(+)
Comment 23 Robert Clausecker freebsd_committer freebsd_triage 2023-11-18 20:30:54 UTC
Thank you for your contribution.
Comment 24 Tino Engel 2023-11-19 06:55:11 UTC
Thanks a lot for your help Oleh & Robert.