From e25342da9c0aafa9df34c7b770e237572e1e0c0e Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Thu, 8 Jan 2009 10:21:15 +0000 Subject: [PATCH] ebl Add script to build w64 dependencies git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8338 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/win32/External-mingw-w64 | 68 ++++++ bacula/src/win32/build-depkgs-mingw-w64 | 267 ++++++++++++++++++++++++ 2 files changed, 335 insertions(+) create mode 100644 bacula/src/win32/External-mingw-w64 create mode 100755 bacula/src/win32/build-depkgs-mingw-w64 diff --git a/bacula/src/win32/External-mingw-w64 b/bacula/src/win32/External-mingw-w64 new file mode 100644 index 0000000000..85f906f51f --- /dev/null +++ b/bacula/src/win32/External-mingw-w64 @@ -0,0 +1,68 @@ +# +# This file provides information about the External dependencies required by +# Bacula. +# +# There are four fields delimited by |. Only the first two fields are +# required. The other two are used when the top level directory of the +# archive is not the same as the file name with any suffixes removed. +# +# Field 1 is the name of the dependency. It is used to define the +# name of the three variables which are assigned the values of fields 2 to 4. +# +# Field 2 is the URL of the archive. It is assigned to the variable +# URL_[field1]. +# +# Field 3 is the top directory of the archive or the name of a directory that +# must be created and the archive extracted into it. It is assigned to the +# variable DIR_[field1]. +# +# Field 4 indicates if the directory specified in field 3 must be created +# first and the archive extracted into it. It is assigned to the variable +# MKD_[field1] +# +#CMD_UTILS|http://www.bacula.org/depkgs-mingw32/cmd-utils-0.1.tar.gz +#DVD_RW_TOOLS|http://www.bacula.org/depkgs-mingw32/dvd+rw-tools-7.0.tar.gz +#MKISOFS|http://www.bacula.org/depkgs-mingw32/mkisofs.exe +#MT|http://www.bacula.org/depkgs-mingw32/mt-st-0.9b.tar.gz +#MTX|http://www.bacula.org/depkgs-mingw32/mtx-1.3.9.tar.gz +#MYSQL|http://www.bacula.org/depkgs-mingw32/mysql-noinstall-5.0.27-win32.zip|mysql-5.0.27-win32 +#NSIS_BIN|http://www.bacula.org/depkgs-mingw32/nsis-2.17.zip +#NSIS_SRC|http://www.bacula.org/depkgs-mingw32/nsis-2.17-src.tar.bz2 +OPENSSL|http://www.bacula.org/depkgs-mingw32/openssl-0.9.8j.tar.gz +PCRE|http://www.bacula.org/depkgs-mingw32/pcre-6.3.tar.bz2 +#POSTGRESQL|http://www.bacula.org/depkgs-mingw32/postgresql-base-8.1.4.tar.bz2|postgresql-8.1.4 +PTHREADS|http://www.bacula.org/depkgs-mingw32/pthreads-snap-2004-06-22.tar.gz +#Qt4|http://www.bacula.org/depkgs-mingw32/qt-win-opensource-src-4.3.4.zip +#SCONS|http://www.bacula.org/depkgs-mingw32/scons-0.96.92.tar.gz +#SED|http://www.bacula.org/depkgs-mingw32/sed-4.1.5.tar.gz +#SQLITE|http://www.bacula.org/depkgs-mingw32/sqlite-3.3.17.tar.gz +#STAB2CV|http://www.bacula.org/depkgs-mingw32/stab2cv-0.1.tar.bz2 +#WX|http://www.bacula.org/depkgs-mingw32/wxWidgets-2.8.7.tar.gz +ZLIB|http://www.bacula.org/depkgs-mingw32/zlib-1.2.3.tar.gz +#DB|http://www.bacula.org/depkgs-mingw32/db-4.7.25.tar.gz +# +# +# Original file locations +# +# CDRTOOLS|ftp://ftp.berlios.de/pub/cdrecord/alpha/cdrtools-2.01.01a22.tar.bz2 +# CMD_UTILS|http://superb-west.dl.sourceforge.net/sourceforge/cmd-utils/cmd-utils-0.1.tar.gz +# DVD_RW_TOOLS|http://fy.chalmers.se/~appro/linux/DVD+RW/tools/dvd+rw-tools-7.0.tar.gz +# MKISOFS|http://fy.chalmers.se/~appro/linux/DVD+RW/tools/win32/mkisofs.exe +# MT|http://www.ibiblio.org/pub/linux/system/backup/mt-st-0.9b.tar.gz +# MTX|http://superb-west.dl.sourceforge.net/sourceforge/mtx/mtx-1.3.9.tar.gz +# MYSQL|http://mirror.x10.com/mirror/mysql/Downloads/MySQL-5.0/mysql-noinstall-5.0.27-win32.zip|mysql-5.0.27-win32 +# NSIS_BIN|http://superb-west.dl.sourceforge.net/sourceforge/nsis/nsis-2.17.zip +# NSIS_SRC|http://superb-west.dl.sourceforge.net/sourceforge/nsis/nsis-2.17-src.tar.bz2 +# OPENSSL|http://www.openssl.org/source/openssl-0.9.8b.tar.gz +# PCRE|http://superb-west.dl.sourceforge.net/sourceforge/pcre/pcre-6.3.tar.bz2 +# POSTGRESQL|ftp://ftp2.us.postgresql.org/postgresql/source/v8.1.4/postgresql-base-8.1.4.tar.bz2|postgresql-8.1.4 +# PTHREADS|ftp://sources.redhat.com/pub/pthreads-win32/pthreads-snap-2004-06-22.tar.gz +# Qt4|ftp://ftp.trolltech.com/qt/source/qt-win-opensource-src-4.3.0.zip +# SCONS|http://superb-west.dl.sourceforge.net/sourceforge/scons/scons-0.96.92.tar.gz +# SED|ftp://mirrors.kernel.org/gnu/sed/sed-4.1.5.tar.gz +# SQLITE|http://www.sqlite.org/sqlite-3.3.8.tar.gz +# SQLITE|http://www.sqlite.org/sqlite-3.3.17.tar.gz +# STAB2CV|http://superb-west.dl.sourceforge.net/sourceforge/stab2cv/stab2cv-0.1.tar.bz2 +# WX|http://superb-west.dl.sourceforge.net/sourceforge/wxwindows/wxWidgets-2.7.0.tar.gz +# ZLIB|http://www.zlib.net/zlib-1.2.3.tar.gz +# DB|http://download.oracle.com/berkeley-db/db-4.7.25.tar.gz diff --git a/bacula/src/win32/build-depkgs-mingw-w64 b/bacula/src/win32/build-depkgs-mingw-w64 new file mode 100755 index 0000000000..998c28d017 --- /dev/null +++ b/bacula/src/win32/build-depkgs-mingw-w64 @@ -0,0 +1,267 @@ +#!/bin/sh +# +# This file is driven by the parameters that are defined in +# the file External-mingw-w64 +# + +usage() +{ + echo "usage: $0 [-h] [-C] [] [] ..." + echo " -h Displays this usage" + echo " -C Clobbers (overwrites) the source code by " + echo " reextracting the archive and reapplying the" + echo " patches." + echo "" + echo " Optional dependency, If none are given then all" + echo " of them will be built." + echo "" + echo "Valid dependencies are:" + grep -v '^#' < External-mingw-w64 | cut -d'|' -f1 | cut -d'_' -f1 | tr A-Z a-z | sort -u | awk '{ print " " $1 }' +} + +CLOBBER_SOURCE= + +while getopts "hHC" opt; do + case ${opt} in + H|h|\?) usage;exit 1;; + C) CLOBBER_SOURCE=true;; + esac +done + +[ ${OPTIND} -gt 1 ] && shift `expr ${OPTIND} - 1` + +cwd=`pwd` +cd `dirname $0` +SCRIPT_DIR=`pwd` + +cd ../../.. +TOP_DIR=`pwd` + +if [ -e ${TOP_DIR}/cross-tools/mingw-w64/bin/x86_64-pc-mingw32-gcc ] +then + cd ${TOP_DIR}/cross-tools/mingw-w64/bin + BIN_DIR=`pwd` +else + echo "The GCC cross compiler isn\'t installed." + echo "You must run build-win64-cross-tools first" + exit 1 +fi + +[ ! -e ${TOP_DIR}/depkgs-mingw-w64 ] && mkdir ${TOP_DIR}/depkgs-mingw-w64 +cd ${TOP_DIR}/depkgs-mingw-w64 +DEPPKG_DIR=`pwd` + +export PATH=${BIN_DIR}:${PATH} + +[ ! -e bin ] && mkdir bin +[ ! -e src ] && mkdir src +[ ! -e include ] && mkdir include +[ ! -e lib ] && mkdir lib + +OLD_IFS=${IFS};IFS="|"; +while read package url dir mkd; do + echo "Got package ${package}" + case ${package} in + \#*) ;; + *) eval "URL_${package}=${url};DIR_${package}=${dir};MKD_${package}=${mkd}";; + esac +done < ${SCRIPT_DIR}/External-mingw-w64 +IFS=${OLD_IFS};unset OLD_IFS + +get_source() +{ + URL=$1 + SRC_DIR=$2 + MAKE_DIR=$3 + echo "Processing ${URL}" + ARCHIVE=`basename ${URL}` + + case ${ARCHIVE} in + *.tar.gz) ARCHIVER="tar xzf"; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.tar\.gz'`;; + *.tar.bz2) ARCHIVER="tar xjf"; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.tar\.bz2'`;; + *.zip) ARCHIVER="unzip -q"; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.zip'`;; + *.exe) ARCHIVER=""; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.zip'`;; + *) echo Unsupported archive type - $ARCHIVE; exit 1;; + esac + + cd ${DEPPKG_DIR}/src + + if [ ! -e "${ARCHIVE}" ] + then + echo Downloading "${URL}" + if wget --passive-ftp "${URL}" + then + : + else + echo Unable to download ${ARCHIVE} + exit 1 + fi + fi + + [ -z "${ARCHIVER}" ] && return 0 + + if [ ! -e "${SRC_DIR}" -o "${CLOBBER_SOURCE}" = "true" ] + then + rm -rf ${SRC_DIR} + echo Extracting ${ARCHIVE} + if [ "${MAKE_DIR}" = "true" ] + then + mkdir ${SRC_DIR} + cd ${SRC_DIR} + ${ARCHIVER} ../${ARCHIVE} > ../${ARCHIVE}.log 2>&1 + else + ${ARCHIVER} ${ARCHIVE} > ${ARCHIVE}.log 2>&1 + cd ${SRC_DIR} + fi + return 0 + fi + + cd ${SRC_DIR} + return 1 +} + +parse_output() +{ + sed -ne '/\\$/N' -e 's/\\\n//' -e 's/\t\+/ /g' -e 's/ \+/ /g' \ + -e '/ error: /p' \ + -e "s%.*Entering directory[ ]\\+.${DEPPKG_DIR}/\\([^ ]\+\).%Entering \\1%p" \ + -e "s%.*Leaving directory[ ]\\+.${DEPPKG_DIR}/\\([^ ]\+.\).%Leaving \\1%p" \ + -e '/gcc \|g\+\+ \|ar /!d' \ + -e 's/ \(\.\.\/\)\+/ /g' \ + -e 's/.* \([^ ]\+\(\.c\|\.cpp\|\.cc\|\.cxx\)\)\( .*\|\)$/Compiling \1/p' \ + -e 's/.* \([^ ]\+\.s\)\( .*\|\)$/Assembling \1/p' \ + -e 's/.*ar [^ ]\+ \([^ ]\+\)\(\( [^ ]\+\.o\)\+\)/Updating \1 -\2/p' \ + -e 's/.* -o \([^ ]\+\)\( .*\|\)$/Linking \1/p' +} + +do_patch() +{ + PATCH_FILE=${SCRIPT_DIR}/patches/$1; shift + + if patch -f -p0 "$@" >>patch.log < ${PATCH_FILE} + then + : + else + echo "Patch failed - Check `pwd`/patch.log" > /dev/tty + exit 1 + fi +} + +do_make() +{ + if make -f "$@" 2>&1 + then + : + else + echo "Make failed - Check `pwd`/make.log" > /dev/tty + exit 1 + fi | tee -a make.log | parse_output +} + +process_zlib() +{ + if get_source "${URL_ZLIB}" "${DIR_ZLIB}" "${MKD_ZLIB}" + then + echo "Patching zlib" + >patch.log + do_patch zlib.patch + fi + echo Building zlib + > make.log + do_make win32/Makefile.mingw32 PREFIX=${DEPPKG_DIR} all + echo Installing zlib + do_make win32/Makefile.mingw32 PREFIX=${DEPPKG_DIR} install +} + +process_pcre() +{ + if get_source "${URL_PCRE}" "${DIR_PCRE}" "${MKD_PCRE}" + then + echo Patching PCRE + >patch.log + do_patch pcre.patch + echo Configuring PCRE + ./configure CC_FOR_BUILD=gcc \ + CXX_FOR_BUILD=g++ \ + --host=x86_64-pc-mingw32 \ + --prefix=${DEPPKG_DIR} \ + --enable-utf8 \ + --enable-unicode-properties >make.log 2>&1 + fi + echo Building PCRE + do_make Makefile PREFIX=${DEPPKG_DIR} all + echo Installing PCRE + do_make Makefile PREFIX=${DEPPKG_DIR} install +} + +process_db() +{ + if get_source "${URL_DB}" "${DIR_DB}" "${MKD_DB}" + then + echo No Patch + fi + cd build_unix + ../dist/configure --host=x86_64-pc-mingw32 --enable-mingw --prefix=${DEPPKG_DIR} + > make.log + echo Building DB + do_make Makefile + echo Installing DB + do_make Makefile install_setup install_include install_lib +} + +process_pthreads() +{ + if get_source "${URL_PTHREADS}" "${DIR_PTHREADS}" "${MKD_PTHREADS}" + then + echo Patching pthreads + >patch.log + do_patch pthreads-w64+bacula.patch + fi + echo Building pthreads + > make.log + do_make GNUmakefile GCE + echo Installing pthreads + rm -rf ${DEPPKG_DIR}/include/pthreads + mkdir ${DEPPKG_DIR}/include/pthreads + cp -p *.h ${DEPPKG_DIR}/include/pthreads + cp -p *.dll ${DEPPKG_DIR}/bin + cp -p *.a ${DEPPKG_DIR}/lib +} + +process_openssl() +{ + if get_source "${URL_OPENSSL}" "${DIR_OPENSSL}" "${MKD_OPENSSL}" + then + echo Patching openssl + >patch.log + do_patch openssl-w64.patch + echo Configuring openssl + ./Configure --prefix=${DEPPKG_DIR} \ + shared zlib-dynamic no-dso no-hw \ + threads \ + --with-zlib-include=${DEPPKG_DIR}/include \ + mingw64 > make.log 2>&1 + fi + echo Building openssl + perl util/mkdef.pl 32 libeay no-static-engine >ms/libeay32.def + perl util/mkdef.pl 32 ssleay >ms/ssleay32.def + perl util/mkdef.pl crypto ssl NT update + CFLAG=-I${DEPPKG_DIR}/include do_make Makefile all + echo Installing openssl + do_make Makefile install_sw +} + +if [ "$#" -eq 0 ] +then +# process_zlib +# process_pcre +# process_pthreads + process_openssl +else + for dependency in "$@" + do + eval "process_${dependency}" + done +fi +#vss +#Need to download from Microsoft -- 2.39.5