3 # This file may help you build the dependency packages that
4 # are needed to cross compile the Win64 bit version of the Bacula
5 # File daemon. This file is provided as is, and we don't guarantee
6 # that it will work. We run it only on Ubuntu Hardy. Trying to use
7 # it on any other GNU/Linux distro will probably require changes.
9 # This file is driven by the parameters that are defined in
10 # the file External-mingw-w64
15 echo "usage: $0 [-h] [-C] [<dependency 1>] [<dependency 2>] ..."
16 echo " -h Displays this usage"
17 echo " -C Clobbers (overwrites) the source code by "
18 echo " reextracting the archive and reapplying the"
21 echo "<dependency N> Optional dependency, If none are given then all"
22 echo " of them will be built."
24 echo "Valid dependencies are:"
25 grep -v '^#' < External-mingw-w64 | cut -d'|' -f1 | cut -d'_' -f1 | tr A-Z a-z | sort -u | awk '{ print " " $1 }'
30 while getopts "hHC" opt; do
32 H|h|\?) usage;exit 1;;
33 C) CLOBBER_SOURCE=true;;
37 [ ${OPTIND} -gt 1 ] && shift `expr ${OPTIND} - 1`
46 if [ -e ${TOP_DIR}/cross-tools/mingw-w64/bin/x86_64-pc-mingw32-gcc ]
48 cd ${TOP_DIR}/cross-tools/mingw-w64/bin
51 echo "The GCC cross compiler isn\'t installed."
52 echo "You must run build-win64-cross-tools first"
56 [ ! -e ${TOP_DIR}/depkgs-mingw-w64 ] && mkdir ${TOP_DIR}/depkgs-mingw-w64
57 cd ${TOP_DIR}/depkgs-mingw-w64
60 export PATH=${BIN_DIR}:${PATH}
62 [ ! -e bin ] && mkdir bin
63 [ ! -e src ] && mkdir src
64 [ ! -e include ] && mkdir include
65 [ ! -e lib ] && mkdir lib
67 OLD_IFS=${IFS};IFS="|";
68 while read package url dir mkd; do
69 echo "Got package ${package}"
72 *) eval "URL_${package}=${url};DIR_${package}=${dir};MKD_${package}=${mkd}";;
74 done < ${SCRIPT_DIR}/External-mingw-w64
75 IFS=${OLD_IFS};unset OLD_IFS
82 echo "Processing ${URL}"
83 ARCHIVE=`basename ${URL}`
86 *.tar.gz) ARCHIVER="tar xzf"; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.tar\.gz'`;;
87 *.tar.bz2) ARCHIVER="tar xjf"; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.tar\.bz2'`;;
88 *.zip) ARCHIVER="unzip -q"; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.zip'`;;
89 *.exe) ARCHIVER=""; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.zip'`;;
90 *) echo Unsupported archive type - $ARCHIVE; exit 1;;
95 if [ ! -e "${ARCHIVE}" ]
97 echo Downloading "${URL}"
98 if wget --passive-ftp "${URL}"
102 echo Unable to download ${ARCHIVE}
107 [ -z "${ARCHIVER}" ] && return 0
109 if [ ! -e "${SRC_DIR}" -o "${CLOBBER_SOURCE}" = "true" ]
112 echo Extracting ${ARCHIVE}
113 if [ "${MAKE_DIR}" = "true" ]
117 ${ARCHIVER} ../${ARCHIVE} > ../${ARCHIVE}.log 2>&1
119 ${ARCHIVER} ${ARCHIVE} > ${ARCHIVE}.log 2>&1
131 sed -ne '/\\$/N' -e 's/\\\n//' -e 's/\t\+/ /g' -e 's/ \+/ /g' \
133 -e "s%.*Entering directory[ ]\\+.${DEPPKG_DIR}/\\([^ ]\+\).%Entering \\1%p" \
134 -e "s%.*Leaving directory[ ]\\+.${DEPPKG_DIR}/\\([^ ]\+.\).%Leaving \\1%p" \
135 -e '/gcc \|g\+\+ \|ar /!d' \
136 -e 's/ \(\.\.\/\)\+/ /g' \
137 -e 's/.* \([^ ]\+\(\.c\|\.cpp\|\.cc\|\.cxx\)\)\( .*\|\)$/Compiling \1/p' \
138 -e 's/.* \([^ ]\+\.s\)\( .*\|\)$/Assembling \1/p' \
139 -e 's/.*ar [^ ]\+ \([^ ]\+\)\(\( [^ ]\+\.o\)\+\)/Updating \1 -\2/p' \
140 -e 's/.* -o \([^ ]\+\)\( .*\|\)$/Linking \1/p'
145 PATCH_FILE=${SCRIPT_DIR}/patches/$1; shift
147 if patch -f -p0 "$@" >>patch.log < ${PATCH_FILE}
151 echo "Patch failed - Check `pwd`/patch.log" > /dev/tty
162 echo "Make failed - Check `pwd`/make.log" > /dev/tty
164 fi | tee -a make.log | parse_output
169 if get_source "${URL_ZLIB}" "${DIR_ZLIB}" "${MKD_ZLIB}"
177 do_make win32/Makefile.mingw32 PREFIX=${DEPPKG_DIR} all
179 do_make win32/Makefile.mingw32 PREFIX=${DEPPKG_DIR} install
184 if get_source "${URL_PCRE}" "${DIR_PCRE}" "${MKD_PCRE}"
189 echo Configuring PCRE
190 ./configure CC_FOR_BUILD=gcc \
192 --host=x86_64-pc-mingw32 \
193 --prefix=${DEPPKG_DIR} \
195 --enable-unicode-properties >make.log 2>&1
198 do_make Makefile PREFIX=${DEPPKG_DIR} all
200 do_make Makefile PREFIX=${DEPPKG_DIR} install
205 if get_source "${URL_DB}" "${DIR_DB}" "${MKD_DB}"
210 ../dist/configure --host=x86_64-pc-mingw32 --enable-mingw --prefix=${DEPPKG_DIR}
215 do_make Makefile install_setup install_include install_lib
220 if get_source "${URL_PTHREADS}" "${DIR_PTHREADS}" "${MKD_PTHREADS}"
222 echo Patching pthreads
224 do_patch pthreads-w64.patch
226 echo Building pthreads
228 do_make GNUmakefile GCE
229 echo Installing pthreads
230 rm -rf ${DEPPKG_DIR}/include/pthreads
231 mkdir ${DEPPKG_DIR}/include/pthreads
232 cp -p *.h ${DEPPKG_DIR}/include/pthreads
233 cp -p *.dll ${DEPPKG_DIR}/bin
234 cp -p *.a ${DEPPKG_DIR}/lib
239 if get_source "${URL_OPENSSL}" "${DIR_OPENSSL}" "${MKD_OPENSSL}"
241 echo Patching openssl
243 do_patch openssl-w64.patch
244 echo Configuring openssl
245 echo ./Configure --prefix=${DEPPKG_DIR} \
246 shared zlib-dynamic no-dso no-hw \
248 --with-zlib-include=${DEPPKG_DIR}/include \
250 ./Configure --prefix=${DEPPKG_DIR} \
251 shared zlib-dynamic no-dso no-hw \
253 --with-zlib-include=${DEPPKG_DIR}/include \
254 mingw64 > make.log 2>&1
256 echo Building openssl
257 perl util/mkdef.pl 32 libeay no-static-engine >ms/libeay32.def
258 perl util/mkdef.pl 32 ssleay >ms/ssleay32.def
259 perl util/mkdef.pl crypto ssl NT update
260 sed -i 's/CC=/CC=mingw32-gcc #/' crypto/comp/Makefile
261 sed -i 's/AR=/AR=mingw32-ar r #/' crypto/comp/Makefile
262 sed -i "s:^CFLAGS=:CFLAGS= -I${DEPPKG_DIR}/include:" crypto/comp/Makefile
266 touch lib4758cca.bad libaep.bad libatalla.bad libcswift.bad libchil.bad libgmp.bad libnuron.bad libsureware.bad libubsec.bad libcapi.bad
269 echo Installing openssl
270 do_make Makefile install_sw install
271 cp *.dll ${DEPPKG_DIR}/bin
281 for dependency in "$@"
283 eval "process_${dependency}"
287 #Need to download from Microsoft