Initial commit
[gotcl.git] / gotcl.py
blob8e4d7fba74b567cc7a8e5c08802dc77c8f7d9ccd
1 Microsoft Windows [Version 5.2.3790]
2 (C) Copyright 1985-2003 Microsoft Corp.
4 d:\Experiments\clbuild>python check
5 python check
6 python: can't open file 'check': [Errno 2] No such file or directory
8 d:\Experiments\clbuild>python clbuild check
9 python clbuild check
10 File "clbuild", line 23
11 if [ "$CLNET_USER" == "" ]; then
13 SyntaxError: invalid syntax
15 d:\Experiments\clbuild>cat clbuild
16 cat clbuild
17 #!/usr/bin/env bash
18 # (we use env for non-Linux OSes)
20 # Script to update/install the latest versions of all the most
21 # important Common Lisp projects. Uses SBCL but otherwise tries to be
22 # somewhat independent of your local environment.
24 # Intended to quickly bootstrap a working development environment for
25 # Lisp free software hackers.
27 # Idea from jhbuild by James Henstridge (a Gnome hacker).
29 # Contributors:
30 # Luke Gorrie <luke@member.fsf.org>
31 # Anthony Chaumas-Pellet <achaumas@wispery.info>
32 # Christophe Rhodes <csr21@cantab.net>
33 # David Lichteblau <david@lichteblau.com>
34 # Eric Marsden <eric.marsden@free.fr>
35 # Andreas Fuchs <asf@boinkor.net>
37 set -e
39 if [ "$CLNET_USER" == "" ]; then
40 CLNET_USER=:pserver:anonymous:anonymous
42 export CLNET_USER
44 # MacOS doesn't have "readlink -e", needed to follow symlinks.
45 # We hack it using readlink, dirname, and cd.
46 readlink_e() {
47 self="$0"
48 while test -h "$self"; do
49 cd "$(dirname $self)"
50 self=`readlink "$self"`
51 done
52 cd "$(dirname $self)"
53 pwd
55 BASE=$(readlink_e)
56 system_dir="$BASE/systems"
57 source_dir="$BASE/source"
58 target_dir="$BASE/target"
60 if test x`uname -o 2>/dev/null` = xCygwin; then
61 windowsp=1
62 else
63 windowsp=""
66 source "$BASE/clbuild.conf.default"
67 if test -f "$BASE/clbuild.conf"; then
68 source "$BASE/clbuild.conf"
70 # Fix up pathnames
71 make_absolute_pn() {
72 if [ -n "$1" ] ; then
73 (cd "$BASE"
74 echo "$(cd "$(dirname "$1")" ; pwd)/$(basename "$1")")
77 case $UPDATE_SCRIPT in
78 update_project)
79 # okay, new name
81 update.sh)
82 # old name
83 UPDATE_SCRIPT=update_project
86 # do will still want this?
87 UPDATE_SCRIPT="$(make_absolute_pn "$UPDATE_SCRIPT")"
89 esac
90 USER_INIT="$(make_absolute_pn "$USER_INIT")"
92 if test -n "$windowsp" -a x$USER_INIT = x/dev/null; then
93 USER_INIT=NUL
96 # CLIM configuration
97 case x$CLIM_BACKEND in
98 xgraphic-forms|xgtkairo|xbeagle)
99 EXTRA_CLIM_FEATURES="(pushnew :clim-$CLIM_BACKEND *features*)"
100 maybe_load_clx="nil"
102 x|xclx)
103 EXTRA_CLIM_FEATURES="nil"
104 maybe_load_clx="(unless (find-package :xlib) (asdf:operate 'asdf:load-op :clx))"
107 echo "invalid $CLIM_BACKEND, see clbuild.conf.default for examples." 1>&2
108 exit 1
110 esac
112 if test -n "$windowsp"; then
113 system_namestring="`cygpath -m $system_dir`/"
114 source_namestring="`cygpath -m $source_dir`/"
115 target_namestring="`cygpath -m $target_dir`/"
116 self="c:/cygwin/bin/bash $self"
117 else
118 system_namestring="$system_dir/"
119 source_namestring="$source_dir/"
120 target_namestring="$target_dir/"
122 if test -n "$SETF_CENTRAL_REGISTRY"; then
123 set_central_registry="(setq asdf:*central-registry* '(#p\"${system_namestring}\"))"
124 else
125 set_central_registry="(push #p\"${system_namestring}\" asdf:*central-registry*)"
128 configure_ccl() {
129 lisp=$1
130 noinform="-Q"
131 end_toplevel_options="" #fixme
132 quit="(ccl:quit)"
133 eval="--eval"
134 require_asdf="(require :asdf)"
135 core_option="-I"
137 if test x"$USER_INIT" = x/dev/null; then
138 # -l /dev/null does not work
139 common_options="-n"
140 elif test -n "$USER_INIT"; then
141 common_options="-n -l $USER_INIT"
142 else
143 common_options=""
146 # fixme: this doesn't quite match the SBCL version yet:
147 build_options="$noinform --batch $common_options"
148 run_options="--batch $common_options"
151 configure_clisp() {
152 lisp=$1
153 echo '*** Using CLISP. Please note that CLISP support is not complete.'
154 lisp="$CLISP -repl"
156 noinform="" #fixme
157 end_toplevel_options="" #fixme
158 quit="(ext:quit)"
159 eval="-x"
160 require_asdf="(load \"$BASE/source/asdf-for-clisp/asdf.lisp\")"
161 core_option="-M"
163 if test -n "$USER_INIT"; then
164 common_options="-norc -i $USER_INIT"
165 else
166 common_options=""
169 build_options="-on-error exit $common_options"
170 run_options="-on-error exit $common_options"
172 if test -d "$BASE/source/asdf-for-clisp"; then
173 echo "*** asdf checkout found"
174 echo
175 else
176 echo "NEW checking out asdf for use with clisp"
177 (cd "$BASE/source" && cvs -d ${SF_USER}@sbcl.cvs.sourceforge.net:/cvsroot/sbcl co -d asdf-for-clisp sbcl/contrib/asdf)
181 configure_sbcl() {
182 lisp=$1
184 noinform="--noinform"
185 end_toplevel_options="--end-toplevel-options"
186 quit="(sb-ext:quit)"
187 eval="--eval"
188 require_asdf="(require :asdf)"
189 core_option="--core"
191 if test -n "$USER_INIT"; then
192 common_options="--userinit $USER_INIT"
193 else
194 common_options=""
197 build_options="$noinform --noprint --disable-debugger $common_options"
198 run_options="--disable-debugger $common_options"
201 if [ ! -z $CCL ]; then
202 configure_ccl "$CCL"
203 elif [ ! -z $CLISP ]; then
204 configure_clisp "$CLISP"
205 elif [ ! -z "$SBCL" ]; then
206 configure_sbcl "$SBCL"
207 elif [ -x ${target_dir}/bin/sbcl ]; then
208 export SBCL_HOME=${target_namestring}lib/sbcl/
209 lisp="${target_dir}/bin/sbcl"
210 if ! test -f "$BASE"/monster.core; then
211 lisp="$lisp --core ${target_namestring}lib/sbcl/sbcl.core"
213 configure_sbcl "$lisp"
214 elif [ -x ${source_dir}/ccl/lx86cl64 ]; then
215 configure_ccl ${source_dir}/ccl/lx86cl64
216 else
217 configure_sbcl sbcl
220 [ -d "$system_dir" ] || mkdir "$system_dir"
221 [ -d "$source_dir" ] || mkdir "$source_dir"
222 [ -d "$target_dir" ] || mkdir "$target_dir"
224 clbuild_lisp() {
225 ${lisp} $common_options \
226 $eval "$require_asdf" \
227 $eval "$set_central_registry" \
228 $eval "$EXTRA_CLIM_FEATURES" \
229 "$@"
232 lisp_trampoline() {
233 # Start the Lisp with user arguments. For SBCL, we can do that using
234 # --end-toplevel-options. For other Lisps, go through a temporary
235 # file.
237 options="$1"
238 shift
240 if test -n "$end_toplevel_options"; then
241 ${lisp} \
242 $options \
243 $eval "$require_asdf" \
244 $eval "$set_central_registry" \
245 $eval "$EXTRA_CLIM_FEATURES" \
246 $eval "(load \"$BASE/clbuild.lisp\")" \
247 $end_toplevel_options \
248 "$@"
249 else
250 TMPDIR=`mktemp -d /tmp/clbuild.XXXXXXXXXX`
251 export TMPDIR
253 cleanup() {
254 rm -rf $TMPDIR
256 trap cleanup exit
258 while test -n "$1"; do
259 # fixme: whitespacea
260 echo $1 >>$TMPDIR/args
261 shift
262 done
264 ${lisp} \
265 $options \
266 $eval "$require_asdf" \
267 $eval "$set_central_registry" \
268 $eval "$EXTRA_CLIM_FEATURES" \
269 $eval "(defparameter cl-user::*clbuild-args* \"$TMPDIR/args\")" \
270 $eval "(load \"$BASE/clbuild.lisp\")"
274 start_application() {
275 lisp_trampoline "$noinform $run_options" "$@"
278 recompile() {
279 if test x"$1" = x--dump; then
280 dump="--dump t"
281 shift
282 else
283 dump=""
286 concatenated_args="$@"
287 if test -z "$concatenated_args"; then
288 concatenated_args="$main_projects"
291 cd "$BASE"
292 lisp_trampoline "$build_options" \
293 recompile-systems \
294 $dump \
295 "$concatenated_args"
298 count_systems() {
299 n_asd=`ls -1 "$system_dir"/*.asd | wc -l`
300 echo "$n_asd system definition files registered"
303 blank_line=" "
304 tail_last() {
305 if tty 0>&1 >/dev/null; then
306 while read line; do
307 echo -e '\r\c'
308 echo -n "$blank_line"
309 echo -e '\r\c'
310 echo -n $line | cut -b 1-65 | tr -d '\n'
311 done
312 echo -e '\r\c'
313 echo -n "$blank_line"
314 echo -e '\r\c'
315 else
316 while read line; do
317 echo $line
318 done
322 dribble_get() {
323 label="$1"
324 name="$2"
326 if test -d `echo ${name}*/ | awk '{print $1;}'`; then
327 echo -n "UPDATE "
328 else
329 echo -n "NEW "
331 echo "$label $name"
334 dry_run_ok() {
335 if test -n "$dry_run"; then
336 echo "OK: $1"
340 dry_run_missing() {
341 if test -n "$dry_run"; then
342 echo "MISSING: $1"
346 get_darcs() {
347 name="$1"
348 url="$2"
350 if [ -d $name ]; then
351 actual="`cat $name/_darcs/prefs/defaultrepo`"
352 if test "x$actual" = "x$url"; then
353 dry_run_ok $1
354 else
355 echo "MISMATCH: $1 was installed from $actual, current is $url"
357 else
358 dry_run_missing $1
360 if test -n "$dry_run"; then
361 exit 0
364 # don't use tail_last, since darcs already has this kind of progress bar
365 if [ -d $name ]; then
366 dribble_get "darcs pull" $name
368 cd $name
369 if ! test -d _darcs; then
370 echo ERROR: not a darcs repository
371 exit 1
373 darcs pull --all
375 else
376 dribble_get "darcs get" $name
377 darcs get $url $name
381 get_git() {
382 name="$1"
383 url="$2"
385 if [ -d $name ]; then
386 actual="`cd $name && git config --get remote.origin.url`"
387 if test "x$actual" = "x$url"; then
388 dry_run_ok $1
389 else
390 echo "MISMATCH: $1 was installed from $actual, current is $url"
392 else
393 dry_run_missing $1
395 if test -n "$dry_run"; then
396 exit 0
399 if [ -d $name ]; then
400 dribble_get "git pull" $name
402 cd $name
403 if ! test -d .git; then
404 echo ERROR: not a git repository
405 exit 1
407 git pull
409 else
410 dribble_get "git clone" $name
411 git clone $url $name
415 get_svn() {
416 name="$1"
417 url="$2"
419 if [ -d $name ]; then
420 actual="`cd $name && svn info | grep ^URL: | awk '{print $2;}'`"
421 if test "x$actual" = "x$url"; then
422 dry_run_ok $1
423 else
424 echo "MISMATCH: $1 was installed from $actual, current is $url"
426 else
427 dry_run_missing $1
429 if test -n "$dry_run"; then
430 exit 0
433 dribble_get "svn co" $name
435 svn co $url $name | tail_last
438 get_cvs_aux() {
439 module="$1"
440 repository="$2"
441 target_directory="$3"
443 if [ -d $module ]; then
444 actual="`cat $module/CVS/Root`"
445 if test "x$actual" = "x$repository"; then
446 dry_run_ok $1
447 else
448 echo "MISMATCH: $1 was installed from $actual, current is $repository"
450 else
451 dry_run_missing $1
453 if test -n "$dry_run"; then
454 exit 0
457 dribble_get "cvs co" $module
459 cvs -d $repository co ${3+-d "$3"} $module | tail_last
462 get_cvs_full() {
463 get_cvs_aux $3 $2 $1
466 get_tarball() {
467 name="$1"
468 url="$2"
469 flags="${3:-z}"
471 echo "Warning: Using deprecated method get_tarball."
473 if test -n "$dry_run"; then
474 if ls -d ${name}* >/dev/null; then
475 directories="`ls -d ${name}*`"
476 echo "TARBALL: $directories installed from a tarball, cannot check"
477 else
478 dry_run_missing $1
480 exit 0
483 tmp=$TMPDIR/${name}.tar.gz
485 dribble_get wget $name
487 # We used to delete old directories completely here. Unfortunately,
488 # that can easily lead to loss of changes, a problem all the VC checkout
489 # method do not have to the extent. Save all old data instead. Users
490 # can delete the resulting backup directories easily enough themselves.
491 if ls ${name}* >/dev/null; then
492 echo got here
493 backup=`mktemp -d backup_${name}_XXXXXXXXXX`
494 mv ${name}* "$backup/"
496 wget \
497 --no-check-certificate \
498 --progress=dot \
499 -O "$tmp" \
500 $url \
501 2>&1 | tail_last
502 tar v${flags}xf "$tmp" | tail_last
503 rm "$tmp"
506 get_svn_clnet() {
507 name="$1"
508 path="$2"
510 get_svn $name svn://common-lisp.net/project/$name/svn/$2
513 get_cvs_clnet() {
514 module="$1"
515 project="${2:-$1}"
517 get_cvs_aux $module ${CLNET_USER}@common-lisp.net:/project/$project/cvsroot
520 get_cvs_clnet_full() {
521 clbuildproject="$1"
522 clnetproject="${2:-$1}"
523 path="$3"
525 get_cvs_aux $path ${CLNET_USER}@common-lisp.net:/project/$clnetproject/cvsroot $clbuildproject
528 get_cvs_sfnet() {
529 module="$1"
530 project="${2:-$1}"
532 get_cvs_aux $module ${SF_USER}@$project.cvs.sourceforge.net:/cvsroot/$project
535 get_ediware() {
536 get_darcs $1 http://common-lisp.net/~loliveira/ediware/$1
539 get_clbuild_mirror() {
540 get_darcs $1 http://common-lisp.net/project/clbuild/mirror/$1
543 get_lichteblau_com() {
544 get_git $1 http://www.lichteblau.com/git/$1.git
547 get_b9_com() {
548 get_git $1 http://git.b9.com/$1.git
551 get_xach_com() {
552 get_git $1 http://git.xach.com/$1.git
555 get_tarball_bz2() {
556 get_tarball "$1" "$2" j
559 update_project() {
560 if test x$1 = x--dry-run; then
561 shift
562 dry_run=1
563 else
564 unset dry_run
566 export dry_run
568 if test $# -ne 1; then
569 exec 1>&2
570 echo error: invalid number of arguments
571 echo usage: ... update [--dry-run] PROJECT_NAME
572 exit 1
575 if ! grep -h "^$1 " "$BASE/projects" "$BASE/wnpp-projects" "$BASE/implementations" >/dev/null; then
576 echo Error: cannot download unknown project $1
577 rm "$BASE/.clbuild-resume"
578 exit 1
580 found=`grep -h "^$1 " "$BASE/projects" "$BASE/wnpp-projects" "$BASE/implementations" | cut -d\# -f1`
581 update_project_2 $found
584 update_project_2() {
585 name="$1"
586 action="$2"
587 shift
588 shift
589 ( $action $name "$@" )
592 update() {
593 if test -n "$clbuild_resume"; then
594 if test $# -gt 0; then
595 echo "error: --resume conflicts with arguments" 1>&2
596 exit 1
598 previous=`cat "$BASE/.clbuild-resume"`
599 CLBUILD_DEPENDENCIES=no update_1 $previous
600 elif test $# -gt 0; then
601 rm -f $source_dir/*/.clbuild-skip-update
602 update_1 $*
603 else
604 exec 1>&2
605 echo "Error: arguments expected"
606 echo "Usage:"
607 echo " clbuild update PROJECT1 PROJECT2 PROJECT3... # only these"
608 echo " clbuild update --resume # resume interrupted update"
609 echo " clbuild update --main-projects # all in projects file"
610 echo " clbuild update --wnpp-projects # all in wnpp-projects file"
611 echo " clbuild update --all-projects # both files"
612 echo " clbuild update --installed # everything in source/"
613 exit 1
617 update_1() {
618 touch "$BASE"/.core-is-stale
620 TMPDIR=`mktemp -d /tmp/clbuild.XXXXXXXXXX`
621 export TMPDIR
623 cleanup() {
624 if test -f "$BASE/.clbuild-resume"; then
625 exec 1>&2
626 echo
627 echo error: update was interrupted.
628 echo 'Use "clbuild update --resume" to retry. (See also "clbuild skip PROJECT").'
630 rm -rf $TMPDIR
632 trap cleanup exit
634 cd "$source_dir"
636 touch $TMPDIR/dependencies0
637 while test $# -ge 1; do
638 echo $1 >>$TMPDIR/arguments0
639 if grep "^$1 " ../dependencies >/dev/null; then
640 found=`grep "^$1 " ../dependencies`
641 for x in $found; do
642 echo $x >>$TMPDIR/dependencies0
643 done
644 else
645 echo $1 >>$TMPDIR/dependencies0
646 echo "warning: no dependencies for $1 found" 1>&2
648 shift
649 done
650 sort <$TMPDIR/arguments0 | uniq >$TMPDIR/arguments
651 sort <$TMPDIR/dependencies0 | uniq >$TMPDIR/dependencies
653 if ! cmp $TMPDIR/arguments $TMPDIR/dependencies >/dev/null; then
654 case "$CLBUILD_DEPENDENCIES" in
655 ask)
656 extra=`diff $TMPDIR/arguments $TMPDIR/dependencies | grep '^>' | cut -d' ' -f2 | xargs echo`
657 echo "The following extra dependencies were found: $extra"
658 echo -n "include dependencies in update? (Y/n)"
659 read reply
660 case _"$reply" in
661 _Y|_y|_)
664 mv $TMPDIR/arguments $TMPDIR/dependencies
667 echo Invalid reply
668 exit 1
670 esac
672 yes)
675 mv $TMPDIR/arguments $TMPDIR/dependencies
678 echo "error: invalid \$CLBUILD_DEPENDENCIES" 1>&2
679 exit 1
680 esac
683 cp $TMPDIR/dependencies "$BASE/.clbuild-resume"
685 for project in $(cat $TMPDIR/dependencies); do
686 skipfile="$project"/.clbuild-skip-update
687 if test -f "$skipfile" -a -n "$clbuild_resume"; then
688 echo "resume: skipping update of $project"
689 else
690 ${UPDATE_SCRIPT} ${UPDATE_ARGS} $project
691 ln -f -s $(pwd)/${project}*/*.asd "${system_dir}"/
692 touch "$skipfile"
694 done
696 link_extra_asds
698 rm "$BASE/.clbuild-resume"
700 echo "update complete"
701 count_systems
702 cd ..
705 link_extra_asds() {
706 # some (buggy) projects try to hide their .asd files from us:
707 ln -sf $source_dir/mcclim/Experimental/freetype/*.asd ${system_dir}/
708 ln -sf $source_dir/eclipse/system.lisp ${system_dir}/eclipse.asd
709 ln -f -s $source_dir/graphic-forms/src/external-libraries/*/*/*.asd \
710 ${system_dir}
711 ln -sf $source_dir/clg/*/*.asd ${system_dir}
712 ln -sf $source_dir/cells-gtk/*/*.asd ${system_dir}
714 # also, override uffi:
715 ln -sf $source_dir/cffi/uffi-compat/uffi.asd ${system_dir}/
718 help() {
719 cat <<EOF
720 Usage:
721 check check availability of all necessary helper applications
723 list [PATTERN] list all projects, or projects matching PATTERN
725 update [--dependencies|--no-dependencies] PROJECT_SPEC
726 download/update this project
727 update [--resume]
728 download/update main projects. With --resume, consider
729 only projects that a previous update run failed to fetch.
730 skip PROJECT_NAME
731 mark this project as done for the purposes of update --resume
733 recompile PROJECT_SPEC compile fasls
734 dumpcore PROJECT_SPEC recompile and dump a core file for faster startup
735 build PROJECT_SPEC update && dumpcore
737 diff show local changes (for all version-controlled projects)
738 check-urls compared installed repository urls agains current locations
739 clean-links remove broken symlinks in systems/
740 update-missing download only projects not present yet
741 register-asd PROJECT add .asd file symlinks for PROJECT
743 compile-implementation sbcl [XC_HOST] compile SBCL
744 compile-implementation ccl compile Clozure CL
745 compile-implementation clisp compile CLISP
747 world build sbcl and specified projects
749 clean [PROJECT] delete all compiled object files [in source/PROJECT]
750 trash PROJECT move source/PROJECT to trash/
751 mrproper trash all projects
753 slime run the Superior Lisp Interaction Mode in a fresh Emacs
754 lisp run Lisp in the terminal (using sbcl.core)
755 preloaded run Lisp in the terminal (using monster.core)
756 slime-configuration print .emacs excerpt for slime
758 record-dependencies rebuild dependency information file
760 For update/recompile/build/dumpcore a PROJECT_SPEC can be used:
761 PROJECT1 PROJECT2 PROJECT3... # only these
762 --main-projects # all in projects file
763 --wnpp-projects # all in wnpp-projects file
764 --all-projects # both files
765 --installed # everything in source/
767 Starting applications:
769 run APPLICATION run this application
770 run --help show help for applications
772 If you do 'world' or 'buildsbcl' then SBCL will be installed in
773 target/ and used for future commands. If you don't run these commands
774 (or you remove target/) then clbuild uses the 'sbcl' in your PATH.
776 For configuration options (including for non-SBCL lisps), see clbuild.conf.
781 help_run() {
782 cat <<EOF
783 clbuild run APPLICATION [ARGS...]
785 run listener run the McCLIM listener
786 run gsharp run the Gsharp score editor
787 run climacs run the Climacs text editor
788 run closure [HOME_PAGE_URL] run the CLOSURE web browser
789 (required Debian packages: gif2png,libjpeg-progs)
790 run beirc run the Beirc IRC client
791 run climplayer run the CLIMPlayer music player
792 (required Debian packages: mplayer, fileschanged, fam)
793 run demodemo run some random CLIM examples
794 run clim-alerts run CLIM alerts
795 run eclipse [DPY] run the eclipse window manager
797 run hunchentoot run the Hunchentoot web server test
798 run webdav DIR run the CL-WEBDAV server, serving directory DIR
799 (required Debian packages: libssl-dev)
801 run parse-xml FILENAME
802 check XML for well-formedness
803 run validate-xml FILENAME
804 check XML for validity
805 run validate-relax-ng [--compact yes] XML-FILENAME SCHEMA-FILENAME
806 check XML for validity against a Relax NG Schema
807 run html-to-xhtml HTML-FILENAME OUTPUT-FILENAME
808 run xhtml-to-html XML-FILENAME OUTPUT-FILENAME
809 convert between HTML 4 and XHTMl
811 run vecto-demo generate a test image using vecto
812 run adw-charting-demo generate a test image using adw-charting
814 run ltk-demo show a dialog using ltk
818 check_program() {
819 if ! "$1" --help >/dev/null; then
820 echo Error: Cannot find a working installation of "$1"
821 exit 1
823 echo "found `which $1`"
826 # for programs that don't understand --help, or (like cvs) are stupid enough
827 # to return a failure code when invoked using a correct --help option...
828 check_misdesigned_program() {
829 if ! which "$1" >/dev/null; then
830 echo Error: Cannot find an installation of "$1" at all
831 exit 1
833 echo "found `which $1`"
836 check() {
837 echo "Checking for helper applications..."
838 check_misdesigned_program cvs
839 check_program svn
840 check_program darcs
841 check_program wget
842 # get_tarball is evil and unused anyway, so no need to bother the FreeBSD
843 # users with warnings about their non-GNU version of tar
844 # check_program tar
845 check_misdesigned_program curl
846 check_misdesigned_program git
847 check_misdesigned_program mktemp
848 echo "Success: All helper applications found."
850 echo
851 echo "Checking Lisp startup..."
852 if ${lisp} $run_options $eval $quit >/dev/null; then
853 echo "Success: Lisp starts up using \"$lisp\""
854 else
855 echo "Error: Cannot run Lisp using \"$lisp\""
856 exit 1
859 echo
860 echo "Looking for installable systems..."
861 count_systems
864 dumpcore() {
865 rm -f "$BASE"/.core-is-stale
866 rm -f "$BASE"/monster.core
867 recompile --dump "$@"
870 if test -f "$BASE"/monster.core; then
871 # Initially I thought this warning might be helpful, but it's usually
872 # false alarm:
873 # if test -f "$BASE/.core-is-stale"; then
874 # echo "using $BASE/monster.core"
875 # echo 'note: "clbuild update" was used since core file creation'
876 # echo 'note: consider re-running dumpcore'
877 # fi
878 run_options="$core_option "$BASE"/monster.core $run_options"
881 scan_projects() {
882 cat $1 | awk '{print $1;}' | while read name; do
883 if test -n "$name" -a x"$name" != 'x#'; then
884 echo -n "$name "
886 done
889 scan_installed() {
890 for f in ${source_dir}/*; do
891 name=`basename "$f"`
892 if test -d "$f"; then
893 if test -d "$f"/_darcs \
894 -o -d "$f"/.git \
895 -o -d "$f"/.svn \
896 -o -d "$f"/CVS \
897 && grep "^$name " "$BASE/dependencies" >/dev/null
898 then
899 echo $name
900 else
901 echo "skipping $f" 1>&2
904 done
907 main_projects=`scan_projects "$BASE/projects"`
908 wnpp_projects=`scan_projects "$BASE/wnpp-projects"`
909 all_projects="$main_projects $wnpp_projects"
911 implementations=`scan_projects "$BASE/implementations"`
913 set_installed_projects() {
914 installed_projects=`scan_installed`
917 list() {
918 pattern="$1"
920 TMPDIR=`mktemp -d /tmp/clbuild.XXXXXXXXXX`
921 export TMPDIR
923 cleanup() {
924 rm -rf $TMPDIR
926 trap cleanup exit
928 cat "$BASE/projects" "$BASE/wnpp-projects" "$BASE/implementations" | sort | grep -i -E "$pattern" | while read project rest; do
929 if test -n "$project" -a x"$project" != 'x#'; then
930 description=`echo $rest | cut -d\# -f2`
931 case `cd $source_dir && ${UPDATE_SCRIPT} --dry-run $project | cut -d: -f1` in
932 MISSING)
933 status=u
935 MISMATCH)
936 status="!"
939 status="i"
942 echo "failed to check URL" 1>&2
944 esac
946 echo "$status $project" >>$TMPDIR/left
947 echo $description >>$TMPDIR/right
949 done
950 paste $TMPDIR/left $TMPDIR/right | expand -t 25
951 exit 0
954 ensure_clppcre() {
955 if ! test -d "$source_dir/cl-ppcre"; then
957 cd "$source_dir"
958 update_project cl-ppcre
959 ln -f -s $source_dir/cl-ppcre/*.asd "${system_dir}"/
964 write_slime_configuration() {
965 if test -n "$START_SLIME_USING_CORE"; then
966 cmd=preloaded
967 else
968 cmd=lisp
970 cat <<EOF
972 ;; possibly controversial as a global default, but shipping a lisp
973 ;; that dies trying to talk to slime is stupid, so:
974 (set-language-environment "UTF-8")
975 (setq slime-net-coding-system 'utf-8-unix)
977 ;; load slime:
978 (setq load-path (cons "${source_namestring}slime" load-path))
979 (setq load-path (cons "${source_namestring}slime/contrib" load-path))
980 (setq slime-backend "$BASE/.swank-loader.lisp")
981 (setq inhibit-splash-screen t)
982 (load "${source_namestring}slime/slime")
983 (setq inferior-lisp-program "$BASE/clbuild $cmd")
984 (setq slime-use-autodoc-mode nil)
985 (slime-setup '(slime-fancy slime-tramp slime-asdf))
986 (slime)
988 # while we're at it, also write the swank loader
989 cat >$BASE/.swank-loader.lisp <<EOF
990 (unless (find-package 'swank-loader)
991 (load "$source_dir/slime/swank-loader.lisp"))
995 trash() {
996 mkdir -p "$BASE/trash"
997 basename=`basename $1`
998 today=`date +'%Y-%m-%d'`
999 trash="$BASE/trash/$today"
1000 if test -e "$trash"; then
1001 if test -e "$trash/$basename"; then
1002 trash=`mktemp -d $BASE/trash/${today}_${basename}_XXXXXXXXXX`
1004 else
1005 mkdir $trash
1007 echo moving "$1" to "$trash/$basename"
1008 mv "$1" "$trash"
1011 case $1 in
1012 check)
1013 check
1015 list)
1016 list "${2:-.*}"
1018 clean)
1019 clean_fasls() {
1020 echo cleaning fasls in `pwd`
1021 find . -name "*.fasl" -exec rm {} \;
1022 find . -name "*.lx64fsl" -exec rm {} \;
1024 if test $# -gt 1; then
1025 while test $# -gt 1; do
1026 ( cd "$source_dir/$2" && clean_fasls )
1027 shift
1028 done
1029 else
1030 core="$BASE"/monster.core
1031 if test -f "$core"; then
1032 echo removing $core
1033 rm -f "$core"
1035 cd $source_dir
1036 clean_fasls
1039 trash)
1040 if test $# -le 1; then
1041 echo 'usage: trash [PROJECT...]'
1042 exit 1
1044 while test $# -gt 1; do
1045 d="$source_dir/$2"
1046 if test -d "$d"; then
1047 trash "$d"
1048 else
1049 echo "cannot trash non-existing directory $d"
1051 shift
1052 done
1054 mrproper)
1055 for d in $source_dir/* $target_dir; do
1056 if test -d "$d"; then
1057 trash "$d"
1058 else
1059 echo "skipping $d"
1061 done
1062 echo "deleting monster.core systems/*"
1063 rm -f "$BASE"/monster.core ${system_dir}/*
1065 skip)
1066 touch "$source_dir/$2/.clbuild-skip-update"
1068 update)
1069 unset clbuild_resume
1070 unset extra
1071 while test -n "$2"; do
1072 case "$2" in
1073 --no-dependencies)
1074 CLBUILD_DEPENDENCIES="no"
1075 shift
1077 --dependencies)
1078 CLBUILD_DEPENDENCIES="yes"
1079 shift
1081 --resume)
1082 clbuild_resume="yes"
1083 shift
1085 --main-projects)
1086 extra="$extra $main_projects"
1087 shift
1089 --wnpp-projects)
1090 extra="$extra $wnpp_projects"
1091 shift
1093 --all-projects)
1094 extra="$extra $all_projects"
1095 shift
1097 --installed)
1098 set_installed_projects
1099 extra="$extra $installed_projects"
1100 shift
1103 break
1105 esac
1106 done
1107 export clbuild_resume
1108 export CLBUILD_DEPENDENCIES
1109 shift
1110 update "$@" $extra
1112 update-missing)
1113 for project in ${2:-$main_projects}; do
1114 if ! test -d "${source_dir}/$project"; then
1115 update $project
1117 done
1119 recompile|build|dumpcore|world)
1120 operation="$1"
1121 shift
1122 unset projects
1123 while test -n "$1"; do
1124 case "$1" in
1125 --main-projects)
1126 projects="$projects $main_projects"
1127 shift
1129 --wnpp-projects)
1130 projects="$projects $wnpp_projects"
1131 shift
1133 --all-projects)
1134 projects="$projects $all_projects"
1135 shift
1137 --installed)
1138 CLBUILD_DEPENDENCIES="yes"
1139 set_installed_projects
1140 projects="$projects $installed_projects"
1141 shift
1144 break
1146 esac
1147 done
1148 if test -z "$projects" -a $# -eq 0; then
1149 exec 1>&2
1150 echo "Error: arguments expected"
1151 echo "Usage:"
1152 echo " clbuild $operation PROJECT1 PROJECT2 PROJECT3... # only these"
1153 echo " clbuild $operation --main-projects # all in projects file"
1154 echo " clbuild $operation --wnpp-projects # all in wnpp-projects file"
1155 echo " clbuild $operation --all-projects # both files"
1156 echo " clbuild $operation --installed # everything in source/"
1157 exit 1
1159 ensure_clppcre
1160 case $operation in
1161 recompile)
1162 recompile "$@" $projects
1164 build)
1165 update "$@" $projects
1166 dumpcore "$@" $projects
1168 dumpcore)
1169 dumpcore "$@" $projects
1171 world)
1172 "$0" clean && "$0" update sbcl && "$0" compile-implementation sbcl && "$0" build "$@" $projects
1174 esac
1176 updatesbcl)
1177 exec 1>&2
1178 echo "error: invalid command updatesbcl"
1179 echo "Use 'clbuild update sbcl' instead."
1180 exit 1
1182 buildsbcl)
1183 exec 1>&2
1184 echo "error: invalid command buildsbcl"
1185 echo "Use 'clbuild compile-implementation sbcl' instead."
1186 exit 1
1188 compile-implementation)
1189 case $2 in
1190 sbcl)
1191 if [ -n "$CCL" ]; then
1192 echo "Cowardly refusing to build SBCL when \$CCL is set." 1>&2
1193 exit 1
1195 if ! test -d ${source_dir}/sbcl; then
1196 echo "sbcl not found, try running 'clbuild update sbcl'" 1>&2
1197 exit 1
1199 # Enable threads
1200 if test -z "$windowsp"; then
1201 ctf=$source_dir/sbcl/customize-target-features.lisp
1202 if test -f $ctf; then
1203 echo $ctf already exists
1204 else
1205 echo creating $ctf
1206 cat >$ctf <<EOF
1207 (lambda (list)
1208 (pushnew :sb-thread list)
1209 list)
1213 (cd $source_dir/sbcl; sh make.sh "$3"; SBCL_HOME= INSTALL_ROOT=${target_dir} sh install.sh)
1215 ccl)
1216 if [ -z "$CCL" ]; then
1217 echo "can't build CCL unless \$CCL is set." 1>&2
1218 exit 1
1220 if ! test -d ${source_dir}/ccl; then
1221 echo "ccl not found, try running 'clbuild update ccl'" 1>&2
1222 exit 1
1224 ccl_old=`dirname "$CCL"`
1225 ccl_new=${source_dir}/ccl
1226 case `uname` in
1227 Linux)
1228 case `uname -m` in
1229 x86_64)
1230 headerdir=x86-headers64
1231 binary=lx86cl64
1232 image=LX86CL64
1235 echo "don't know how to build CCL for your ISA, please adjust clbuild as needed" 2>&1
1236 exit 1
1238 esac
1241 echo "don't know how to build CCL for your OS, please adjust clbuild as needed" 2>&1
1242 exit 1
1244 esac
1245 if ! test -f "$ccl_old/$image"; then
1246 echo "can't find existing CCL installation in $ccl_old" 2>&1
1247 exit 1
1249 # cp $ccl_old/$headerdir/libc/*.cdb $ccl_new/$headerdir/libc/
1250 cp -r $ccl_old/$headerdir $ccl_new/ || true
1251 cp $ccl_old/$binary $ccl_old/$image $ccl_new/
1252 cd $ccl_new
1253 chmod +x $binary
1254 ./$binary -e '(rebuild-ccl :force t)'
1255 cat <<EOF
1258 Done compiling CCL.
1259 Set this in clbuild.conf to enable the new CCL:
1260 CCL=$ccl_old/$binary
1263 clisp)
1264 if ! test -d ${source_dir}/clisp; then
1265 echo "clisp not found, try running 'clbuild update clisp'" 1>&2
1266 exit 1
1268 cd $source_dir/clisp
1269 ./autogen.sh
1270 ulimit -s 16384
1271 rm -f src/config.cache
1272 ./configure --with-libsigsegv-prefix=/usr
1273 cd src
1274 make
1277 echo "unrecognized argument. valid are: sbcl ccl clisp" 2>&1
1278 exit 1
1280 esac
1282 lisp)
1283 shift;
1284 clbuild_lisp "$@"
1286 preloaded)
1287 shift;
1288 if test -f "$BASE"/monster.core; then
1289 common_options="$core_option "$BASE"/monster.core $common_options"
1291 clbuild_lisp "$@"
1293 slime)
1294 shift
1295 emacs_args="$@"
1296 emacs=${EMACS-emacs}
1297 write_slime_configuration >"$BASE/.start-slime.el"
1298 $emacs -l "$BASE/.start-slime.el" ${emacs_args}
1300 slime-configuration)
1301 shift
1302 echo ';; add this to your ~/.emacs to use clbuild and its slime:'
1303 echo ';;'
1304 write_slime_configuration
1306 run)
1307 shift
1308 case $1 in
1309 --help)
1310 help_run
1311 exit 0
1313 climplayer)
1314 check_program fileschanged
1315 check_misdesigned_program mplayer
1317 hunchentoot|webdav)
1318 if ! test -f /usr/lib/libssl.so; then
1319 echo "WARNING: /usr/lib/libssl.so not found, did you install OpenSSL?"
1320 echo "(type RET to continue anyway)"
1321 read
1324 perfectstorm)
1325 if ! test -f /usr/include/GL/glut.h; then
1326 echo "WARNING: /usr/include/GL/glut.h not found, did you install OpenGL libraries?"
1327 echo "(type RET to continue anyway)"
1328 read
1331 esac
1332 start_application "$@"
1334 record-dependencies)
1335 cd "$BASE"
1336 for project in $all_projects; do
1337 if ! test -d "${source_dir}/$project"; then
1338 update $project
1340 done
1341 # hack: don't want the core here
1342 run_options="$build_options"
1343 start_application record-dependencies "$all_projects"
1345 check-urls)
1346 cd "$source_dir"
1347 for project in ${2:-$all_projects}; do
1348 ${UPDATE_SCRIPT} --dry-run $project
1349 done
1351 clean-links)
1352 cd "$system_dir"
1353 for f in *; do
1354 if test -h "$f"; then
1355 link_target=`readlink "$f"`
1356 if ! test -e "$link_target"; then
1357 echo "removing broken link from $f to $link_target"
1358 rm "$f"
1361 done
1363 register-asd)
1364 project="$2"
1365 dir="$source_dir/$project"
1367 if test -z "$project"; then
1368 echo "usage: clbuild register-asd PROJECT" 1>&2
1369 exit 1
1371 if ! test -d "$dir"; then
1372 echo "cannot find $dir" 1>&2
1373 exit 1
1375 for f in $dir/*.asd; do
1376 if test -f "$f"; then
1377 echo "$f"
1378 ln -f -s $f "${system_dir}"/
1380 done
1381 link_extra_asds
1382 count_systems
1384 diff)
1385 diff="${source_dir}/.diff"
1386 cp /dev/null "$diff"
1387 cd "${source_dir}"
1388 darcs diff -u >>"$diff"
1389 set +e
1390 for f in *; do
1391 g="${source_dir}/$f"
1392 if test -d "$g"; then
1393 cd "$g"
1394 echo -n diffing $f... 1>&2
1395 if test -d CVS; then
1396 cvs diff -u 2>/dev/null | grep -v '^?' >>"$diff"
1397 elif test -d .svn; then
1398 svn diff >>"$diff"
1399 elif test -d '{arch}'; then
1400 baz diff >>"$diff"
1401 elif test -d _darcs; then
1402 darcs diff -u >>"$diff"
1403 elif test -d .git; then
1404 git diff >>"$diff"
1405 else
1406 echo -n " FAILED" 1>&2
1408 echo 1>&2
1410 done
1411 less "$diff"
1413 help|--long-help|-H|""|--help|-h)
1414 case $2 in
1415 run)
1416 help_run
1419 help
1420 esac
1423 echo "invalid command $1, try --help for help"
1424 exit 1
1425 esac
1427 d:\Experiments\clbuild>python clbuild.py check
1428 python clbuild.py check
1429 File "clbuild.py", line 23
1430 exincept OSError:
1432 SyntaxError: invalid syntax
1434 d:\Experiments\clbuild>python clbuild.py check
1435 python clbuild.py check
1436 File "clbuild.py", line 147
1437 print >>asdffile, r"#+clisp (dolist (dir-candidate (directory (concatenate 'string *lisp-dirs* \"*/\"))) (let ((asd-candidate (merge-pathnames \"*.asd\" dir-candidate))) (when (directory asd-candidate) (push dir-candidate asdf:*central-registry*))))")
1439 SyntaxError: invalid syntax
1441 d:\Experiments\clbuild>python clbuild.py check
1442 python clbuild.py check
1443 File "clbuild.py", line 193
1444 getopt.getopt(sys.argv[1:], "", [ "setup=", "check" ]])]
1446 SyntaxError: invalid syntax
1448 d:\Experiments\clbuild>python clbuild.py check
1449 python clbuild.py check
1450 File "clbuild.py", line 193
1451 getopt.getopt(sys.argv[1:], "", [ "setup=", "check" ]])
1453 SyntaxError: invalid syntax
1455 d:\Experiments\clbuild>python clbuild.py check
1456 python clbuild.py check
1457 Traceback (most recent call last):
1458 File "clbuild.py", line 5, in <module>
1459 import pat
1460 ImportError: No module named pat
1462 d:\Experiments\clbuild>python clbuild.py check
1463 python clbuild.py check
1464 Traceback (most recent call last):
1465 File "clbuild.py", line 181, in <module>
1466 if (lisp == "clisp"):
1467 NameError: name 'lisp' is not defined
1469 d:\Experiments\clbuild>python clbuild.py check
1470 python clbuild.py check
1472 d:\Experiments\clbuild>python clbuild.py check
1473 python clbuild.py check
1475 d:\Experiments\clbuild>python clbuild.py check
1476 python clbuild.py check
1477 File "clbuild.py", line 184
1478 def main()
1480 SyntaxError: invalid syntax
1482 d:\Experiments\clbuild>python clbuild.py check
1483 python clbuild.py check
1485 d:\Experiments\clbuild>python clbuild.py --check
1486 python clbuild.py --check
1487 CVS Found and present.
1488 SVN Found and present.
1489 Darcs found and present
1490 GIT Found and present.
1492 d:\Experiments\clbuild> cd ..
1493 cd ..
1495 D:\Experiments>