From a6cd08a8d5650f09f350b2e09ff026b33419d628 Mon Sep 17 00:00:00 2001
From: Malin Freeborn <malinfreeborn@tutamail.com>
Date: Tue, 15 Dec 2020 14:22:08 +0100
Subject: [PATCH] replace autocompile with Makefile

---
 .gitlab-ci.yml   | 11 ++---------
 CS/resources.tex | 21 ++++++++++-----------
 Makefile         | 20 ++++++++++++++++++++
 autocompile.sh   |  1 -
 4 files changed, 32 insertions(+), 21 deletions(-)
 create mode 100644 Makefile
 delete mode 120000 autocompile.sh

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ce7ee8d7..e830f6c8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,15 +1,8 @@
 compile_pdf:
   image: aergus/latex
   script:
-    - pdflatex main.tex
-    - makeglossaries main
-    - makeindex main.idx
-    - pdflatex main.tex
-    - mv main.pdf bind.pdf
-    - cd CS
-    - pdflatex resources.tex
-    - cd ..
-    - mv CS/resources.pdf .
+    - make resources
+    - make
   only:
     - master
     - run
diff --git a/CS/resources.tex b/CS/resources.tex
index dab1b998..41f1b820 100644
--- a/CS/resources.tex
+++ b/CS/resources.tex
@@ -1,28 +1,27 @@
 \documentclass[a4paper,openany]{report}
-\usepackage{glossaries}
 
-\input{../config/preamble.tex}
-\input{../config/monsters.tex}
+\usepackage{config/bind}
+\usepackage{config/monsters}
 
 \settoggle{verbose}{true}
 
 \begin{document}
 
-\input{GS.tex}
+\input{CS/GS.tex}
 
-\input{CS.tex}
+\input{CS/CS.tex}
 
-\input{CS.tex}
+\input{CS/CS.tex}
 
-\input{CS.tex}
+\input{CS/CS.tex}
 
-\input{CS.tex}
+\input{CS/CS.tex}
 
-\input{CS.tex}
+\input{CS/CS.tex}
 
-\input{CS.tex}
+\input{CS/CS.tex}
 
-\input{init.tex}
+\input{CS/init.tex}
 
 \end{document}
 
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..9247a3dc
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,20 @@
+filename=main
+branch := $(shell git rev-parse --abbrev-ref HEAD)
+output: main.pdf main.aux
+	pdflatex ${filename}.tex
+main.aux:
+	pdflatex ${filename}.tex
+main.pdf:
+	pdflatex ${filename}.tex
+resources:
+	pdflatex CS/resources.tex
+	cd ..
+	mv main.pdf bind.pdf
+tree:
+	[ -e ../config ] || ( echo "You don't have a local config repo" && exit 1 )
+	git status
+	git subtree -P config pull ../config ${branch}
+	git subtree -P config push ../config ${branch}
+
+clean:
+	rm *.aux *.toc *.acn *.log *.ptc *.out *.idx *.ist *.glo
diff --git a/autocompile.sh b/autocompile.sh
deleted file mode 120000
index fc81db84..00000000
--- a/autocompile.sh
+++ /dev/null
@@ -1 +0,0 @@
-config/autocompile.sh
\ No newline at end of file
-- 
GitLab