Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does make think the target is up to date?

Tags:

makefile

People also ask

What type of file is a makefile?

Script written as a Makefile, a developer file type that is used for compiling and linking programs from source code files; stores instructions using the GNU make standard. NOTE: Makefiles more commonly are created with the filename Makefile, which does not have a file extension.

What is makefile phony?

PHONY: allows to declare phony targets, so that make will not check them as actual file names: it will work all the time even if such files still exist. You can put several . PHONY: in your Makefile : .

Where does the makefile go?

some projects put their makefile in src/ subdirectory of the root directories of the projects, some projects put their makefiles in the root directory of the project.


Maybe you have a file/directory named test in the directory. If this directory exists, and has no dependencies that are more recent, then this target is not rebuild.

To force rebuild on these kind of not-file-related targets, you should make them phony as follows:

.PHONY: all test clean

Note that you can declare all of your phony targets there.

A phony target is one that is not really the name of a file; rather it is just a name for a recipe to be executed when you make an explicit request.


EDIT: This only applies to some versions of make - you should check your man page.

You can also pass the -B flag to make. As per the man page, this does:

-B, --always-make Unconditionally make all targets.

So make -B test would solve your problem if you were in a situation where you don't want to edit the Makefile or change the name of your test folder.


It happens when you have a file with the same name as Makefile target name in the directory where the Makefile is present.

enter image description here


my mistake was making the target name "filename.c:" instead of just "filename:"