2 # $Id: build.sh 4634 2013-04-21 14:45:45Z hhenkel $
4 # Copyright (c) 2005-2011 Martin Schröder <martin@luatex.org>
5 # Copyright (c) 2009-2011 Taco Hoekwater <taco@luatex.org>
6 # Copyright (c) 2013-2013 Luigi Scarso and Hans Hagen (mingw stuff)
8 # Permission to use, copy, modify, and distribute this software for any
9 # purpose with or without fee is hereby granted, provided that the above
10 # copyright notice and this permission notice appear in all copies.
12 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 # new script to build luatex binaries
23 # --make : only make, no make distclean; configure
24 # --parallel : make -j 2 -l 3.0
25 # --nostrip : do not strip binary
26 # --warnings= : enable compiler warnings
27 # --mingw : crosscompile for mingw32 from i-386linux
28 # --mingw32 : crosscompile 32 binary on unix
29 # --mingw64 : crosscompile 64 binary on unix
30 # --msys : crosscompile 32 binary on windows
31 # --msys32 : crosscompile 32 binary on windows
32 # --msys64 : crosscompile 64 binary on windows
33 # --host= : target system for mingw32 cross-compilation
34 # --build= : build system for mingw32 cross-compilation
35 # --arch= : crosscompile for ARCH on OS X
36 # --debug : CFLAGS="-g -O0" --warnings=max --nostrip
38 # L/H: we assume a 64 bit build system .. it took us two days of experimenting with all
39 # kind of permutations to figure it out .. partly due to tangle/tie dependencies and
40 # we're not there yes as there are messages with respect to popen and so
44 # - generate ctangle and tie
45 # - get rid of otangle and tangle dependencies
46 # - don't generate bins we don't need
47 # - maybe make cario in mplib optional
49 # Patch suggested by Fabrice Popineau in texk/web2c/lib/lib.h: #define eof weof
53 # try to find bash, in case the standard shell is not capable of
54 # handling the generated configure's += variable assignments
55 if which bash
>/dev
/null
57 CONFIG_SHELL
=`which bash`
61 # try to find gnu make; we may need it
63 if make -v 2>&1|
grep "GNU Make" >/dev
/null
65 echo "Your make is a GNU-make; I will use that"
66 elif gmake
-v >/dev
/null
2>&1
70 echo "You have a GNU-make installed as gmake; I will use that"
72 echo "I can't find a GNU-make; I'll try to use make and hope that works."
73 echo "If it doesn't, please install GNU-make."
86 JOBS_IF_PARALLEL
=${JOBS_IF_PARALLEL:-3}
87 MAX_LOAD_IF_PARALLEL
=${MAX_LOAD_IF_PARALLEL:-2}
93 --make ) ONLY_MAKE
=TRUE
;;
94 --nostrip ) STRIP_LUATEX
=FALSE
;;
95 --debug ) STRIP_LUATEX
=FALSE
; WARNINGS
=max
; CFLAGS
="-g -O0 $CFLAGS" ;;
96 --warnings=*) WARNINGS
=`echo $1 | sed 's/--warnings=\(.*\)/\1/' ` ;;
97 --mingw ) MINGWCROSS
=TRUE
;;
98 --mingw32 ) MINGWCROSS
=TRUE
;;
99 --mingw64 ) MINGWCROSS64
=TRUE
;;
100 --msys ) MINGWMSYS
=TRUE
;;
101 --msys32 ) MINGWMSYS
=TRUE
;;
102 --msys64 ) MINGWMSYS64
=TRUE
;;
103 --host=* ) CONFHOST
="$1" ;;
104 --build=* ) CONFBUILD
="$1" ;;
105 --parallel ) MAKE
="$MAKE -j $JOBS_IF_PARALLEL -l $MAX_LOAD_IF_PARALLEL" ;;
106 --arch=* ) MACCROSS
=TRUE
; ARCH
=`echo $1 | sed 's/--arch=\(.*\)/\1/' ` ;;
107 * ) echo "ERROR: invalid build.sh parameter: $1"; exit 1 ;;
117 MINGW64
* ) LUATEXEXE
=luatex.exe
;;
118 MINGW32
* ) LUATEXEXE
=luatex.exe
;;
119 CYGWIN
* ) LUATEXEXE
=luatex.exe
;;
122 WARNINGFLAGS
=--enable-compiler-warnings=$WARNINGS
128 if [ "$MINGWCROSS" = "TRUE" ]
131 PATH
=`pwd`/extrabin
/mingw
:$PATH
133 CFLAGS
="-mtune=nocona -g -O3 $CFLAGS"
134 CXXFLAGS
="-mtune=nocona -g -O3 $CXXFLAGS"
135 CONFHOST
="--host=i586-mingw32msvc"
136 CONFBUILD
="--build=x86_64-unknown-linux-gnu"
137 STRIP
="${CONFHOST#--host=}-strip"
138 LDFLAGS
="-Wl,--large-address-aware $CFLAGS"
139 export CFLAGS CXXFLAGS LDFLAGS
142 if [ "$MINGWCROSS64" = "TRUE" ]
145 PATH
=`pwd`/extrabin
/mingw
:$PATH
147 CFLAGS
="-mtune=nocona -g -O3 -static-libgcc -static-libstdc++ $CFLAGS"
148 CXXFLAGS
="-mtune=nocona -g -O3 $CXXFLAGS"
149 CONFHOST
="--host=x86_64-w64-mingw32"
150 CONFBUILD
="--build=x86_64-unknown-linux-gnu"
151 STRIP
="${CONFHOST#--host=}-strip"
153 export CFLAGS CXXFLAGS LDFLAGS
156 if [ "$MINGWMSYS" = "TRUE" ]
159 PATH
=`pwd`/extrabin
/msys
:$PATH
162 CFLAGS
="-mtune=nocona -m32 -g -O3 $CFLAGS"
163 CXXFLAGS
="-mtune=nocona -m32 -g -O3 $CXXFLAGS"
164 CONFHOST
="--host=i586-mingw32"
165 CONFBUILD
="--build=x86_64-w64-mingw32"
168 export CFLAGS CXXFLAGS LDFLAGS CPPFLAGS
171 if [ "$MINGWMSYS64" = "TRUE" ]
174 PATH
=`pwd`/extrabin
/mingw
:$PATH
177 CFLAGS
="-mtune=nocona -g -O3 $CFLAGS"
178 CXXFLAGS
="-mtune=nocona -g -O3 $CXXFLAGS"
179 CONFHOST
="--host=x86_64-w64-mingw32"
180 CONFBUILD
="--build=x86_64-w64-mingw32"
183 export CFLAGS CXXFLAGS LDFLAGS CPPFLAGS
186 if [ "$MACCROSS" = "TRUE" ]
188 # make sure that architecture parameter is valid
190 i386 | x86_64 | ppc | ppc64
) ;;
191 * ) echo "ERROR: architecture $ARCH is not supported"; exit 1;;
194 CFLAGS
="-arch $ARCH -g -O2 $CFLAGS"
195 CXXFLAGS
="-arch $ARCH -g -O2 $CXXFLAGS"
196 LDFLAGS
="-arch $ARCH $LDFLAGS"
197 export CFLAGS CXXFLAGS LDFLAGS
200 if [ "$STRIP_LUATEX" = "FALSE" ]
206 # clean up, if needed
207 if [ -r "$B"/Makefile
-a $ONLY_MAKE = "FALSE" ]
210 elif [ ! -r "$B"/Makefile
]
219 # get a new svn version header
220 ( cd source ; .
/texk
/web2c
/luatexdir
/getluatexsvnversion.sh
)
224 if [ "$ONLY_MAKE" = "FALSE" ]
226 TL_MAKE
=$MAKE ..
/source
/configure
$CONFHOST $CONFBUILD $WARNINGFLAGS\
227 --enable-cxx-runtime-hack \
228 --enable-silent-rules \
231 --disable-largefile \
234 --enable-dump-share \
237 --without-system-harfbuzz \
238 --without-system-ptexenc \
239 --without-system-kpathsea \
240 --without-system-poppler \
241 --without-system-xpdf \
242 --without-system-freetype \
243 --without-system-freetype2 \
244 --without-system-gd \
245 --without-system-libpng \
246 --without-system-teckit \
247 --without-system-zlib \
248 --without-system-t1lib \
249 --without-system-icu \
250 --without-system-graphite \
251 --without-system-zziplib \
252 --without-mf-x-toolkit --without-x \
258 # the fact that these makes inside libs/ have to be done manually for the cross
259 # compiler hints that something is wrong in the --enable/--disable switches above,
260 # but I am too lazy to look up what is wrong exactly.
261 # (perhaps more files needed to be copied from TL?)
263 (cd libs
/zziplib
; $MAKE all
)
264 (cd libs
/zlib
; $MAKE all
)
265 (cd libs
/libpng
; $MAKE all
)
266 (cd libs
/poppler
; $MAKE all
)
268 (cd texk
/kpathsea
; $MAKE )
269 (cd texk
/web2c
; $MAKE $LUATEXEXE )
274 if [ "$STRIP_LUATEX" = "TRUE" ] ;
276 $STRIP "$B"/texk
/web2c
/$LUATEXEXE
278 echo "luatex binary not stripped"
284 ls -l "$B"/texk
/web2c
/$LUATEXEXE