make takes an argument as an argument. If you say that you want to do hello_word.c , it will look, look that this file already exists and has no dependencies, and decides its relevance - therefore, there is nothing to do.
When you say make hello_world , make looks for hello_word , can't find it, then looks for hello_world.o , can't find it, then looks for hello_world.c , finds it, and then uses its implicit rule to build hello_world from it.
You can use make -d to see how make decisions are made. Here is an example for make hello_world.c - I cut the heap to demonstrate the last part you care about:
... Considering target file `hello_world.c'. Looking for an implicit rule for `hello_world.c'. ... No implicit rule found for `hello_world.c'. Finished prerequisites of target file `hello_world.c'. No need to remake target `hello_world.c'. make: Nothing to be done for `hello_world.c'.
Then for make hello_world :
... Considering target file `hello_world'. File `hello_world' does not exist. Looking for an implicit rule for `hello_world'. Trying pattern rule with stem `hello_world'. Trying implicit prerequisite `hello_world.o'. Trying pattern rule with stem `hello_world'. Trying implicit prerequisite `hello_world.c'. Found an implicit rule for `hello_world'. Considering target file `hello_world.c'. Looking for an implicit rule for `hello_world.c'. Trying pattern rule with stem `hello_world'. ... No implicit rule found for `hello_world.c'. Finished prerequisites of target file `hello_world.c'. No need to remake target `hello_world.c'. Finished prerequisites of target file `hello_world'. Must remake target `hello_world'. cc hello_world.c -o hello_world ... Successfully remade target file `hello_world'.
source share