This repository has been archived by the owner on Mar 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.sh
executable file
·447 lines (390 loc) · 11.6 KB
/
build.sh
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
#!/usr/bin/env bash
#
# Copyright (c) 2005-2011 Martin Schröder <martin@luatex.org>
# Copyright (c) 2009-2014 Taco Hoekwater <taco@luatex.org>
# Copyright (c) 2012-2014 Luigi Scarso <luigi@luatex.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# new script to build luatex binaries
# ----------
# Options:
# --jit : also build luajittex
# --nojit : don't build luajit
# --buildtag= : build directory <- 'build'-<tag>
# --make : only make, no make distclean; configure
# --parallel : make -j 8 -l 8.0
# --nostrip : do not strip binary
# --warnings= : enable compiler warnings
# --lua53 : build luatex with luatex 53
# --nolua53 : don't build luatex with luatex 53
# --mingw[32] : crosscompile for mingw32
# --mingw64 : crosscompile for mingw64
# --host= : target system for mingw32 cross-compilation
# --build= : build system for mingw32 cross-compilation
# --arch= : crosscompile for ARCH on OS X
# --clang : use clang & clang++
# --debug : CFLAGS="-g -O0" --warnings=max --nostrip
# --debugopt : CFLAGS="-g -O3" --warnings=max --nostrip
# --musl : use musl libc (EXPERIMENTAL)
# --stripbin : strip program to use (default strip)
# --tlopt : option to pass to TeXLive configure
$DEBUG
#export CFLAGS="-D_FORTIFY_SOURCE=2 -O3"
#export CXXFLAGS="-D_FORTIFY_SOURCE=2 -O3"
# try to find bash, in case the standard shell is not capable of
# handling the generated configure's += variable assignments
if which bash >/dev/null
then
CONFIG_SHELL=`which bash`
export CONFIG_SHELL
fi
# try to find gnu make; we may need it
MAKE="make V=1"
if make -v 2>&1| grep "GNU Make" >/dev/null
then
echo "Your make is a GNU-make; I will use that"
elif gmake -v >/dev/null 2>&1
then
MAKE=gmake;
export MAKE;
echo "You have a GNU-make installed as gmake; I will use that"
else
echo "I can't find a GNU-make; I'll try to use make and hope that works."
echo "If it doesn't, please install GNU-make."
fi
BUILDJIT=FALSE
BUILDLUA53=TRUE
BUILDLUAHB=FALSE
BUILDJITHB=FALSE
BUILDTAG=
ONLY_MAKE=FALSE
STRIP_LUATEX=TRUE
WARNINGS=yes
MINGW=FALSE
MINGWCROSS32=FALSE
MINGWCROSS64=FALSE
MACCROSS=FALSE
CLANG=FALSE
CONFHOST=
CONFBUILD=
JOBS_IF_PARALLEL=${JOBS_IF_PARALLEL:-8}
MAX_LOAD_IF_PARALLEL=${MAX_LOAD_IF_PARALLEL:-8}
TARGET_CC=gcc
TARGET_TCFLAGS=
STRIPBIN=
USEMUSL=FALSE
TEXLIVEOPT=
CFLAGS="$CFLAGS"
CXXFLAGS="$CXXFLAGS"
until [ -z "$1" ]; do
case "$1" in
--arch=* ) MACCROSS=TRUE; ARCH=`echo $1 | sed 's/--arch=\(.*\)/\1/' ` ;;
--build=* ) CONFBUILD="$1" ;;
--buildtag=* ) BUILDTAG="$1" ;;
--clang ) export CC=clang; export CXX=clang++ ; TARGET_CC=$CC ; CLANG=TRUE ;;
--debug ) STRIP_LUATEX=FALSE; WARNINGS=max ; CFLAGS="-O0 -g -ggdb3 $CFLAGS" ; CXXFLAGS="-O0 -g -ggdb3 $CXXFLAGS" ;;
--debugopt ) STRIP_LUATEX=FALSE; WARNINGS=max ; CFLAGS="-O3 -g -ggdb3 $CFLAGS" ; CXXFLAGS="-O3 -g -ggdb3 $CXXFLAGS" ;;
--host=* ) CONFHOST="$1" ;;
--jit ) BUILDJIT=TRUE ;;
--jithb ) BUILDJITHB=TRUE ;;
--lua53 ) BUILDLUA53=TRUE ;;
--luahb ) BUILDLUAHB=TRUE ;;
--make ) ONLY_MAKE=TRUE ;;
--mingw|--mingw32 ) MINGWCROSS32=TRUE ;;
--mingw64 ) MINGWCROSS64=TRUE ;;
--musl ) USEMUSL=TRUE ;;
--nojit ) BUILDJIT=FALSE ;;
--nojithb ) BUILDJITHB=FALSE ;;
--nolua53 ) BUILDLUA53=FALSE ;;
--noluahb ) BUILDLUAHB=FALSE ;;
--nostrip ) STRIP_LUATEX=FALSE ;;
--parallel ) MAKE="$MAKE -j $JOBS_IF_PARALLEL -l $MAX_LOAD_IF_PARALLEL" ;;
--stripbin=* ) STRIPBIN="$1" ;;
--tlopt=* ) TEXLIVEOPT=`echo $1 | sed 's/--tlopt=\(.*\)/\1/' ` ;;
--warnings=* ) WARNINGS=`echo $1 | sed 's/--warnings=\(.*\)/\1/' ` ;;
* ) echo "ERROR: invalid build.sh parameter: $1"; exit 1 ;;
esac
shift
done
#
STRIP=strip
LUATEXEXEJIT=luajittex
LUATEXEXE=luatex
LUATEXEXE53=luatex
LUAHBTEXEXE=luahbtex
LUAHBTEXEXEJIT=luajithbtex
case `uname` in
CYGWIN* ) LUATEXEXEJIT=luajittex.exe ; LUATEXEXE=luatex.exe ; LUATEXEXE53=luatex.exe ; LUAHBTEXEXEJIT=luajithbtex.exe ; LUAHBTEXEXE=luahbtex.exe ;;
MINGW* ) LUATEXEXEJIT=luajittex.exe ; LUATEXEXE=luatex.exe ; LUATEXEXE53=luatex.exe ; LUAHBTEXEXEJIT=luajithbtex.exe ; LUAHBTEXEXE=luahbtex.exe ;;
Darwin ) STRIP="strip -u -r" ;;
esac
WARNINGFLAGS=--enable-compiler-warnings=$WARNINGS
B=build
if [ "x$CONFHOST" != "x" ]
then
B="build-$CONFHOST"
B=`printf "$B"| sed 's/--host=//'`
fi
if [ "$CLANG" = "TRUE" ]
then
B="$B-clang"
fi
if [ "x$BUILDTAG" != "x" ]
then
B="${BUILDTAG#--buildtag=}"
fi
OLDPATH=$PATH
if [ "$MINGWCROSS32" = "TRUE" ]
then
B=build-windows32
: ${CONFHOST:=--host=i686-w64-mingw32}
CFLAGS="-Wno-unknown-pragmas -mtune=nocona -g -O3 $CFLAGS"
CXXFLAGS="-Wno-unknown-pragmas -mtune=nocona -g -O3 $CXXFLAGS"
LDFLAGS="-Wl,--large-address-aware -Wl,--stack,2621440 $CFLAGS"
export CFLAGS CXXFLAGS LDFLAGS
fi
if [ "$MINGWCROSS64" = "TRUE" ]
then
B=build-windows64
: ${CONFHOST:=--host=x86_64-w64-mingw32}
CFLAGS="-Wno-unknown-pragmas -mtune=nocona -g -O3 -fno-lto -fno-use-linker-plugin $CFLAGS"
CXXFLAGS="-Wno-unknown-pragmas -mtune=nocona -g -O3 -fno-lto -fno-use-linker-plugin $CXXFLAGS"
LDFLAGS="${LDFLAGS} -fno-lto -fno-use-linker-plugin -static-libgcc -static-libstdc++"
export CFLAGS CXXFLAGS LDFLAGS
fi
if [ "$MINGWCROSS32" = "TRUE" ] || [ "$MINGWCROSS64" = "TRUE" ]
then
case `uname -s` in
Linux) platform="x86_64-linux"; build_tripple="x86_64-unknown-linux-gnu" ;;
Darwin) platform="x86_64-darwin"; build_tripple="x86_64-apple-darwin" ;;
esac
: ${CONFBUILD:=--build=$build_tripple}
PATH=`pwd`/extrabin/mingw/$platform:/usr/mingw32/bin:$PATH
LUATEXEXEJIT=luajittex.exe
LUATEXEXE=luatex.exe
LUATEXEXE53=luatex.exe
LUAHBTEXEXEJIT=luajithbtex.exe
LUAHBTEXEXE=luahbtex.exe
RANLIB="${CONFHOST#--host=}-ranlib"
STRIP="${CONFHOST#--host=}-strip"
fi
if [ "$MACCROSS" = "TRUE" ]
then
# make sure that architecture parameter is valid
case $ARCH in
i386 | x86_64 | ppc | ppc64 ) ;;
* ) echo "ERROR: architecture $ARCH is not supported"; exit 1;;
esac
B=build-$ARCH
if [ "x$CONFHOST" != "x" ]
then
B="build-$CONFHOST"
B=`printf "$B"| sed 's/--host=//'`
fi
CFLAGS="-arch $ARCH -g -O2 $CFLAGS"
CXXFLAGS="-arch $ARCH -g -O2 $CXXFLAGS"
LDFLAGS="-arch $ARCH $LDFLAGS"
STRIP="${CONFHOST#--host=}-strip -u -r -A -n"
#STRIP="${CONFHOST#--host=}-strip"
export CFLAGS CXXFLAGS LDFLAGS
fi
if [ "$USEMUSL" = "TRUE" ]
then
TARGET_CC=musl-gcc
CC=musl-gcc
B="$B-musl"
LIBS="$LIBS -ldl"
export LIBS
fi
### Dirty trick to check Darwin X86_64
# 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)
# HOST_SYS=$(uname -s)
# echo HOST_SYS=$HOST_SYS
# echo TARGET_TESTARCH=$TARGET_TESTARCH
# if [ $HOST_SYS == "Darwin" ]
# then
# if [ $TARGET_TESTARCH == "x64" ]
# then
# export LDFLAGS="-pagezero_size 10000 -image_base 100000000 $LDFLAGS"
# echo Setting LDFLAGS=$LDFLAGS
# fi
# fi
if [ "x$STRIPBIN" != "x" ]
then
STRIP="${STRIPBIN#--stripbin=}"
fi
if [ "$STRIP_LUATEX" = "FALSE" ]
then
export CFLAGS
export CXXFLAGS
fi
# ----------
# clean up, if needed
if [ -r "$B"/Makefile -a $ONLY_MAKE = "FALSE" ]
then
rm -rf "$B"
elif [ ! -r "$B"/Makefile ]
then
ONLY_MAKE=FALSE
fi
if [ ! -r "$B" ]
then
mkdir "$B"
fi
#
# get a new svn version header
#if [ "$WARNINGS" = "max" ]
#then
# rm -f source/texk/web2c/luatexdir/luatex_svnversion.h
#fi
#( cd source ; ./texk/web2c/luatexdir/getluatexsvnversion.sh )
cd "$B"
JITENABLE="--enable-luajittex=no "
if [ "$BUILDJIT" = "TRUE" ]
then
JITENABLE="--enable-luajittex --without-system-luajit "
fi
JITHBENABLE="--enable-luajithbtex=no "
if [ "$BUILDJITHB" = "TRUE" ]
then
JITHBENABLE="--enable-luajithbtex --without-system-luajit "
fi
if [ "$BUILDJIT" = "FALSE" ] && [ "$BUILDJITHB" = "FALSE" ]
then
JITENABLE="$JITENABLE --enable-mfluajit=no "
JITHBENABLE="$JITHBENABLE --enable-mfluajit=no "
fi
LUA53ENABLE=--enable-luatex
if [ "$BUILDLUA53" = "FALSE" ]
then
LUAHBENABLE="--enable-luahbtex=no "
fi
LUAHBENABLE=--enable-luahbtex=no
if [ "$BUILDLUAHB" = "TRUE" ]
then
LUAHBENABLE="--enable-luahbtex"
fi
if [ "$ONLY_MAKE" = "FALSE" ]
then
TL_MAKE=$MAKE ../source/configure $TEXLIVEOPT $CONFHOST $CONFBUILD $WARNINGFLAGS\
--enable-silent-rules \
--disable-all-pkgs \
--disable-shared \
--disable-ptex \
--disable-largefile \
--disable-xetex \
--disable-ipc \
--disable-dump-share \
--disable-native-texlive-build \
--enable-coremp \
--enable-web2c \
$LUA53ENABLE $JITENABLE $LUAHBENABLE $JITHBENABLE \
--without-system-cairo \
--without-system-pixman \
--without-system-ptexenc \
--without-system-kpathsea \
--without-system-xpdf \
--without-system-freetype \
--without-system-freetype2 \
--without-system-gd \
--without-system-libpng \
--without-system-pplib \
--without-system-poppler \
--without-system-gmp \
--without-system-mpfr \
--without-system-teckit \
--without-system-zlib \
--without-system-t1lib \
--without-system-icu \
--without-system-harfbuzz \
--without-system-graphite \
--without-system-zziplib \
--without-mf-x-toolkit --without-x \
|| exit 1
fi
$MAKE
# the fact that these makes inside libs/ have to be done manually for the cross
# compiler hints that something is wrong in the --enable/--disable switches above,
# but I am too lazy to look up what is wrong exactly.
# (perhaps more files needed to be copied from TL?)
(cd libs; $MAKE all )
(cd libs/zziplib; $MAKE all )
(cd libs/harfbuzz; $MAKE all )
(cd libs/zlib; $MAKE all )
(cd libs/pplib; $MAKE all )
(cd libs/libpng; $MAKE all )
(cd texk; $MAKE all )
(cd texk/kpathsea; $MAKE all )
if [ "$BUILDJIT" = "TRUE" ]
then
(cd libs/luajit; $MAKE all )
(cd texk/web2c; $MAKE $LUATEXEXEJIT )
fi
if [ "$BUILDJITHB" = "TRUE" ]
then
(cd libs/luajit; $MAKE all)
(cd texk/web2c; $MAKE $LUAHBTEXEXEJIT )
fi
if [ "$BUILDLUA53" = "TRUE" ]
then
(cd texk/web2c; $MAKE $LUATEXEXE53 )
fi
if [ "$BUILDLUAHB" = "TRUE" ]
then
(cd texk/web2c; $MAKE $LUAHBTEXEXE )
fi
# go back
cd ..
if [ "$STRIP_LUATEX" = "TRUE" ] ;
then
if [ "$BUILDJIT" = "TRUE" ]
then
$STRIP "$B"/texk/web2c/$LUATEXEXEJIT
fi
if [ "$BUILDLUA53" = "TRUE" ]
then
$STRIP "$B"/texk/web2c/$LUATEXEXE53
fi
if [ "$BUILDLUAHB" = "TRUE" ]
then
$STRIP "$B"/texk/web2c/$LUAHBTEXEXE
fi
if [ "$BUILDJITHB" = "TRUE" ]
then
$STRIP "$B"/texk/web2c/$LUAHBTEXEXEJIT
fi
else
echo "lua(jit)tex binary not stripped"
fi
if [ "$MINGWCROSS32" = "TRUE" ] || [ "$MINGWCROSS64" = "TRUE" ]
then
PATH=$OLDPATH
fi
# show the result
if [ "$BUILDLUA53" = "TRUE" ]
then
ls -l "$B"/texk/web2c/$LUATEXEXE
fi
if [ "$BUILDLUAHB" = "TRUE" ]
then
ls -l "$B"/texk/web2c/$LUAHBTEXEXE
fi
if [ "$BUILDJIT" = "TRUE" ]
then
ls -l "$B"/texk/web2c/$LUATEXEXEJIT
fi
if [ "$BUILDJITHB" = "TRUE" ]
then
ls -l "$B"/texk/web2c/$LUAHBTEXEXEJIT
fi