]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/build-dependencies
Update win32 README
[bacula/bacula] / bacula / src / win32 / build-dependencies
1 VERBOSE=n
2 OVERWRITE=n
3
4 URL_ZLIB=http://www.zlib.net/zlib-1.2.3.tar.gz
5 #URL_ZLIB=http://superb-west.dl.sourceforge.net/sourceforge/libpng/zlib-1.2.3.tar.gz
6 DIR_ZLIB=
7 URL_PCRE=http://superb-west.dl.sourceforge.net/sourceforge/pcre/pcre-6.3.tar.bz2
8 DIR_PCRE=
9 URL_PTHREADS=ftp://sources.redhat.com/pub/pthreads-win32/pthreads-snap-2004-06-22.tar.gz
10 DIR_PTHREADS=
11 URL_OPENSSL=http://www.openssl.org/source/openssl-0.9.8b.tar.gz
12 DIR_OPENSSL=
13 URL_MYSQL=http://mirror.x10.com/mirror/mysql/Downloads/MySQL-5.0/mysql-noinstall-5.0.22-win32.zip
14 DIR_MYSQL=mysql-5.0.22-win32
15 URL_POSTGRESQL=ftp://ftp2.us.postgresql.org/postgresql/source/v8.1.4/postgresql-base-8.1.4.tar.bz2
16 DIR_POSTGRESQL=postgresql-8.1.4
17 URL_SQLITE=http://www.sqlite.org/sqlite-3.3.6.tar.gz
18 DIR_SQLITE=
19 URL_WX=http://superb-west.dl.sourceforge.net/sourceforge/wxwindows/wxWidgets-2.6.3.tar.gz
20 DIR_WX=
21 URL_SCONS=http://superb-west.dl.sourceforge.net/sourceforge/scons/scons-0.96.92.tar.gz
22 DIR_SCONS=
23 URL_NSIS_BIN=http://superb-west.dl.sourceforge.net/sourceforge/nsis/nsis-2.17.zip
24 DIR_NSIS_BIN=
25 URL_NSIS_SRC=http://superb-west.dl.sourceforge.net/sourceforge/nsis/nsis-2.17-src.tar.bz2
26 DIR_NSIS_SRC=
27
28 cwd=`pwd`
29 cd `dirname $0`
30 SCRIPT_DIR=`pwd`
31
32 cd ../../..
33 TOP_DIR=`pwd`
34
35 if [ ! -e ${TOP_DIR}/cross-tools/mingw32/bin/mingw32-gcc ] 
36 then
37         echo The GCC cross compiler isn\'t installed.
38         echo You must run build-win32-cross-tools first
39         exit 1
40 fi
41
42 cd ${TOP_DIR}/cross-tools/mingw32/bin
43 BIN_DIR=`pwd`
44
45 [ ! -e ${TOP_DIR}/depkgs-mingw32 ] && mkdir ${TOP_DIR}/depkgs-mingw32
46 cd ${TOP_DIR}/depkgs-mingw32
47 DEPPKG_DIR=`pwd`
48 cd ${DEPPKG_DIR}
49
50 case "${VERBOSE}" in
51 y*|t*)  VERBOSE=true ;;
52 n*|f*)  VERBOSE=false ;;
53 *)      VERBOSE=false ;;
54 esac
55
56 case ${OVERWRITE} in
57 y*|t*)  OVERWRITE=true ;;
58 n*|f*)  OVERWRITE=false ;;
59 *)      OVERWRITE=true ;;
60 esac
61
62 export PATH=${BIN_DIR}:${PATH}
63
64 [ ! -e bin ] && mkdir bin
65 [ ! -e src ] && mkdir src
66 [ ! -e include ] && mkdir include
67 [ ! -e lib ] && mkdir lib
68
69 get_source()
70 {
71         URL=$1
72         SRC_DIR=$2
73         ARCHIVE=`basename ${URL}`
74         
75         case ${ARCHIVE} in
76         *.tar.gz)       ARCHIVER="tar xzf"; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.tar\.gz'`;;
77         *.tar.bz2)      ARCHIVER="tar xjf"; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.tar\.bz2'`;;
78         *.zip)          ARCHIVER="unzip -q";   [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.zip'`;;
79         *)              echo Unsupported archive type - $ARCHIVE; exit 1;;
80         esac
81         
82         cd ${DEPPKG_DIR}/src
83         
84         if [ ! -e "${ARCHIVE}" ]
85         then 
86                 echo Downloading "${URL}"
87                 if wget --passive-ftp "${URL}"
88                 then
89                         :
90                 else
91                         echo Unable to download ${ARCHIVE}
92                         exit 1
93                 fi
94         fi
95
96         if [ ! -e "${SRC_DIR}" -o "${OVERWRITE}" = "true" ]
97         then
98                 rm -rf ${SRC_DIR}
99                 echo Extracting ${ARCHIVE}
100                 ${ARCHIVER} ${ARCHIVE} &> ${ARCHIVE}.log
101                 cd ${SRC_DIR}
102                 return 0
103         fi
104
105         cd ${SRC_DIR}
106         return 1
107 }
108
109 parse_output()
110 {
111     if [ "${VERBOSE}" = "true" ]
112     then
113         cat
114     else
115         sed -ne '/\\$/N' -e 's/\\\n//' -e 's/\t\+/ /g' -e 's/ \+/ /g' \
116             -e '/ error: /p' \
117             -e "s%.*Entering directory[ ]\\+.${DEPPKG_DIR}/\\([^ ]\+\).%Entering \\1%p" \
118             -e "s%.*Leaving directory[ ]\\+.${DEPPKG_DIR}/\\([^ ]\+.\).%Leaving \\1%p" \
119             -e '/gcc \|g\+\+ \|ar /!d' \
120             -e 's/ \(\.\.\/\)\+/ /g' \
121             -e 's/.* \([^ ]\+\(\.c\|\.cpp\|\.cc\|\.cxx\)\)\( .*\|\)$/Compiling \1/p' \
122             -e 's/.* \([^ ]\+\.s\)\( .*\|\)$/Assembling \1/p' \
123             -e 's/.*ar [^ ]\+ \([^ ]\+\)\(\( [^ ]\+\.o\)\+\)/Updating \1 -\2/p' \
124             -e 's/.* -o \([^ ]\+\)\( .*\|\)$/Linking \1/p'
125     fi
126 }
127
128 do_patch()
129 {
130         PATCH_FILE=${SCRIPT_DIR}/patches/$1; shift
131         
132         if patch -f -p0 "$@" >patch.log < ${PATCH_FILE}
133         then
134                 :
135         else
136                 echo Patch failed - Check `pwd`/patch.log > /dev/tty
137                 exit 1
138         fi
139 }
140
141 do_make()
142 {
143         if make -f "$@" 2>&1
144         then
145                 :
146         else
147                 echo Make failed - Check `pwd`/make.log > /dev/tty
148                 exit 1
149         fi | tee -a make.log | parse_output
150 }
151
152 process_zlib()
153 {
154         if get_source "${URL_ZLIB}" "${DIR_ZLIB}"
155         then
156                 echo Patching zlib
157                 do_patch zlib.patch
158         fi
159         echo Building zlib
160         > make.log
161         do_make win32/Makefile.mingw32 PREFIX=${DEPPKG_DIR} all
162         echo Installing zlib
163         do_make win32/Makefile.mingw32 PREFIX=${DEPPKG_DIR} install
164 }
165
166 process_pcre()
167 {
168         if get_source "${URL_PCRE}" "${DIR_PCRE}"
169         then
170                 echo Patching PCRE
171                 do_patch pcre.patch
172         fi
173         echo Configuring PCRE
174         ./configure CC_FOR_BUILD=gcc CXX_FOR_BUILD=g++ --host=mingw32 --prefix=${DEPPKG_DIR} --enable-utf8 --enable-unicode-properties &>make.log
175         echo Building PCRE
176         do_make Makefile PREFIX=${DEPPKG_DIR} all
177         echo Installing PCRE
178         do_make Makefile PREFIX=${DEPPKG_DIR} install
179 }
180
181 process_pthreads()
182 {
183         if get_source "${URL_PTHREADS}" "${DIR_PTHREADS}"
184         then
185                 echo Patching pthreads
186                 do_patch pthreads.patch
187         fi
188         echo Building pthreads
189         > make.log
190         do_make GNUmakefile GCE
191         echo Installing pthreads
192         rm -rf ${DEPPKG_DIR}/include/pthreads
193         mkdir ${DEPPKG_DIR}/include/pthreads
194         cp -p *.h ${DEPPKG_DIR}/include/pthreads
195         cp -p *.dll ${DEPPKG_DIR}/bin
196         cp -p *.a ${DEPPKG_DIR}/lib
197 }
198
199 process_openssl()
200 {
201         if get_source "${URL_OPENSSL}" "${DIR_OPENSSL}"
202         then
203                 echo Patching openssl
204                 do_patch openssl.patch
205         fi
206         echo Configuring openssl
207         ./Configure --prefix=${DEPPKG_DIR} shared zlib-dynamic threads --with-zlib-include=${DEPPKG_DIR}/include mingw32 &> make.log
208         echo Building openssl
209         perl util/mkdef.pl 32 libeay no-static-engine >ms/libeay32.def
210         perl util/mkdef.pl 32 ssleay >ms/ssleay32.def
211         do_make Makefile all
212         echo Installing openssl
213         do_make Makefile install_sw
214 }
215
216 process_mysql()
217 {
218         get_source "${URL_MYSQL}" "${DIR_MYSQL}"
219         echo Converting mysql lib file
220         ${BIN_DIR}/../mingw32/bin/reimp --dlltool ${BIN_DIR}/mingw32-dlltool --as ${BIN_DIR}/mingw32-as lib/opt/libmysql.lib
221         echo Installing mysql
222         cp -p liblibmysql.a ../../lib/libmysql.a
223         rm -rf ../../include/mysql
224         mkdir ../../include/mysql
225         cp -p include/* ../../include/mysql 2>&1 | grep -v 'omitting directory'
226         cp -p lib/opt/libmysql.dll ../../bin
227 }
228
229 process_postgreSQL()
230 {
231         if get_source "${URL_POSTGRESQL}" "${DIR_POSTGRESQL}"
232         then
233                 echo Patching postgreSQL
234                 do_patch postgresql.patch
235         fi
236         echo Configuring postgreSQL
237         ./configure --host=mingw32 --enable-shared --enable-thread-safety --prefix=${DEPPKG_DIR} --with-includes=${DEPPKG_DIR}/include:${DEPPKG_DIR}/include/pthreads --with-libraries=${DEPPKG_DIR}/lib &> make.log
238         echo Building postgreSQL
239         if [ -e /usr/sbin/zic ]; then ZIC=/usr/sbin/zic
240         elif [ -e /sbin/zic ]; then ZIC=/sbin/zic
241         elif [ -e /usr/bin/zic ]; then ZIC=/usr/bin/zic
242         elif [ -e /bin/zic ]; then ZIC=/bin/zic
243         else ZIC=./zic
244         fi
245         do_make Makefile AR=mingw32-ar DLLTOOL=mingw32-dlltool DLLWRAP=mingw32-dllwrap WINDRES=mingw32-windres PTHREAD_LIBS=-lpthreadGCE ZIC=${ZIC} clean all
246         echo Installing postgreSQL
247         do_make Makefile AR=mingw32-ar DLLTOOL=mingw32-dlltool DLLWRAP=mingw32-dllwrap WINDRES=mingw32-windres PTHREAD_LIBS=-lpthreadGCE ZIC=${ZIC} install
248 }
249
250 process_sqlite()
251 {
252         if get_source "${URL_SQLITE}" "${DIR_SQLITE}"
253         then
254                 echo Patching SQLite
255                 do_patch sqlite.patch
256         fi
257         echo Configuring SQLite
258         [ ! -e bld ] && mkdir bld
259         cd bld
260         echo Building SQLite
261         > make.log
262         do_make ../Makefile.mingw32 CROSSTOOLS=${BIN_DIR} TLIBS="-L${DEPPKG_DIR}/lib" TCL_FLAGS="-I${DEPPKG_DIR}/include" clean all
263         echo Installing SQLite
264         cp -p sqlite3.exe ${DEPPKG_DIR}/bin
265         cp -p libsqlite3.a ${DEPPKG_DIR}/lib
266         cp -p sqlite3.h ${DEPPKG_DIR}/include
267 }
268
269 process_wxWidgets()
270 {
271         if get_source "${URL_WX}" "${DIR_WX}"
272         then
273                 echo Patching wxWidgets
274                 do_patch wx.patch -o build/msw/config.mingw32
275                 find . -name makefile.gcc -exec sh -c "sed -f ${SCRIPT_DIR}/patches/wx.sed {} > \`echo {} | sed s/\.gcc$/\.mingw32/\`" \;
276         fi
277         echo Building wxWidgets
278         cd build/msw
279         > make.log
280         do_make makefile.mingw32 SHARED=1 VENDOR=bacula
281         echo Installing wxWidgets
282         cd ../..
283         rm -rf ../../include/wx
284         mkdir ../../include/wx
285         cp -p include/wx/* ../../include/wx 2>&1 | grep -v 'omitting directory'
286         mkdir ../../include/wx/generic
287         cp -p include/wx/generic/* ../../include/wx/generic 2>&1 | grep -v 'omitting directory'
288         mkdir ../../include/wx/msw
289         cp -p include/wx/msw/* ../../include/wx/msw 2>&1 | grep -v 'omitting directory'
290         cp -p lib/gcc_dll/*.dll ../../bin
291         rm -rf ../../lib/wx_dll
292         mkdir ../../lib/wx_dll
293         cp -p lib/gcc_dll/*.a ../../lib/wx_dll
294         mkdir ../../lib/wx_dll/msw
295         cp -p lib/gcc_dll/msw/* ../../lib/wx_dll/msw 2>&1 | grep -v 'omitting directory'
296         mkdir ../../lib/wx_dll/msw/wx
297         cp -p lib/gcc_dll/msw/wx/* ../../lib/wx_dll/msw/wx 2>&1 | grep -v 'omitting directory'
298         mkdir ../../lib/wx_dll/msw/wx/msw
299         cp -p lib/gcc_dll/msw/wx/msw/* ../../lib/wx_dll/msw/wx/msw 2>&1 | grep -v 'omitting directory'
300 }
301
302 process_scons()
303 {
304         get_source "${URL_SCONS}" "${DIR_SCONS}"
305         echo Installing scons
306         if python setup.py install --prefix=${DEPPKG_DIR}/scons &> make.log
307         then
308                 :
309         else
310                 echo Make failed - Check `pwd`/make.log
311                 exit 1
312         fi
313 }
314
315 process_nsis()
316 {
317         get_source "${URL_NSIS_BIN}" "${DIR_NSIS_BIN}"
318         cd ..
319         rm -rf ../nsis
320         mv nsis-2.17 ../nsis
321         if get_source "${URL_NSIS_SRC}" "${DIR_NSIS_SRC}"
322         then
323                 echo Patching nsis
324                 do_patch nsis.patch
325         fi
326         echo Building nsis
327         if ../../scons/bin/scons SKIPSTUBS=all SKIPPLUGINS=all SKIPUTILS=all SKIPMISC=all \
328                 PREFIX=${DEPPKG_DIR}/nsis PREFIX_BIN=${DEPPKG_DIR}/nsis/Bin \
329                 PREFIX_CONF=${DEPPKG_DIR}/nsis PREFIX_DATA=${DEPPKG_DIR}/nsis \
330                 PREFIX_DOC=${DEPPKG_DIR}/nsis/Docs 2>&1 | tee make.log | parse_output
331         then
332                 :
333         else
334                 echo Scons failed - Check `pwd`/make.log
335                 exit 1
336         fi
337         echo Installing nsis
338         cp -p build/release/makensis/makensis ../../nsis
339 }
340
341 if [ "$#" -eq 0 ]
342 then
343         process_zlib
344         process_pcre
345         process_pthreads
346         process_openssl
347         process_mysql
348         process_sqlite
349         process_postgreSQL
350         process_wxWidgets
351         process_scons
352         process_nsis
353 else
354         for dependency in "$@"
355         do
356                 eval "process_${dependency}"
357         done
358
359 fi
360 #vss
361 #Need to download from Microsoft