Is it reasonable to use Makefile targets as scripts?

So for example, instead of having a script script_A, script_B, etc, and running them as standard executables with ./script_A, we have a makefile that has targets script_A, script_B, and run them by invoker make script_A. There are no dependencies between the scripts.

In my eyes, this seems like an abuse of make. We're not using make to build programs, let alone for dependency management (i.e. topological sorting).

  • Reserver moral judgments for those things where they matter. – Robert Harvey Sep 29 '16 at 22:22

This is not completely unusual, one could call it an idiom or pattern for make.

If you have certain build or processing steps for a project which somehow "belong together", and some of these steps just consist of running a script (maybe manually), then it makes sense to put the script calls simply as targets into the makefile, just as any other build target. This is a form of documentation, indicating that certain scripts belong to the project (and others, which are not part of the makefile targets, do not belong to it).

This only becomes an abuse if you start putting arbitrary, unrelated scripts into one makefile, just for the sake of making it possible to start them by typing make script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.