Re: [dev] Special target ".POSIX" in Makefiles

2021-12-30 Thread NRK
On Fri, Dec 31, 2021 at 12:49:46PM +0600, NRK wrote:
> What would be a posix replacement for `?=` ? I assume something like:
> 
>   VAR = $$(if test -n "$$VAR"; then printf "%s" "$$VAR"; else printf 
> "fallback"; fi)
> 

Now that I think about it, posix shell has parameter expansion that
could be used here for a more compact assignment:

VAR = $${VAR:-fallback}

should also do the trick. I guess it could also be double quoted to
protect against word splitting as well. But I don't think that'd be a
good idea for things like CFLAGS where word splitting is desired.

- NRK



Re: [dev] Special target ".POSIX" in Makefiles

2021-12-30 Thread NRK
On Thu, Dec 30, 2021 at 09:17:32PM +0100, Mattias Andrée wrote:
> I've actually being thinking of writing a makefile linter.
> How interested would people be in such a tool?
> 
> The reason to have a linter separate from a make utility itself
> is that it would not have to reject non-standard features that
> you don't want to implement in make. And I also think it would for
> cleaner implementation of both projects. Additionally, I would
> suspect that a lot of people would just stay with GNU make because
> it's in every distro, so having it as a separate project would
> probably give it wider adoption.

I'd definitely be interested in such a tool. Weather it be in form of a
make implementation or linter doesn't matter a whole lot to me as long
as the end goal of having a tool to help write portable makefile is
achieved.

On Thu, Dec 30, 2021 at 11:07:35PM +0100, Laslo Hunhold wrote:
>$ snake -l
>Makefile:1:1: warning: Missing ".POSIX" target.
>config.mk:2:4: warning: "?=" is a GNU-extension. 
>Makefile:20:34: warning: A prerequisite must not contain a macro.
>$

Hmm, I was under the impression that `?=` was accepted into POSIX. But I
cannot find any mention of it in the posix manpage (man 1p make) so I
guess I was wrong.

What would be a posix replacement for `?=` ? I assume something like:

VAR = $$(if test -n "$$VAR"; then printf "%s" "$$VAR"; else printf 
"fallback"; fi)

- NRK



Re: [dev] Special target ".POSIX" in Makefiles

2021-12-30 Thread Mattias Andrée
On Thu, 30 Dec 2021 23:07:35 +0100
Laslo Hunhold  wrote:

> On Thu, 30 Dec 2021 21:17:32 +0100
> Mattias Andrée  wrote:
> 
> Dear Mattias,
> 
> > I've actually being thinking of writing a makefile linter.
> > How interested would people be in such a tool?  
> 
> very interested! Even though, when you implement the logic, you might
> as well go all the way and offer a make(1) that also offers linting
> (comparable to mandoc(1)).

Yes, of course you could add it to make(1) also, but for the explained
reasons I think it would be useful as a standalone implementation.

However, a linter could do thinks that I do not want to do in make(1)
itself. For example, it could do analysis to and find a portable
solution (e.g. just removing "$(@:.o=.c)"), or explain that an
non-standard feature is being used in vain (e.g. "PREFIX ?= /usr/local").

make(1) should of course tell you when you are not being POSIX
compliant, but ultimately to what extent it would hold you hand
and how pedantic it be would be determined at time of implementation.
It would probably be very little. For example, I think that the
linker could warn about bugs in other implementations or about
potential whitespace issues which are probably just fine in every
implementation people use, but I do not want to do this in
make(1) itself.


> 
> > The reason to have a linter separate from a make utility itself
> > is that it would not have to reject non-standard features that
> > you don't want to implement in make. And I also think it would for
> > cleaner implementation of both projects. Additionally, I would
> > suspect that a lot of people would just stay with GNU make because
> > it's in every distro, so having it as a separate project would
> > probably give it wider adoption.  
> 
> You wouldn't have to reject non-standard features, but offer printing a
> warning for undefined behaviour and non-standard extensions while still
> supporting them to a certain extent, something like:
> 
>$ snake -l
>Makefile:1:1: warning: Missing ".POSIX" target.
>config.mk:2:4: warning: "?=" is a GNU-extension. 
>Makefile:20:34: warning: A prerequisite must not contain a macro.
>$
> 
> Optionally you could also choose to always print warnings and turn
> them into hard errors with the l-flag.
> 
> It would be necessary to assess how many extensions are necessary
> to implement. With sbase/ubase we found out that while GNU-extensions
> are used, they are not all too widespread and only a small subset of
> the entire GNU bloat.
> 
> With Makefiles you don't really need the GNU extensions and they,
> as usual with GNU extensions, seem to originate from a misunderstanding
> or caving in to simply wrong usage-patterns (just think of cat -v) by
> users who probably don't know it better or about the right tools for the
> job.

I think there are situations where some of the extensions offered by
GNU are useful as they can make things cleaner, but they are hardly
necessary, and often they are inappropriately used, and of course there
are some features I cannot find an inappropriate use case for at all.

