Skip to content

Instantly share code, notes, and snippets.

@quantentunnels
Last active February 23, 2016 13:22
Show Gist options
  • Save quantentunnels/93557f7c7d7e120d7816 to your computer and use it in GitHub Desktop.
Save quantentunnels/93557f7c7d7e120d7816 to your computer and use it in GitHub Desktop.
# Makefile to convert media files to formats usable
# by pdfletex and beamer
.PHONY: videos figures clean all
## Target files ##
# collect media files in current directory:
epsFiles := $(wildcard *.eps)
svgFiles := $(wildcard *.svg)
aviFiles := $(wildcard *.avi)
# replace original file extensions with target extension
epsFiles := $(patsubst %.eps,%.pdf,$(epsFiles))
svgFiles := $(patsubst %.svg,%.pdf,$(svgFiles))
aviFiles := $(patsubst %.avi,%.mp4,$(aviFiles))
## Figures ##
figures: $(epsFiles) $(svgFiles)
%.pdf: %.eps
epstopdf $<
%.pdf: %.svg
inkscape -A $*.pdf $*.svg
## Videos ## (mp4 files are required by the media9 package for beamer)
videos: $(aviFiles)
%.mp4: %.avi
avconv -i $*.avi -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -c:v libx264 $*.mp4
## Main rule for the project, for example:
all: figures videos
#TODO "make clean" target
# cleanup routine (carefull for files that have no other source than pdf!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment