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 targetscompile
andrun
.run
is phony and will be run anyway.compile
is non-phony, but there is no file namedcompile
, so make will try to build this target (expecting it to producecompile
file, but it wouldn't).You need to add
One
non-phony target and build your binary here, e.g.: