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 SED ?= sed
     35 
     36 OS := $(shell uname)
     37 ifeq ($(OS), Darwin)
     38 	SED := gsed
     39 endif
     40 
     41 all: html pdf
     42 
     43 $(TMPDIR):
     44 	mkdir -p $(TMPDIR)
     45 
     46 $(TMPDIR)/%.md: %.md | $(TMPDIR)
     47 	cp -f $< $(TMPDIR)/
     48 	@# Substitute markdown links for conversion into PDF links
     49 	$(SED) -i -re 's:(\[`[^`]*`\])\([^#]*([^\)]):\1\(\2:g' $@
     50 
     51 $(TMPDIR)/policy.cil: $(TESTDIR)/policy.cil
     52 	cp -f $< $@
     53 	@# add a title for the TOC to policy.cil. This is needed to play nicely with the PDF conversion.
     54 	$(SED) -i '1i Example Policy\n=========\n```' $@
     55 	echo '```' >> $@
     56 
     57 html: $(PANDOC_FILE_LIST) $(TMPDIR)/policy.cil
     58 	mkdir -p $(HTMLDIR)
     59 	$(PANDOC) -t html $^ -o $(HTMLDIR)/$(HTML_OUT)
     60 
     61 pdf: $(PANDOC_FILE_LIST) $(TMPDIR)/policy.cil
     62 	mkdir -p $(PDFDIR)
     63 	$(PANDOC) --standalone --toc $^ -o $(PDFDIR)/$(PDF_OUT)
     64 
     65 clean:
     66 	rm -rf $(HTMLDIR)
     67 	rm -rf $(PDFDIR)
     68 	rm -rf $(TMPDIR)
     69