programming:make:fake_target
This is an old revision of the document!
Programming - Make - Fake Target
By default, make only tries to build the first thing it finds.
Sometimes you’ll see a fake target as the first thing like this:
- Makefile
all : hello hello2 hello3
NOTE: This assumes that there are rules for the 3 hello programs elsewhere and make will build all three.
This works as long as you never have a file name all in the working directory.
Prevent problems using all
To prevent that being a problem, you can declare that target as phony by using this statement in the makefile:
- Makefile
.PHONY: all
NOTE: Actions can be attached to phony targets as well. For example:
- Makefile
.PHONY: clean clean: rm *.o
NOTE: You can issue make clean from the command line to remove all the object files.
programming/make/fake_target.1612456848.txt.gz · Last modified: 2021/02/04 16:40 by peter