summaryrefslogtreecommitdiff
path: root/cli/doc/buildfile
blob: 211e232f05d5fc9c03f9db1c3fd3d10cfb462ee9 (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# file      : doc/buildfile
# license   : MIT; see accompanying LICENSE file

define css: doc
css{*}: extension = css

define xhtml: doc
xhtml{*}: extension = xhtml

define ps: doc
ps{*}: extension = ps

define pdf: doc
pdf{*}: extension = pdf

define html2ps: file
html2ps{*}: extension = html2ps

# Import the cli program only if explicitly requested. This way a distribution
# that includes pre-generated files can be built without installing cli.
#
if ($config.cli != [null] && $config.cli != false)
  import! [metadata] cli = cli%exe{cli}

# Import the html2ps and ps2pdf14 programs only if present in the system. This
# way a distribution that includes pre-generated files can be built without
# installing these programs.
#
import? html2ps  = html2ps%exe{html2ps}
import? ps2pdf14 = ps2pdf14%exe{ps2pdf14}

./: css{default}

# Note that we include all the generated files into the distribution and don't
# remove them when cleaning in src (so that clean results in a state identical
# to distributed).
#

# Generate the manual files if the cli program is imported and handle
# (install, distribute, etc) the pre-generated files otherwise, if present.
#
if ($cli != [null])
{
  ./: {man1 xhtml}{cli}

  options = -v project="CLI" -v version="$version.project_id" \
            -v copyright="$copyright" --suppress-undocumented --stdout

  man1{cli}: $src_root/cli/cli{options}          \
             file{cli-prologue.1 cli-epilogue.1} \
             $cli
  {
    dist  = true
    clean = ($src_root != $out_root)
  }
  % [diag=cli]
  {{
    # Note that the date change doesn't change the script semantics, thus the
    # variable is defined locally.
    #
    date +"%B %Y" | set date

    $cli --generate-man -v date="$date" $options \
         --man-prologue-file $path($<[1])        \
         --man-epilogue-file $path($<[2])        \
         $path($<[0]) >$path($>)
  }}

  xhtml{cli}: $src_root/cli/cli{options}                  \
              file{cli-prologue.xhtml cli-epilogue.xhtml} \
              $cli
  {
    dist  = true
    clean = ($src_root != $out_root)
  }
  % [diag=cli]
  {{
    $cli --generate-html $options          \
         --html-prologue-file $path($<[1]) \
         --html-epilogue-file $path($<[2]) \
         $path($<[0]) >$path($>)
  }}
}
else
  ./: {man1 xhtml}{+cli} file{cli-prologue* cli-epilogue*}

guide/
{
  ../: xhtml{index}

  # Generate the user guide ps/pdf files if the html2ps and ps2pdf14 programs
  # are imported and handle (install, distribute, etc) the pre-generated files
  # otherwise, if present.
  #
  if ($html2ps != [null])
  {
    ../: ps{cli-guide}

    ps{cli-guide}: html2ps{guide} xhtml{index} $html2ps
    {
      options =

      dist  = true
      clean = ($src_root != $out_root)
    }
    % [diag=html2ps]
    {{
      $html2ps $options -f $path($<[0]) -o $path($>) $path($<[1])
    }}

    if ($ps2pdf14 != [null])
    {
      ../: pdf{cli-guide}

      pdf{cli-guide}: ps{cli-guide} $ps2pdf14
      {
        options = -dOptimize=true -dEmbedAllFonts=true

        dist  = true
        clean = ($src_root != $out_root)
      }
      % [diag=ps2pdf14]
      {{
        $ps2pdf14 $options $path($<[0]) $path($>)
      }}
    }
    else
      ../: pdf{+cli-guide}
  }
  else
    ../: {ps pdf}{+cli-guide}
}

doc{*}: install.subdirs = true