#############################
# Graphics file compilation #
#############################
#
# Asymptote
#
sub asy2pdf {
  my $fn = shift;
  my ($basename, $dirname) = fileparse($fn);
  return system("asy -f pdf -cd '$dirname' '$basename'");
}
add_cus_dep("asy","pdf",0,"asy2pdf");
#
# If your asymptote files are only inline then the previous pdf asymptote
# command is not required.  Just uncomment the pdf line
# below.  This fails in the case of external asy -> pdf compilation
# for which the asy command does not know to make a pdf however.
sub asy {
  my $fn = shift;
  my ($basename, $dirname) = fileparse($fn);
  return system("asy -cd '$dirname' '$basename'");
}
#add_cus_dep("asy","pdf",0,"asy");
add_cus_dep("asy","eps",0,"asy");
add_cus_dep("asy","tex",0,"asy");
#
# Xfig
#
sub fig2pdf {
  my $fn = shift;
  my ($basename, $dirname) = fileparse($fn);
  return system("cd '$dirname' ; if [ -e localsymbols.sty ] ; then TEXINPUTS=\$PWD\/\/: fig2pdf --add=bm,amsfonts,bbm,localsymbols --nogv '$basename''.fig' ; else fig2pdf --add=bm,amsfonts,bbm --nogv '$basename''.fig' ; fi");
}
add_cus_dep("fig","pdf",0,"fig2pdf");
#
sub fig2eps {
  my $fn = shift;
  my ($basename, $dirname) = fileparse($fn);
  return system("cd '$dirname' ; if [ -e localsymbols.sty ] ; then TEXINPUTS=\$PWD\/\/: fig2eps --add=bm,amsfonts,bbm,localsymbols --nogv '$basename''.fig' ; else fig2eps --add=bm,amsfonts,bbm --nogv '$basename''.fig' ; fi");
}
add_cus_dep("fig","eps",0,"fig2eps");
#
###############################
# Further compilation Options #
###############################
# The following will make pdflatex and latex not stop when it finds a
# missing images upon compilation which allows useful compilation from
# source graphics files. Note however that if errors are generated
# it will not block.
$pdflatex = "yes '' | pdflatex -interaction=nonstopmode";
$latex = "yes '' | latex -interaction=nonstopmode";
#
# This makes latexmk default to creating a pdf (equivalent to
# the -pdf command line option to latexmk)
$pdf_mode = 1;
#
# This makes evince the default pdf viewer if you run -pv or -pvc option
# Comment this out or change it if you do not use this viewer.
$pdf_previewer = "start evince";
$pdf_update_method = 0;
#
# This sets the default file to be our document so we can run
# latexmk without an argument.
@default_files = ('master');
#
