summaryrefslogtreecommitdiff
path: root/binary/mingw/build-dist
blob: b4fc4dc5dc6078d18df640b707b15437eb65809c (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
#! /usr/bin/env bash

# Create ODB compiler Windows distribution.
#
# -rebuild
# -pack      get the source distributions from /tmp/pack/
#
trap 'exit 1' ERR

function error ()
{
  echo "$*" 1>&2
}

rebuild=n
pack=n

while [ $# -gt 0 ]; do
  case $1 in
    -rebuild)
      rebuild=y
      shift
      ;;
    -pack)
      pack=y
      rebuild=y
      shift
      ;;
    *)
      error "unknown option: $1"
      exit 1
      ;;
  esac
done


out_root=`pwd`
version=`cat $HOME/work/odb/odb/version`
install_root="/tmp/odb-$version-i686-windows"

if [ $pack = n ]; then
  src_root=$HOME/work
else
  src_root=/tmp
fi

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
  rn -rf libodb-qt
  rm -rf odb
  rm -rf odb-build/*
  rm -rf $install_root

  cp -r mingw-rt/* /mingw/
  # make -C binutils-build install
  cp -r mingw-binutils/* /mingw/
fi

if [ $pack = n ]; then
  rm -f /tmp/odb-$version-i686-windows.zip
else
  rm -f /tmp/pack/odb-$version-i686-windows.zip
fi

# Build libplugin-stub
#
if [ $rebuild = y ]; then
  mkdir -p libplugin-stub
  cd libplugin-stub
  i686-mingw32-gcc -O2 -c ../plugin-stub.c
  i686-mingw32-ar cr libplugin-stub.a plugin-stub.o
  i686-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 $src_root/odb/libodb dist dist_prefix=$out_root/libodb

  if [ $rebuild = y ]; then
    cd libodb
    ./bootstrap
    cd ..
  fi
else
  tar xfz $src_root/pack/libodb-$version.tar.gz
  mv libodb-$version libodb
fi

cd libodb

if [ $rebuild = y ]; then
  ../libodb-configure
fi

make
cd odb
make install-data
cd ../..

# Build libodb-boost
#
if [ $pack = n ]; then
  make -C $src_root/odb/libodb-boost dist dist_prefix=$out_root/libodb-boost

  if [ $rebuild = y ]; then
    cd libodb-boost
    ./bootstrap
    cd ..
  fi
else
  tar xfz $src_root/pack/libodb-boost-$version.tar.gz
  mv libodb-boost-$version libodb-boost
fi

cd libodb-boost

if [ $rebuild = y ]; then
  ../libodb-boost-configure
fi

make
make install-data
cd ..

# Build libodb-qt
#
if [ $pack = n ]; then
  make -C $src_root/odb/libodb-qt dist dist_prefix=$out_root/libodb-qt

  if [ $rebuild = y ]; then
    cd libodb-qt
    ./bootstrap
    cd ..
  fi
else
  tar xfz $src_root/pack/libodb-qt-$version.tar.gz
  mv libodb-qt-$version libodb-qt
fi

cd libodb-qt

if [ $rebuild = y ]; then
  ../libodb-qt-configure
fi

make
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 ]; then
    cd libcutl
    ./bootstrap
    cd ..
  fi
else
  cutl_version=`cat $HOME/work/cutl/libcutl/version`
  tar xfz $src_root/libcutl-$cutl_version.tar.gz
  mv libcutl-$cutl_version libcutl
fi

cd libcutl

if [ $rebuild = y ]; then
  ../libcutl-configure
fi

make
cd ..

# Build odb
#
if [ $pack = n ]; then
  make -C $src_root/odb/odb dist dist_prefix=$out_root/odb

  if [ $rebuild = y ]; then
    cd odb
    ./bootstrap
    cd ..
  fi
else
  tar xfz $src_root/pack/odb-$version.tar.gz
  mv odb-$version odb
fi

mkdir -p odb-build
cd odb-build

if [ $rebuild = y ]; then
  ../odb-configure $version
fi

make
make install-strip
rm -f $install_root/bin/odb.a
cd ..

# Build gcc
#
mkdir -p gcc-build
cd gcc-build

if [ $rebuild = y ]; then
  ../gcc-configure
else
  rm -f gcc/cc1plus.exe gcc/cc1plus-dummy.exe
fi

make 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"
make install
make -C i686-mingw32/libstdc++-v3 install-strip
cd ..

# Copy /mingw over to installation
#
cp -r /mingw $install_root/

# 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 -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
zip -r pack/odb-$version-i686-windows.zip odb-$version-i686-windows
cd $out_root