Make dependency issue

Status
Not open for further replies.

neilhwatson

Ars Scholae Palatinae
1,236
Greetings, please consider this makefile and its running.
Code:
027_testdir = /tmp/neil

027_01_files = $(027_testdir)/01/a.txt $(027_testdir)/01/b.txt $(027_testdir)/01/c.html

PHONY: all
all: 027_efl_test 037_efl_test
	echo finshed

PHONY: 027_efl_test
027_efl_test: $(027_01_files)
	rm -f $(027_testdir)/01/a.txt
	echo $@

$(027_01_files): $(027_testdir)/01/.
	echo $@ > $@

$(027_testdir)/01/.:
	test -d $(027_testdir)/01 || mkdir -p $(027_testdir)/01

PHONY: 037_efl_test
037_efl_test: $(027_01_files)
	ls -l $^
	rm -fr $^
	echo $@

neil@ettin ~/src/make $ make all
echo /tmp/neil/01/a.txt > /tmp/neil/01/a.txt
echo /tmp/neil/01/b.txt > /tmp/neil/01/b.txt
echo /tmp/neil/01/c.html > /tmp/neil/01/c.html
rm -f /tmp/neil/01/a.txt
echo 027_efl_test
027_efl_test
ls -l /tmp/neil/01/a.txt /tmp/neil/01/b.txt /tmp/neil/01/c.html
ls: cannot access /tmp/neil/01/a.txt: No such file or directory
-rw-r--r-- 1 neil neil 19 Dec 19 15:40 /tmp/neil/01/b.txt
-rw-r--r-- 1 neil neil 20 Dec 19 15:40 /tmp/neil/01/c.html
makefile:22: recipe for target '037_efl_test' failed
make: *** [037_efl_test] Error 2

In 027_efl_test the file a.txt is deleted. In text 037_efl_test the file a.txt is a dependency, but make does not return to make the file anew. Why and is there a fix?
 
Status
Not open for further replies.