Makefile (3138B)
1 #################### Variables. 2 3 OUTDIR = public 4 5 dirname = $(patsubst %/,%,$(dir $(1))) 6 dirnames = $(sort $(call dirname,$(1))) 7 8 languages = en 9 languages_folders = $(foreach l,$(languages),$(OUTDIR)/$(l)) 10 11 pages_src = $(filter-out template.html,$(wildcard *.html)) \ 12 $(foreach l,$(languages), \ 13 $(filter-out $(l)/template.html,$(wildcard $(l)/*.html))) 14 15 pages = $(foreach p,$(pages_src),$(OUTDIR)/$(p)) 16 17 members_src = $(wildcard *.membre.in \ 18 $(foreach l,$(languages),$(l))/*.membre.in) 19 members_pages = $(patsubst %.membre.in,$(OUTDIR)/%.html,$(members_src)) 20 21 feeds_src = feed.xml $(foreach l,$(languages), \ 22 $(l)/feed.xml) 23 feeds = $(foreach f,$(feeds_src),$(OUTDIR)/$(f)) 24 25 images = $(foreach img,$(shell find images -type f),$(OUTDIR)/$(img)) 26 images_folders = $(call dirnames,$(images)) 27 28 stylesheets = $(foreach img,$(shell find stylesheets -type f),$(OUTDIR)/$(img)) 29 stylesheets_folders = $(call dirnames,$(stylesheets)) 30 31 fonts = $(foreach font,$(shell find fonts -type f),$(OUTDIR)/$(font)) 32 fonts_folders = $(call dirnames,$(fonts)) 33 34 scripts = $(foreach img,$(shell find scripts -type f),$(OUTDIR)/$(img)) 35 scripts_folders = $(call dirnames,$(scripts)) 36 37 #################### Top-level targets. 38 39 # Building: 40 .PHONY: all clean site 41 42 # Maintenance: 43 .PHONY: feeds indexes upload 44 45 #################### Recipes. 46 47 all: site 48 49 feeds: 50 ./admin/feeds/build-feeds.sh $(feeds_src) 51 52 indexes: 53 ./admin/build-indexes.sh . $(languages) 54 55 upload: site 56 ./upload.sh $(OUTDIR) 57 58 clean: 59 -rm -r $(OUTDIR) 60 61 site: $(pages) $(members_pages) $(feeds) $(images) $(stylesheets) $(fonts) $(scripts) 62 63 $(images) $(stylesheets) $(fonts) $(scripts) $(feeds): $(OUTDIR)/%: % 64 cp $< $@ 65 66 .SECONDEXPANSION: 67 68 # 🔪 HACK ATTACK 🔪 69 # Ideally I'd like to just stick $$(<D)/template.html in the 70 # prerequisite list, but unlike $$(@D), $$(<D) seems to expand to 71 # nothing. No idea if that's a bug or if I'm just Doing It Wrong. 72 langdir = . 73 $(OUTDIR)/en/%: langdir = en 74 75 $(pages): $(OUTDIR)/%.html: %.html %.sh $$(langdir)/template.html settings.sh 76 ./build.sh $< $*.sh $(langdir)/template.html $(OUTDIR) $*.html 77 78 $(members_pages): $(OUTDIR)/%.html: %.membre.in build-member.sh $$(langdir)/template.html settings.sh 79 ./build-member.sh $< $(langdir)/template.html $(OUTDIR) $*.html 80 81 $(OUTDIR)/quatuor.html: quatuor.md 82 $(OUTDIR)/programmes.html: programs.in 83 $(OUTDIR)/concerts.html: concerts.in 84 $(OUTDIR)/légal.html: légal.md 85 $(OUTDIR)/plan.html: plan.md 86 $(OUTDIR)/en/quartet.html: en/quartet.md 87 $(OUTDIR)/en/programs.html: en/programs.in 88 $(OUTDIR)/en/concerts.html: en/concerts.in 89 $(OUTDIR)/en/legal.html: en/legal.md 90 $(OUTDIR)/en/sitemap.html: en/sitemap.md 91 92 # Rules for automatic, incremental folder creation. 93 94 # Our lists of target directories are created from the lists of leaf 95 # resources; some intermediate directories that only hold subdirs do 96 # not appear in these lists. Work around that with -p. 97 $(OUTDIR) $(languages_folders) $(images_folders) $(stylesheets_folders) $(fonts_folders) $(scripts_folders): 98 mkdir -p $@ 99 100 $(feeds) $(images) $(stylesheets) $(fonts) $(scripts) $(pages) $(members_pages): | $$(@D)