GNU's strategy is to make things as easy for users as possible, and
offer “more value” than the software they are replacing, which naturally
lead to it's current miserable situation. They just haven't learned to
say No. Which is probably to toughest but most valuable lesson for any
programmer to learn.

> 
> Anyway, tl;dr: Such a strict POSIX-compliant make would be really awesome!
> I'm sure many would pick it up. Null program wrote a great post[0]
> about this topic, indicating that there's no tool out there that is
> explicit about standard conformance, _especially_ undefined behaviour.

A few month ago I started writing a POSIX-like shell[0], it has
requirements that makes it impossible to be fully POSIX, but it
if you start it as sh it will be strictly POSIX and if it, in this
mode, encounters an extension it will warn you that it will not
be recognising it. It will also warn you in some situations that
look like mistakes, and yell at you (in lower case) if you are
using backquotes (read up on the backquote syntax in sh and you
will understand why).

> 
> With best regards
> 
> Laslo
> 
> [0]:https://nullprogram.com/blog/2017/08/20/
> 

Regards,
Mattias Andrée


[0] https://github.com/maandree/apsh



Re: [dev] Special target ".POSIX" in Makefiles

2021-12-30 Thread Laslo Hunhold
On Thu, 30 Dec 2021 21:17:32 +0100
Mattias Andrée  wrote:

Dear Mattias,

> I've actually being thinking of writing a makefile linter.
> How interested would people be in such a tool?

very interested! Even though, when you implement the logic, you might
as well go all the way and offer a make(1) that also offers linting
(comparable to mandoc(1)).

> The reason to have a linter separate from a make utility itself
> is that it would not have to reject non-standard features that
> you don't want to implement in make. And I also think it would for
> cleaner implementation of both projects. Additionally, I would
> suspect that a lot of people would just stay with GNU make because
> it's in every distro, so having it as a separate project would
> probably give it wider adoption.

You wouldn't have to reject non-standard features, but offer printing a
warning for undefined behaviour and non-standard extensions while still
supporting them to a certain extent, something like:

   $ snake -l
   Makefile:1:1: warning: Missing ".POSIX" target.
   config.mk:2:4: warning: "?=" is a GNU-extension. 
   Makefile:20:34: warning: A prerequisite must not contain a macro.
   $

Optionally you could also choose to always print warnings and turn
them into hard errors with the l-flag.

It would be necessary to assess how many extensions are necessary
to implement. With sbase/ubase we found out that while GNU-extensions
are used, they are not all too widespread and only a small subset of
the entire GNU bloat.

With Makefiles you don't really need the GNU extensions and they,
as usual with GNU extensions, seem to originate from a misunderstanding
or caving in to simply wrong usage-patterns (just think of cat -v) by
users who probably don't know it better or about the right tools for the
job.

Anyway, tl;dr: Such a strict POSIX-compliant make would be really awesome!
I'm sure many would pick it up. Null program wrote a great post[0]
about this topic, indicating that there's no tool out there that is
explicit about standard conformance, _especially_ undefined behaviour.

With best regards

Laslo

[0]:https://nullprogram.com/blog/2017/08/20/



[dev] surf: mouse button: 8, 9

