4

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).

gardenhead
  • 4,719
  • 2
  • 19
  • 24

1 Answers1

1

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.

Doc Brown
  • 199,015
  • 33
  • 367
  • 565