On
make
both the compile and run targets are rebuilt, even though no changes are made to the file One.c
all: compile run
compile: One.c
gcc One.c -o One
run: One
./One
.PHONY: run
I am using Ubuntu-15.04 as OS, and Geany as editor.
One.c contains only one print statement, "hello world".
When you run
makeit will try to build first rule in makefile (all), which depends on targetscompileandrun.runis phony and will be run anyway.compileis non-phony, but there is no file namedcompile, so make will try to build this target (expecting it to producecompilefile, but it wouldn't).You need to add
Onenon-phony target and build your binary here, e.g.: