Home | History | Annotate | Download | only in docs
      1 CWD ?= $(shell pwd)
      2 HTMLDIR ?= $(CWD)/html
      3 PDFDIR ?= $(CWD)/pdf
      4 TMPDIR ?= $(CWD)/tmp
      5 TESTDIR ?= $(CWD)/../test
      6 
      7 # All the markdown files that make up the guide:
      8 FILE_LIST ?= cil_introduction.md \
      9 	cil_reference_guide.md \
     10 	cil_access_vector_rules.md \
     11 	cil_call_macro_statements.md \
     12 	cil_class_and_permission_statements.md \
     13 	cil_conditional_statements.md \
     14 	cil_constraint_statements.md \
     15 	cil_container_statements.md \
     16 	cil_context_statement.md \
     17 	cil_default_object_statements.md \
     18 	cil_file_labeling_statements.md \
     19 	cil_mls_labeling_statements.md \
     20 	cil_network_labeling_statements.md \
     21 	cil_policy_config_statements.md \
     22 	cil_role_statements.md \
     23 	cil_sid_statements.md \
     24 	cil_type_statements.md \
     25 	cil_user_statements.md \
     26 	cil_infiniband_statements.md \
     27 	cil_xen_statements.md
     28 
     29 PANDOC_FILE_LIST = $(addprefix $(TMPDIR)/,$(FILE_LIST))
     30 
     31 PDF_OUT=CIL_Reference_Guide.pdf
     32 HTML_OUT=CIL_Reference_Guide.html
     33 PANDOC = pandoc
     34 
     35 all: html pdf
     36 
     37 $(TMPDIR):
     38 	mkdir -p $(TMPDIR)
     39 
     40 $(TMPDIR)/%.md: %.md | $(TMPDIR)
     41 	cp -f $< $(TMPDIR)/
     42 	@# Substitute markdown links for conversion into PDF links
     43 	sed -i -re 's:(\[`[^`]*`\])\([^#]*([^\)]):\1\(\2:g' $@
     44 
     45 $(TMPDIR)/policy.cil: $(TESTDIR)/policy.cil
     46 	cp -f $< $@
     47 	@# add a title for the TOC to policy.cil. This is needed to play nicely with the PDF conversion.
     48 	sed -i '1i Example Policy\n=========\n```' $@
     49 	echo '```' >> $@
     50 
     51 html: $(PANDOC_FILE_LIST) $(TMPDIR)/policy.cil
     52 	mkdir -p $(HTMLDIR)
     53 	$(PANDOC) -t html $^ -o $(HTMLDIR)/$(HTML_OUT)
     54 
     55 pdf: $(PANDOC_FILE_LIST) $(TMPDIR)/policy.cil
     56 	mkdir -p $(PDFDIR)
     57 	$(PANDOC) --standalone --toc $^ -o $(PDFDIR)/$(PDF_OUT)
     58 
     59 clean:
     60 	rm -rf $(HTMLDIR)
     61 	rm -rf $(PDFDIR)
     62 	rm -rf $(TMPDIR)
     63