contrib/clfswm: Add support to cmucl, ccl and ecl.
[clfswm.git] / contrib / clfswm
blobf04f07619666635b71cf89a3c26682425e0efb6f
1 #!/bin/bash -e
3 # (C) 2008 Xavier Maillard <xma@gnu.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 # --------------------------------------------------------------------------
21 # Documentation:
23 # Original code and idea: http://stumpwm.antidesktop.net/cgi-bin/wiki/SetUp
25 # Installation:
26 # Put this script wherever you want and just call it from your .xinitrc file
28 # The first time you will launch it, it will build the final
29 # executable and then call it. To force a rebuild of your executable
30 # (say you have updated something in the CLFSWM source tree), just
31 # delete the image and restart your X session.
32 # --------------------------------------------------------------------------
35 no_start=no
36 lisp=clisp
37 lisp_opt=''
38 dump_path="$XDG_CACHE_HOME/clfswm/"
39 asdf_path="$(pwd)/contrib"
40 clfswm_asd_path="$(pwd)"
43 usage() {
45 echo "$0 [options]
47 n,no-start don't start CLFSWM after image dump
48 f,force force image dump
49 rebuild same as -f,--force
50 l,with-lisp use <lisp> as the common lisp implementation [$lisp]
51 o,lisp-opt use <opt> as lisp option
52 d,dump-path path to the dump directory [\$XDG_CACHE_HOME=$XDG_CACHE_HOME]
53 with-clfswm path to clfswm.asd file
54 with-asdf path to the asdf.lisp file"
56 exit 0
59 die() {
60 echo >&2 "$@"
61 exit 1
64 build_clisp ()
66 clisp $lisp_opt -m 8MB -E ISO-8859-1 -q -i $asdf_path/asdf.lisp -x "(load \"$clfswm_asd_path/clfswm.asd\")
67 (asdf:oos 'asdf:load-op :clfswm) \
68 (EXT:SAVEINITMEM \"$dump_image\" :INIT-FUNCTION (lambda () (clfswm:main) (quit)) :EXECUTABLE t :norc t)"
71 build_sbcl()
73 sbcl $lisp_opt --disable-debugger --eval "(require :asdf)" \
74 --eval "(load \"$clfswm_asd_path/clfswm.asd\")" \
75 --eval "(require :clfswm)" \
76 --eval "(save-lisp-and-die \"$dump_image\" :toplevel 'clfswm:main)"
79 build_cmucl()
81 cmucl $lisp_opt -eval "(load \"$asdf_path/asdf.lisp\")" \
82 -eval "(load \"$clfswm_asd_path/clfswm.asd\")" \
83 -eval "(require :clx)" \
84 -eval "(asdf:oos 'asdf:load-op :clfswm)" \
85 -eval "(save-lisp \"$dump_image\" :init-function (lambda () (clfswm:main) (quit)))"
88 build_ccl()
90 ccl $lisp_opt --eval "(require :asdf)" \
91 --eval "(load \"$clfswm_asd_path/clfswm.asd\")" \
92 --eval "(asdf:oos 'asdf:load-op :clfswm)" \
93 --eval "(save-application \"$dump_image\" :toplevel-function (lambda () (clfswm:main) (quit)))"
96 build_ecl()
98 ecl $lisp_opt -eval "(require :asdf)" \
99 -eval "(load \"$clfswm_asd_path/clfswm.asd\")" \
100 -eval "(asdf:make-build :clfswm :type :program :monolithic t :move-here \".\" :prologue-code '(progn (require :asdf) (require :clx)))" \
101 -eval "(ext:quit 0)"
102 mv ./clfswm-mono $dump_image
103 echo $dump_image
107 while test $# != 0
109 case "$1" in
110 -n|--no-start)
111 no_start=yes ;;
112 -f|--force|--rebuild)
113 force=yes ;;
114 -d|--dump-path)
115 shift
116 dump_path="$1" ;;
117 --with-clfswm)
118 shift
119 clfswm_asd_path="$1" ;;
120 --with-asdf)
121 shift
122 asdf_path="$1" ;;
123 -l|--with-lisp)
124 shift
125 case "$1" in
127 usage;;
128 clisp|sbcl|cmucl|ccl|ecl)
129 lisp="$1" ;;
130 esac
132 -o|--lisp-opt)
133 shift
134 lisp_opt="$1" ;;
136 shift
137 break ;;
139 usage ;;
140 esac
141 shift
142 done
145 dump_image="$dump_path/clfswm-$(cksum $(type -p $lisp) | cut -d ' ' -f 1).core"
147 if test yes = "$force" && test -e "$dump_image"
148 then
149 echo "Removing old image."
150 rm -f "$dump_image"
153 if test ! -e "$dump_image" ||
154 ( for i in "$(dirname $(readlink $clfswm_asd_path/clfswm.asd))"/*.lisp
155 do test "$dump_image" -ot "$i" && exit 1
156 done )
157 then
158 test -x $(type -p $lisp) || die "$lisp can't be found."
159 test -e $clfswm_asd_path/clfswm.asd || die "can't find clfswm.asd in $clfswm_asd_path"
160 test -e $asdf_path/asdf.lisp || die "can't find asdf.lisp in $asdf_path"
162 mkdir -p "$dump_path"
163 mkdir -p "$dump_path/contrib"
164 eval build_$lisp
165 rm -rf "$dump_path/contrib"
166 cp -R "$clfswm_asd_path/contrib/" "$dump_path/"
167 rm -rf $(find "$dump_path/" -name "*svn")
170 # Run the resulting image
171 if test no = "$no_start"
172 then
173 cd $dump_path
174 case $lisp in
175 clisp ) $dump_image ;;
176 sbcl ) exec sbcl --core "$dump_image" ;;
177 cmucl ) exec cmucl -core "$dump_image" ;;
178 ccl ) exec ccl -I "$dump_image" ;;
179 ecl ) $dump_image -eval "(progn (clfswm:main) (ext:quit 0))" ;;
180 *) echo "..." ;;
181 esac
182 else
183 echo "As requested, we have just dumped the image."