1#!/bin/sh
2set -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
17echo //entering make-target-contrib.sh
18
19LANG=C
20LC_ALL=C
21
22# Just doing CC=${CC:-cc} may be enough, but it needs to be checked
23# that cc is available on all platforms.
24if [ -z $CC ]; then
25    if [ -x "`command -v cc`" ]; then
26        CC=cc
27    else
28        CC=gcc
29    fi
30fi
31
32unset EXTRA_CFLAGS # avoid any potential interference
33export CC LANG LC_ALL
34
35# Load our build configuration
36. output/build-config
37
38. ./sbcl-pwd.sh
39sbcl_pwd
40
41SBCL_HOME="$SBCL_PWD/obj/sbcl-home"
42export SBCL_HOME SBCL_PWD
43if [ "$OSTYPE" = "cygwin" ] ; then
44    SBCL_PWD=`echo $SBCL_PWD | sed s/\ /\\\\\\\\\ /g`
45fi
46
47SBCL="$SBCL_PWD/src/runtime/sbcl --noinform --core $SBCL_PWD/output/sbcl_core \
48--lose-on-corruption --disable-debugger --no-sysinit --no-userinit"
49SBCL_BUILDING_CONTRIB=1
50export SBCL SBCL_BUILDING_CONTRIB
51
52# deleting things here lets us not worry about interaction with stale
53# fasls.  This is not good, but is better than :FORCE on each asdf
54# operation, because that causes multiple builds of base systems such
55# as SB-RT and SB-GROVEL, but FIXME: there's probably a better
56# solution.  -- CSR, 2003-05-30
57if [ -z "$DONT_CLEAN_SBCL_CONTRIB" ] ; then
58  find contrib/ obj/asdf-cache/ obj/sbcl-home/contrib/ \
59    \( -name '*.fasl' -o \
60       -name '*.FASL' -o \
61       -name 'foo.c' -o \
62       -name 'FOO.C' -o \
63       -name 'a.out' -o \
64       -name 'A.OUT' -o \
65       -name 'alien.so' -o \
66       -name 'ALIEN.SO' -o \
67       -name '*.o' -o \
68       -name '*.O' \) \
69    -print | xargs rm -f
70fi
71
72find output -name 'building-contrib.*' -print | xargs rm -f
73
74# Ignore all source registries.
75if [ -z "$*" ]; then
76    contribs_to_build="`cd contrib ; echo *`"
77else
78    contribs_to_build="$*"
79fi
80
81for i in $contribs_to_build; do
82    test -d contrib/$i && test -f contrib/$i/Makefile || continue;
83    test -f contrib/$i/test-passed && rm contrib/$i/test-passed # remove old convention
84    test -f obj/asdf-cache/$i/test-passed.test-report && rm obj/asdf-cache/$i/test-passed.test-report
85    mkdir -p obj/asdf-cache/$i/
86    # hack to get exit codes right.
87    if $GNUMAKE -C contrib/$i test < /dev/null 2>&1 && touch obj/asdf-cache/$i/test-passed.test-report ; then
88	:
89    else
90	exit $?
91    fi | tee output/building-contrib.`basename $i`
92done
93
94# Otherwise report expected failures:
95HEADER_HAS_BEEN_PRINTED=false
96for dir in `cd obj/asdf-cache/ ; echo *`; do
97  f="obj/asdf-cache/$dir/test-passed.test-report"
98  if test -f "$f" && grep -i fail "$f" >/dev/null; then
99      if ! $HEADER_HAS_BEEN_PRINTED; then
100          cat <<EOF
101
102Note: Test suite failures which are expected for this combination of
103platform and features have been ignored:
104EOF
105          HEADER_HAS_BEEN_PRINTED=true
106      fi
107      echo "  contrib/$dir"
108      (unset IFS; while read line; do echo "    $line"; done <"$f")
109  fi
110done
111
112# Sometimes people used to see the "No tests failed." output from the last
113# DEFTEST in contrib self-tests and think that's all that is. So...
114HEADER_HAS_BEEN_PRINTED=false
115for dir in `cd contrib ; echo *`
116do
117  if [ -d "contrib/$dir" -a -f "contrib/$dir/Makefile" -a ! -f "obj/asdf-cache/$dir/test-passed.test-report" ]; then
118      if $HEADER_HAS_BEEN_PRINTED; then
119          echo > /dev/null
120      else
121          cat <<EOF
122
123WARNING! Some of the contrib modules did not build successfully or pass
124their self-tests. Failed contribs:"
125EOF
126          HEADER_HAS_BEEN_PRINTED=true
127      fi
128      echo "  $dir"
129  fi
130done
131
132if [ $HEADER_HAS_BEEN_PRINTED = true ]; then
133  exit 1
134fi
135