-
Notifications
You must be signed in to change notification settings - Fork 3
/
build-shared.sh
executable file
·461 lines (406 loc) · 12 KB
/
build-shared.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
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
#!/usr/bin/env bash
# $Id: build.sh 4999 2014-05-06 08:52:33Z taco $
#
# Copyright (c) 2005-2011 Martin Schröder <[email protected]>
# Copyright (c) 2009-2014 Taco Hoekwater <[email protected]>
# Copyright (c) 2012-2014 Luigi Scarso <[email protected]>
#
# 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
# --make : only make, no make distclean; configure
# --parallel : make -j 2 -l 3.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 : crosscompile for mingw32 from x86_64linux
# --mingw32 : crosscompile for mingw32 from x86_64linux
# --mingw64 : crosscompile for mingw64 from x86_64linux
# --shared : enable shared build (currently mingw only)
# --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
$DEBUG
# 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
MINGWCROSS=FALSE
MINGWCROSS64=FALSE
MACCROSS=FALSE
CLANG=FALSE
ENABLESHARED=TRUE
CONFHOST=
CONFBUILD=
JOBS_IF_PARALLEL=${JOBS_IF_PARALLEL:-3}
MAX_LOAD_IF_PARALLEL=${MAX_LOAD_IF_PARALLEL:-2}
STRIPBIN=
TARGET_CC=gcc
TARGET_TCFLAGS=
CFLAGS="$CFLAGS"
CXXFLAGS="$CXXFLAGS"
until [ -z "$1" ]; do
case "$1" in
--jit ) BUILDJIT=TRUE ;;
--jithb ) BUILDJITHB=TRUE ;;
--luahb ) BUILDLUAHB=TRUE ;;
--lua53 ) BUILDLUA53=TRUE ;;
--nojit ) BUILDJIT=FALSE ;;
--make ) ONLY_MAKE=TRUE ;;
--nostrip ) STRIP_LUATEX=FALSE ;;
--debug ) STRIP_LUATEX=FALSE; WARNINGS=max ; CFLAGS="-g -O0 -ggdb3 $CFLAGS" ; CXXFLAGS="-g -O0 -ggdb3 $CXXFLAGS" ;;
--clang ) export CC=clang; export CXX=clang++ ; TARGET_CC=$CC ; CLANG=TRUE ;;
--warnings=*) WARNINGS=`echo $1 | sed 's/--warnings=\(.*\)/\1/' ` ;;
--mingw ) MINGWCROSS=TRUE ;;
--mingw32 ) MINGWCROSS=TRUE ;;
--mingw64 ) MINGWCROSS64=TRUE ;;
--shared ) ENABLESHARED=TRUE ;;
--host=* ) CONFHOST="$1" ;;
--build=* ) CONFBUILD="$1" ;;
--parallel ) MAKE="$MAKE -j $JOBS_IF_PARALLEL -l $MAX_LOAD_IF_PARALLEL" ;;
--stripbin=*) STRIPBIN="$1" ;;
--arch=* ) MACCROSS=TRUE; ARCH=`echo $1 | sed 's/--arch=\(.*\)/\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
MINGW64* ) MINGW=TRUE ; LUATEXEXEJIT=luajittex.exe ; LUATEXEXE=luatex.exe ; LUATEXEXE53=luatex.exe ; LUAHBTEXEXEJIT=luajithbtex.exe ; LUAHBTEXEXE=luahbtex.exe ;;
MINGW32* ) MINGW=TRUE ; LUATEXEXEJIT=luajittex.exe ; LUATEXEXE=luatex.exe ; LUATEXEXE53=luatex.exe ; LUAHBTEXEXEJIT=luajithbtex.exe ; LUAHBTEXEXE=luahbtex.exe ;;
CYGWIN* ) LUATEXEXEJIT=luajittex.exe ; LUATEXEXE=luatex.exe ; LUATEXEXE53=luatex.exe ; LUAHBTEXEXEJIT=luajithbtex.exe ; LUAHBTEXEXE=luahbtex.exe ;;
esac
WARNINGFLAGS=--enable-compiler-warnings=$WARNINGS
B=build
if [ "$CLANG" = "TRUE" ]
then
B=build-clang
fi
OLDPATH=$PATH
if [ "$MINGWCROSS64" = "TRUE" ]
then
B=build-windows64
LUATEXEXEJIT=luajittex.exe
LUATEXEXE=luatex.exe
LUATEXEXE53=luatex.exe
LUAHBTEXEXEJIT=luajithbtex.exe
LUAHBTEXEXE=luahbtex.exe
PATH=/usr/mingw32/bin:$PATH
PATH=`pwd`/extrabin/mingw/x86_64-linux:$PATH
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"
: ${CONFHOST:=--host=x86_64-w64-mingw32}
: ${CONFBUILD:=--build=x86_64-unknown-linux-gnu}
RANLIB="${CONFHOST#--host=}-ranlib"
STRIP="${CONFHOST#--host=}-strip"
LDFLAGS="${LDFLAGS} -fno-lto -fno-use-linker-plugin -static-libgcc -static-libstdc++"
export CFLAGS CXXFLAGS LDFLAGS
fi
if [ "$MINGWCROSS" = "TRUE" ]
then
B=build-windows
LUATEXEXEJIT=luajittex.exe
LUATEXEXE=luatex.exe
LUATEXEXE53=luatex.exe
LUAHBTEXEXEJIT=luajithbtex.exe
LUAHBTEXEXE=luahbtex.exe
PATH=/usr/mingw32/bin:$PATH
PATH=`pwd`/extrabin/mingw/x86_64-linux:$PATH
CFLAGS="-Wno-unknown-pragmas -m32 -mtune=nocona -g -O3 $CFLAGS"
CXXFLAGS="-Wno-unknown-pragmas -m32 -mtune=nocona -g -O3 $CXXFLAGS"
: ${CONFHOST:=--host=i686-w64-mingw32}
: ${CONFBUILD:=--build=x86_64-unknown-linux-gnu}
RANLIB="${CONFHOST#--host=}-ranlib"
STRIP="${CONFHOST#--host=}-strip"
LDFLAGS="-Wl,--large-address-aware -Wl,--stack,2621440 -static-libgcc -static-libstdc++ $CFLAGS"
export CFLAGS CXXFLAGS LDFLAGS BUILDCXX BUILDCC
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
CFLAGS="-arch $ARCH -g -O2 $CFLAGS"
CXXFLAGS="-arch $ARCH -g -O2 $CXXFLAGS"
LDFLAGS="-arch $ARCH $LDFLAGS"
export CFLAGS CXXFLAGS LDFLAGS
fi
if [ "x$STRIPBIN" != "x" ]
then
STRIP="${STRIPBIN#--stripbin=}"
fi
if [ "$STRIP_LUATEX" = "FALSE" ]
then
export CFLAGS
export CXXFLAGS
fi
# ----------
# clean up, if needed
SHAREDENABLE="--disable-shared "
if [ "$ENABLESHARED" = "TRUE" ]
then
SHAREDENABLE="--enable-shared --disable-native-texlive-build --disable-static"
if [ ! -r "$B-shared" ]
then
mkdir "$B-shared"
fi
B="$B-shared"
fi
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
JITENABLE="--enable-luajittex=no --enable-mfluajit=no"
if [ "$BUILDJIT" = "TRUE" ]
then
JITENABLE="--enable-luajittex --without-system-luajit "
fi
BUILDLUA53=TRUE
LUA53ENABLE="--enable-luatex"
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 $CONFHOST $CONFBUILD $WARNINGFLAGS\
--enable-cxx-runtime-hack \
--enable-silent-rules \
--disable-all-pkgs \
$SHAREDENABLE \
--disable-largefile \
--disable-xetex \
--disable-ptex \
--disable-ipc \
--disable-native-texlive-build \
--disable-dump-share \
--disable-web-progs \
--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-potrace \
--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/zlib; $MAKE all )
(cd libs/pplib; $MAKE all )
(cd libs/libpng; $MAKE all )
(cd texk; $MAKE web2c/Makefile)
(cd texk/kpathsea; $MAKE )
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 [ "$MINGWCROSS" = "TRUE" ] || [ "$MINGWCROSS64" = "TRUE" ] || [ "$MINGW" = "TRUE" ]
then
PATH=$OLDPATH
if [ "$ENABLESHARED" = "TRUE" ]
then
K=$(find "$B/texk/kpathsea" -name "libkpathsea*dll")
L1=$(find "$B/libs" -name "texluajit.dll")
L3=$(find "$B/libs" -name "texlua.dll")
if [ "$STRIP_LUATEX" = "TRUE" ]
then
$STRIP "$K"
if [ "$BUILDJIT" = "TRUE" ]
then
$STRIP "$B/texk/web2c/.libs/$LUATEXEXEJIT" "$L1"
fi
if [ "$BUILDJITHB" = "TRUE" ]
then
$STRIP "$B/texk/web2c/.libs/$LUAHBTEXEXEJIT" "$L1"
fi
if [ "$BUILDLUA53" = "TRUE" ]
then
$STRIP "$B/texk/web2c/.libs/$LUATEXEXE53" "$L3"
fi
if [ "$BUILDLUAHB" = "TRUE" ]
then
$STRIP "$B/texk/web2c/.libs/$LUAHBTEXEXE" "$L3"
fi
fi
cp "$K" "$B"
if [ "$BUILDJIT" = "TRUE" ]
then
cp "$B/texk/web2c/.libs/$LUATEXEXEJIT" "$B"
cp "$L1" "$B"
fi
if [ "$BUILDJITHB" = "TRUE" ]
then
cp "$B/texk/web2c/.libs/$LUAHBTEXEXEJIT" "$B"
cp "$L1" "$B"
fi
if [ "$BUILDLUA53" = "TRUE" ]
then
cp "$B/texk/web2c/.libs/$LUATEXEXE53" "$B"
cp "$L3" "$B"
fi
if [ "$BUILDLUAHB" = "TRUE" ]
then
cp "$B/texk/web2c/.libs/$LUAHBTEXEXE" "$B"
cp "$L3" "$B"
fi
fi
fi
# show the result
if [ -e "$B/$LUATEXEXEJIT" ]
then
ls -l "$B/$LUATEXEXEJIT"
fi
if [ -e "$B/$LUAHBTEXEXEJIT" ]
then
ls -l "$B/$LUAHBTEXEXEJIT"
fi
if [ -e "$B/$LUATEXEXE" ]
then
ls -l "$B/$LUATEXEXE"
fi
if [ -e "$B/$LUAHBTEXEXE" ]
then
ls -l "$B/$LUAHBTEXEXE"
fi