]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blob - rpp-test-sw/commands/doc/Makefile
Generate documentation correctly depending on the selected target
[pes-rpp/rpp-test-sw.git] / rpp-test-sw / commands / doc / Makefile
1 include ../../../rpp-lib/Makefile.config
2 include ../../../rpp-lib/common.mk # for UPPERCASE
3 include ../../Makefile.var
4
5 COMMANDS=$(notdir $(filter commands/cmd%,$(SOURCES)))
6 OBJS=$(COMMANDS:%.c=%.o) docgen.o
7
8 CFLAGS = -Wall -std=c99 -I../.. -I../../cmdproc/include -I../../rpp-lib/rpp/include -DDOCGEN -DNULL=0 -D'CMD_HANDLER(x)=0'
9 CFLAGS += -DTARGET_$(call UPPERCASE,$(TARGET))
10
11
12 all:print-doc
13
14 print-doc: docgen
15         ./docgen
16
17 docgen: $(OBJS)
18
19 %.o: ../%.c
20         $(CC) $(CFLAGS) -c -o $@ $<
21
22 clean::
23         rm -f $(OBJS) docgen
24
25 markdown = $(shell if pandoc -h|grep -q markdown_strict; then echo markdown_strict; else echo markdown; fi)
26
27 doc.mw: docgen
28         (echo '<div class="toclimit-2" style="float: right; margin-left: 1em;">__TOC__</div>'; ./docgen wiki) | pandoc -f $(markdown) -t mediawiki > $@
29
30 doc.mdwn: docgen Makefile
31 #       ./docgen wiki | pandoc -f markdown_strict -t markdown_strict > $@
32         ./docgen wiki  > $@
33
34 doc.html: docgen Makefile
35         ./docgen wiki | pandoc -f $(markdown) -t html --base-header-level=2 > $@
36
37
38 doc.tex: docgen Makefile
39         ./docgen pdfdoc > $@.1
40         pandoc -f $(markdown) -t latex --base-header-level=1 $@.1 -o $@.2
41         sed -e 's/\\subsection/\\newpage\\subsection/' $@.2 > $@
42         rm $@.?
43
44 upload: upload-mw upload-web
45
46 upload-mw: doc.mw
47         cat $< | ./wiki-edit.pl TestCommands -
48
49 WEB=../../../../web/
50 WEBDST=$(WEB)test-sw-commands/rpp-test-sw.mdwn
51 upload-web: doc.mdwn
52 ifneq ($(wildcard $(WEBDST)),)
53         cp $< $(WEBDST)
54         make -C $(WEB)
55         git -C $(WEB) add $(WEBDST:$(WEB)%=%)
56         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
57 endif
58
59 FORCE: