r/programming • u/hapshaps • Dec 23 '17
"A simple makefile" is a unicorn
http://nibblestew.blogspot.dk/2017/12/a-simple-makefile-is-unicorn.html?m=1
151
Upvotes
r/programming • u/hapshaps • Dec 23 '17
View all comments
6
u/[deleted] Dec 23 '17 edited Dec 23 '17
Just for fun I'm posting my own build script.
The main advantage this script has over 'make' is that you don't have to manually add each source file to the script. It automatically detects and compiles any new ones you put in the source folder. It even notices if you edit the build script itself (eg to change compiler flags).
Header file changes are not detected. It's a bit hard to "correctly" work out which source files to recompile when a header is changed, as #include <something.h> might be #ifdef'd out, and header files can #include each other, but I have an idea of a 'good-enough' solution that I might write soon. To force a full recompile (ala 'make clean && make') you 'rm build_bits_linux' then re-run the script.
I based this off a much more complex script that inferred information about how to compile sources based on directory hierarchy; namely to work out whether a source file should end up being its own executable or just a dependency of others. I still have that lying around, but it's not as pretty.
Public domain or similar alternative or similar equivalent