build.sh 6.89 KB
Newer Older
rtoy's avatar
rtoy committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#!/bin/sh 

# Build CMUCL from source.  The intent of this script is to make it a
# little easier invoke the other scripts and build CMUCL.  In the
# simplest case where your lisp is named cmulisp and no special
# bootfiles are needed, you would build CMUCL using:
#
#    src/tools/build.sh -C ""
#
# This will create a set of directories named build-2, build-3, and
# build-4 and CMUCL will be built 3 consecutive times, using the
# version of CMUCL from the previous build.
#
#
# You can control which of the builds are done by using the -1, -2, -3
# options, but it is up to you to make sure the previous builds exist.
#
# A more realistic example would be
#
#    src/tools/build.sh -v "My build" -B boot-19b.lisp -o "my-lisp -noinit"
#
# where you need to load the bootfile boot-19b.lisp and your lisp is
# not named cmulisp, but my-lisp.
#
# For more complicated builds, you will need to run create-target.sh
# manually, and adjust the bootstrap or setenv files by hand.  Once
# this is done, you can run build.sh to build everything.  Just be
# sure to leave off the -C option.
#
# Cross compiling is not supported with this script.  You will have to
# do that by hand.
#
# For more information see src/BUILDING.
rtoy's avatar
rtoy committed
34
#
35
# $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/tools/build.sh,v 1.38 2010/11/10 19:17:55 rtoy Exp $
rtoy's avatar
rtoy committed
36
#
rtoy's avatar
rtoy committed
37 38 39 40 41

ENABLE2="yes"
ENABLE3="yes"
ENABLE4="yes"

42
version=20c
rtoy's avatar
rtoy committed
43 44
SRCDIR=src
TOOLDIR=$SRCDIR/tools
45
VERSION="`date '+%Y-%m-%d %H:%M:%S'`"
46
GIT_HASH="`(cd src; git describe --dirty 2>/dev/null)`"
47 48
# Add the tree hash to the version
VERSION="$VERSION $GIT_HASH"
rtoy's avatar
rtoy committed
49
BASE=build
50 51
OLDLISPFLAGS="-noinit -nositeinit"
OLDLISP="cmulisp"
rtoy's avatar
rtoy committed
52 53 54

SKIPUTILS=no

rtoy's avatar
rtoy committed
55 56
# If gmake exists, assume it is GNU make and use it.
if [ -z "$MAKE" ]; then
57
    MAKE="`which gmake`"
58 59 60 61 62 63 64 65 66

    # Some versions of which set an error code if it fails.  Others
    # say "no foo in <path>".  In either of these cases, just assume
    # make is GNU make.

    if [ $? -ne 0 ]; then
	MAKE="make"
    fi
    if echo "X$MAKE" | grep '^Xno' > /dev/null; then
67 68
	MAKE="make"
    fi
rtoy's avatar
rtoy committed
69 70
fi

