]> rtime.felk.cvut.cz Git - rpp-test-sw.git/blob - rpp-test-sw/commands/doc/Makefile
cmd: Add echoserver functionality and command
[rpp-test-sw.git] / rpp-test-sw / commands / doc / Makefile
1 COMMANDS=$(wildcard ../cmd*.c)
2 OBJS=$(COMMANDS:../%.c=%.o) docgen.o
3
4 CFLAGS=-Wall -std=c99 -I../.. -I../../cmdproc/include -I../../rpp-lib/rpp/include -DDOCGEN -DNULL=0 -D'CMD_HANDLER(x)=0'
5
6 all: print-doc
7
8 print-doc: docgen
9         ./docgen
10
11 docgen: $(OBJS)
12
13 %.o: ../%.c
14         $(CC) $(CFLAGS) -c -o $@ $<
15
16 clean:
17         rm -f $(OBJS) docgen
18
19 markdown = $(shell if pandoc -h|grep -q markdown_strict; then echo markdown_strict; else echo markdown; fi)
20
21 doc.mw: docgen
22         (echo '<div class="toclimit-2" style="float: right; margin-left: 1em;">__TOC__</div>'; ./docgen wiki) | pandoc -f $(markdown) -t mediawiki > $@
23
24 doc.mdwn: docgen Makefile
25 #       ./docgen wiki | pandoc -f markdown_strict -t markdown_strict > $@
26         ./docgen wiki  > $@
27
28 doc.html: docgen Makefile
29         ./docgen wiki | pandoc -f $(markdown) -t html --base-header-level=2 > $@
30
31
32 doc.tex: docgen Makefile
33         ./docgen pdfdoc > $@.1
34         pandoc -f $(markdown) -t latex --base-header-level=1 $@.1 -o $@.2
35         sed -e 's/\\subsection/\\newpage\\subsection/' $@.2 > $@
36         rm $@.?
37
38 upload: upload-mw upload-web
39
40 upload-mw: doc.mw
41         cat $< | ./wiki-edit.pl TestCommands -
42
43 WEB=../../../../web/
44 WEBDST=$(WEB)test-sw-commands/rpp-test-sw.mdwn
45 upload-web: doc.mdwn
46 ifneq ($(wildcard $(WEBDST)),)
47         cp $< $(WEBDST)
48         make -C $(WEB)
49         git -C $(WEB) add $(WEBDST:$(WEB)%=%)
50         if ! git -C $(WEB) diff --cached --quiet; then git  -C $(WEB) commit -m 'Automatic update of command reference' $(WEBDST:$(WEB)%=%) && git -C $(WEB) push; fi
51 endif
52
53 FORCE: