move Makefile callables to lev-templates.mk
This commit is contained in:
		
							parent
							
								
									7fdbc77a7f
								
							
						
					
					
						commit
						b585819c7b
					
				
					 2 changed files with 80 additions and 74 deletions
				
			
		
							
								
								
									
										64
									
								
								src/lenaisten/lev-templates.mk
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								src/lenaisten/lev-templates.mk
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,64 @@ | |||
| # compile markdown using pandoc
 | ||||
| # params:
 | ||||
| # 1: input file
 | ||||
| # 2: pandoc template
 | ||||
| # 3: output format
 | ||||
| # 4: output file
 | ||||
| compile_md = pandoc \
 | ||||
| 	$(1) \
 | ||||
| 	--standalone \
 | ||||
| 	--from markdown \
 | ||||
| 	--to $(3) \
 | ||||
| 	--template $(2) \
 | ||||
| 	--variable colorlinks:true \
 | ||||
| 	--variable csquotes:true \
 | ||||
| 	--variable hyperrefoptions:pdfa \
 | ||||
| 	--variable lang:de-DE \
 | ||||
| 	--output $(4) | ||||
| 
 | ||||
| GSFLAGS := \
 | ||||
| 	-sDEVICE=pdfwrite \
 | ||||
| 	-dNOOUTERSAVE \
 | ||||
| 	-dNOPAUSE \
 | ||||
| 	-dQUIET \
 | ||||
| 	-dBATCH | ||||
| 
 | ||||
| # post-process and compress PDF files
 | ||||
| # params:
 | ||||
| # 1: input file
 | ||||
| # 2: output file
 | ||||
| postprocess_pdf = gs \
 | ||||
| 	$(GSFLAGS) \
 | ||||
| 	-sPAPERSIZE=a4 \
 | ||||
| 	-dFIXEDMEDIA \
 | ||||
| 	-dPDFFitPage \
 | ||||
| 	-dCompatibilityLevel=1.7 \
 | ||||
| 	-dPDFSETTINGS=/ebook \
 | ||||
| 	-sOutputFile=$(2) \
 | ||||
| 	$(1) | ||||
| 
 | ||||
| # convert PDF to PDF/A 2-b
 | ||||
| # params:
 | ||||
| # 1: input file
 | ||||
| # 2: output file
 | ||||
| convert_pdfa = /opt/pdfa/bin/gs-919-linux_x86_64 \
 | ||||
| 	$(GSFLAGS) \
 | ||||
| 	-dPDFA=2 \
 | ||||
| 	-sProcessColorModel=DeviceRGB \
 | ||||
| 	-dPDFACompatibilityPolicy=1 \
 | ||||
| 	-sOutputFile=$(2) \
 | ||||
| 	/opt/pdfa/PDFA_def.ps \
 | ||||
| 	$(1) | ||||
| 
 | ||||
| # convert markdown to PDF
 | ||||
| # params:
 | ||||
| # 1: input file
 | ||||
| # 2: pandoc template
 | ||||
| # 3: output file
 | ||||
| md2pdf = $(call compile_md,$(1),$(2),pdf,-) | $(call postprocess_pdf,-,$(3)) | ||||
| 
 | ||||
| # convert markdown to PDF
 | ||||
| # 1: input file
 | ||||
| # 2: pandoc template
 | ||||
| # 3: output file
 | ||||
| md2pdfa = $(call md2pdf,$(1),$(2),-) | $(call convert_pdfa,-,$(3)) | ||||
|  | @ -1,97 +1,39 @@ | |||
| #%SRCPAT% \.prot\.md
 | ||||
| 
 | ||||
| ############
 | ||||
| # Settings #
 | ||||
| ############
 | ||||
| include lev-templates.mk | ||||
| 
 | ||||
| suffixPub := | ||||
| suffixInt := _intern | ||||
| 
 | ||||
| 
 | ||||
| ###########
 | ||||
| # Default #
 | ||||
| ###########
 | ||||
| 
 | ||||
| suffixSubst = $(patsubst %.$(2),%$(4).$(3),$(1)) | ||||
| 
 | ||||
| mdFiles     := $(wildcard *.prot.md) | ||||
| mdSuffix    =  $(patsubst %.prot.md,%$(1),$(mdFiles)) | ||||
| 
 | ||||
| pdfFilesPub := $(call suffixSubst,$(mdFiles),prot.md,pdf,$(suffixPub)) | ||||
| texFilesPub := $(call suffixSubst,$(mdFiles),prot.md,tex,$(suffixPub)) | ||||
| pdfFilesPub := $(call mdSuffix,$(suffixPub).pdf) | ||||
| texFilesPub := $(call mdSuffix,$(suffixPub).tex) | ||||
| 
 | ||||