rtoy's avatar
rtoy committed
71 72
usage ()
{
rtoy's avatar
rtoy committed
73
    echo "build.sh [-123obvuBCU?]"
rtoy's avatar
rtoy committed
74 75 76 77 78
    echo "    -1        Skip build 1"
    echo "    -2        Skip build 2"
    echo "    -3        Skip build 3"
    echo "    -o x      Use specified Lisp to build.  Default is cmulisp"
    echo "               (only applicable for build 1)"
rtoy's avatar
rtoy committed
79
    echo '    -b d      The different build directories are named ${d}-2, ${d}-3 ${d}-4'
rtoy's avatar
rtoy committed
80 81 82 83
    echo '               with a default of "build"'
    echo '    -v v      Use the given string as the version.  Default is'
    echo "               today's date"
    echo "    -u        Don't build CLX, CLM, or Hemlock"
rtoy's avatar
rtoy committed
84 85 86
    echo '    -i n      Make build "n" interactive, so output is sent to *standard-output*'
    echo '               instead of the log file. "n" should be a string consisting of'
    echo '                the numbers 1, 2, or 3.'
rtoy's avatar
rtoy committed
87 88
    echo "    -B file   Use file as a boot file.  Maybe be specified more than once"
    echo "               The file is relative to the bootfiles/<version> directory"
rtoy's avatar
rtoy committed
89 90 91
    echo '    -C [l m]  Create the build directories.  The args are what'
    echo '               you would give to create-target.sh for the lisp'
    echo '               and motif variant.'
92
    echo '    -f mode   FPU mode:  x87, sse2, or auto.  Default is auto'
93 94
    echo '    -P        On the last build, do NOT generate cmucl.pot and do NOT update'
    echo '               the translations.'
rtoy's avatar
rtoy committed
95
    echo "    -?        This help message"
96
    echo "    -w        Specify a different build-world.sh script"
Raymond Toy's avatar
Raymond Toy committed
97
    echo "    -U        If translations are done, overwrite the files with the"
98 99 100
    echo "               translations instead of computing and displaying the diffs."
    echo "    -O opt    Any additional command-line flags to use when building."
    echo "               The flags always include -noinit -nositeinit"
rtoy's avatar
rtoy committed
101 102 103
    exit 1
}

104 105 106 107 108 109 110 111 112
# Figure out if we need to run build-world twice
case `uname -s` in
  SunOS) BUILD_WORLD2=yes ;;
  Darwin)
      case `uname -m` in
	ppc) BUILD_WORLD2=yes ;;
      esac ;;
esac

rtoy's avatar
rtoy committed
113 114
buildit ()
{
rtoy's avatar
rtoy committed
115 116 117 118 119 120
    if echo $INTERACTIVE_BUILD | grep $BUILD > /dev/null; then
	INTERACTIVE=t
    else
	INTERACTIVE=nil
    fi

rtoy's avatar
rtoy committed
121 122 123 124 125 126 127 128
    if [ ! -d $TARGET ]; then
	if [ -n "$CREATE_DIRS" ]; then
	    $TOOLDIR/create-target.sh $TARGET $CREATE_OPT
	fi
    fi

    if [ "$ENABLE" = "yes" ]; 
    then
129
	$TOOLDIR/clean-target.sh $CLEAN_FLAGS $TARGET || { echo "Failed: $TOOLDIR/clean-target.sh"; exit 1; }
130
	time $BUILDWORLD $TARGET $OLDLISP $BOOT || { echo "Failed: $BUILDWORLD"; exit 1; }
131 132 133 134 135
	# Set the LANG to C.  For whatever reason, if I (rtoy) don't
        # do this on my openSuSE system, any messages from gcc are
        # basically garbled.  This should be harmless on other
        # systems.
	LANG=C $MAKE -C $TARGET/lisp $MAKE_TARGET || { echo "Failed: $MAKE -C $TARGET/lisp"; exit 1; }
136 137
	if [ "$BUILD_WORLD2" = "yes" ];
	then
138
	    $BUILDWORLD $TARGET $OLDLISP $BOOT || { echo "Failed: $BUILDWORLD"; exit 1; }
rtoy's avatar
rtoy committed
139
	fi
140 141
	$TOOLDIR/load-world.sh $TARGET "$VERSION" || { echo "Failed: $TOOLDIR/load-world.sh"; exit 1; }

rtoy's avatar
rtoy committed
142
	$TARGET/lisp/lisp -batch -noinit -nositeinit $FPU_MODE < /dev/null || { echo "Failed: $TARGET/lisp/lisp -batch -noinit $FPU_MODE"; exit 1; }
143
	return 0;
rtoy's avatar
rtoy committed
144 145 146
    fi
}

147
FPU_MODE=
148
BUILDWORLD="$TOOLDIR/build-world.sh"
149
BUILD_POT="yes"
rtoy's avatar
rtoy committed
150
UPDATE_TRANS=
151

