If I have a Makefile as follows
server : network.o storage.o logic.o
ld network.o storage.o logic.o -o server
network.o : network.c netdefs.h
cc -c -o network.o network.c
storage.o : storage.c defs.h
cc -c -o storage.o storage.c
logic.o : logic.c defs.h
cc -c -o logic.o logic.c
.PHONY : promote clean reallyclean
promote : server
cp server /staging/new_servers
clean :
rm -f *.o
reallyclean : clean
rm -f server
And I do the following sequence of commands
make server # builds ther server from source
make clean # tidies up the .o files
make promote # send the built server to the staging area
make, not unsurprisingly, re-builds the server from scratch, as the .o files are dependencies of server and are missing.
I do want this to happen if the server file itself is not there (there'd be nothing to promote otherwise) but if there is a server and no .o files then I want make to assume that the server is up-to-date and to promote it.
Is this achievable?