1
1
#! /bin/bash
2
2
3
3
rel=${rel:- 2.5.0}
4
+ subrel=${subrel:- 1}
4
5
make=" -j 2"
5
6
which nproc >& /dev/null && make=" -j $(( $(nproc) + 1 )) "
6
7
gitopt=" --depth 1 --single-branch"
7
8
9
+ arduino=${arduino:- $HOME / Arduino/ hardware/ esp8266com/ esp8266}
10
+
8
11
gcc=${gcc:- 4.8}
9
12
case $gcc in
10
13
4.8|4.9) isl=0.12.2; xtensa_branch=call0-${gcc} .2;;
@@ -48,20 +51,59 @@ clean()
48
51
cleangit lx106-hal
49
52
}
50
53
51
- set -e
52
-
53
- unfinished=" zzz-not-fully-built-yet-zzz"
54
-
55
- case " $1 " in
56
- clean) clean; exit 0;;
57
- build) : ;;
58
- * ) echo " need 'clean', 'build'" ; exit 1;;
59
- esac
60
54
55
+ install ()
56
+ {
57
+ # Need to rebuild and make install on newlib to get proper headers. Crufty, but we have an odd dir structure
58
+ echo " -------- Building installable newlib"
59
+ rm -rf arena/newlib-install
60
+ mkdir -p arena/newlib-install
61
+ (cd arena/newlib-install; ../../dl/newlib-xtensa/configure ${configurenewlibinstall} ) & > $log .20.newlib.conf.log
62
+ (cd arena/newlib-install; CROSS_CFLAGS=" -DSIGNAL_PROVIDED -DABORT_PROVIDED -DMALLOC_PROVIDED" make ${make} ) & > $log .21.newlib.make.log
63
+ (cd arena/newlib-install; make install) & > $log .22.newlib.install.log
64
+ echo " -------- Building installable hal"
65
+ rm -rf arena/hal-install
66
+ mkdir -p arena/hal-install
67
+ (cd arena/hal-install; ../../dl/lx106-hal/configure --prefix=${arduino} /tools/sdk/libc --libdir=${arduino} /tools/sdk/lib --host=xtensa-lx106-elf $( echo ${configure} | sed ' s/--host=[a-zA-Z0-9_-]*//' | sed ' s/--prefix=[a-zA-Z0-9_-\\]*//' ) ) & > $log .23.hal.conf.log
68
+ (cd arena/hal-install; make ${make} ) & > $log .24.hal.make.log
69
+ (cd arena/hal-install; make install) & > $log .25.hal.install.log
70
+ echo " -------- Copying GCC libs"
71
+ cp ${installnative} /lib/gcc/xtensa-lx106-elf/* /libgcc.a ${arduino} /tools/sdk/lib/.
72
+ cp ${installnative} /xtensa-lx106-elf/lib/libstdc++.a ${arduino} /tools/sdk/lib/.
73
+ echo " -------- Copying toolchain directory"
74
+ rm -rf ${arduino} /tools/sdk/xtensa-lx106-elf
75
+ cp -a ${installnative} /xtensa-lx106-elf ${arduino} /tools/sdk/xtensa-lx106-elf
76
+ echo " -------- Updating package.json"
77
+ git=$( git rev-parse --short HEAD)
78
+ ver=${rel} -${git} -${subrel}
79
+ pkgfile=${arduino} /package/package_esp8266com_index.template.json
80
+ (cat << EOF
81
+ import glob
82
+ import json
83
+ import os
84
+ with open("$pkgfile ") as f:
85
+ data = json.load(f)
86
+ for i in range(0, len(data["packages"][0]["platforms"][0]["toolsDependencies"])):
87
+ if data["packages"][0]["platforms"][0]["toolsDependencies"][i]["name"] == "xtensa-lx106-elf-gcc":
88
+ data["packages"][0]["platforms"][0]["toolsDependencies"][i]["version"] = "$ver "
89
+ for i in range(0, len(data["packages"][0]["tools"])):
90
+ if data["packages"][0]["tools"][i]["name"] == "xtensa-lx106-elf-gcc":
91
+ data["packages"][0]["tools"][i]["version"] = "$ver "
92
+ data["packages"][0]["tools"][i]["systems"] = []
93
+ for j in glob.glob("*xtensa-lx106-elf*"+"$git "+"*json"):
94
+ with open(j) as s:
95
+ part = json.load(s)
96
+ data["packages"][0]["tools"][i]["systems"].append(part)
97
+ print json.dumps(data, indent=3, separators=(',',': '))
98
+ EOF
99
+ ) | python > $pkgfile .new
100
+ mv -f ${pkgfile} .new ${pkgfile}
101
+ echo " Install done"
102
+ }
61
103
62
- echo " Building GCC-$gcc "
63
- echo " For architecture: $host "
104
+ set -e
64
105
106
+ unfinished=" zzz-not-fully-built-yet-zzz"
65
107
66
108
installnative=$( pwd) /xtensa-lx106-elf.x86_64
67
109
install=$( pwd) /xtensa-lx106-elf${EXT}
@@ -83,6 +125,19 @@ configure+=" --disable-bootstrap"
83
125
configure+=" --enable-lto"
84
126
configure+=" --disable-libstdcxx-verbose"
85
127
128
+ configurenewlibcom=" --with-newlib --enable-multilib --disable-newlib-io-c99-formats --disable-newlib-supplied-syscalls"
129
+ configurenewlibcom+=" --enable-newlib-nano-formatted-io --enable-newlib-reent-small --enable-target-optspace"
130
+ configurenewlibcom+=" --disable-option-checking"
131
+ configurenewlibcom+=" --target=xtensa-lx106-elf"
132
+ configurenewlibcom+=" --disable-shared"
133
+
134
+
135
+ configurenewlibinstall=" --prefix=${arduino} /tools/sdk/libc --with-target-subdir=xtensa-lx106-elf"
136
+ configurenewlibinstall+=${configurenewlibcom}
137
+
138
+ configurenewlib=" --prefix=${install} "
139
+ configurenewlib+=${configurenewlibcom}
140
+
86
141
if $lto ; then
87
142
export CFLAGS_FOR_TARGET=' -mlongcalls -flto -Wl,-flto -Os -g'
88
143
export CXXFLAGS_FOR_TARGET=' -mlongcalls -flto -Wl,-flto -Os -g'
@@ -91,18 +146,32 @@ else
91
146
export CXXFLAGS_FOR_TARGET=' -mlongcalls -Os -g'
92
147
fi
93
148
149
+ export CFLAGS=" -I${install} /include -pipe"
150
+ export LDFLAGS=" -L${install} /lib"
151
+ export PATH=" ${installnative} /bin:${PATH} "
152
+ export LD_LIBRARY_PATH=" ${installnative} /lib"
153
+
154
+
155
+ case " $1 " in
156
+ clean) clean; exit 0;;
157
+ build) : ;;
158
+ install) install; exit 0;;
159
+ * ) echo " need 'clean', 'build', or 'install'" ; exit 1;;
160
+ esac
161
+
162
+
163
+ echo " Building GCC-$gcc "
164
+ echo " For architecture: $host "
165
+
166
+
167
+
94
168
echo " -------- Checking for required tools"
95
169
MISS=0
96
170
for i in flex bison autogen makeinfo autoreconf make gcc g++; do
97
171
which $i >& /dev/null || ( echo " Missing: $i " && MISS=1 )
98
172
done
99
173
if [ $MISS -ne 0 ]; then exit ; fi
100
174
101
- export CFLAGS=" -I${install} /include -pipe"
102
- export LDFLAGS=" -L${install} /lib"
103
- export PATH=" ${installnative} /bin:${PATH} "
104
- export LD_LIBRARY_PATH=" ${installnative} /lib"
105
-
106
175
mkdir -p arena
107
176
108
177
if [ ! -r arena/downloaded ]; then
@@ -215,8 +284,8 @@ if [ ! -r arena/gcc/jobdone-newlib ]; then
215
284
echo " -------- newlib"
216
285
# configure and build newlib
217
286
mkdir -p arena/newlib
218
- (cd arena/newlib; ../../dl/newlib-xtensa/configure ${configure } ) & > $log .06.newlib.conf.log
219
- (cd arena/newlib; make ${make} ) & > $log .07.newlib.make.log
287
+ (cd arena/newlib; ../../dl/newlib-xtensa/configure ${configurenewlib } ) & > $log .06.newlib.conf.log
288
+ (cd arena/newlib; CROSS_CFLAGS= " -DSIGNAL_PROVIDED -DABORT_PROVIDED -DMALLOC_PROVIDED " make ${make} ) & > $log .07.newlib.make.log
220
289
touch arena/gcc/jobdone-newlib
221
290
fi
222
291
(cd arena/newlib; make install) & > $log .08.newlib.install.log
@@ -264,7 +333,7 @@ tarballsha256=$(sha256sum ${tarball} | cut -f1 -d" ")
264
333
echo ' "archiveFileName": "' ${tarball} ' ",' &&
265
334
echo ' "checksum": "SHA-256:' ${tarballsha256} ' ",' &&
266
335
echo ' "size": "' ${tarballsize} ' "' &&
267
- echo ' }, ' ) > ${tarball} .json
336
+ echo ' }' ) > ${tarball} .json
268
337
rm -rf pkg
269
338
270
339
echo " all done (${install} )"
0 commit comments