152
while getopts "123Po:b:v:uB:C:Ui:f:w:O:?" arg
rtoy's avatar
rtoy committed
153 154 155 156 157 158 159
do
    case $arg in
	1) ENABLE2="no" ;;
	2) ENABLE3="no" ;;
	3) ENABLE4="no" ;;
	o) OLDLISP=$OPTARG ;;
	b) BASE=$OPTARG ;;
160
	v) VERSION="$OPTARG $GIT_HASH" ;;
rtoy's avatar
rtoy committed
161 162 163 164
	u) SKIPUTILS="yes" ;;
	C) CREATE_OPT="$OPTARG"
	   CREATE_DIRS=yes ;;
	B) bootfiles="$bootfiles $OPTARG" ;;
rtoy's avatar
rtoy committed
165
        i) INTERACTIVE_BUILD="$OPTARG" ;;
166
	f) FPU_MODE="-fpu $OPTARG" ;;
167
        P) BUILD_POT=no ;;
168
        w) BUILDWORLD="$OPTARG" ;;
rtoy's avatar
rtoy committed
169
        U) UPDATE_TRANS="yes";;
170
	O) OLDLISPFLAGS="$OLDLISPFLAGS $OPTARG" ;;
rtoy's avatar
rtoy committed
171
	\?) usage
rtoy's avatar
rtoy committed
172 173 174 175 176 177 178 179 180 181 182
	    ;;
    esac
done

bootfiles_dir=$SRCDIR/bootfiles/$version
if [ -n "$bootfiles" ]; then
    for file in $bootfiles; do
	BOOT="$BOOT -load $bootfiles_dir/$file"
    done
fi

183 184 185
build_started=`date`
echo "//starting build: $build_started"

rtoy's avatar
rtoy committed
186 187
TARGET=$BASE-2
ENABLE=$ENABLE2
188
MAKE_TARGET=all
rtoy's avatar
rtoy committed
189
export INTERACTIVE
rtoy's avatar
rtoy committed
190

rtoy's avatar
rtoy committed
191
BUILD=1
192
OLDLISP="$OLDLISP $OLDLISPFLAGS $FPU_MODE"
rtoy's avatar
rtoy committed
193 194 195 196 197
buildit

bootfiles=

TARGET=$BASE-3
198
OLDLISP="${BASE}-2/lisp/lisp $OLDLISPFLAGS $FPU_MODE"
rtoy's avatar
rtoy committed
199 200
ENABLE=$ENABLE3

rtoy's avatar
rtoy committed
201
BUILD=2
rtoy's avatar
rtoy committed
202 203 204
# We shouldn't have to run build-world again because nothing should
# have changed in the C code after the first build.
BUILD_WORLD2=
rtoy's avatar
rtoy committed
205 206 207
buildit

TARGET=$BASE-4
208
CLEAN_FLAGS="-K all"
209
OLDLISP="${BASE}-3/lisp/lisp $OLDLISPFLAGS $FPU_MODE"
rtoy's avatar
rtoy committed
210 211
ENABLE=$ENABLE4

212 213
if [ "${BUILD_POT}" = "yes" ]; then
   MAKE_POT=yes
rtoy's avatar
rtoy committed
214 215 216 217 218
   if [ "${UPDATE_TRANS}" = "yes" ]; then
       MAKE_TARGET="all translations-update"
   else
       MAKE_TARGET="all translations"
   fi
219 220 221
   export MAKE_POT
fi

rtoy's avatar
rtoy committed
222
BUILD=3
rtoy's avatar
rtoy committed
223 224 225 226
buildit

if [ "$SKIPUTILS" = "no" ];
then
227
    OLDLISP="${BASE}-4/lisp/lisp $OLDLISPFLAGS $FPU_MODE"
rtoy's avatar
rtoy committed
228
    time $TOOLDIR/build-utils.sh $TARGET $FPU_MODE
rtoy's avatar
rtoy committed
229
fi
230 231 232 233 234

build_finished=`date`
echo
echo "//build started:  $build_started"
echo "//build finished: $build_finished"