Running Makefile continuously gives `No rule to make target` error

I'm new to using makefiles for my projects, and I decided to start since I got tired of writing out all of the commands and arguments.

The current makefile that I have looks like this:

        python DIR/ --setup2

When I run this program using the following command:

make run_program

I get the following error:

make: *** No rule to make target 'run_program'.  Stop

I've made sure that the makefile is in the appropriate directory and that there are no spelling errors of the sort, but I'm having trouble figuring out what I did wrong. I've checked others answers such as gcc makefile error: “No rule to make target …” but I'm not sure how to apply it to my case.

Any tips or advice are greatly appreciated. Thanks in advance.

1 answer

  • answered 2019-11-14 06:07 dash-o

    Per 'make' info page:

    make executes commands in the makefile to update one or more target names, where name is typically a program. If no -f option is present, make will look for the makefiles GNUmakefile, makefile, and Makefile, in that order.

    If you name your makefile in other name, you will have to use the '-f'. While this is a good practice to name makefiles with '.mk' suffix (e.g., makefile for sub projects), most projects will name the "main" makefile to match on the the defaults, usually 'Makefile'.