patch from Élie Roux for pdfgen.w (trunk)
[luatex.git] / build.sh
blob90c4d87a679ee310b9ea1eb60b7f5ae7ded26024
1 #!/usr/bin/env bash
2 # $Id$
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
21 # ----------
22 # Options:
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" CXXFLAGS="-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
42 # todo:
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 cairo in mplib optional
49 # Patch suggested by Fabrice Popineau in texk/web2c/lib/lib.h: #define eof weof
51 $DEBUG
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
56 then
57 CONFIG_SHELL=`which bash`
58 export CONFIG_SHELL
61 # try to find gnu make; we may need it
62 MAKE=make;
63 if make -v 2>&1| grep "GNU Make" >/dev/null
64 then
65 echo "Your make is a GNU-make; I will use that"
66 elif gmake -v >/dev/null 2>&1
67 then
68 MAKE=gmake;
69 export MAKE;
70 echo "You have a GNU-make installed as gmake; I will use that"
71 else
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."
76 ONLY_MAKE=FALSE
77 STRIP_LUATEX=TRUE
78 WARNINGS=yes
79 MINGWCROSS=FALSE
80 MINGWCROSS64=FALSE
81 MINGWMSYS=FALSE
82 MINGWMSYS64=FALSE
83 CONFHOST=
84 CONFBUILD=
85 MACCROSS=FALSE
86 JOBS_IF_PARALLEL=${JOBS_IF_PARALLEL:-3}
87 MAX_LOAD_IF_PARALLEL=${MAX_LOAD_IF_PARALLEL:-2}
89 CFLAGS="$CFLAGS"
90 CXXFLAGS="$CXXFLAGS"
92 until [ -z "$1" ]; do
93 case "$1" in
94 --make ) ONLY_MAKE=TRUE ;;
95 --nostrip ) STRIP_LUATEX=FALSE ;;
96 --debug ) STRIP_LUATEX=FALSE; WARNINGS=max ; CFLAGS="-g -O0 $CFLAGS" ; CXXFLAGS="-g -O0 $CXXFLAGS" ;;
97 --warnings=*) WARNINGS=`echo $1 | sed 's/--warnings=\(.*\)/\1/' ` ;;
98 --mingw ) MINGWCROSS=TRUE ;;
99 --mingw32 ) MINGWCROSS=TRUE ;;
100 --mingw64 ) MINGWCROSS64=TRUE ;;
101 --msys ) MINGWMSYS=TRUE ;;
102 --msys32 ) MINGWMSYS=TRUE ;;
103 --msys64 ) MINGWMSYS64=TRUE ;;
104 --host=* ) CONFHOST="$1" ;;
105 --build=* ) CONFBUILD="$1" ;;
106 --parallel ) MAKE="$MAKE -j $JOBS_IF_PARALLEL -l $MAX_LOAD_IF_PARALLEL" ;;
107 --arch=* ) MACCROSS=TRUE; ARCH=`echo $1 | sed 's/--arch=\(.*\)/\1/' ` ;;
108 * ) echo "ERROR: invalid build.sh parameter: $1"; exit 1 ;;
109 esac
110 shift
111 done
114 STRIP=strip
115 LUATEXEXE=luatex
117 case `uname` in
118 MINGW64* ) LUATEXEXE=luatex.exe ;;
119 MINGW32* ) LUATEXEXE=luatex.exe ;;
120 CYGWIN* ) LUATEXEXE=luatex.exe ;;
121 esac
123 WARNINGFLAGS=--enable-compiler-warnings=$WARNINGS
125 B=build
127 OLDPATH=$PATH
129 if [ "$MINGWCROSS" = "TRUE" ]
130 then
131 B=build-windows
132 PATH=`pwd`/extrabin/mingw:$PATH
133 LUATEXEXE=luatex.exe
134 CFLAGS="-mtune=nocona -g -O3 $CFLAGS"
135 CXXFLAGS="-mtune=nocona -g -O3 $CXXFLAGS"
136 CONFHOST="--host=i586-mingw32msvc"
137 CONFBUILD="--build=x86_64-unknown-linux-gnu"
138 STRIP="${CONFHOST#--host=}-strip"
139 LDFLAGS="-Wl,--large-address-aware $CFLAGS"
140 export CFLAGS CXXFLAGS LDFLAGS
143 if [ "$MINGWCROSS64" = "TRUE" ]
144 then
145 B=build-windows64
146 PATH=`pwd`/extrabin/mingw:$PATH
147 LUATEXEXE=luatex.exe
148 CFLAGS="-mtune=nocona -g -O3 -static-libgcc -static-libstdc++ $CFLAGS"
149 CXXFLAGS="-mtune=nocona -g -O3 $CXXFLAGS"
150 CONFHOST="--host=x86_64-w64-mingw32"
151 CONFBUILD="--build=x86_64-unknown-linux-gnu"
152 STRIP="${CONFHOST#--host=}-strip"
153 LDFLAGS="$CFLAGS"
154 export CFLAGS CXXFLAGS LDFLAGS
157 if [ "$MINGWMSYS" = "TRUE" ]
158 then
159 B=build-win32
160 PATH=`pwd`/extrabin/msys:$PATH
161 LUATEXEXE=luatex.exe
162 STRIP=strip.exe
163 CFLAGS="-mtune=nocona -m32 -g -O3 $CFLAGS"
164 CXXFLAGS="-mtune=nocona -m32 -g -O3 $CXXFLAGS"
165 CONFHOST="--host=i586-mingw32"
166 CONFBUILD="--build=x86_64-w64-mingw32"
167 LDFLAGS="-m32"
168 CPPFLAGS="-m32"
169 export CFLAGS CXXFLAGS LDFLAGS CPPFLAGS
172 if [ "$MINGWMSYS64" = "TRUE" ]
173 then
174 B=build-win64
175 PATH=`pwd`/extrabin/mingw:$PATH
176 LUATEXEXE=luatex.exe
177 STRIP=strip.exe
178 CFLAGS="-mtune=nocona -g -O3 $CFLAGS"
179 CXXFLAGS="-mtune=nocona -g -O3 $CXXFLAGS"
180 CONFHOST="--host=x86_64-w64-mingw32"
181 CONFBUILD="--build=x86_64-w64-mingw32"
182 LDFLAGS=""
183 CPPFLAGS=""
184 export CFLAGS CXXFLAGS LDFLAGS CPPFLAGS
187 if [ "$MACCROSS" = "TRUE" ]
188 then
189 # make sure that architecture parameter is valid
190 case $ARCH in
191 i386 | x86_64 | ppc | ppc64 ) ;;
192 * ) echo "ERROR: architecture $ARCH is not supported"; exit 1;;
193 esac
194 B=build-$ARCH
195 CFLAGS="-arch $ARCH -g -O2 $CFLAGS"
196 CXXFLAGS="-arch $ARCH -g -O2 $CXXFLAGS"
197 LDFLAGS="-arch $ARCH $LDFLAGS"
198 export CFLAGS CXXFLAGS LDFLAGS
201 if [ "$STRIP_LUATEX" = "FALSE" ]
202 then
203 export CFLAGS
204 export CXXFLAGS
207 # ----------
208 # clean up, if needed
209 if [ -r "$B"/Makefile -a $ONLY_MAKE = "FALSE" ]
210 then
211 rm -rf "$B"
212 elif [ ! -r "$B"/Makefile ]
213 then
214 ONLY_MAKE=FALSE
216 if [ ! -r "$B" ]
217 then
218 mkdir "$B"
221 # get a new svn version header
222 if [ "$WARNINGS" = "max" ]
223 then
224 rm -f source/texk/web2c/luatexdir/luatex_svnversion.h
226 ( cd source ; ./texk/web2c/luatexdir/getluatexsvnversion.sh )
228 cd "$B"
230 if [ "$ONLY_MAKE" = "FALSE" ]
231 then
232 TL_MAKE=$MAKE ../source/configure $CONFHOST $CONFBUILD $WARNINGFLAGS\
233 --enable-cxx-runtime-hack \
234 --enable-silent-rules \
235 --disable-all-pkgs \
236 --disable-shared \
237 --disable-largefile \
238 --disable-ptex \
239 --disable-ipc \
240 --disable-linked-scripts \
241 --enable-dump-share \
242 --enable-mp \
243 --enable-luatex \
244 --without-system-harfbuzz \
245 --without-system-ptexenc \
246 --without-system-kpathsea \
247 --without-system-poppler \
248 --without-system-xpdf \
249 --without-system-freetype \
250 --without-system-freetype2 \
251 --without-system-gd \
252 --without-system-libpng \
253 --without-system-teckit \
254 --without-system-zlib \
255 --without-system-t1lib \
256 --without-system-icu \
257 --without-system-graphite \
258 --without-system-zziplib \
259 --without-mf-x-toolkit --without-x \
260 || exit 1
263 $MAKE
265 # the fact that these makes inside libs/ have to be done manually for the cross
266 # compiler hints that something is wrong in the --enable/--disable switches above,
267 # but I am too lazy to look up what is wrong exactly.
268 # (perhaps more files needed to be copied from TL?)
270 (cd libs; $MAKE )
271 (cd libs/zziplib; $MAKE all )
272 (cd libs/zlib; $MAKE all )
273 (cd libs/libpng; $MAKE all )
274 (cd libs/poppler; $MAKE all )
276 (cd texk/kpathsea; $MAKE )
277 (cd texk; $MAKE )
278 (cd texk/web2c; $MAKE $LUATEXEXE )
280 # go back
281 cd ..
283 if [ "$STRIP_LUATEX" = "TRUE" ] ;
284 then
285 $STRIP "$B"/texk/web2c/$LUATEXEXE
286 else
287 echo "luatex binary not stripped"
290 PATH=$OLDPATH
292 # show the results
293 ls -l "$B"/texk/web2c/$LUATEXEXE