summaryrefslogtreecommitdiffstats
path: root/update-file-lists.mk
blob: f777300d2e6d707b80a9c5b28541f35dcea8d72f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/make -srf

summary := $(wildcard */summary)

which ?= all

ifeq (,$(summary))

dirs := $(wildcard */)

ifeq (,$(dirs))
$(which).list:
	@echo "`pwd` not good"; exit 2
else
$(which).list: %: $(dirs:=$(which).list)
	cat -- $^ > $@.new
	mv -f $@.new $@
endif

me := $(MAKEFILE_LIST)

FORCE:;
%/$(which).list: FORCE
	$(MAKE) -f `(cd $(dir $(me)); pwd)`/$(notdir $(me)) \
		-C $(@D) which=$(which)

else

$(which).list: %.list: $(summary)
	(echo 'all:\'; \
	 list-files.sh $* | sed 's,^.*$$,test@/&\\,' | sort -R; \
	 echo) > $@.new
	mv -f $@.new $@

endif