3 # Copyright (c) 2005-2011 Martin Schröder <martin@luatex.org>
4 # Copyright (c) 2009-2014 Taco Hoekwater <taco@luatex.org>
5 # Copyright (c) 2012-2014 Luigi Scarso <luigi@luatex.org>
7 # Permission to use, copy, modify, and distribute this software for any
8 # purpose with or without fee is hereby granted, provided that the above
9 # copyright notice and this permission notice appear in all copies.
11 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 # new script to build luatex binaries
22 # --jit : also build luajittex
23 # --make : only make, no make distclean; configure
24 # --parallel : make -j 8 -l 8.0
25 # --nostrip : do not strip binary
26 # --warnings= : enable compiler warnings
27 # --mingw : crosscompile for mingw32 from x86_64linux
28 # --mingw32 : crosscompile for mingw32 from x86_64linux
29 # --mingw64 : crosscompile for mingw64 from x86_64linux
30 # --host= : target system for mingw32 cross-compilation
31 # --build= : build system for mingw32 cross-compilation
32 # --arch= : crosscompile for ARCH on OS X
33 # --clang : use clang & clang++
34 # --debug : CFLAGS="-g -O0" --warnings=max --nostrip
35 # --debugopt : CFLAGS="-g -O3" --warnings=max --nostrip
37 #export CFLAGS="-D_FORTIFY_SOURCE=2 -O3"
38 #export CXXFLAGS="-D_FORTIFY_SOURCE=2 -O3"
40 # try to find bash, in case the standard shell is not capable of
41 # handling the generated configure's += variable assignments
42 if which bash
>/dev
/null
44 CONFIG_SHELL
=`which bash`
48 # try to find gnu make; we may need it
50 if make -v 2>&1|
grep "GNU Make" >/dev
/null
52 echo "Your make is a GNU-make; I will use that"
53 elif gmake
-v >/dev
/null
2>&1
57 echo "You have a GNU-make installed as gmake; I will use that"
59 echo "I can't find a GNU-make; I'll try to use make and hope that works."
60 echo "If it doesn't, please install GNU-make."
73 JOBS_IF_PARALLEL
=${JOBS_IF_PARALLEL:-8}
74 MAX_LOAD_IF_PARALLEL
=${MAX_LOAD_IF_PARALLEL:-8}
83 --jit ) BUILDJIT
=TRUE
;;
84 --nojit ) BUILDJIT
=FALSE
;;
85 --make ) ONLY_MAKE
=TRUE
;;
86 --nostrip ) STRIP_LUATEX
=FALSE
;;
87 --debugopt ) STRIP_LUATEX
=FALSE
; WARNINGS
=max
; CFLAGS
="-O3 -g -g3 $CFLAGS" ; CXXFLAGS
="-O3 -g -g3 $CXXFLAGS" ;;
88 --debug ) STRIP_LUATEX
=FALSE
; WARNINGS
=max
; CFLAGS
="-O0 -g -g3 $CFLAGS" ; CXXFLAGS
="-O0 -g -g3 $CXXFLAGS" ;;
89 --clang ) export CC
=clang
; export CXX
=clang
++ ; TARGET_CC
=$CC ; CLANG
=TRUE
;;
90 --warnings=*) WARNINGS
=`echo $1 | sed 's/--warnings=\(.*\)/\1/' ` ;;
91 --mingw ) MINGWCROSS
=TRUE
;;
92 --mingw32 ) MINGWCROSS
=TRUE
;;
93 --mingw64 ) MINGWCROSS64
=TRUE
;;
94 --host=* ) CONFHOST
="$1" ;;
95 --build=* ) CONFBUILD
="$1" ;;
96 --parallel ) MAKE
="$MAKE -j $JOBS_IF_PARALLEL -l $MAX_LOAD_IF_PARALLEL" ;;
97 --arch=* ) MACCROSS
=TRUE
; ARCH
=`echo $1 | sed 's/--arch=\(.*\)/\1/' ` ;;
98 * ) echo "ERROR: invalid build.sh parameter: $1"; exit 1 ;;
105 LUATEXEXEJIT
=luajittex
109 MINGW32
* ) LUATEXEXEJIT
=luajittex.exe
; LUATEXEXE
=luatex.exe
;;
110 CYGWIN
* ) LUATEXEXEJIT
=luajittex.exe
; LUATEXEXE
=luatex.exe
;;
111 Darwin
) STRIP
="strip -u -r" ;;
114 WARNINGFLAGS
=--enable-compiler-warnings=$WARNINGS
118 ## Useful for cross-compilation for ARM
119 if [ "x$CONFHOST" != "x" ]
122 B
=`printf "$B"| sed 's/--host=//'`
125 if [ "$CLANG" = "TRUE" ]
130 if [ "$MINGWCROSS64" = "TRUE" ]
133 LUATEXEXEJIT
=luajittex.exe
136 PATH
=/usr
/mingw32
/bin
:$PATH
137 PATH
=`pwd`/extrabin
/mingw
:$PATH
138 CFLAGS
="-mtune=nocona -g -O3 -fno-lto -fno-use-linker-plugin $CFLAGS"
139 CXXFLAGS
="-mtune=nocona -g -O3 -fno-lto -fno-use-linker-plugin $CXXFLAGS"
140 : ${CONFHOST:=--host=x86_64-w64-mingw32}
141 : ${CONFBUILD:=--build=x86_64-unknown-linux-gnu}
142 RANLIB
="${CONFHOST#--host=}-ranlib"
143 STRIP
="${CONFHOST#--host=}-strip"
144 LDFLAGS
="${LDFLAGS} -fno-lto -fno-use-linker-plugin -static-libgcc -static-libstdc++"
145 export CFLAGS CXXFLAGS LDFLAGS
148 if [ "$MINGWCROSS" = "TRUE" ]
151 LUATEXEXEJIT
=luajittex.exe
154 PATH
=/usr
/mingw32
/bin
:$PATH
155 PATH
=`pwd`/extrabin
/mingw
:$PATH
156 CFLAGS
="-mtune=nocona -g -O3 $CFLAGS"
157 CXXFLAGS
="-mtune=nocona -g -O3 $CXXFLAGS"
158 : ${CONFHOST:=--host=i586-mingw32msvc}
159 : ${CONFBUILD:=--build=x86_64-unknown-linux-gnu}
160 RANLIB
="${CONFHOST#--host=}-ranlib"
161 STRIP
="${CONFHOST#--host=}-strip"
162 LDFLAGS
="-Wl,--large-address-aware -Wl,--stack,2621440 $CFLAGS"
163 export CFLAGS CXXFLAGS LDFLAGS BUILDCXX BUILDCC
167 if [ "$MACCROSS" = "TRUE" ]
169 # make sure that architecture parameter is valid
171 i386 | x86_64 | ppc | ppc64
) ;;
172 * ) echo "ERROR: architecture $ARCH is not supported"; exit 1;;
175 if [ "x$CONFHOST" != "x" ]
178 B
=`printf "$B"| sed 's/--host=//'`
180 CFLAGS
="-arch $ARCH -g -O2 $CFLAGS"
181 CXXFLAGS
="-arch $ARCH -g -O2 $CXXFLAGS"
182 LDFLAGS
="-arch $ARCH $LDFLAGS"
183 STRIP
="${CONFHOST#--host=}-strip -u -r -A -n"
184 export CFLAGS CXXFLAGS LDFLAGS
188 ### Dirty trick to check Darwin X86_64
189 # TARGET_TESTARCH=$( ($TARGET_CC $TARGET_TCFLAGS -E source/libs/luajit/luajit-2.0.2/src/lj_arch.h -dM|grep -q LJ_TARGET_X64 && echo x64) || echo NO)
190 # HOST_SYS=$(uname -s)
191 # echo HOST_SYS=$HOST_SYS
192 # echo TARGET_TESTARCH=$TARGET_TESTARCH
193 # if [ $HOST_SYS == "Darwin" ]
195 # if [ $TARGET_TESTARCH == "x64" ]
197 # export LDFLAGS="-pagezero_size 10000 -image_base 100000000 $LDFLAGS"
198 # echo Setting LDFLAGS=$LDFLAGS
203 if [ "$STRIP_LUATEX" = "FALSE" ]
210 # clean up, if needed
211 if [ -r "$B"/Makefile
-a $ONLY_MAKE = "FALSE" ]
214 elif [ ! -r "$B"/Makefile
]
223 # get a new svn version header
224 if [ "$WARNINGS" = "max" ]
226 rm -f source
/texk
/web2c
/luatexdir
/luatex_svnversion.h
228 ( cd source ; .
/texk
/web2c
/luatexdir
/getluatexsvnversion.sh
)
233 if [ "$BUILDJIT" = "TRUE" ]
235 JITENABLE
="--enable-luajittex --without-system-luajit "
241 if [ "$ONLY_MAKE" = "FALSE" ]
243 TL_MAKE
=$MAKE ..
/source
/configure
$CONFHOST $CONFBUILD $WARNINGFLAGS\
244 --enable-cxx-runtime-hack \
245 --enable-silent-rules \
249 --disable-largefile \
251 --enable-dump-share \
253 --enable-luatex $JITENABLE \
254 --without-system-ptexenc \
255 --without-system-kpathsea \
256 --without-system-poppler \
257 --without-system-xpdf \
258 --without-system-freetype \
259 --without-system-freetype2 \
260 --without-system-gd \
261 --without-system-libpng \
262 --without-system-teckit \
263 --without-system-zlib \
264 --without-system-t1lib \
265 --without-system-icu \
266 --without-system-graphite \
267 --without-system-zziplib \
268 --without-mf-x-toolkit --without-x \
274 # the fact that these makes inside libs/ have to be done manually for the cross
275 # compiler hints that something is wrong in the --enable/--disable switches above,
276 # but I am too lazy to look up what is wrong exactly.
277 # (perhaps more files needed to be copied from TL?)
279 (cd libs
; $MAKE all
)
280 (cd libs
/zziplib
; $MAKE all
)
281 (cd libs
/zlib
; $MAKE all
)
282 (cd libs
/libpng
; $MAKE all
)
283 (cd libs
/poppler
; $MAKE all
)
284 (cd texk
; $MAKE web2c
/Makefile
)
285 (cd texk
/kpathsea
; $MAKE )
286 if [ "$BUILDJIT" = "TRUE" ]
288 (cd libs
/luajit
; $MAKE all
)
289 (cd texk
/web2c
; $MAKE $LUATEXEXEJIT)
291 (cd texk
/web2c
; $MAKE $LUATEXEXE )
297 if [ "$STRIP_LUATEX" = "TRUE" ] ;
299 if [ "$BUILDJIT" = "TRUE" ]
301 $STRIP "$B"/texk
/web2c
/$LUATEXEXEJIT
303 $STRIP "$B"/texk
/web2c
/$LUATEXEXE
305 echo "lua(jit)tex binary not stripped"
308 if [ "$MINGWCROSS" = "TRUE" ]
314 if [ "$BUILDJIT" = "TRUE" ]
316 ls -l "$B"/texk
/web2c
/$LUATEXEXEJIT
318 ls -l "$B"/texk
/web2c
/$LUATEXEXE