SRC_DIR = src
BUILD_DIR = build
SPINE = title.xhtml \
        abstract.xhtml \
        frontmatter.xhtml \
        introduction.xhtml \
        prior-transduction.xhtml \
        four-level-transduction.xhtml \
        biphoton-generation.xhtml \
        conclusion.xhtml \
        bibliography.xhtml \
        barnett-longdell-reverse.xhtml \
        efficiency-fit.xhtml \
        printed-code.xhtml
FIGURES_DIR = figures
FIGURES = quantum-networking.png \
          hybrid-systems.png \
          lambda-and-v-systems.png \
          inhomogeneous-broadening.png \
          atoms-in-cavity.png \
          3lt-phase.png \
          3lt-replication.png \
          4lt-device-and-diagram.png \
          4lt-example-scan.png \
          feature-finding.png \
          4lt-pixel-intersections.png \
          trench-duplication.png \
          neighbourhood-integration.png \
          4lt-model-scan.png \
          4lt-scan-hyperbolas.png \
          4lt-hybridisation-ratio.png \
          biphoton-results-small.png \
          biphoton-results-large.png \
          4lt-power-calibration.png
SPINE_BUILD_PATHS = $(SPINE:%=$(BUILD_DIR)/%)
SPINE_SRC_PATHS = $(SPINE:%=$(SRC_DIR)/%)
FIGURES_PATHS = $(FIGURES:%=$(FIGURES_DIR)/%)
FIGURES_BUILD_PATHS = $(FIGURES:%=$(BUILD_DIR)/%)

TITLE = "Numerical Modelling for Microwave-Optical Transduction and Photon Pair Generation using Atomic Ensembles"
AUTHOR = "Maria Nicolae"
PRETTYDATE = "May 17, 2024"
ISODATE = "2024-05-17"

.PHONY: all clean

all: thesis.epub
clean:
	rm -f thesis.epub
	rm -f $(BUILD_DIR)/*

thesis.epub: $(SPINE_BUILD_PATHS) $(BUILD_DIR)/toc.xhtml \
             $(BUILD_DIR)/style.css $(BUILD_DIR)/signature.png \
			 $(FIGURES_BUILD_PATHS)
	epubsynth --output $@ \
	    --dc-title $(TITLE) \
	    --dc-identifier "https://marianicolae.com/files/MariaNicolaeHonoursThesis.epub" \
	    --dc-creator $(AUTHOR) \
	    --dc-date $(ISODATE) \
	    --dc-language "en-AU" \
	    --source-dir $(BUILD_DIR) \
	    --spine $(SPINE) \
	    --toc toc.xhtml \
	    --stylesheets style.css \
	    --resources signature.png $(FIGURES)
	epubcheck $@

$(SPINE_BUILD_PATHS) $(BUILD_DIR)/toc.xhtml: $(SPINE_SRC_PATHS) $(SRC_DIR)/toc.xhtml
	dochint $(SPINE) toc.xhtml \
	    --output $(BUILD_DIR) \
	    --source-dir $(SRC_DIR) \
	    --text-macro title $(TITLE) \
	    --text-macro author $(AUTHOR) \
	    --text-macro prettydate $(PRETTYDATE) \
	    --text-macro isodate $(ISODATE) \
	    --set-numbering introduction.xhtml 1 \
	    --set-numbering barnett-longdell-reverse.xhtml A

$(BUILD_DIR)/style.css: $(SRC_DIR)/style.css
	cp $< $@

$(BUILD_DIR)/signature.png: signature.png
	cp $< $@

$(FIGURES_BUILD_PATHS): $(BUILD_DIR)/%: $(FIGURES_DIR)/%
	cp $< $@