| pdfFilesInt := $(call suffixSubst,$(mdFiles),prot.md,pdf,$(suffixInt)) | ||||
| texFilesInt := $(call suffixSubst,$(mdFiles),prot.md,tex,$(suffixInt)) | ||||
| pdfFilesInt := $(call mdSuffix,$(suffixInt).pdf) | ||||
| texFilesInt := $(call mdSuffix,$(suffixInt).tex) | ||||
| 
 | ||||
| .PHONY: all pdf pdfPub pdfInt tex texPub texInt | ||||
| all: pdf | ||||
| .PHONY: all autodoc | ||||
| all: pdf tex | ||||
| autodoc: pdf | ||||
| 
 | ||||
| pdf: pdfPub pdfInt | ||||
| pdfPub: $(pdfFilesPub) | ||||
| pdfInt: $(pdfFilesInt) | ||||
| 
 | ||||
| tex: texPub texInt | ||||
| texPub: $(texFilesPub) | ||||
| texInt: $(texFilesInt) | ||||
| 
 | ||||
| 
 | ||||
| ###########
 | ||||
| # Recipes #
 | ||||
| ###########
 | ||||
| 
 | ||||
| compile_md = pandoc \
 | ||||
| 	$(2) \
 | ||||
| 	--standalone \
 | ||||
| 	--from markdown \
 | ||||
| 	--to $(1) \
 | ||||
| 	--template lev-protokoll \
 | ||||
| 	--variable colorlinks:true \
 | ||||
| 	--variable csquotes:true \
 | ||||
| 	--variable hyperrefoptions:pdfa \
 | ||||
| 	--variable lang:de-DE \
 | ||||
| 	--output $(3) | ||||
| 
 | ||||
| GSFLAGS := \
 | ||||
| 	-sDEVICE=pdfwrite \
 | ||||
| 	-dNOOUTERSAVE \
 | ||||
| 	-dNOPAUSE \
 | ||||
| 	-dQUIET \
 | ||||
| 	-dBATCH | ||||
| 
 | ||||
| postprocess_pdf = gs \
 | ||||
| 	$(GSFLAGS) \
 | ||||
| 	-sPAPERSIZE=a4 \
 | ||||
| 	-dFIXEDMEDIA \
 | ||||
| 	-dPDFFitPage \
 | ||||
| 	-dCompatibilityLevel=1.7 \
 | ||||
| 	-dPDFSETTINGS=/ebook \
 | ||||
| 	-sOutputFile=$(2) \
 | ||||
| 	$(1) | ||||
| 
 | ||||
| convert_pdfa = /opt/pdfa/bin/gs-919-linux_x86_64 \
 | ||||
| 	$(GSFLAGS) \
 | ||||
| 	-dPDFA=2 \
 | ||||
| 	-sProcessColorModel=DeviceRGB \
 | ||||
| 	-dPDFACompatibilityPolicy=1 \
 | ||||
| 	-sOutputFile=$(2) \
 | ||||
| 	/opt/pdfa/PDFA_def.ps \
 | ||||
| 	$(1) | ||||
| 
 | ||||
| md2pdf = $(call compile_md,pdf,$(1),-) | $(call postprocess_pdf,-,$(2)) | ||||
| 
 | ||||
| md2pdfa = $(call md2pdf,$(1),-) | $(call convert_pdfa,-,$(2)) | ||||
| .PHONY: pdf tex | ||||
| pdf: $(pdfFilesPub) $(pdfFilesInt) | ||||
| tex: $(texFilesPub) $(texFilesInt) | ||||
| 
 | ||||
| # pdf
 | ||||
| 
 | ||||
| %$(suffixPub).pdf: %.prot.md lev-shorthands.sty | ||||
| 	python3 /opt/lenaisten/redact.py $< | $(call md2pdfa,-,$@) | ||||
| 	python3 /opt/lenaisten/redact.py $< | $(call md2pdfa,-,lev-protokoll,$@) | ||||
| 
 | ||||
| %$(suffixInt).pdf: %.prot.md lev-shorthands.sty | ||||
| 	python3 /opt/lenaisten/redact.py -i $< | $(call md2pdfa,-,$@) | ||||
| 	python3 /opt/lenaisten/redact.py --internal $< | $(call md2pdfa,-,lev-protokoll,$@) | ||||
| 
 | ||||
| # tex
 | ||||
| 
 | ||||
| %$(suffixPub).tex: %.prot.md lev-shorthands.sty | ||||
| 	python3 /opt/lenaisten/redact.py $< | $(call compile_md,latex,-,$@) | ||||
| 	python3 /opt/lenaisten/redact.py $< | $(call compile_md,-,lev-protokoll,latex,$@) | ||||
| 
 | ||||
| %$(suffixInt).tex: %.prot.md lev-shorthands.sty | ||||
| 	python3 /opt/lenaisten/redact.py -i $< | $(call compile_md,latex,-,$@) | ||||
| 	python3 /opt/lenaisten/redact.py --internal $< | $(call compile_md,-,lev-protokoll,latex,$@) | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue