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 make
it will try to build first rule in makefile (all
), which depends on targets compile
and run
.
run
is phony and will be run anyway. compile
is non-phony, but there is no file named compile
, so make will try to build this target (expecting it to produce compile
file, but it wouldn't).
You need to add One
non-phony target and build your binary here, e.g.:
all: compile run
compile: One
One: One.c
gcc One.c -o One
run: One
./One
.PHONY: run compile