summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/support/latexmk/example_rcfiles/fix-aux.latexmkrc
blob: a8cf90ae47b11dad515d759668164665e82fa414 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# This shows how to implement the use different values for $aux_dir and
# $out_dir when the latex (etc) engines don't support the -aux-directory
# option.  (Of the standard distributions, MiKTeX supports -aux-directory,
# but TeXLive does not.)


foreach my $cmd ('latex', 'lualatex', 'pdflatex', 'xelatex' ) {
    ${$cmd} = "internal latex_fix_aux $cmd %O %S";
}
$xelatex  =~ s/%O/-no-pdf %O/;


#---------------------------

sub latex_fix_aux {
  # Fudge to allow use of -aux_directory option with non-MiKTeX system.
  # Just communicate by arguments, and don't use latexmk's variables
  # $aux_dir, etc.
  my $auxD = '';
  my $outD = '';
  foreach (@_) {
     if ( /^-aux-directory=(.*)$/ ) {
        $auxD = $1;
     }
     elsif ( /^-output-directory=(.*)$/ ) {
        $outD = $1;
     }
  }
  if ( $outD eq '' ) { $outD = '.'; }
  if ( $auxD eq '' ) { $auxD = $outD; }
  my @args_act = ();
  my $set_outD = 0;
  foreach (@_) {
     if ( /^-(aux|output)-directory=.*$/ ) {
        if ( ! $set_outD ) {
	   push @args_act, "-output-directory=$auxD";
	   $set_outD = 1;
	}
     }
     else {
        push @args_act, $_;
     }
  }
  my $outD1 = $outD;
  my $auxD1 = $auxD;
  foreach ( $auxD1, $outD1 ) {
     if ( ($_ ne '')  && ! m([\\/\:]$) ) {
        $_ .= '/';
     }
     while ( s[^\.\/][] ) {}
   }

  print "Running: '@args_act'\n";
  my $ret = system @args_act;
  if ($auxD ne $outD) {
     print "Moving dvi, fls, ps, pdf files from '$auxD' to '$outD'\n";
     foreach my $ext ('dvi', 'fls', 'ps', 'pdf' ) {
        rename "$auxD1$root_filename.$ext", "$outD1$root_filename.$ext",;
     }
  }
  return $ret;
}

#---------------------------