1CWD = $(shell pwd) 2HTMLDIR = $(CWD)/html 3PDFDIR = $(CWD)/pdf 4TMPDIR = $(CWD)/tmp 5TESTDIR = $(CWD)/../test 6 7# All the markdown files that make up the guide: 8FILE_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 29PANDOC_FILE_LIST = $(addprefix $(TMPDIR)/,$(FILE_LIST)) 30 31PANDOC_HIGHLIGHT_STYLE="theme.theme" 32 33PDF_OUT=CIL_Reference_Guide.pdf 34HTML_OUT=CIL_Reference_Guide.html 35PANDOC = pandoc 36SED ?= sed 37 38OS := $(shell uname) 39ifeq ($(OS), Darwin) 40 SED := gsed 41endif 42 43all: html pdf 44 45$(TMPDIR): 46 mkdir -p $(TMPDIR) 47 48$(TMPDIR)/%.md: %.md | $(TMPDIR) 49 cp -f $< $(TMPDIR)/ 50 @# Substitute markdown links for conversion into PDF links 51 $(SED) -i -re 's:(\[`[^`]*`\])\([^#]*([^\)]):\1\(\2:g' $@ 52 53$(TMPDIR)/policy.cil: $(TESTDIR)/policy.cil 54 cp -f $< $@ 55 @# add a title for the TOC to policy.cil. This is needed to play nicely with the PDF conversion. 56 $(SED) -i '1i Example Policy\n=========\n```secil' $@ 57 echo '```' >> $@ 58 59html: $(PANDOC_FILE_LIST) $(TMPDIR)/policy.cil secil.xml 60 mkdir -p $(HTMLDIR) 61 $(PANDOC) --highlight-style=$(PANDOC_HIGHLIGHT_STYLE) --syntax-definition=secil.xml --standalone --metadata title="CIL Reference Guide" -t html $(PANDOC_FILE_LIST) $(TMPDIR)/policy.cil -o $(HTMLDIR)/$(HTML_OUT) 62 63pdf: $(PANDOC_FILE_LIST) $(TMPDIR)/policy.cil secil.xml 64 mkdir -p $(PDFDIR) 65 $(PANDOC) --highlight-style=$(PANDOC_HIGHLIGHT_STYLE) --syntax-definition=secil.xml --standalone --toc $(PANDOC_FILE_LIST) $(TMPDIR)/policy.cil -o $(PDFDIR)/$(PDF_OUT) 66 67clean: 68 rm -rf $(HTMLDIR) 69 rm -rf $(PDFDIR) 70 rm -rf $(TMPDIR) 71