systemd / zram-generator

Systemd unit generator for zram devices
MIT License
575 stars 48 forks source link

More make shenanigans #128

Closed keszybz closed 2 years ago

keszybz commented 2 years ago

PTAL again.

keszybz commented 2 years ago

CARGOFLAGS := --$(BUILDTYPE) $(CARGOFLAGS)

I had it this, but changed to the shorter form for simplicity…

nabijaczleweli commented 2 years ago

ya, that's good, but I'd like the first commit to also use the make clippy CARGOFLAGS="-- -D warnings" stanza in the GHA config (maybe I shoulda made that a more obvious point in my last comment)

nabijaczleweli commented 2 years ago

Oh, also, there does seem to be a useful difference between DEFAULT = dfl:

nabijaczleweli@tarta:~/uwu$ cat Makefile
DEFAULT = dfl
_:
        @echo $(DEFAULT)
nabijaczleweli@tarta:~/uwu$ make
dfl
nabijaczleweli@tarta:~/uwu$ make DEFAULT=a
a
nabijaczleweli@tarta:~/uwu$ DEFAULT=a make
dfl

vs:

nabijaczleweli@tarta:~/uwu$ cat Makefile
DEFAULT ?= dfl
_:
        @echo $(DEFAULT)
nabijaczleweli@tarta:~/uwu$ make
dfl
nabijaczleweli@tarta:~/uwu$ make DEFAULT=a
a
nabijaczleweli@tarta:~/uwu$ DEFAULT=a make
a

Which means that the variable just gets quietly eaten if you use =! The manual backs this up (6th paragraph down):

If you’d like a variable to be set to a value only if it’s not already set, then you can use the shorthand operator ‘?=’ instead of ‘=’.

In retrospect, this does explain why the makefile didn't seem to work right when I first tried it.

As an additional Fun Time, we are forbidden from modifying arguments, unless we use override, which seems so obscure vim doesn't even highlight it, the assignment gets ignored.

In the process of writing and testing this comment (and GNU make's own documentation), I've made a branch and it seems to have reached functional equilibrium, so instead of blabbing more I'll just open a PR.