Changed the license to the AGPL3. Downcased all the lisp sources. Completed the READM...
[com-informatimago:com-informatimago.git] / common-lisp / compile-with-asdf.lisp
1 ;;;; -*- mode:lisp;coding:utf-8 -*-
2 ;;;;**************************************************************************
3 ;;;;FILE:               compile-with-asdf.lisp
4 ;;;;LANGUAGE:           Common-Lisp
5 ;;;;SYSTEM:             Common-Lisp
6 ;;;;USER-INTERFACE:     NONE
7 ;;;;DESCRIPTION
8 ;;;;    
9 ;;;;    Compile the com.informatimago.common-lisp libraries with ASDF.
10 ;;;;    
11 ;;;;AUTHORS
12 ;;;;    <PJB> Pascal J. Bourguignon <pjb@informatimago.com>
13 ;;;;MODIFICATIONS
14 ;;;;    2010-11-01 <PJB> Created.
15 ;;;;BUGS
16 ;;;;LEGAL
17 ;;;;    AGPL3
18 ;;;;    
19 ;;;;    Copyright Pascal J. Bourguignon 2010 - 2010
20 ;;;;    
21 ;;;;    This program is free software: you can redistribute it and/or modify
22 ;;;;    it under the terms of the GNU Affero General Public License as published by
23 ;;;;    the Free Software Foundation, either version 3 of the License, or
24 ;;;;    (at your option) any later version.
25 ;;;;    
26 ;;;;    This program is distributed in the hope that it will be useful,
27 ;;;;    but WITHOUT ANY WARRANTY; without even the implied warranty of
28 ;;;;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29 ;;;;    GNU Affero General Public License for more details.
30 ;;;;    
31 ;;;;    You should have received a copy of the GNU Affero General Public License
32 ;;;;    along with this program.  If not, see <http://www.gnu.org/licenses/>.
33 ;;;;**************************************************************************
34
35 (in-package :cl-user)
36
37 (defvar *asdf-source*
38   #p"/data/lisp/packages/net/common-lisp/projects/asdf/asdf/asdf.lisp")
39
40 (defvar *asdf-binary-locations-directory*
41   #p"/data/lisp/packages/net/common-lisp/projects/asdf-binary-locations/asdf-binary-locations/")
42
43
44 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
45 ;;;
46 ;;; ASDF
47 ;;;
48
49 (unless (find-package :asdf)
50   (handler-case (require :asdf)
51     (error ()   (load (compile-file *asdf-source*)))))
52
53 (defun push-asdf-repository (path)
54   (pushnew path asdf:*central-registry* :test #'equal))
55
56 (defun asdf-load (&rest systems)
57   (mapcar (lambda (system) (asdf:operate 'asdf:load-op system))
58           systems))
59
60 (defun asdf-delete-system (&rest systems)
61   (mapc (lambda (system) (remhash (string-downcase system) asdf::*defined-systems*))
62         systems)
63   (values))
64
65 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
66 ;;;
67 ;;; ASDF-BINARY-LOCATIONS
68 ;;;
69
70 (defun hostname ()
71   (let ((outpath (format nil "/tmp/hostname-~8,'0X.txt" (random #x100000000))))
72     (asdf:run-shell-command
73      "( hostname --fqdn 2>/dev/null || hostname --long 2>/dev/null || hostname ) > ~A"
74      outpath)
75     (prog1 (with-open-file (hostname outpath)
76              (read-line hostname))
77       (delete-file outpath))))
78
79 (let ((sym (find-symbol "ENABLE-ASDF-BINARY-LOCATIONS-COMPATIBILITY" "ASDF")))
80   (when (and sym (fboundp sym))
81     (push :has-asdf-enable-asdf-binary-locations-compatibility *features*)))
82
83 #+has-asdf-enable-asdf-binary-locations-compatibility
84 (progn
85   (format *trace-output* "enable-asdf-binary-locations-compatibility ~%")
86   (asdf:enable-asdf-binary-locations-compatibility
87    :centralize-lisp-binaries     t
88    :default-toplevel-directory   (merge-pathnames (format nil ".cache/common-lisp/~A/" (hostname))
89                                                   (user-homedir-pathname) nil)
90    :include-per-user-information nil
91    :map-all-source-files t
92    :source-to-target-mappings    nil))
93
94 #-has-asdf-enable-asdf-binary-locations-compatibility
95 (progn
96  (push-asdf-repository *asdf-binary-locations-directory*)
97  (asdf-load :asdf-binary-locations))
98
99 #-has-asdf-enable-asdf-binary-locations-compatibility
100 (progn
101   (format *trace-output* "enable-asdf-binary-locations-compatibility ~%")
102   (setf asdf:*centralize-lisp-binaries*     t
103         asdf:*include-per-user-information* nil
104         asdf:*default-toplevel-directory*
105         (merge-pathnames (format nil ".cache/common-lisp/~A/" (hostname))
106                          (user-homedir-pathname) nil)
107         asdf:*source-to-target-mappings* '()))
108
109 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
110 ;;;
111 ;;; Compiling com.informatimago.common-lisp
112 ;;;
113
114 (setf asdf:*central-registry*
115       (append (remove-duplicates
116                (mapcar (lambda (path)
117                          (make-pathname :name nil :type nil :version nil :defaults path))
118                        (directory "**/*.asd"))
119                :test (function equalp))
120               asdf:*central-registry*))
121
122 (asdf-load  :com.informatimago.common-lisp)
123
124
125 ;;;; THE END ;;;;
126
127
128