What is the difference between the two rules without prerequisite?

27 Views Asked by At

I have some difficulty to understand how to write a rule to let Makefile make a soft link on a file. It turns out that only write in one line works. Can someone help me understand why Make work in such way specifically for no prerequisite rule?

make runsimq # it can create a symbolic link on $(MY_LOG) named $(IT_LOG)

make runsimq1 # make: Nothing to be done for `runsimq1'.

MY_LOG = ./my.log
IT_LOG = it.log
IT_LOG1 = it_1.log

.PHONY: $(IT_LOG) $(IT_LOG1)

runsimq: $(IT_LOG)

runsimq1: $(IT_LOG1)

runsimq2: runsimq1
    @echo why say Nothing to be done?

# put target, prerequisite(empty) and recipe in one line, work
$(IT_LOG):;@echo create a symbolic link; ln -nsf $(MY_LOG) ./$(IT_LOG);

# put recipe in different lines, not work
$(IT_LOG1):
    @echo create a symbolic link; \
    ln -nsf $(MY_LOG) ./$(IT_LOG1);
0

There are 0 best solutions below