Boost logo

Boost :

Subject: Re: [boost] mkmakefile
From: Ggh (ggh_at_[hidden])
Date: 2018-04-05 04:58:58




Quoting Seth via Boost <boost_at_[hidden]>:

> On 01-04-18 17:13, Ggh via Boost wrote:
>> wondering...if I'm reinventing the wheel ( again as many do)....I
>> guess there's loads of similar stuff
> Similar to what? Shell scripts that write a makefile?
> Also, your link was broken. The fixed link leads to incomplete code (
> You  don't state the target implementations (just GNU make? what
> versions?), features required, features already supported, etc.
> I think what I've seen is trivial. I'm not at all convinced that
> cramming the options all on some command line to be parsed by a ...
> questionable script is better than writing the equivalent makefile (or
>, m4 template or CMakeLists.txt, ... if you intend to
> generate the makefile).
> The code is... what I'd call bad code. You should probably have posted
> it for review instead ( e.g.).
> It fails to use all the conventions in place to make Makefiles
> maintainable. You subvert default variable naming (CC for CXX, really?).
> Here's the same program converted to actual C++ - in 306 lines of code
> (instead of the incomplete 560 lines):
> Now note that *LOTS* of things have been fixed with respect to quoting
> of path names, but lots of things still don't work (no way to pass
> compiler/linker flags, static libraries aren't built (because the target
> rule was wrong), static libraries cannot link (because it needs position
> indepent code, but, again, compiler flags cannot be passed), the linker
> is always using `g++` instead of `gcc` even if all source files were
> compiled with the C compiler etc.
> To fix things, I cleaned things up **A LOT** MORE:
> Now the code is 351 lines of code, but actually organized (you could
> split headers and implementations here), it has actually working
>      - much simplified rules
>      - dependency detection / creation
>      - using OBJS instead of hardcoding names and even `*.o` (ugh)
>      - separating discover_sourcefiles, generate_makefile, run_make
>      - deduceLinker (instead of using g++ to link C programs...)
>      - allow for compiler flags
>      - don't repeat includes and libraries with each (intermediate) target
> A screenshot of interactively bootstrapping the program using itself:
>, using the command line:
> ./bootstrap/mymakemaker -hd -t mymakemaker -cxxflags -std=c++1z -tt exe
> -wd bootstrap -mk -cc 'clang++' -i ~/custom/boost -L
> ~/custom/boost/stage/lib/ -l boost_program_options -l stdc++fs
> Reading directory:    "bootstrap"
> Creating makefile:
> Making...
> ------------------------------------------------------
> "clang++"  -I"/home/sehe/custom/boost" -MMD    -std=c++1z -c test.cpp -o
> "./test.o"
> "clang++"  -I"/home/sehe/custom/boost" -MMD    -std=c++1z "./test.o"  
> -L"/home/sehe/custom/boost/stage/lib/" -l"boost_program_options"
> -l"stdc++fs" -o "mymakemaker"
> ------------------------------------------------------
> The resulting generated makefile looks like
> _______________________________________________
> Unsubscribe & other changes:

Boost list run by bdawes at, gregod at, cpdaniel at, john at