Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to make all targets '.PHONY' ? (gmake)

Tags:

makefile

I have a Makefile, where none of the targets reference files, so if this can be done in some loop it would be convenient.

Is there some way to set every target in a makefile as .PHONY ?


The reason I'm asking this is I never want any files in the same directory as the makefile to conflict with the targets (where the makefile will automatically associate any target with a directory of file).

like image 542
ideasman42 Avatar asked Dec 19 '14 10:12

ideasman42


1 Answers

You can ensure targets always build by defining one empty "FORCE" target and have all you're other targets depend on it

target1: FORCE
      ./foobar $@
target2: FORCE
      ./dongle $@
FORCE:

(as suggested in the make manual)

You can also run "make -B" instead of "make"?

`-B'
`--always-make'
     Consider all targets out-of-date.  GNU `make' proceeds to consider
     targets and their prerequisites using the normal algorithms;
     however, all these targets are remade, regardless of the status of
     their prerequisites.
like image 169
andree Avatar answered Sep 30 '22 10:09

andree