blob: 0c1e082fd30020dce7e1b3e0f877b51886bf6c67 (
plain)
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
|
#! /usr/bin/env bash
# Create ODB compiler Windows distribution.
#
# -rebuild
# -pack get the source distributions from /tmp/pack/
# -j <jobs> [default is 8]
#
trap 'exit 1' ERR
function error ()
{
echo "$*" 1>&2
}
# Find output directory for a project. It is either $1-default or if
# that doesn't exist, it is $1.
#
function find_out_dir ()
{
# Get the actual directory in case -default is a symlink.
#
tmp=`realpath $1-default 2>/dev/null`
if [ -n "$tmp" -a -d "$tmp" ]; then
echo "$tmp"
else
echo "$1"
fi
}
rebuild=n
pack=n
jobs=8
while [ $# -gt 0 ]; do
case $1 in
-rebuild)
rebuild=y
shift
;;
-pack)
pack=y
rebuild=y
shift
;;
-j)
shift
jobs=$1
shift
;;
*)
error "unknown option: $1"
exit 1
;;
esac
done
if [ $pack = n ]; then
src_root=$HOME/work
over=`cat $HOME/work/odb/odb/version`
else
src_root=/tmp
cver=`echo $src_root/libcutl-?.*.tar.gz | sed -e "s%$src_root/libcutl-\(.*\).tar.gz%\1%"`
over=`echo $src_root/pack/odb-?.*.tar.gz | sed -e "s%$src_root/pack/odb-\(.*\).tar.gz%\1%"`
mver=`echo $over | sed -e 's%\([0-9]*\.[0-9]*\).*%\1%'`
fi
out_root=`pwd`
install_root="/tmp/odb-$over-i686-windows"
export PATH=$out_root/cross/mingw/bin:$PATH
# Clean everything up if we are rebuilding.
#
if [ $rebuild = y ]; then
rm -rf /mingw/*
rm -rf libplugin-stub
rm -rf gcc-build/*
rm -rf libcutl
rm -rf libodb
rm -rf libodb-boost
rm -rf libodb-qt
rm -rf odb
rm -rf odb-build/*
rm -rf $install_root
cp -r mingw-rt/* /mingw/
cp -r mingw-binutils/* /mingw/
mkdir /mingw/mingw
ln -s /mingw/i686-w64-mingw32/lib64 /mingw/mingw/lib
fi
# Build libplugin-stub
#
if [ $rebuild = y ]; then
mkdir -p libplugin-stub
cd libplugin-stub
i686-w64-mingw32-gcc -O2 -c ../plugin-stub.c
i686-w64-mingw32-ar cr libplugin-stub.a plugin-stub.o
i686-w64-mingw32-ranlib libplugin-stub.a
cd ..
mkdir -p gcc-build/gcc
cp libplugin-stub/libplugin-stub.a gcc-build/gcc/
fi
# Build libodb
#
if [ $pack = n ]; then
make -C `find_out_dir $src_root/odb/libodb` -f $src_root/odb/libodb/makefile \
dist dist_prefix=$out_root/libodb
if [ $rebuild = y -o ! -f configure ]; then
cd libodb
./bootstrap
cd ..
fi
else
libodb=`echo $src_root/pack/libodb-$mver.*.tar.gz | sed -e "s%$src_root/pack/\(.*\)\.tar\.gz%\1%"`
tar xfz $src_root/pack/$libodb.tar.gz
mv $libodb libodb
fi
cd libodb
if [ $rebuild = y -o ! -f Makefile ]; then
../libodb-configure
fi
make -j $jobs
cd odb
make install-data
cd ../..
# Build libodb-boost
#
if [ $pack = n ]; then
make -C `find_out_dir $src_root/odb/libodb-boost` -f $src_root/odb/libodb-boost/makefile \
dist dist_prefix=$out_root/libodb-boost
if [ $rebuild = y -o ! -f configure ]; then
cd libodb-boost
./bootstrap
cd ..
fi
else
libodb_boost=`echo $src_root/pack/libodb-boost-$mver.*.tar.gz | sed -e "s%$src_root/pack/\(.*\)\.tar\.gz%\1%"`
tar xfz $src_root/pack/$libodb_boost.tar.gz
mv $libodb_boost libodb-boost
fi
cd libodb-boost
if [ $rebuild = y -o ! -f Makefile ]; then
../libodb-boost-configure
fi
make -j $jobs
make install-data
cd ..
# Build libodb-qt
#
if [ $pack = n ]; then
make -C `find_out_dir $src_root/odb/libodb-qt` -f $src_root/odb/libodb-qt/makefile \
dist dist_prefix=$out_root/libodb-qt
if [ $rebuild = y -o ! -f configure ]; then
cd libodb-qt
./bootstrap
cd ..
fi
else
libodb_qt=`echo $src_root/pack/libodb-qt-$mver.*.tar.gz | sed -e "s%$src_root/pack/\(.*\)\.tar\.gz%\1%"`
tar xfz $src_root/pack/$libodb_qt.tar.gz
mv $libodb_qt libodb-qt
fi
cd libodb-qt
if [ $rebuild = y -o ! -f Makefile ]; then
../libodb-qt-configure
fi
make -j $jobs
make install-data
cd ..
# Build libcutl
#
if [ $pack = n ]; then
make -C $src_root/cutl/libcutl dist dist_prefix=$out_root/libcutl
if [ $rebuild = y -o ! -f configure ]; then
cd libcutl
./bootstrap
cd ..
fi
else
tar xfz $src_root/libcutl-$cver.tar.gz
mv libcutl-$cver libcutl
fi
cd libcutl
if [ $rebuild = y -o ! -f Makefile ]; then
../libcutl-configure
fi
make -j $jobs
cd ..
# Build odb
#
if [ $pack = n ]; then
make -C $src_root/odb/odb dist dist_prefix=$out_root/odb
if [ $rebuild = y -o ! -f configure ]; then
cd odb
./bootstrap
cd ..
fi
else
tar xfz $src_root/pack/odb-$over.tar.gz
mv odb-$over odb
fi
mkdir -p odb-build
cd odb-build
if [ $rebuild = y -o ! -f Makefile ]; then
../odb-configure $over
fi
make -j $jobs
make install-strip
rm -r $install_root/libexec # odb/odb.a
cd ..
# Build gcc
#
mkdir -p gcc-build
cd gcc-build
if [ $rebuild = y -o ! -f Makefile ]; then
../gcc-configure
else
rm -f gcc/cc1plus.exe gcc/cc1plus-dummy.exe
fi
make -j $jobs STATIC_PLUGIN_LIBS="-Wl,--whole-archive $out_root/odb-build/odb/.libs/odb.a -Wl,--no-whole-archive $out_root/libcutl/cutl/.libs/libcutl.a -lstdc++ -static-libgcc"
# Split 32 and 64 libs/dlls.
#
rm -rf /mingw/bin64
mv /mingw/bin /mingw/bin32
make install
make -C i686-w64-mingw32/libstdc++-v3/src install-strip
mv /mingw/bin/* /mingw/bin32/
rm -rf /mingw/bin /mingw/bin64
make -C i686-w64-mingw32/64/libstdc++-v3/src install-strip
mv /mingw/bin /mingw/bin64
mv /mingw/bin32 /mingw/bin
cd ..
# Copy /mingw over to installation.
#
cp -r /mingw $install_root/
# Move some DLLs to mingw/bin/.
mv $install_root/mingw/lib/libgcc_s_sjlj-1.dll $install_root/mingw/bin/
mv $install_root/mingw/i686-w64-mingw32/lib/libwinpthread-1.dll $install_root/mingw/bin/
mv $install_root/mingw/lib64/libgcc_s_sjlj-1.dll $install_root/mingw/bin64/
mv $install_root/mingw/i686-w64-mingw32/lib64/libwinpthread-1.dll $install_root/mingw/bin64/
# Move doc and man out of share/
#
rm -rf $install_root/doc $install_root/man
mv $install_root/share/man $install_root/
mv $install_root/share/doc/odb $install_root/doc
rm -r $install_root/share
# Clean some things up.
#
rm -r $install_root/mingw/mingw
rm -f $install_root/mingw/lib/libbfd.*
rm -f $install_root/mingw/include/bfd*.h
rm -f $install_root/mingw/lib/libopcodes.*
rm -f $install_root/mingw/lib/libiberty.a
rm -f `find $install_root -name '*.la'`
# Copy msys over to installation.
#
cp -r msys/* $install_root/mingw/
# Copy the default options file.
#
mkdir -p $install_root/etc/odb
cp -L default.options $install_root/etc/odb/
todos $install_root/etc/odb/default.options
# Copy manifest.
#
cp -L manifest.txt $install_root/mingw/
todos $install_root/mingw/manifest.txt
# Copy README.
#
cp -L README $install_root/README
todos $install_root/README
# Zip it up.
#
cd /tmp
mkdir -p pack
rm -f pack/odb-$over-i686-windows.zip
zip -r pack/odb-$over-i686-windows.zip odb-$over-i686-windows
cd $out_root
|