News for hackers. Stuff that matters.
Re:Good Makefiles (2018) by hoytech on Friday February 01, 2019 @04:42PM (#19058966)
You shouldn't hard-code gcc. make has an implicit CC variable for this: https://www.gnu.org/software/make/manual/html_node/Implicit-...

Your makefile will then work on systems without gcc, and it is also easier to override it, ie:

    make CC=clang
Re:Good Makefiles (2018) by flukus on Sunday February 03, 2019 @06:29PM (#19072895)
> You shouldn't hard-code gcc.

You should unless you've committed to writing portable code. If you're using GCC specific features then using CC would imply a false level of compatibility.

In this case they are using gcc specific features "-MMD -MP -MT".

Re:Good Makefiles (2018) by hoytech on Thursday February 07, 2019 @11:45AM (#19106362)
I just tested and this Makefile works fine with clang, except that -flto should be added to LDFLAGS.

In fact I believe it should be there for gcc too, according to https://gcc.gnu.org/wiki/LinkTimeOptimization so perhaps this is a bug in the Makefile?

Flushing out issues like this is another reason to commit to writing portable code (and build systems), as you put it.

Re:Good Makefiles (2018) by jdmoreira on Friday February 01, 2019 @04:53PM (#19059087)
or just rely on the /usr/bin/cc symbolic link
Re:Good Makefiles (2018) by ohithereyou on Friday February 01, 2019 @04:55PM (#19059106)
Not every system that can use Makefiles has a C compiler at /usr/bin/cc
Re:Good Makefiles (2018) by jdmoreira on Saturday February 02, 2019 @05:01AM (#19062170)
we shouldn't hardcode the path but I would assume that most unixes with a C compiler will have a cc symlinked somewhere in the $PATH
Re:Good Makefiles (2018) by ohithereyou on Sunday February 03, 2019 @06:19PM (#19072863)
Okay, and what if someone wants to cross-compile?