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_xen_statements.md 27 28 PANDOC_FILE_LIST = $(addprefix $(TMPDIR)/,$(FILE_LIST)) 29 30 PDF_OUT=CIL_Reference_Guide.pdf 31 HTML_OUT=CIL_Reference_Guide.html 32 PANDOC = pandoc 33 34 all: html pdf 35 36 $(TMPDIR): 37 mkdir -p $(TMPDIR) 38 39 $(TMPDIR)/%.md: %.md | $(TMPDIR) 40 cp -f $< $(TMPDIR)/ 41 @# Substitute markdown links for conversion into PDF links 42 sed -i -re 's:(\[`[^`]*`\])\([^#]*([^\)]):\1\(\2:g' $@ 43 44 $(TMPDIR)/policy.cil: $(TESTDIR)/policy.cil 45 cp -f $< $@ 46 @# add a title for the TOC to policy.cil. This is needed to play nicely with the PDF conversion. 47 sed -i '1i Example Policy\n=========\n```' $@ 48 echo '```' >> $@ 49 50 html: $(PANDOC_FILE_LIST) $(TMPDIR)/policy.cil 51 mkdir -p $(HTMLDIR) 52 $(PANDOC) -t html $^ -o $(HTMLDIR)/$(HTML_OUT) 53 54 pdf: $(PANDOC_FILE_LIST) $(TMPDIR)/policy.cil 55 mkdir -p $(PDFDIR) 56 $(PANDOC) --standalone --toc $^ -o $(PDFDIR)/$(PDF_OUT) 57 58 clean: 59 rm -rf $(HTMLDIR) 60 rm -rf $(PDFDIR) 61 rm -rf $(TMPDIR) 62