i'm having trouble understanding why Make will run the "lib"-recipe even if the file already exists. Shouldn't it be ignored as long "$(LIBBIN)" is not in .PHONY ?
Here is an extract from the Makefile in question (ts=2, see "TODO").
.PHONY: all clean default apps lib examples
default: lib
all: apps lib examples
apps: $(APPBINS)
lib: $(LIBBIN)
examples: $(EXBINS)
$(LIBBIN): % : %.$(VERSION)
# TODO -f should really not be necessary. why is the recipe run, when the file exists?
ln -sf $^ $@
$(LIBBIN).$(VERSION): $(LIBOBJECTS) | $(LIBOUTDIR)
$(CC) $^ -o $@ $(LIBLDFLAGS)
chmod 755 $@
i was hoping one of you gurus knows the answer ;-)
kind regards, yogo1212
EDIT: maybe i should say, that i've already tried to make the prereqs. of lib and all order-only. There was no visible effect.
EDIT2: turns out that this works indeed. the link file seemed to have had a timestamp that was off by a minute and make was confused. the phenomenon went away after re-creating the folder structure and restarting.
The makefile part you've given is correct and works for me, after I simplified it due to missing details in your example. So, your example is not accurately reflecting your situation. Please try to provide a SSCCE
$ cat Makefile
LIBBIN = /tmp/foo
VERSION = 1.0
lib: $(LIBBIN)
$(LIBBIN): % : %.$(VERSION)
ln -s $^ $@
$(LIBBIN).$(VERSION): $(LIBOBJECTS) | $(LIBOUTDIR)
touch $@
$ make
touch /tmp/foo.1.0
ln -s /tmp/foo.1.0 /tmp/foo
$ make -f /tmp/x3.mk
make: Nothing to be done for `lib'.