(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...
  ;   + config/coq_config.py
  ;   + tools/coqdoc/coqdoc.css
  (package rocq-runtime)
  (package rocq-core)
  (source_tree sphinx)
  (source_tree tools/rocqrst)
  ../config/coq_config.py
  unreleased.rst
  (env_var SPHINXWARNOPT)
  (env_var ROCQRST_EXTRA)))

(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 ../ide/rocqide/coq.png  (alias refman-deps))
 (action
  (progn
   (run env sphinx-build -q %{env:SPHINXWARNOPT=-W} -b latex sphinx %{targets})
   (chdir %{targets} (run make LATEXMKOPTS=-silent)))))
