21

Wow!
Makefiles are SO much cooler than I thought before

$< = the first dependency file
$^ = all the dependency files
$@ = the build target

AND if I try to build something who's dependencies don't exist, it'll automatically try to build them!

Comments
  • 5
    I need to get into make very soon for my dr client. I'll be pinning this.
  • 1
    @AlgoRythm if you need a good tutorial, then oddly enough the best one I've found was embedded somewhere within this pdf: https://cs.bham.ac.uk/~exr/...

    (Automating with makefiles, in the contents page)
  • 1
    Makefiles are really nice and super powerful. I use them as much as possible in projects, that way I can keep a set interface to building, running tests, lint etc even though it’s using different tools under the hood. (make build, make test, make lint etc). And also it auto completes the targets in your terminal.
  • 0
    I used to wonder what these cryptic files were all about. Then I picked up a book about GNU Make and understand them a lot more now. Filename pattern substitution is pretty neat (you can define a list of .c source files, have the Makefile substitute the .c for .o to work out what needs building etc.)

    It's clever. But not too clever. Obviously there's cmake and other build systems but this does the job quite simply.
Add Comment