]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blobdiff - 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
index a93a5769695969a9e66ed38fda27c1c514d6c199..bdd65b519d6060797f2732221c2f36f49e1f6e7a 100644 (file)
@@ -1,9 +1,15 @@
-COMMANDS=$(wildcard ../cmd*.c)
-OBJS=$(COMMANDS:../%.c=%.o) docgen.o
+include ../../../rpp-lib/Makefile.config
+include ../../../rpp-lib/common.mk # for UPPERCASE
+include ../../Makefile.var
 
-CFLAGS=-Wall -std=c99 -I../.. -I../../cmdproc/include -I../../rpp-lib/rpp/include -DDOCGEN -DNULL=0 -D'CMD_HANDLER(x)=0'
+COMMANDS=$(notdir $(filter commands/cmd%,$(SOURCES)))
+OBJS=$(COMMANDS:%.c=%.o) docgen.o
 
-all: print-doc
+CFLAGS = -Wall -std=c99 -I../.. -I../../cmdproc/include -I../../rpp-lib/rpp/include -DDOCGEN -DNULL=0 -D'CMD_HANDLER(x)=0'
+CFLAGS += -DTARGET_$(call UPPERCASE,$(TARGET))
+
+
+all:print-doc
 
 print-doc: docgen
        ./docgen
@@ -13,18 +19,27 @@ docgen: $(OBJS)
 %.o: ../%.c
        $(CC) $(CFLAGS) -c -o $@ $<
 
-clean:
+clean::
        rm -f $(OBJS) docgen
 
+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_strict -t mediawiki > $@
+       (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_strict -t html --base-header-level=2 > $@
+       ./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