3 # This file is driven by the parameters that are defined in
4 # the file External-mingw-w64
9 echo "usage: $0 [-h] [-C] [<dependency 1>] [<dependency 2>] ..."
10 echo " -h Displays this usage"
11 echo " -C Clobbers (overwrites) the source code by "
12 echo " reextracting the archive and reapplying the"
15 echo "<dependency N> Optional dependency, If none are given then all"
16 echo " of them will be built."
18 echo "Valid dependencies are:"
19 grep -v '^#' < External-mingw-w64 | cut -d'|' -f1 | cut -d'_' -f1 | tr A-Z a-z | sort -u | awk '{ print " " $1 }'
24 while getopts "hHC" opt; do
26 H|h|\?) usage;exit 1;;
27 C) CLOBBER_SOURCE=true;;
31 [ ${OPTIND} -gt 1 ] && shift `expr ${OPTIND} - 1`
40 if [ -e ${TOP_DIR}/cross-tools/mingw-w64/bin/x86_64-pc-mingw32-gcc ]
42 cd ${TOP_DIR}/cross-tools/mingw-w64/bin
45 echo "The GCC cross compiler isn\'t installed."
46 echo "You must run build-win64-cross-tools first"
50 [ ! -e ${TOP_DIR}/depkgs-mingw-w64 ] && mkdir ${TOP_DIR}/depkgs-mingw-w64
51 cd ${TOP_DIR}/depkgs-mingw-w64
54 export PATH=${BIN_DIR}:${PATH}
56 [ ! -e bin ] && mkdir bin
57 [ ! -e src ] && mkdir src
58 [ ! -e include ] && mkdir include
59 [ ! -e lib ] && mkdir lib
61 OLD_IFS=${IFS};IFS="|";
62 while read package url dir mkd; do
63 echo "Got package ${package}"
66 *) eval "URL_${package}=${url};DIR_${package}=${dir};MKD_${package}=${mkd}";;
68 done < ${SCRIPT_DIR}/External-mingw-w64
69 IFS=${OLD_IFS};unset OLD_IFS
76 echo "Processing ${URL}"
77 ARCHIVE=`basename ${URL}`
80 *.tar.gz) ARCHIVER="tar xzf"; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.tar\.gz'`;;
81 *.tar.bz2) ARCHIVER="tar xjf"; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.tar\.bz2'`;;
82 *.zip) ARCHIVER="unzip -q"; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.zip'`;;
83 *.exe) ARCHIVER=""; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.zip'`;;
84 *) echo Unsupported archive type - $ARCHIVE; exit 1;;
89 if [ ! -e "${ARCHIVE}" ]
91 echo Downloading "${URL}"
92 if wget --passive-ftp "${URL}"
96 echo Unable to download ${ARCHIVE}
101 [ -z "${ARCHIVER}" ] && return 0
103 if [ ! -e "${SRC_DIR}" -o "${CLOBBER_SOURCE}" = "true" ]
106 echo Extracting ${ARCHIVE}
107 if [ "${MAKE_DIR}" = "true" ]
111 ${ARCHIVER} ../${ARCHIVE} > ../${ARCHIVE}.log 2>&1
113 ${ARCHIVER} ${ARCHIVE} > ${ARCHIVE}.log 2>&1
125 sed -ne '/\\$/N' -e 's/\\\n//' -e 's/\t\+/ /g' -e 's/ \+/ /g' \
127 -e "s%.*Entering directory[ ]\\+.${DEPPKG_DIR}/\\([^ ]\+\).%Entering \\1%p" \
128 -e "s%.*Leaving directory[ ]\\+.${DEPPKG_DIR}/\\([^ ]\+.\).%Leaving \\1%p" \
129 -e '/gcc \|g\+\+ \|ar /!d' \
130 -e 's/ \(\.\.\/\)\+/ /g' \
131 -e 's/.* \([^ ]\+\(\.c\|\.cpp\|\.cc\|\.cxx\)\)\( .*\|\)$/Compiling \1/p' \
132 -e 's/.* \([^ ]\+\.s\)\( .*\|\)$/Assembling \1/p' \
133 -e 's/.*ar [^ ]\+ \([^ ]\+\)\(\( [^ ]\+\.o\)\+\)/Updating \1 -\2/p' \
134 -e 's/.* -o \([^ ]\+\)\( .*\|\)$/Linking \1/p'
139 PATCH_FILE=${SCRIPT_DIR}/patches/$1; shift
141 if patch -f -p0 "$@" >>patch.log < ${PATCH_FILE}
145 echo "Patch failed - Check `pwd`/patch.log" > /dev/tty
156 echo "Make failed - Check `pwd`/make.log" > /dev/tty
158 fi | tee -a make.log | parse_output
163 if get_source "${URL_ZLIB}" "${DIR_ZLIB}" "${MKD_ZLIB}"
171 do_make win32/Makefile.mingw32 PREFIX=${DEPPKG_DIR} all
173 do_make win32/Makefile.mingw32 PREFIX=${DEPPKG_DIR} install
178 if get_source "${URL_PCRE}" "${DIR_PCRE}" "${MKD_PCRE}"
183 echo Configuring PCRE
184 ./configure CC_FOR_BUILD=gcc \
186 --host=x86_64-pc-mingw32 \
187 --prefix=${DEPPKG_DIR} \
189 --enable-unicode-properties >make.log 2>&1
192 do_make Makefile PREFIX=${DEPPKG_DIR} all
194 do_make Makefile PREFIX=${DEPPKG_DIR} install
199 if get_source "${URL_DB}" "${DIR_DB}" "${MKD_DB}"
204 ../dist/configure --host=x86_64-pc-mingw32 --enable-mingw --prefix=${DEPPKG_DIR}
209 do_make Makefile install_setup install_include install_lib
214 if get_source "${URL_PTHREADS}" "${DIR_PTHREADS}" "${MKD_PTHREADS}"
216 echo Patching pthreads
218 do_patch pthreads-w64+bacula.patch
220 echo Building pthreads
222 do_make GNUmakefile GCE
223 echo Installing pthreads
224 rm -rf ${DEPPKG_DIR}/include/pthreads
225 mkdir ${DEPPKG_DIR}/include/pthreads
226 cp -p *.h ${DEPPKG_DIR}/include/pthreads
227 cp -p *.dll ${DEPPKG_DIR}/bin
228 cp -p *.a ${DEPPKG_DIR}/lib
233 if get_source "${URL_OPENSSL}" "${DIR_OPENSSL}" "${MKD_OPENSSL}"
235 echo Patching openssl
237 do_patch openssl-w64.patch
238 echo Configuring openssl
239 ./Configure --prefix=${DEPPKG_DIR} \
240 shared zlib-dynamic no-dso no-hw \
242 --with-zlib-include=${DEPPKG_DIR}/include \
243 mingw64 > make.log 2>&1
245 echo Building openssl
246 perl util/mkdef.pl 32 libeay no-static-engine >ms/libeay32.def
247 perl util/mkdef.pl 32 ssleay >ms/ssleay32.def
248 perl util/mkdef.pl crypto ssl NT update
249 CFLAG=-I${DEPPKG_DIR}/include do_make Makefile all
250 echo Installing openssl
251 do_make Makefile install_sw
261 for dependency in "$@"
263 eval "process_${dependency}"
267 #Need to download from Microsoft