This is a makefile build system to build a fairly large
-
Seperation of build files and source files.
BibTeX
normally doesn't support writing output files to directories outside the source file. But here we don't want to clutter our source with build files. The workaround is to creat symlinks in the source pointing to the build directory. These symlinks can later be removed. -
Configurablity.
A number variables allow you to organise your own source directory. the makefile will detect all tex files within that directory. Further you can configure dependancies with a
config.mk
file, which allows you to do things like build the main file even when there are work-in-progress subfiles. -
Automatic detection of source files.
As mentioned above, This makefile will detect the source files once you configure your project directory structure. This structure needs to be defined only once when you first build your project.
Usage is simple, Downlaod the makefile and place it in your project directory:
cd /path/to/your/project
# Downlaod using curl
curl -sL https://raw.githubusercontent.com/SidhBhat/make-latex/main/Makefile > Makefile
After that you will need to do first time configuration by setting some variables within the makefile:
### ------- User Configurable Options ------- ###
## ------------- Latex executables ------------- ##
LATEX = xelatex
BIBTEX = bibtex
LATEX_FLAGS = -interaction=batchmode
## ------- Project directories and files ------- ##
# Source Directory: where all your latex files are located
SRCDIR = src/
# Build Directory: where the build files should be written
BUILDIR = build/
## NOTE: EVERYTHING BELOW IS RELATIVE TO SOURCE DIRECTORY NOTE ##
# Subfiles Directory: where files compiled as subfiles are located
# NOTE: these files should be compilable as independant latex files
SUBDIR = subfiles/
# TEX Directory: where you want make to search for your helper scripts
TEXDIR = tex/
# Image Directory: where you want make to search for your images
IMGDIR = images/
# The main tex file for the project
MAINFILE = main.tex
# How you want the output pdf file to be called
OUTPUT = main.pdf
## ---------------------------------------------- ##
# The Shell interpreter
SHELL = bash
## ---------------------------------------------- ##
The comments should guide you pretty good enough.
The directory structure expected by make will be:
graph
ProjectDir-->Makefile
ProjectDir-->srcdir/
ProjectDir-->buildir/
srcdir/-->subdir/
srcdir/-->texdir/
srcdir/-->imgdir/
srcdir/-->user_packages
srcdir/-->bibliography_files
srcdir/-->mainfile.tex
buildir/-->mainfile.pdf
buildir/-->sub-buildir/-->subfile.pdfs
We have a number of standard phony targets like build
.
# build the main document
make build
# clean
make clean
You can even specify the name of the output pdf wihout the directory prefix. for the
subfiles prefix only the SUBDIR
before the file name.
# build the main file
make main.pdf
# build some subfile
make subfiles/somesubfile.pdf
You can get the list of all targets with:
make help
There is one special target generate-configfile
, which generates a file called config.mk
.
This file is then included in the main makefile.
make generate-configfile
# or make config.mk
This file contains some varibles, where you can list the dependancies of the file.
I store the src/
to
.git/info/exclude
so you can test before you commit. Another tag marks
a complete setup of this project including the configured makefile.
I currently have no official channel for contributions, you can simply create a merge request.