On Tue, 2020-01-14, Paavo Helde wrote:
> On 14.01.2020 15:38, Frederick Gotham wrote:
>> A few months ago I posted about my generic Makefile that builds a
>> C/C++ program from all the source files in the current
>> directory. I've been using this Makefile for the past few months on
>> loads of different programs (big and small) and it works well.
...
>> OBJECTS += $(SRC_FILES_C:.c=.c.o) $(SRC_FILES_CXX:.cpp=.cpp.o)
>>
>> DEPENDENCIES += $(OBJECTS:.o=.d)
>>
>> .PHONY: all
>> all: $(PROGRAM) $(DEPENDENCIES)
...
> I agree with other responders. The above looks more like assembler or
> PostScript code, i.e. not really something meant for humans to write.
> And the result looks pretty non-portable and limited to a single type of
> projects.
I believe that was his goal: a single Makefile for all matching
projects, not meant to be easily read and understood.
Like I argued the first time around, a hand-written Makefile,
written /for a certain project/, can be written clearly and elegantly
(modulo a dozen lines of boilerplate for the dependency generation).
IMO, this one of mine is an example: <git://
snipabacken.se/groblad>.
But the OP wanted (as I understood it last time) a Makefile he could
copy into any directory containing source code, so he could ignore
whatever build system was already in place.
> While I have done my share of makefile programming in the past I'm ready
> to admit I never got it quite right; by looking at makefiles generated
> by CMake I can now understand why.
It's autogenerated makefiles, designed to use recursive make strategy;
they are bound to be atypical.
> So what's wrong with using CMake instead?
Personally I've never been able to understand CMake. Trivial tasks are
easy; other tasks end up, IME, an exercise in cargo-culting and
trial-and-error.
For the OP's use case, CMake could be a better fit.
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/
snipabacken.se> O o .