-
Notifications
You must be signed in to change notification settings - Fork 0
/
strap
executable file
·148 lines (134 loc) · 3.86 KB
/
strap
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
#!/bin/sh -e
# This file is dedicated to the public domain.
. scripts/lib.sh
if [ "$CC" != "" ]; then cc="$CC"; else . scripts/cc-pick.sh; fi
. scripts/cc-target.sh
. scripts/cc-info.sh
# Manage expectations!
case "$target_os" in
linux) ;; linux_musl) ;; freebsd) ;; netbsd) ;; openbsd) ;; illumos) ;;
macos)
warn "warning: macOS is known to be a really BAD Unix implementation!"
warn " it is also currently totally untested - expect issues!" ;;
unknown)
warn "warning: build is not tested on your OS, so you may have issues..."
warn "* let me know how it goes! *" ;;
*)
warn "heads up: this OS has yet to be tested, but should work in theory."
warn "* let me know how you get on! *" ;;
esac
warn "note: compiling unoptimised bootstrap version"
warn " this will take a moment because modern compilers are ridiculously slow"
cflags="-O0 -w -fpic"
ldflags="-O0"
lsocket=
if [ "$target_os" = illumos ]; then lsocket=" -lsocket"; fi # ugh.
. scripts/find-cpoly.sh
mkdir -p build/strap/bin build/strap/lib
num_items=4 # ← remember to change this manually
is_tty && printf "[0/$num_items] build " || :
extrasrc=""
if [ "$cpoly_use_bundled" = 1 ]; then
extrasrc="
libcpoly/src/arc4random/arc4random.c
libcpoly/src/progname.c
libcpoly/src/reallocarray.c
libcpoly/src/strchrnul.c
libcpoly/src/strtonum.c"
fi
$cc $cflags $cpoly_cflags $ldflags$lsocket $cpoly_ldflags \
-Icbits/include \
src/build.c \
src/db.c \
src/db-strpool.c \
src/evloop.c \
src/fpath.c \
src/fd.c \
src/infile.c \
src/ipcserver.c \
src/proc.c \
src/sigstr.c \
src/task.c \
src/time.c \
src/tui.c \
cbits/src/errmsg.c \
cbits/src/errorstring.c \
cbits/src/fmt.c \
cbits/src/iobuf.c \
cbits/src/path.c $extrasrc \
-o build/strap/bin/build
is_tty && printf "\r[K[1/$num_items] libbuild " || :
extrasrc=""
if [ "$cpoly_use_bundled" = 1 ]; then
extrasrc="
libcpoly/src/progname.c"
fi
$cc -shared $cflags $cpoly_cflags $ldflags$lsocket $cpoly_ldflags \
-fvisibility=hidden \
-Icbits/include \
src/ipcclient.c \
src/libbuild.c \
cbits/src/errmsg.c \
cbits/src/errorstring.c \
cbits/src/iobuf.c $extrasrc \
-o build/strap/lib/libbuild.so
is_tty && printf "\r[K[2/$num_items] build-dep " || :
extrasrc=""
if [ "$cpoly_use_bundled" = 1 ]; then
extrasrc="
libcpoly/src/progname.c"
fi
$cc $cflags $cpoly_cflags $ldflags $cpoly_ldflags \
-Icbits/include \
-Lbuild/strap/lib -lbuild \
src/build-dep.c \
cbits/src/errmsg.c \
cbits/src/errorstring.c \
cbits/src/iobuf.c $extrasrc \
-o build/strap/bin/build-dep
is_tty && printf "\r[K[3/$num_items] build-infile " || :
extrasrc=""
if [ "$cpoly_use_bundled" = 1 ]; then
extrasrc="
libcpoly/src/progname.c"
fi
$cc $cflags $cpoly_cflags $ldflags $cpoly_ldflags \
-Icbits/include \
-Lbuild/strap/lib -lbuild \
src/build-infile.c \
cbits/src/errmsg.c \
cbits/src/errorstring.c \
cbits/src/iobuf.c $extrasrc \
-o build/strap/bin/build-infile
is_tty && printf "\r[K[3/$num_items] build-tasktitle " || :
extrasrc=""
if [ "$cpoly_use_bundled" = 1 ]; then
extrasrc="
libcpoly/src/progname.c"
fi
$cc $cflags $cpoly_cflags $ldflags $cpoly_ldflags \
-Icbits/include \
-Lbuild/strap/lib -lbuild \
src/build-tasktitle.c \
cbits/src/errmsg.c \
cbits/src/errorstring.c \
cbits/src/iobuf.c $extrasrc \
-o build/strap/bin/build-tasktitle
is_tty && printf "\r[K" || :
# note: this step sort of precludes cross-compiling from strap, but that's okay,
# we can bootstrap locally and use that to cross-compile to elsewhere!)
warn "note: now confirming that build works by using it to build itself!"
(
export LD_LIBRARY_PATH="build/strap/lib:$LD_LIBRARY_PATH"
export PATH="build/strap/bin:$PATH"
# blegh
if [ "$CC" = "" ]; then
exec build
else
exec build ./Buildfile cc="$cc"
fi
)
full_build_dir="build/$target_os-$target_arch-$cc_type-$cc_ver"
warn "success! installation files are in $full_build_dir/out"
warn " you can also invoke build without installing using ./runbuild"
# vi: sw=4 ts=4 noet tw=80 cc=80