1bb2176b08330e9ad93652156b795228cf14e6ae
[fiveam.git] / docs / Makefile.lisp
1 (in-package :smake-user)
2
3 (defvar *asciidoc-root* #P"/usr/local/etc/asciidoc/")
4
5 (program "asciidoc")
6
7 (defun static-file (name &optional source destination)
8
9   (cond
10     ((null source)
11      (setf source (source-pathname name)))
12     ((stringp source)
13      (setf source (source-pathname source))))
14
15   (cond
16     ((null destination)
17      (setf destination (build-pathname name)))
18     ((stringp destination)
19      (setf destination (build-pathname destination))))
20
21   (target* `(static-file ,name) ()
22     (when (file-newer-p source destination)
23       (path:cp source destination))))
24
25 (static-file "asciidoc.css" (path:catfile *asciidoc-root* "stylesheets/" "asciidoc.css"))
26
27 (static-file "asciidoc.js" (path:catfile *asciidoc-root* "javascripts/" "asciidoc.js"))
28
29 (static-file "fiveam.css")
30
31 (target (static-directory "asciidoc/images") ()
32   (ensure-directories-exist (build-pathname "images/icons/callouts/"))
33   (dolist (src (directory (path:catfile *asciidoc-root* "images/" "icons/" "callouts/" "*.png")))
34     (let ((dst (build-pathname (path:catfile "images/icons/callouts/" (path:basename src)))))
35       (when (file-newer-p src dst)
36         (path:cp src dst)))))
37
38 (defun asciidoc.html (source &optional requires)
39   (target* `(asciidoc ,source) (:requires (append requires
40                                                   '((program "asciidoc")
41                                                     (static-file "asciidoc.js")
42                                                     (static-file "asciidoc.css")
43                                                     (static-file "fiveam.css")
44                                                     (static-directory "asciidoc/images"))))
45     (when (file-newer-p (source-pathname source) (build-pathname source :type "html"))
46       (unless (path:-e (build-pathname source))
47         (sys `(ln -s ,(source-pathname source) ,(build-pathname source))))
48       (sys `(asciidoc -o ,(build-pathname source :type "html") ,(build-pathname source))))))
49
50 (target "docstrings" ()
51   (unless (path:-d (build-pathname "docstrings/"))
52     (sys `(ccl64 --load ../extract-docstrings.lisp))
53     (sys `(rm -f ,(build-pathname "manual.html") ,(build-pathname "tutorial.html")))))
54
55 (asciidoc.html "manual.txt" '("docstrings"))
56 (asciidoc.html "tutorial.txt" '((asciidoc "manual.txt")))
57
58 (target "documentation" (:requires '((asciidoc "manual.txt")
59                                      (asciidoc "tutorial.txt"))))
60
61 (target "all" (:requires '("documentation")))
62