2021-12-30 Thread René
Hi,
I found the values in the subject although I remember the mouse
numbers are in range (0, 5> e.g. 1 means left btn, 2 middle and 3
right button. What are these for?!? Thanks
Rene



Re: [dev] Special target ".POSIX" in Makefiles

2021-12-30 Thread Mattias Andrée
On Thu, 30 Dec 2021 21:07:06 +0100
Laslo Hunhold  wrote:

> On Thu, 30 Dec 2021 17:49:23 +0100
> crae...@gmail.com wrote:
> 
> Dear craekz,
> 
> > As far as I can see, we could add `.POSIX` to the following programs:
> > dwm, dmenu, dwmstatus, sent and tabbed
> > I've just looked over the Makefiles very briefly, so I may have
> > overseen something. Note: I just picked out the "biggest" programs.  
> 
> sadly the make-implementations out there don't offer a "strict" mode to
> warn you about non-compliance or undefined behaviour. GNU make (as

I've actually being thinking of writing a makefile linter.
How interested would people be in such a tool?

The reason to have a linter separate from a make utility itself
is that it would not have to reject non-standard features that
you don't want to implement in make. And I also think it would for
cleaner implementation of both projects. Additionally, I would
suspect that a lot of people would just stay with GNU make because
it's in every distro, so having it as a separate project would
probably give it wider adoption.


> usual with GNU products) added a lot of GNU-extensions and poisoned the
> entire ecosystem. It's really easy to write non-compliant makefiles and
> have things silently break or behave slightly different across
> implementations.
> 
> Adding a .POSIX target is one thing, it's another to actually verify
> the makefiles are POSIX-compliant.
> 
> It would be a cool project-idea to write a very strict POSIX-compliant
> make-implementation that, if it includes extensions, marks them as such
> and prints a warning if desired. mk by plan9 is also very nice, of
> course, but makefiles are the common denominator in the scene and it
> might be a cool incentive to have such a validating make.
> 
> A lot of new systems are used all over the place, like cmake, ninja and
> whatnot, so it might be cool to show how zen it is to just work with a
> make-based build-system. One example is the really trivial way to
> package suckless-projects, e.g. libgrapheme[0]. It doesn't get simpler
> than that.
> 
> With best regards
> 
> Laslo
> 
> [0]:https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=libgrapheme
> 




Re: [dev] Special target ".POSIX" in Makefiles

2021-12-30 Thread Laslo Hunhold
On Thu, 30 Dec 2021 17:49:23 +0100
crae...@gmail.com wrote:

Dear craekz,

> As far as I can see, we could add `.POSIX` to the following programs:
> dwm, dmenu, dwmstatus, sent and tabbed
> I've just looked over the Makefiles very briefly, so I may have
> overseen something. Note: I just picked out the "biggest" programs.

sadly the make-implementations out there don't offer a "strict" mode to
warn you about non-compliance or undefined behaviour. GNU make (as
usual with GNU products) added a lot of GNU-extensions and poisoned the
entire ecosystem. It's really easy to write non-compliant makefiles and
have things silently break or behave slightly different across
implementations.

Adding a .POSIX target is one thing, it's another to actually verify
the makefiles are POSIX-compliant.

It would be a cool project-idea to write a very strict POSIX-compliant
make-implementation that, if it includes extensions, marks them as such
and prints a warning if desired. mk by plan9 is also very nice, of
course, but makefiles are the common denominator in the scene and it
might be a cool incentive to have such a validating make.

A lot of new systems are used all over the place, like cmake, ninja and
whatnot, so it might be cool to show how zen it is to just work with a
make-based build-system. One example is the really trivial way to
package suckless-projects, e.g. libgrapheme[0]. It doesn't get simpler
than that.

With best regards

Laslo

[0]:https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=libgrapheme



Re: [dev] Special target ".POSIX" in Makefiles

2021-12-30 Thread craekz7
>I agree that it shall be added to all Makefile, because
>otherwise the behavior of make is unspecified.
>(Quote from the POSIX specifications)
I'm sure you meant it like that, but just to clarify it:
It is only unspecified if it doesn't appear as the first non-comment line,
has prerequisites or commands.

>.POSIX can be used as long a the makefile does not
>use any feature that conflicts with POSIX. But I think
>it would mislead people into thinking the non-POSIX
>features are POSIX feature, so it would be best skip
>it in that case.
I agree with that.

As far as I can see, we could add `.POSIX` to the following programs:
dwm, dmenu, dwmstatus, sent and tabbed
I've just looked over the Makefiles very briefly, so I may have overseen 
something.
Note: I just picked out the "biggest" programs.

>I do however think some Makefile here that use the @
>macro in the prerequisite. This is not a POSIX feature,
>is seldom needed, and should be removed assuming it
>is redundant given the inferred prerequisite of
>inference rules.
sbase does it but I haven't looked closer.

--
craekz



Re: [dev] Special target ".POSIX" in Makefiles

2021-12-30 Thread Mattias Andrée
I agree that it shall be added to all Makefile, because
“otherwise, the behavior of make is unspecified.”
(Quote from the POSIX specifications)

Probably missing because people don't usually learn
make(1) by reading the entire manual.

.POSIX can be used as long a the makefile does not
use any feature that conflicts with POSIX. But I think
it would mislead people into thinking the non-POSIX
features are POSIX feature, so it would be best skip
it in that case.

I do however think some Makefile here that use the @
macro in the prerequisite. This is not a POSIX feature,
is seldom needed, and should be removed assuming it
is redundant given the inferred prerequisite of
inference rules.


Regards,
Mattias Andrée


On Thu, 30 Dec 2021 15:58:33 +0100
crae...@gmail.com wrote:

> Hi,
> 
> I'm wondering why the Makefiles of some suckless programs (and libs) have the
> special target `.POSIX` in them and some don't.
> For example, dwm doesn't have it in it's Makefile but there isn't a single
> non-POSIX feature used. I think it would be better to include the `.POSIX` 
> target
> simply to follow the standard and guarantee portability.
> If there is a good reason why it isn't included, please let me know.
> 
> --
> craekz
> 




[dev] Special target ".POSIX" in Makefiles

2021-12-30 Thread craekz7
Hi,

I'm wondering why the Makefiles of some suckless programs (and libs) have the
special target `.POSIX` in them and some don't.
For example, dwm doesn't have it in it's Makefile but there isn't a single
non-POSIX feature used. I think it would be better to include the `.POSIX` 
target
simply to follow the standard and guarantee portability.
If there is a good reason why it isn't included, please let me know.

--
craekz