summaryrefslogtreecommitdiff
path: root/texmf-dist/scripts/cjk-gs-integrate-macos/cjk-gs-integrate-macos.pl
blob: 088bc5ab1c3b0bb101b7cf70daad9563c5fd461b (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env perl
#
# cjk-gs-integrate-macos - wrapper for cjk-gs-integrate on macOS
#
# Copyright 2017-2020 by Japanese TeX Development Community
#
# This file is licensed under GPL version 3 or any later version.
# For copyright statements see end of file.
#
# For development see
#  https://github.com/texjporg/cjk-gs-support
#

$^W = 1;
use Getopt::Long qw(:config no_autoabbrev ignore_case_always pass_through);
use File::Basename;
use strict;
(my $prg = basename($0)) =~ s/\.pl$//;

my $opt_help = 0;
GetOptions("h|help" => \$opt_help);

sub macosx { return ($^O=~/^darwin$/i); }

if ($opt_help) {
  print "Usage: [perl] $prg\[.pl\] [OPTIONS]\n";
  print "This is a wrapper for cjk-gs-integrate on macOS.\n";
  exit 0;
}

my $addname;
if (macosx()) {
  my $macos_ver = `sw_vers -productVersion`;
  my $macos_ver_major = $macos_ver;
  $macos_ver_major =~ s/^(\d+)\.(\d+).*/$1/;
  my $macos_ver_minor = $macos_ver;
  $macos_ver_minor =~ s/^(\d+)\.(\d+).*/$2/;
  chomp($macos_ver_major);
  chomp($macos_ver_minor);
  if ($macos_ver_major==10) {
    if ($macos_ver_minor==8) {
      $addname = "mountainlion";
    } elsif ($macos_ver_minor==9) {
      $addname = "mavericks";
    } elsif ($macos_ver_minor==10) {
      $addname = "mavericks"; # yosemite
    } elsif ($macos_ver_minor==11) {
      $addname = "elcapitan";
    } elsif ($macos_ver_minor==12) {
      $addname = "sierra";
    } elsif ($macos_ver_minor==13) {
      $addname = "highsierra";
    } elsif ($macos_ver_minor==14) {
      $addname = "highsierra"; # mojave
    } elsif ($macos_ver_minor==15) {
      $addname = "highsierra"; # catalina -- at least nothing is wrong
    } elsif ($macos_ver_minor>=16) {
      print STDERR "Warning: macOS 10.$macos_ver_minor is untested.\n";
      $addname = "highsierra"; # (the most recent one)
    }
  }
}

my @newarg;
push @newarg, "--fontdef-add=cjkgs-macos-$addname.dat" if ($addname);
push @newarg, @ARGV;
if (-f "cjk-gs-integrate.pl") {
  system("perl cjk-gs-integrate.pl @newarg");
} else {
  system("cjk-gs-integrate @newarg");  
}


### Local Variables:
### perl-indent-level: 2
### tab-width: 2
### indent-tabs-mode: nil
### End:
# vim: set tabstop=2 expandtab autoindent: