(rule
 (targets unreleased.rst)
 (deps (source_tree changelog))
 (action (with-stdout-to %{targets} (bash "cat changelog/00-title.rst changelog/*/*.rst"))))

(alias
 (name refman-deps)
 (deps
  ; We could use finer dependencies here so the build is faster:
  ;
  ; - vo files: generated by sphinx after parsing the doc, promoted,
  ; - Static files:
  ;   + %{bin:coqdoc} etc...
  ;   + tools/coqdoc/coqdoc.css
  (package rocq-stdlib)
  (source_tree sphinx)
  (source_tree tools/rocqrst)
  unreleased.rst
  (env_var SPHINXWARNOPT)))

(rule
 (targets
  (dir refman-html))
 (alias refman-html)
 (deps (alias refman-deps))
 (action
  (run env sphinx-build -q %{env:SPHINXWARNOPT=-W} -b html sphinx %{targets})))

(rule
 (targets
  (dir refman-pdf))
 (alias refman-pdf)
 (deps (alias refman-deps))
 (action
  (progn
   (run env sphinx-build -q %{env:SPHINXWARNOPT=-W} -b latex sphinx %{targets})
   (chdir %{targets} (run make LATEXMKOPTS=-silent)))))
