]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blobdiff - rpp-test-sw/commands/doc/Makefile
Merge branches 'master' and 'rm48/master'
[pes-rpp/rpp-test-sw.git] / rpp-test-sw / commands / doc / Makefile
index 02494017fe9e075909b5a113bb6ff01f409247c6..6f1d32c17e7e003289436d23ff17077ea5734c4d 100644 (file)
@@ -1,9 +1,13 @@
+include ../../../rpp-lib/Makefile.config
+
 COMMANDS=$(wildcard ../cmd*.c)
+COMMANDS+=$(wildcard ../_$(TARGET)/cmd*.c)
 OBJS=$(COMMANDS:../%.c=%.o) docgen.o
 
 CFLAGS=-Wall -std=c99 -I../.. -I../../cmdproc/include -I../../rpp-lib/rpp/include -DDOCGEN -DNULL=0 -D'CMD_HANDLER(x)=0'
 
-all: print-doc
+
+all:print-doc
 
 print-doc: docgen
        ./docgen
@@ -13,11 +17,46 @@ docgen: $(OBJS)
 %.o: ../%.c
        $(CC) $(CFLAGS) -c -o $@ $<
 
+_$(TARGET)/%.o: ../_$(TARGET)/%.c
+       mkdir -p _$(TARGET)
+       $(CC) $(CFLAGS) -c -o $@ $<
+
 clean:
        rm -f $(OBJS) docgen
+       rm -rf _$(TARGET)
+
+markdown = $(shell if pandoc -h|grep -q markdown_strict; then echo markdown_strict; else echo markdown; fi)
+
+doc.mw: docgen
+       (echo '<div class="toclimit-2" style="float: right; margin-left: 1em;">__TOC__</div>'; ./docgen wiki) | pandoc -f $(markdown) -t mediawiki > $@
+
+doc.mdwn: docgen Makefile
+#      ./docgen wiki | pandoc -f markdown_strict -t markdown_strict > $@
+       ./docgen wiki  > $@
+
+doc.html: docgen Makefile
+       ./docgen wiki | pandoc -f $(markdown) -t html --base-header-level=2 > $@
+
+
+doc.tex: docgen Makefile
+       ./docgen pdfdoc > $@.1
+       pandoc -f $(markdown) -t latex --base-header-level=1 $@.1 -o $@.2
+       sed -e 's/\\subsection/\\newpage\\subsection/' $@.2 > $@
+       rm $@.?
+
+upload: upload-mw upload-web
 
+upload-mw: doc.mw
+       cat $< | ./wiki-edit.pl TestCommands -
 
-upload: docgen
-       ./docgen wiki | ./wiki-edit.pl TestCommands -
+WEB=../../../../web/
+WEBDST=$(WEB)test-sw-commands/rpp-test-sw.mdwn
+upload-web: doc.mdwn
+ifneq ($(wildcard $(WEBDST)),)
+       cp $< $(WEBDST)
+       make -C $(WEB)
+       git -C $(WEB) add $(WEBDST:$(WEB)%=%)
+       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
+endif
 
 FORCE: