summaryrefslogtreecommitdiff
path: root/makefile
blob: 7bdcc0c073d9ba7b61103e946d648b6a8f026706 (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
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

MD_CMD=remark --rc-path remarkrc
CATCH_CMD=pup
BASE_HTML=left.htm headers.htm
ALL_ARTICLES=$(wildcard article/*.md)
ALL_ARTICLES_OUT=$(ALL_ARTICLES:.md=.html)
ALL_ARTICLES_INTRO_OUT=$(ALL_ARTICLES:.md=_intro.html)

all: $(ALL_ARTICLES_OUT) $(BASE_HTML) index.html contact/index.html

article/%.html: article/%.md $(BASE_HTML)
	cat $< | ${MD_CMD} > ${@:.html=.htm}
	m4 -D TITLE_TITLE="`echo Licornes, hérissons et renards`" headers.m4  > ${basename $@}_header.html
	m4 -D tmpFileNameArticle=${@:.html=.htm} -D linkFileNameArticle=${<:.md=} -D HEADER_HEADER=${basename $@}_header.html -D CANONIC="/$@" article/article.m4 > $@

article/%_intro.html: article/%.html
	cat $< | ${CATCH_CMD} "h1" > ${@:.html=.htm}
	cat $< | ${CATCH_CMD} "h1 + p" | sed 's/res\//article\/res\//' >> ${@:.html=.htm}
	cat $< | ${CATCH_CMD} "h1 + p + p" >> ${@:.html=.htm}
	m4 -D tmpFileNameArticle=${@:.html=.htm} -D linkFileNameArticle=${<:.html=} article/intro.m4 > $@

articles.htm: $(ALL_ARTICLES_INTRO_OUT)
	cat $(ALL_ARTICLES_INTRO_OUT) > $@


headers_index.htm:
	m4 -D TITLE_TITLE="Licornes, hérissons et renards" -D CANONIC="/" headers.m4  > $@

index.html: index.m4 $(BASE_HTML) headers_index.htm articles.htm
	m4 $< > $@

contact/index.html: contact/index.md
	${MD_CMD} $< > ${@:.html=.htm}
	m4 -D TITLE_TITLE="`grep h1 ${@:.html=.htm} | cut -d'>' -f 2 | cut -d'<' -f 1`" headers.m4  > ${basename $@}_header.html
	m4 -D tmpFileNameArticle=${@:.html=.htm} -D linkFileNameArticle=${<:.md=} -D HEADER_HEADER=${basename $@}_header.html -D CANONIC="/contact" article/article.m4 > $@

left.htm: res/twitterLogo.svg res/mastoLogo.svg res/gitLogo.svg res/acheLogo.svg left.m4
	m4 left.m4 > left.htm

headers.htm: headers.m4
	m4 headers.m4 > headers.htm

clean:
	rm -f $(BASE_HTML)
	rm -f articles.htm
	rm -f $(ALL_ARTICLES:.md=_intro.htm)
	rm -f $(ALL_ARTICLES:.md=.htm)
	rm -f article/*.htm
	rm -f article/*_header.html
	rm -f contact/*.htm
	rm -f contact/*_header.html
	rm -f headers_index.htm

mrproper: clean
	rm -f index.html
	rm -f $(ALL_ARTICLES_OUT)
	rm -f $(ALL_ARTICLES_INTRO_OUT)
	rm -f contact/index.html