-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·540 lines (498 loc) · 13.4 KB
/
configure
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
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
#!/bin/sh
set -e
[ -z "$CC" ] && CC=cc
[ -z "$HOSTCC" ] && HOSTCC="$CC"
CFLAGS="$CFLAGS -std=c99 -Wall -D_FORTIFY_SOURCE=2 -D_XOPEN_SOURCE=700"
CFLAGS="$CFLAGS -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-builtin-declaration-mismatch -Wno-clobbered"
LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
if [ -z "$DEBUG" ]; then
CFLAGS="$CFLAGS -Os -s -DNDEBUG"
LDFLAGS="$LDFLAGS -s"
else
CFLAGS="$CFLAGS -O0 -g"
LDFLAGS="$LDFLAGS -g"
fi
tmpc=/tmp/tmp$$.c
cat > $tmpc <<EOF
#include <netdb.h>
int main () { gethostbyname("localhost"); return 0; }
EOF
if ! $HOSTCC -Wl,--fatal-warnings -static $tmpc -o $tmpc.out 2>&1; then
rm -f $tmpc
echo "warning: your libc does not properly support static linking, trying musl instead..." >&2
CFLAGS="$CFLAGS -nostdinc"
HOSTCC="$PWD/sysroot/bin/musl-gcc"
if [ ! -x "$HOSTCC" ]; then
echo "Run scripts/make-sysroot.sh to install a local copy of musl, or set HOSTCC to the path of musl-gcc"
exit 1
fi
fi
rm -f $tmpc $tmpc.out
cd lib/tcc
./configure --prefix=/ --config-ldl=no --config-bcheck=no --config-backtrace=no \
--ar=ar --cc="$HOSTCC" --extra-cflags="$CFLAGS -DCONFIG_TCC_STATIC" --extra-ldflags="$LDFLAGS"
cd ../..
cat > config.mak <<EOF
CC = $HOSTCC
CFLAGS = $CFLAGS
LDFLAGS = $LDFLAGS
EOF
cat config.mak
export HOSTCC CC=$HOSTCC CFLAGS LDFLAGS
cd lib/toybox
cp -f ../../config.mak .config.mak
cat > .config <<EOF
# CONFIG_TOYBOX_ON_ANDROID is not set
CONFIG_TOYBOX_FORK=y
#
# Posix commands
#
CONFIG_BASENAME=y
# CONFIG_CAL is not set
CONFIG_CAT=y
CONFIG_CHGRP=y
CONFIG_CHOWN=y
CONFIG_CHMOD=y
CONFIG_CKSUM=y
CONFIG_CRC32=y
CONFIG_CMP=y
CONFIG_COMM=y
CONFIG_CP=y
CONFIG_MV=y
CONFIG_INSTALL=y
# CONFIG_CPIO is not set
CONFIG_CUT=y
CONFIG_DATE=y
CONFIG_DD=y
# CONFIG_DF is not set
CONFIG_DIRNAME=y
CONFIG_DU=y
# CONFIG_ECHO is not set
CONFIG_ENV=y
CONFIG_EXPAND=y
# CONFIG_FALSE is not set
CONFIG_FILE=y
CONFIG_FIND=y
CONFIG_FOLD=y
CONFIG_GETCONF=y
CONFIG_GREP=y
CONFIG_EGREP=y
CONFIG_FGREP=y
CONFIG_HEAD=y
# CONFIG_ICONV is not set
CONFIG_ID=y
# CONFIG_ID_Z is not set
CONFIG_GROUPS=y
CONFIG_LOGNAME=y
CONFIG_WHOAMI=y
# CONFIG_KILL is not set
# CONFIG_KILLALL5 is not set
CONFIG_LINK=y
CONFIG_LN=y
# CONFIG_LOGGER is not set
CONFIG_LS=y
CONFIG_MKDIR=y
# CONFIG_MKDIR_Z is not set
CONFIG_MKFIFO=y
# CONFIG_MKFIFO_Z is not set
CONFIG_NICE=y
CONFIG_NL=y
CONFIG_NOHUP=y
CONFIG_OD=y
CONFIG_PASTE=y
CONFIG_PATCH=y
# CONFIG_PRINTF is not set
# CONFIG_PS is not set
# CONFIG_TOP is not set
# CONFIG_IOTOP is not set
# CONFIG_PGREP is not set
# CONFIG_PKILL is not set
# CONFIG_PWD is not set
CONFIG_RENICE=y
CONFIG_RM=y
CONFIG_RMDIR=y
CONFIG_SED=y
CONFIG_SLEEP=y
CONFIG_SORT=y
CONFIG_SORT_FLOAT=y
# CONFIG_SPLIT is not set
CONFIG_STRINGS=y
CONFIG_TAIL=y
CONFIG_TAR=y
CONFIG_TEE=y
# CONFIG_TEST is not set
# CONFIG_TEST_GLUE is not set
CONFIG_TIME=y
CONFIG_TOUCH=y
# CONFIG_TRUE is not set
# CONFIG_TSORT is not set
CONFIG_TTY=y
# CONFIG_ULIMIT is not set
CONFIG_ARCH=y
CONFIG_UNAME=y
CONFIG_UNIQ=y
CONFIG_UNLINK=y
CONFIG_UUDECODE=y
CONFIG_UUENCODE=y
CONFIG_WC=y
CONFIG_WHO=y
CONFIG_XARGS=y
#
# Pending (unfinished) commands
#
# CONFIG_ARP is not set
# CONFIG_ARPING is not set
# CONFIG_AWK is not set
# CONFIG_BC is not set
# CONFIG_BOOTCHARTD is not set
# CONFIG_BRCTL is not set
# CONFIG_CHSH is not set
# CONFIG_CROND is not set
# CONFIG_CRONTAB is not set
# CONFIG_CSPLIT is not set
# CONFIG_DHCP is not set
# CONFIG_DHCP6 is not set
# CONFIG_DHCPD is not set
# CONFIG_DEBUG_DHCP is not set
CONFIG_DIFF=y
# CONFIG_DUMPLEASES is not set
CONFIG_EXPR=y
# CONFIG_FDISK is not set
# CONFIG_FSCK is not set
# CONFIG_GETFATTR is not set
# CONFIG_GETTY is not set
# CONFIG_GITCOMPAT is not set
# CONFIG_GITCLONE is not set
# CONFIG_GITINIT is not set
# CONFIG_GITREMOTE is not set
# CONFIG_GITFETCH is not set
# CONFIG_GITCHECKOUT is not set
# CONFIG_GROUPADD is not set
# CONFIG_GROUPDEL is not set
# CONFIG_HEXDUMP is not set
# CONFIG_HD is not set
# CONFIG_INIT is not set
# CONFIG_IP is not set
# CONFIG_IPCRM is not set
# CONFIG_IPCS is not set
# CONFIG_KLOGD is not set
# CONFIG_KLOGD_SOURCE_RING_BUFFER is not set
# CONFIG_LAST is not set
# CONFIG_LSOF is not set
# CONFIG_MAN is not set
# CONFIG_MDEV is not set
# CONFIG_MDEV_CONF is not set
# CONFIG_MKE2FS is not set
# CONFIG_MKE2FS_JOURNAL is not set
# CONFIG_MKE2FS_GEN is not set
# CONFIG_MKE2FS_LABEL is not set
# CONFIG_MKE2FS_EXTENDED is not set
# CONFIG_MODPROBE is not set
# CONFIG_MORE is not set
# CONFIG_ROUTE is not set
# CONFIG_SH is not set
# CONFIG_CD is not set
# CONFIG_DECLARE is not set
# CONFIG_EXIT is not set
# CONFIG_SET is not set
# CONFIG_UNSET is not set
# CONFIG_EVAL is not set
# CONFIG_EXEC is not set
# CONFIG_EXPORT is not set
# CONFIG_JOBS is not set
# CONFIG_LOCAL is not set
# CONFIG_SHIFT is not set
# CONFIG_SOURCE is not set
# CONFIG_WAIT is not set
# CONFIG_STRACE is not set
# CONFIG_STTY is not set
# CONFIG_SULOGIN is not set
# CONFIG_SYSLOGD is not set
# CONFIG_TCPSVD is not set
# CONFIG_TELNET is not set
# CONFIG_TELNETD is not set
# CONFIG_TFTP is not set
# CONFIG_TFTPD is not set
CONFIG_TR=y
# CONFIG_TRACEROUTE is not set
# CONFIG_USERADD is not set
# CONFIG_USERDEL is not set
# CONFIG_VI is not set
CONFIG_XZCAT=y
#
# Other commands
#
# CONFIG_ACPI is not set
# CONFIG_ASCII is not set
# CONFIG_UNICODE is not set
CONFIG_BASE64=y
# CONFIG_BASE32 is not set
# CONFIG_BLKDISCARD is not set
# CONFIG_BLKID is not set
# CONFIG_FSTYPE is not set
# CONFIG_BLOCKDEV is not set
CONFIG_BUNZIP2=y
CONFIG_BZCAT=y
# CONFIG_CHCON is not set
# CONFIG_CHROOT is not set
# CONFIG_CHRT is not set
CONFIG_CLEAR=y
# CONFIG_COUNT is not set
# CONFIG_DEVMEM is not set
# CONFIG_DOS2UNIX is not set
# CONFIG_UNIX2DOS is not set
# CONFIG_EJECT is not set
# CONFIG_FACTOR is not set
# CONFIG_FALLOCATE is not set
# CONFIG_FLOCK is not set
# CONFIG_FMT is not set
# CONFIG_FREE is not set
# CONFIG_FREERAMDISK is not set
# CONFIG_FSFREEZE is not set
# CONFIG_FSYNC is not set
# CONFIG_GETOPT is not set
# CONFIG_GPIODETECT is not set
# CONFIG_GPIOFIND is not set
# CONFIG_GPIOINFO is not set
# CONFIG_GPIOGET is not set
# CONFIG_GPIOSET is not set
# CONFIG_HELP is not set
# CONFIG_HEXEDIT is not set
# CONFIG_HWCLOCK is not set
# CONFIG_I2CDETECT is not set
# CONFIG_I2CDUMP is not set
# CONFIG_I2CGET is not set
# CONFIG_I2CSET is not set
# CONFIG_I2CTRANSFER is not set
# CONFIG_INOTIFYD is not set
# CONFIG_INSMOD is not set
# CONFIG_IONICE is not set
# CONFIG_IORENICE is not set
# CONFIG_LINUX32 is not set
# CONFIG_LOGIN is not set
# CONFIG_LOSETUP is not set
# CONFIG_LSATTR is not set
# CONFIG_CHATTR is not set
# CONFIG_LSMOD is not set
# CONFIG_LSPCI is not set
# CONFIG_LSUSB is not set
# CONFIG_MAKEDEVS is not set
# CONFIG_MCOOKIE is not set
# CONFIG_MEMEATER is not set
# CONFIG_MIX is not set
# CONFIG_MKPASSWD is not set
# CONFIG_MKSWAP is not set
# CONFIG_MODINFO is not set
# CONFIG_MOUNTPOINT is not set
# CONFIG_NBD_CLIENT is not set
# CONFIG_NBD_SERVER is not set
# CONFIG_UNSHARE is not set
# CONFIG_NSENTER is not set
# CONFIG_ONEIT is not set
# CONFIG_OPENVT is not set
# CONFIG_CHVT is not set
# CONFIG_DEALLOCVT is not set
# CONFIG_PARTPROBE is not set
# CONFIG_PIVOT_ROOT is not set
# CONFIG_PMAP is not set
CONFIG_PRINTENV=y
# CONFIG_PWDX is not set
# CONFIG_PWGEN is not set
# CONFIG_READAHEAD is not set
# CONFIG_READELF is not set
CONFIG_READLINK=y
# CONFIG_REALPATH is not set
CONFIG_REBOOT=y
# CONFIG_RESET is not set
# CONFIG_REV is not set
# CONFIG_RMMOD is not set
# CONFIG_RTCWAKE is not set
# CONFIG_SETFATTR is not set
# CONFIG_SETSID is not set
# CONFIG_SHA3SUM is not set
# CONFIG_SHRED is not set
# CONFIG_SHUF is not set
CONFIG_STAT=y
# CONFIG_SWAPOFF is not set
# CONFIG_SWAPON is not set
# CONFIG_SWITCH_ROOT is not set
# CONFIG_SYSCTL is not set
# CONFIG_TAC is not set
CONFIG_NPROC=y
# CONFIG_TASKSET is not set
CONFIG_TIMEOUT=y
CONFIG_TRUNCATE=y
# CONFIG_TS is not set
# CONFIG_UCLAMPSET is not set
# CONFIG_UPTIME is not set
# CONFIG_USLEEP is not set
# CONFIG_UUIDGEN is not set
# CONFIG_VCONFIG is not set
# CONFIG_VMSTAT is not set
# CONFIG_W is not set
# CONFIG_WATCH is not set
# CONFIG_WATCHDOG is not set
CONFIG_WHICH=y
CONFIG_XXD=y
CONFIG_YES=y
#
# Networking commands
#
# CONFIG_FTPGET is not set
# CONFIG_FTPPUT is not set
# CONFIG_HOST is not set
# CONFIG_HTTPD is not set
CONFIG_IFCONFIG=y
# CONFIG_MICROCOM is not set
# CONFIG_NETCAT is not set
# CONFIG_NETSTAT is not set
# CONFIG_PING is not set
# CONFIG_RFKILL is not set
# CONFIG_SNTP is not set
# CONFIG_TUNCTL is not set
CONFIG_WGET=y
# CONFIG_WGET_LIBTLS is not set
#
# Linux Standard Base commands
#
# CONFIG_DMESG is not set
CONFIG_GZIP=y
CONFIG_GUNZIP=y
CONFIG_ZCAT=y
CONFIG_HOSTNAME=y
# CONFIG_DNSDOMAINNAME is not set
# CONFIG_KILLALL is not set
CONFIG_MD5SUM=y
CONFIG_SHA1SUM=y
CONFIG_SHA224SUM=y
CONFIG_SHA256SUM=y
CONFIG_SHA384SUM=y
CONFIG_SHA512SUM=y
CONFIG_MKNOD=y
# CONFIG_MKNOD_Z is not set
CONFIG_MKTEMP=y
CONFIG_MOUNT=y
# CONFIG_PASSWD is not set
# CONFIG_PASSWD_SAD is not set
# CONFIG_PIDOF is not set
CONFIG_SEQ=y
# CONFIG_SU is not set
# CONFIG_SYNC is not set
CONFIG_UMOUNT=y
#
# Example commands
#
# CONFIG_DEMO_MANY_OPTIONS is not set
# CONFIG_DEMO_NUMBER is not set
# CONFIG_DEMO_SCANKEY is not set
# CONFIG_DEMO_UTF8TOWC is not set
# CONFIG_HELLO is not set
# CONFIG_HOSTID is not set
# CONFIG_LOGPATH is not set
# CONFIG_SKELETON is not set
# CONFIG_SKELETON_ALIAS is not set
#
# Android commands
#
# CONFIG_GETENFORCE is not set
# CONFIG_LOAD_POLICY is not set
# CONFIG_LOG is not set
# CONFIG_RESTORECON is not set
# CONFIG_RUNCON is not set
# CONFIG_SENDEVENT is not set
# CONFIG_SETENFORCE is not set
#
# Toybox global settings
#
CONFIG_TOYBOX=y
CONFIG_TOYBOX_SUID=y
CONFIG_TOYBOX_LSM_NONE=y
# CONFIG_TOYBOX_SELINUX is not set
# CONFIG_TOYBOX_SMACK is not set
# CONFIG_TOYBOX_LIBCRYPTO is not set
# CONFIG_TOYBOX_LIBZ is not set
CONFIG_TOYBOX_FLOAT=y
# CONFIG_TOYBOX_HELP is not set
CONFIG_TOYBOX_HELP_DASHDASH=y
# CONFIG_TOYBOX_ZHELP is not set
# CONFIG_TOYBOX_FREE is not set
# CONFIG_TOYBOX_NORECURSE is not set
# CONFIG_TOYBOX_DEBUG is not set
CONFIG_TOYBOX_UID_SYS=100
CONFIG_TOYBOX_UID_USR=500
# CONFIG_TOYBOX_FORCE_NOMMU is not set
EOF
rm -rf generated
scripts/configure.sh
cd ../..
case $(uname -m) in
x86_64)
SH_CFLAGS='-DCONFIG_TRIPLET="x86_64-linux-gnu" -DTCC_TARGET_X86_64'
;;
i*86)
SH_CFLAGS='-DCONFIG_TRIPLET="i386-linux-gnu" -DTCC_TARGET_I386'
;;
*)
echo "Unsupported architecture"
exit 1
;;
esac
SH_CFLAGS="$SH_CFLAGS -DHAVE_CONFIG_H -I$PWD/src -include $PWD/src/config.h -DBSD=1 -DSHELL -DDEBUG=1 -Wall"
SH_CFLAGS="$SH_CFLAGS -DCONFIG_TCC_BCHECK=0 -DCONFIG_TCC_BACKTRACE=0 -DONE_SOURCE=0 -D_LARGEFILE64_SOURCE -I\$builddir"
SH_SRC=
for f in bltin/printf.c bltin/test.c bltin/times.c alias.c arith_yacc.c arith_yylex.c cd.c error.c eval.c exec.c expand.c input.c jobs.c mail.c main.c memalloc.c miscbltin.c mystring.c options.c output.c parser.c redir.c show.c signames.c trap.c var.c toybox.c tcc.c ar.c util.c samu.c samu/build.c samu/deps.c samu/env.c samu/graph.c samu/htab.c samu/log.c samu/parse.c samu/scan.c samu/tool.c samu/tree.c; do
SH_SRC="$SH_SRC $PWD/src/$f"
done
SH_GENSRC="\$builddir/builtins.c \$builddir/nodes.c \$builddir/syntax.c \$builddir/init.c"
SH_GENHDR="\$builddir/builtins.h \$builddir/nodes.h \$builddir/syntax.h \$builddir/token.h \$builddir/token_vars.h"
cat > build.ninja <<EOF
builddir = $PWD/build
subninja lib/tcc/build.ninja
subninja lib/toybox/build.ninja
rule cc
command = $CC $CFLAGS $SH_CFLAGS -c -o \$out \$in
description = Compiling \$in
rule link
command = $CC -o \$out \$in $LDFLAGS $LIBS
description = Linking \$out
rule exe
command = $HOSTCC $CFLAGS $SH_CFLAGS -o \$out \$in $LDFLAGS $LIBS
description = Compiling \$out
rule generate_builtins
command = sh $PWD/src/mkbuiltins $PWD/src/builtins.def && mv builtins.c builtins.h \$builddir
description = Generating builtins.c and builtins.h
rule generate_nodes
command = \$builddir/mknodes $PWD/src/nodetypes $PWD/src/nodes.c.pat && mv nodes.c nodes.h \$builddir
description = Generating nodes.c and nodes.h
rule generate_syntax
command = \$builddir/mksyntax && mv syntax.c syntax.h \$builddir
description = Generating syntax.c and syntax.h
rule generate_tokens
command = sh $PWD/src/mktokens && mv token.h token_vars.h \$builddir
description = Generating token.h and token_vars.h
rule generate_init
command = \$builddir/mkinit $SH_SRC && mv init.c \$builddir
description = Generating init.c
rule generate_libtcc1a
command = echo "#define LIBTCC1A_LEN \$\$(wc -c < \$in)" > \$out && gzip -9 < \$in | od -Anone -vtx1 | sed 's/ /,0x/g;1s/^,/static char libtcc1a_data[] = {\n /;\$\$s/.*/&};/' >> \$out
description = Generating \$out
build \$builddir/builtins.c \$builddir/builtins.h: generate_builtins $PWD/src/mkbuiltins $PWD/src/builtins.def
build \$builddir/nodes.c \$builddir/nodes.h: generate_nodes \$builddir/mknodes $PWD/src/nodetypes $PWD/src/nodes.c.pat
build \$builddir/syntax.c \$builddir/syntax.h: generate_syntax \$builddir/mksyntax
build \$builddir/token.h \$builddir/token_vars.h: generate_tokens $PWD/src/mktokens
build \$builddir/init.c: generate_init \$builddir/mkinit
build \$builddir/mknodes: exe $PWD/src/mknodes.c
build \$builddir/mksyntax: exe $PWD/src/mksyntax.c | \$builddir/token.h
build \$builddir/mkinit: exe $PWD/src/mkinit.c
build \$builddir/libtcc1a.h: generate_libtcc1a \$builddir/tcc/libtcc1.a
$(
SH_OBJ=
for f in $SH_SRC $SH_GENSRC; do
obj="\$builddir/$(basename $f .c).o"
SH_OBJ="$SH_OBJ $obj"
echo "build $obj: cc $f | $SH_GENHDR \$builddir/libtcc1a.h"
done
echo build \$builddir/bootsh: link $SH_OBJ \$builddir/libtoybox.a \$builddir/tcc/libtcc.a
)
default \$builddir/bootsh
EOF