mmore500 / mmore500/paperproject

Port build of draft in tmpdir

Open
#1 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

SHELL=/bin/bash

# get the basename of the containing directory
# this will be used to name othe output document
BUILD_DIR := oee4

SESSION_ID := x$(shell date +%s%3N)

DRAFT_SUPPLEMENT_PAGE = $(shell pdftk ${BUILD_DIR}-draft.pdf dump_data_utf8 | pcregrep -M -o1 '^BookmarkBegin\nBookmarkTitle: Supplemental Material\nBookmarkLevel: 1\nBookmarkPageNumber: ([0-9]+)$$')

RELEASE_SUPPLEMENT_PAGE = $(shell pdftk ${BUILD_DIR}.pdf dump_data_utf8 | pcregrep -M -o1 '^BookmarkBegin\nBookmarkTitle: Supplemental Material\nBookmarkLevel: 1\nBookmarkPageNumber: ([0-9]+)$$')

all: ${BUILD_DIR}-draft.pdf

draft: ${BUILD_DIR}-draft.pdf ${BUILD_DIR}-manuscript-draft.pdf ${BUILD_DIR}-supplement-draft.pdf ${BUILD_DIR}-draft.tex

release: ${BUILD_DIR}.pdf ${BUILD_DIR}-manuscript.pdf ${BUILD_DIR}-supplement.pdf ${BUILD_DIR}.tex

${BUILD_DIR}.pdf: main.tex
	latexmk -pdf -silent \
    -jobname=${BUILD_DIR} \
    -pdflatex="pdflatex -interaction=nonstopmode" main.tex

${BUILD_DIR}.tex: main.tex
	./script/latexpand.pl main.tex > ${BUILD_DIR}.tex

${BUILD_DIR}-manuscript.pdf: ${BUILD_DIR}.pdf
	pdftk ${BUILD_DIR}.pdf cat 1-$$(( $(RELEASE_SUPPLEMENT_PAGE) - 1 )) output ${BUILD_DIR}-manuscript.pdf

${BUILD_DIR}-supplement.pdf: ${BUILD_DIR}.pdf
	pdftk ${BUILD_DIR}.pdf cat $(RELEASE_SUPPLEMENT_PAGE)-end output ${BUILD_DIR}-supplement.pdf

${BUILD_DIR}-draft.pdf: main.tex bibl.bib draft.tex $(shell find tex -type f) fig/* img/* lib/*
	mkdir -p /tmp/${SESSION_ID}
	ln -sf /tmp/${SESSION_ID}/${BUILD_DIR}-draft.log ${BUILD_DIR}-draft.log
	latexmk -pdf -silent \
    -jobname=${BUILD_DIR}-draft \
	-outdir=/tmp/${SESSION_ID} \
    -pdflatex="pdflatex -interaction=nonstopmode" draft.tex
	mv -f /tmp/${SESSION_ID}/${BUILD_DIR}-draft.pdf ${BUILD_DIR}-draft.pdf
	mv -f /tmp/${SESSION_ID}/${BUILD_DIR}-draft.log ${BUILD_DIR}-draft.log
	rm -rf /tmp/${SESSION_ID}

${BUILD_DIR}-draft.tex: main.tex
	./script/latexpand.pl draft.tex > ${BUILD_DIR}-draft.tex

${BUILD_DIR}-manuscript-draft.pdf: ${BUILD_DIR}-draft.pdf
	pdftk ${BUILD_DIR}-draft.pdf cat 1-$$(( $(DRAFT_SUPPLEMENT_PAGE) - 1 )) output ${BUILD_DIR}-manuscript-draft.pdf

${BUILD_DIR}-supplement-draft.pdf: ${BUILD_DIR}-draft.pdf
	pdftk ${BUILD_DIR}-draft.pdf cat $(DRAFT_SUPPLEMENT_PAGE)-end output ${BUILD_DIR}-supplement-draft.pdf

fresh: cleaner all

clean:
	rm -f ${BUILD_DIR}.pdf
	rm -f ${BUILD_DIR}.tex
	rm -f ${BUILD_DIR}-draft.pdf
	rm -f ${BUILD_DIR}-draft.tex
	rm -f ${BUILD_DIR}-manuscript.pdf
	rm -f ${BUILD_DIR}-manuscript-draft.pdf
	rm -f ${BUILD_DIR}-supplement.pdf
	rm -f ${BUILD_DIR}-supplement-draft.pdf

sview:
	xdg-open ${BUILD_DIR}-draft.pdf 2>/dev/null

cleaner: clean
	latexmk -CA
	# remove auxillary files, excepting .tex and .bib files
	find . -type f -name ${BUILD_DIR}"*" ! -name '*.tex' ! -name '*.bib' -delete
	rm -rf *.bbl *.blg *.aux

.PHONY: draft release clean sview cleaner fresh

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Makefile draft target and inspect its latexmk, temporary-directory, move, and cleanup steps. Run make draft and check whether the draft PDF and log are produced as intended and whether temporary files are removed; the issue needs a clearer definition of the expected port before completion can be verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, latex, shell
Domain
build-system
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.