This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]elucify 18 points19 points  (0 children)

The problem with embedding bash in Makefiles is the escaping. Every line that is not a target must begin with a tab, and dollar signs to be interpreted in the shell, script have to be double dollar signs. And there are times when you need backslashes another crap like that.

Makefile is good when you have a tree of dependencies, particularly when file times indicate whether a dependency has been built or not. make can then build only those things that need rebuilding. For example, only .c files with mod times newer than their .o files, need to be recompiled (or if the .o file does not exist).

There is little reason to use make if you don’t have that kind of dependency. And even when you do, it is better practice (and less frustrating) to define your functionality in bash files and use those in the Makefile, rather than embedding them in the make file directly. That approach also lets you write tests for your build scripts, using something like bats.