--- /dev/null
+# Based on the Latex SConstruct at
+# https://gutefee.massey.ac.nz/moin/HOWTO/LaTeX/LaTeX-SCons-Builder
+#
+import os
+import os.path
+
+#### Some configurations.
+
+LATEX_PROJECT = 'Core2Core'
+
+DEFAULT_TARGET = 'pdf'
+
+GNUPLOT_DIAGRAMS = []
+
+EPS_FIGURES = []
+
+PDF_FIGURES = []
+
+## Some rather fixed configurations:
+
+GNUPLOT_DIRECTORY = 'images'
+GNUPLOT_EXTENSION = '.gnuplot'
+EPS_DIRECTORY = 'eps'
+EPS_EXTENSION = '.eps'
+PDF_DIRECTORY = 'pdf'
+PDF_EXTENSION = '.pdf'
+
+#MAKEINDEX_EXTENSIONS = ['.glg', '.glo', '.gls']
+
+
+#### Defining some new builders.
+env = Environment()
+
+## eps2pdf Builder:
+pdfBuilder = Builder(action='epstopdf $SOURCE --outfile=$TARGET',
+ suffix='.pdf',
+ src_suffix='.eps')
+env.Append(BUILDERS={'Eps2pdf': pdfBuilder})
+
+## eps2eps Builder:
+epsBuilder = Builder(action='pdftops -eps -level3 $SOURCE $TARGET',
+ suffix='.eps',
+ src_suffix='.pdf')
+env.Append(BUILDERS={'Pdf2eps': epsBuilder})
+
+## GNUplot Builder:
+gnuplotBuilder = Builder(action='gnuplot $SOURCE',
+ suffix='.eps',
+ src_suffix='.gnuplot')
+env.Append(BUILDERS={'Gnuplot': gnuplotBuilder})
+
+## Context MkIV Builder:
+contextBuilder = Builder(action=['texexec --lua $SOURCE','scp $TARGET ewi:'],
+ suffix='.pdf',
+ src_suffix='.tex')
+env.Append(BUILDERS={'Context': contextBuilder})
+
+# Import tex settings from the user environment
+env['ENV']['TEXMFCNF'] = os.environ['TEXMFCNF']
+env['ENV']['HOME'] = os.environ['HOME']
+# Allow the SSH agent to be used
+env['ENV']['SSH_AUTH_SOCK'] = os.environ['SSH_AUTH_SOCK']
+
+
+#### The actual builds.
+
+## Context PDF build
+pdfOutput = env.Context(LATEX_PROJECT)
+env.Alias('pdf', LATEX_PROJECT + '.pdf')
+
+# Keep below code happy
+dviOutput = pdfOutput
+
+Default(DEFAULT_TARGET)
+
+## Create makeindex file list for dependencies and clean up:
+#for item in MAKEINDEX_EXTENSIONS:
+# fileName = os.path.join(LATEX_PROJECT + item)
+# Depends(dviOutput, fileName)
+# Depends(pdfOutput, fileName)
+# Clean(dviOutput, fileName)
+# Clean(pdfOutput, fileName)
+
+## Build GNUplot figures:
+for item in GNUPLOT_DIAGRAMS:
+ gnuplotFile = os.path.join(GNUPLOT_DIRECTORY, item + GNUPLOT_EXTENSION)
+ epsFile = os.path.join(EPS_DIRECTORY, item + EPS_EXTENSION)
+ pdfFile = os.path.join(PDF_DIRECTORY, item + PDF_EXTENSION)
+
+ env.Gnuplot(epsFile, gnuplotFile)
+ dep = env.Eps2pdf(pdfFile, epsFile)
+ Depends(dep, epsFile)
+
+ Depends(dviOutput, pdfFile)
+ Depends(pdfOutput, pdfFile)
+
+## Build PDF figures:
+for item in PDF_FIGURES:
+ epsFile = os.path.join(EPS_DIRECTORY, item + EPS_EXTENSION)
+ pdfFile = os.path.join(PDF_DIRECTORY, item + PDF_EXTENSION)
+
+ env.Pdf2eps(epsFile, pdfFile)
+
+ Depends(dviOutput, epsFile)
+
+## Build EPS figures:
+for item in EPS_FIGURES:
+ epsFile = os.path.join(EPS_DIRECTORY, item + EPS_EXTENSION)
+ pdfFile = os.path.join(PDF_DIRECTORY, item + PDF_EXTENSION)
+
+ env.Eps2pdf(pdfFile, epsFile)
+
+ Depends(pdfOutput, pdfFile)