blob: 54d75d065fd70ffb6ab8ea8b2e85d5b030705a77 (
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
|
#!/bin/sh
# TODO build liblzma for each host
# Place C/C++ common flags here
COMMON="-g"
export CFLAGS
export CXXFLAGS
export LDFLAGS
# TODO replace w/ wget
LZMA="xz-5.2.1"
LZMA_FILE="/volume/home/jmacd/src/xdelta-devel/xz-5.2.1.tar.xz"
MAKEFLAGS="-j 10"
MYOS=`uname`
BUILDDIR=${PWD}/build
LZMASRC=${BUILDDIR}/${LZMA}
LIBBASE=$HOME/lib
MINGW_CFLAGS="-DEXTERNAL_COMPRESSION=0 -DVCDIFF_TOOLS=0 -DXD3_WIN32=1 -DSHELL_TESTS=0"
MINGW_LDFLAGS=""
# Location where mingw-w64-build script runs.
MINGW_BASE="/volume/home/jmacd/src/mingwb"
# Windows 32bit
# Run from the source dir.
SRCDIR=$PWD
LINUXTEST1=""
LINUXTEST2=""
WINTEST1=""
WINTEST2=""
find build -type f 2> /dev/null | xargs rm
function setup {
aclocal -I m4
automake
automake --add-missing
autoconf
}
function try {
local w=$1
shift
local dir=$1
shift
echo -n " ${w} ..."
(cd "${dir}" && "$@" >$w.stdout 2>$w.stderr)
local s=$?
if [ $s -eq 0 ]; then
echo " success"
else
echo " failed!"
echo "Error $1 in ${dir}" >&2
fi
return $s
}
function buildlzma {
host=$1
march=$2
local target="${BUILDDIR}/lib-${host}${march}"
echo " ... liblzma"
mkdir -p $target
try configure-lzma ${target} ${LZMASRC}/configure \
--host=${host} \
--prefix=${target} \
--disable-shared \
"CFLAGS=${march}" \
"CXXFLAGS=${march}" \
"LDFLAGS=${march}"
if [ $? -ne 0 ]; then
return
fi
try build-lzma ${target} make ${MAKEFLAGS}
if [ $? -ne 0 ]; then
return
fi
try install-lzma ${target} make install
if [ $? -ne 0 ]; then
return
fi
}
function buildit {
host=$1
march=$2
offsetbits=$3
cargs=$4
largs=$5
BM="${host}${march}"
D="build/${BM}/xoff${offsetbits}"
BMD="${BM}-${offsetbits}"
FULLD="$PWD/$D"
CFLAGS="${COMMON} ${march} ${cargs} -I${PWD}/build/lib-${BM}/include"
CXXFLAGS="${COMMON} ${march} ${cargs} -I${PWD}/build/lib-${BM}/include"
LDFLAGS="${largs} ${march} -L${PWD}/build/lib-${BM}/lib"
mkdir -p ${D}
echo " ... ${BMD}"
cat >> Makefile.test <<EOF
# ${BMD}
.PHONY: regtest-${BMD}
regtest-${BMD}:
(cd ${D} && ./xdelta3regtest 1> \${TMP}/regtest.${BMD}.stdout 2> \${TMP}/regtest.${BMD}.stderr)
.PHONY: selftest-${BMD}
selftest-${BMD}:
(cd ${D} && ./bin/xdelta3 test 1> \${TMP}/selftest.${BMD}.stdout 2> \${TMP}/selftest.${BMD}.stderr)
EOF
case ${host} in
*linux*)
LINUXTEST1="${LINUXTEST1} selftest-${BMD}"
LINUXTEST2="${LINUXTEST2} regtest-${BMD}"
;;
*mingw*)
WINTEST1="${WINTEST1} selftest-${BMD}"
WINTEST2="${WINTEST2} regtest-${BMD}"
;;
esac
try configure-xdelta $FULLD $SRCDIR/configure \
--host=${host} \
--prefix=${FULLD} \
--enable-static \
--disable-shared \
--enable-debug-symbols
if [ $? -ne 0 ]; then
return
fi
try build-xdelta $FULLD make ${MAKEFLAGS} all
if [ $? -ne 0 ]; then
return
fi
try install-xdelta $FULLD make install
}
function buildall {
echo ""
echo "Host $1$2"
echo ""
buildlzma "$1" "$2"
if [ $? -ne 0 ]; then
return
fi
buildit "$1" "$2" 32 "-DXD3_USE_LARGEFILE64=0 $3" "$4"
if [ $? -ne 0 ]; then
return
fi
buildit "$1" "$2" 64 "-DXD3_USE_LARGEFILE64=1 $3" "$4"
if [ $? -ne 0 ]; then
return
fi
}
setup
try untar-lzma ${BUILDDIR} tar -xvf "${LZMA_FILE}"
if [ $? -ne 0 ]; then
return
fi
DATE=`date`
cat > Makefile.test <<EOF
# Auto-generated ${DATE} -*- Mode: Makefile -*-
EOF
# Linux
buildall x86_64-pc-linux-gnu -m32
buildall x86_64-pc-linux-gnu -m64
# Windows
buildall i686-w64-mingw32 -mconsole "${MINGW_CFLAGS}" ""
buildall x86_64-w64-mingw32 -mconsole "${MINGW_CFLAGS}" ""
cat >> Makefile.test <<EOF
linux: linux-selftest linux-regtest
windows: windows-selftest windows-regtest
linux-selftest: ${LINUXTEST1}
linux-regtest: ${LINUXTEST2}
windows-selftest: ${WINTEST1}
windows-regtest: ${WINTEST2}
EOF
|