beta-0.89.2
[luatex.git] / source / Build
blobf5ccc92d1a6c7cb0b44977e2b9a998da38b7cdc8
1 #!/bin/sh
2 # $Id: Build 35438 2014-10-25 15:33:44Z karl $
3 # Public domain. Originally written many years ago by Sebastian Rahtz.
4 # The basic idea is to run configure && make, but with a multitude of
5 # environment variables to allow overriding everything.
6 #
7 # To build again from where it left off, try Build --no-clean.
8 # To build without optimization, try Build --debug.
9 # Any other options given are passed along to configure.
11 # clean up environment
12 unset TEXMFCNF; export TEXMFCNF
13 LANG=C; export LANG
15 # cd to our source directory.
16 mydir=`dirname $0`
17 cd $mydir || exit 1
19 : ${TL_WORKDIR=Work}
21 # allow override of install destination.
22 if test -z "$TL_INSTALL_DEST"; then
23 H=`pwd`
24 test -d inst || mkdir -p inst/texmf # avoid configure warnings
25 TL_INSTALL_DEST=$H/inst
28 # allow override of the make program.
29 # The idea is to use TL_MAKE if that is defined (and set MAKE),
30 # or MAKE if that is defined (and set TL_MAKE),
31 # or default to "make" if neither is set.
32 # We have to end up with both defined because TL_MAKE is used below
33 # in this script, and MAKE is used throughout (in its usual way).
34 if test -n "$TL_MAKE"; then
35 MAKE=$TL_MAKE
36 elif test -n "$MAKE"; then
37 TL_MAKE=$MAKE
38 else
39 TL_MAKE=make
40 MAKE=make
42 export MAKE
44 # make flags
45 : ${TL_MAKE_FLAGS=}
47 # allow override of make target.
48 : ${TL_TARGET=world}
50 if test "x$1" = x--no-clean; then
51 shift
52 else
53 test -f Makefile && $MAKE clean
54 rm -rf $TL_WORKDIR $TL_INSTALL_DEST
57 # allow adding environment setting for build.
58 : ${TL_BUILD_ENV=}
59 if test "x$1" = x--debug || test "x$1" = x-g; then
60 shift
61 # The idea is that with Build -g, you can set TL_COMPILER_GFLAGS in
62 # the environment with options common to all compilers --
63 # not necessarily anything to do with debugging, e.g., -mcpu=sparvc9.
64 : ${TL_COMPILER_GFLAGS=-g}
65 c="CFLAGS='$TL_COMPILER_GFLAGS'"
66 cxx="CXXFLAGS='$TL_COMPILER_GFLAGS'"
67 objcxx="OBJCXXFLAGS='$TL_COMPILER_GFLAGS'" # needed only on macs
68 TL_BUILD_ENV="$c $cxx $objcxx $TL_BUILD_ENV"
71 # allow override of configure location.
72 : ${TL_CONFIGURE=../configure}
74 # allow for changing the banner identification, e.g.,
75 # --with-banner-add='/SomeDistro'; see the build doc.
76 : ${TL_CONF_BANNER=}
78 # default to supporting large files as much as possible;
79 # see comments at --disable-largefile in README.config.
80 : ${TL_CONF_LARGEFILE=--enable-largefile}
82 # default to terminate if requested programs or features must be disabled.
83 : ${TL_CONF_MISSING=--disable-missing}
85 # default to static linking.
86 : ${TL_CONF_SHARED=--disable-shared}
88 # allow override of xdvi toolkit, default to standard xaw.
89 : ${TL_CONF_XDVI_TOOLKIT=--with-xdvi-x-toolkit=xaw}
91 # allow adding arbitrary other configure args, after all the others.
92 : ${TL_CONFIGURE_ARGS=}
94 # allow for doing stuff betwen configure and make.
95 : ${TL_POSTCONFIGURE=true}
97 # Kpathsea is not going to be able to find its cnf files during the
98 # build, so omit the warning about it.
99 : ${KPATHSEA_WARNING=0}
101 # make our working directory.
102 test -d $TL_WORKDIR || mkdir $TL_WORKDIR
103 cd $TL_WORKDIR || exit 1
105 # configure && make. Keep the tee outside, so that we can detect
106 # failure at either step.
108 echo "starting TeX Live build at `date`"
109 echo "on `uname -a`"
110 echo "in `pwd`"
111 echo "$0 $*"
112 echo
113 env | sort >buildenv.log
115 set -vx # show the configure and make commands in the log.
117 eval $TL_BUILD_ENV $TL_CONFIGURE \
118 --prefix=$TL_INSTALL_DEST \
119 --datadir=$TL_INSTALL_DEST \
120 $TL_CONF_BANNER \
121 $TL_CONF_MISSING \
122 $TL_CONF_LARGEFILE \
123 $TL_CONF_SHARED \
124 $TL_CONF_XDVI_TOOLKIT \
125 $TL_CONFIGURE_ARGS \
126 "$@" \
127 && eval $TL_POSTCONFIGURE \
128 && eval $TL_BUILD_ENV $TL_MAKE $TL_MAKE_FLAGS $TL_TARGET
130 # Too arcane to try to propagate the exit status through a pipeline.
131 # Just use a temp file.
132 echo $? >exitstatus.txt
133 } 2>&1 | tee build.log
136 # if we have a bindir, report the number of binaries built.
137 bindir=$TL_INSTALL_DEST/bin
138 if test -d "$bindir"; then
139 count=`find "$bindir" \! -type d -print | wc -l`
140 if test "$count" -gt 0; then
141 echo
142 echo "$0: $count executables in $bindir."
143 else
144 echo "$0: Build failed, no executables under $bindir."
145 echo "$0: Full log in `pwd`/build.log."
146 exit 1
147 fi | tee -a build.log
148 # if no bindir, perhaps they specified --prefix; don't worry.
149 # Any errors will have been duly reported anyway.
152 status=`cat exitstatus.txt`
153 echo "done (exit status $status)" `date` | tee -a build.log
155 exit $status