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 Makefile.am, 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 (https://codereview.stackexchange.com/ 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): https://gist.github.com/sehe/57693dedda3de679c33848074d61c8e6/e48398e97f4207... 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: https://gist.github.com/sehe/57693dedda3de679c33848074d61c8e6/3f22091fc4f393... Now the code is 351 lines of code, but actually organized (you could split headers and implementations here), it has actually working - STATICLIBTARGET and LIBTARGET - 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: https://imgur.com/a/AlYRz, 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: makefile.mk 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 https://paste.ubuntu.com/p/rMhGFxnYHy/