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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(PATH)))))
pick = $(firstword $(foreach prog,$1,$(call pathsearch,$(prog))) false)
RM = rm -f
CP = cp
PATCH = patch
SASS = sass
PHP = $(call pick,php5 php)
PNGCRUSH = $(call pick,pngcrush cp)
SVG2PNG = $(call pick,rsvg-convert convert)
ifeq ($(notdir $(SVG2PNG)),rsvg-convert)
SVG2PNG_OUTFLAG = -o
endif
default: all
include theme.mk
srcfiles += twentyeleven-fix.scss license.txt
srcfiles += .gitignore theme.mk Makefile
all: .gitignore $(targets)
%: %.patch ../twentyeleven/%
$(RM) $@
$(CP) ../twentyeleven/$@ $@
$(PATCH) $@ < $@.patch
%.css: %.scss
$(SASS) $< $@
%: %.php
$(PHP) -f $< > $@
%.png: %.svg
$(SVG2PNG) $< $(SVG2PNG_OUTFLAG) $@.$$$$ && \
$(PNGCRUSH) $@.$$$$ $@ ; \
$(RM) $@.$$$$
###########################################################################
in_dir = $(patsubst ./%,%,$(dir $1))
my_dir = $(patsubst %/,%,$(dir $1))
define gitignore_file
$(if $(in_dir),
$(call gitignore_file,$(my_dir))
echo '$(my_dir)/*' >> '$@';
)
echo '!$1' >> '$@';
endef
.gitignore: Makefile theme.mk
echo "# DO NOT EDIT, this file is automatically made by \`Makefile'" >$@
echo '# ' >> '$@'
echo '# ignore everyting' >> '$@'
echo '*' >> '$@'
echo '# but these:' >> '$@'
$(foreach file,$(srcfiles),$(call gitignore_file,$(file)))
###########################################################################
git2make = $1 $(subst *,.*,$1)
gitignore_y = $(call git2make,$(shell sed -n 's/^[^\#!]/&/p' .gitignore))
gitignore_n = $(call git2make,$(shell sed -n 's/^!//p' .gitignore))
gitignore_i = . .. .git %/.. %/.
gitignore = $(filter-out $(gitignore_i) $(wildcard $(gitignore_n)),$(wildcard $(gitignore_y)))
clean: .gitignore PHONY
$(RM) -r $(filter-out $(targets),$(gitignore))
distclean: .gitignore PHONY
$(RM) -r $(gitignore)
###########################################################################
.PHONY: FORCE PHONY
FORCE: ;
PHONY: ;
|