make it possible to build only selected contribs
[sbcl.git] / make-target-contrib.sh
1 #!/bin/sh
2 set -e
3
4 # This is a script to be run as part of make.sh. The only time you'd
5 # probably want to run it by itself is if you're cross-compiling the
6 # system or doing some kind of troubleshooting.
7
8 # This software is part of the SBCL system. See the README file for
9 # more information.
10 #
11 # This software is derived from the CMU CL system, which was
12 # written at Carnegie Mellon University and released into the
13 # public domain. The software is in the public domain and is
14 # provided with absolutely no warranty. See the COPYING and CREDITS
15 # files for more information.
16
17 echo //entering make-target-contrib.sh
18
19 LANG=C
20 LC_ALL=C
21 export LANG LC_ALL
22
23 # Load our build configuration
24 . output/build-config
25
26 . ./sbcl-pwd.sh
27 sbcl_pwd
28
29 SBCL_HOME="$SBCL_PWD/contrib"
30 export SBCL_HOME
31 if [ "$OSTYPE" = "cygwin" ] ; then
32     SBCL_PWD=`echo $SBCL_PWD | sed s/\ /\\\\\\\\\ /g`
33 fi
34
35 SBCL="$SBCL_PWD/src/runtime/sbcl --noinform --core $SBCL_PWD/output/sbcl.core \
36 --lose-on-corruption --disable-debugger --no-sysinit --no-userinit"
37 SBCL_BUILDING_CONTRIB=1
38 export SBCL SBCL_BUILDING_CONTRIB
39
40 # deleting things here lets us not worry about interaction with stale
41 # fasls.  This is not good, but is better than :FORCE on each asdf
42 # operation, because that causes multiple builds of base systems such
43 # as SB-RT and SB-GROVEL, but FIXME: there's probably a better
44 # solution.  -- CSR, 2003-05-30
45
46 find contrib/ \( -name '*.fasl' -o \
47                  -name '*.FASL' -o \
48                  -name 'foo.c' -o \
49                  -name 'FOO.C' -o \
50                  -name 'a.out' -o \
51                  -name 'A.OUT' -o \
52                  -name 'alien.so' -o \
53                  -name 'ALIEN.SO' -o \
54                  -name '*.o' -o \
55                  -name '*.O' \) \
56   -print | xargs rm -f
57
58 find output -name 'building-contrib.*' -print | xargs rm -f
59
60 # Ignore all source registries.
61 CL_SOURCE_REGISTRY='(:source-registry :ignore-inherited-configuration)'
62 export CL_SOURCE_REGISTRY
63
64 if [ -z "$@" ]; then
65     contribs_to_build=contrib/*
66 else
67     for name in $@; do
68         contribs_to_build="contrib/$name $contribs_to_build"
69     done
70 fi
71
72 for i in $contribs_to_build; do
73     test -d $i && test -f $i/Makefile || continue;
74     # export INSTALL_DIR=$SBCL_HOME/`basename $i `
75     test -f $i/test-passed && rm $i/test-passed
76     # hack to get exit codes right.
77     if $GNUMAKE -C $i test 2>&1 && touch $i/test-passed ; then
78         :
79     else
80         exit $?
81     fi | tee output/building-contrib.`basename $i` 
82 done
83
84 # Sometimes people used to see the "No tests failed." output from the last
85 # DEFTEST in contrib self-tests and think that's all that is. So...
86 HEADER_HAS_BEEN_PRINTED=false
87 for dir in contrib/*
88 do
89   if [ -d "$dir" -a -f "$dir/Makefile" -a ! -f "$dir/test-passed" ]; then
90       if $HEADER_HAS_BEEN_PRINTED; then
91           echo > /dev/null
92       else
93           cat <<EOF
94
95 WARNING! Some of the contrib modules did not build successfully or pass
96 their self-tests. Failed contribs:"
97 EOF
98           HEADER_HAS_BEEN_PRINTED=true
99       fi
100       echo "  `basename $dir`"
101   fi
102 done
103
104 if [ $HEADER_HAS_BEEN_PRINTED = true ]; then
105   exit 1
106 fi