Re: [hackers] [farbfeld] Mark explicit dependency on requisites for BIN || Laslo Hunhold

From: Laslo Hunhold <dev_AT_frign.de>
Date: Sun, 2 Apr 2017 18:16:46 +0200

On Sat, 1 Apr 2017 00:49:15 -0300
Lucas Gabriel Vuotto <lvuotto92_AT_gmail.com> wrote:

Hey Lucas,

> > -.o: $(REQ:=.o)
> > - $(CC) $(LDFLAGS) $($*-LDFLAGS) -o $_AT_ $< $(REQ:=.o)
> > +$(BIN): $(REQ:=.o)
> >
> > $(BIN:=.o): config.mk $(HDR) $(REQ:=.h)
> >
> > +.o: $(REQ:=.o)
> > + $(CC) $(LDFLAGS) $($*-LDFLAGS) -o $_AT_ $< $(REQ:=.o)
>
> This is a recipe for the file `.o'. I'm certain that you don't want
> to do that.

No, this is not a recipe for the file ".o". This is a single suffix
rule for transforming objects into binaries.
Now, I know this is not the most beautiful solution, but in this case
every binary should include the requisite-objects, as every binary is
using util.h in one way or another.
I am certain that I want to do that.

> Also, expanding macros inside macros produces undefined results. The
> proposed patch by Quentin is correct solution [0].
>
> [0]: http://lists.suckless.org/hackers/1703/14849.html

Okay, first off. Please tell me where my Makefile is broken
feature-wise. I'm struggling to find the problem.
Keep in mind, that for explicit single suffix rules make is smart
enough to include the .o in the dependency tree. There's no need to
list it explicitly.

Secondly, where in my Makefile am I triggering undefined results? Are
you talking about "$($*-LDFLAGS)"? As you know, I'd love to know.

> Beside that, you're overriding CC in config.mk with a non-standard
> binary and compiling against c89 for some reason. That goes against
> the idea of making the Makefile POSIX imo.

It's a convenience you'll find in every suckless Makefile and even
beyond that. It's common to provide a command within the Makefile, or
in this case the config.mk, to override the standard C compiler.
"cc" is actually common in Unix systems and points at the default C
compiler.
If you run make with a envvar-prefix "CC=..." it will respect that.

The code is ANSI C (C89, C90 call it however you like), which is why I
point it out here to the compiler. There's nothing wrong with that.
What's your point?

> I suggest you either do as Hiltjo says and revert everything or make
> the build system completely POSIX. Right now, it's an ugly hybrid.

Except from your remark about the undefined behaviour which I'm very
interested to see what you mean, the Makefile as is seems to be POSIX
compliant to me. I hope you can help me in case I am wrong about it.

With best regards

Laslo Hunhold

-- 
Laslo Hunhold <dev_AT_frign.de>
Received on Sun Apr 02 2017 - 18:16:46 CEST

This archive was generated by hypermail 2.3.0 : Sun Apr 02 2017 - 18:24:17 CEST