On Thu, Jul 02, 2009 at 11:04:44AM +0200, Kern Sibbald wrote:
> Eric will need to look at these points.  The only thing I remember was taking 
> the README, finding everything (which I then uploaded to the www.bacula.org 
> site), applying the patches, building, then having to fight with the VSS 
> headers for a bit because of the changes to more recent gccs that complicate 
> programmers lives.
> 
> Eric and I will be reviewing the Win64 build problems during the week of the 
> 13th.

Attached are the build scripts that I've written by trying to follow the
README.mingw file. They don't work, but it would be interesting to find out why
not. Perhaps it is something very obvious.

build-win64-cross-tools-january:
        Uses gmp-4.2.4.tar.bz2, mpfr-2.3.2.tar.bz2, binutils-2.19.tar.bz2,
        gcc-core-4.3.2.tar.bz2, gcc-g++-4.3.2.tar.bz2 and
        mingw-w64-snapshot-20081115.tar.bz2.
        It doesn't complete. It ends up with some problem where it can't
        identify various object files.

build-win64-cross-tools-july:
        This appears to build all the cross tools successfully, and uses
        mingw-w64-src-4.4.0-1.tar.bz2.
        This mingw-w64 package contains its own versions of gcc and binutils
        rather than needing you to download them separately, and contains
        detailed instructions on how to build it.

build-depkgs-mingw64
        I don't get this far with build-win64-cross-tools-january.
        When I use build-win64-cross-tools-july, I end up with a problem with
        zlib where, using openssl-0.9.8j and
        src/win32/patches/openssl-w64.patch, openssl does not understand
        --with-zlib-include=.
#!/bin/sh

BASE_DIR="$1"
if [ -z "$BASE_DIR" ] ; then
        echo "No base directory passed to $0"
        exit 1
fi

cd $BASE_DIR || exit 1
rm -rf cross-tools/mingw-w64
mkdir -p cross-tools/mingw-w64 || exit 1
cd cross-tools/mingw-w64 || exit 1
tar -xzf $BASE_DIR/cross-tools/source/w32api-3.7.tar.gz || exit 1
tar -xzf $BASE_DIR/cross-tools/source/opengl-devel.tar.gz || exit 1
tar -xzf $BASE_DIR/cross-tools/source/directx-devel.tar.gz || exit 1

echo "BUILD GMP"
cd $BASE_DIR/cross-tools/source || exit 1
tar -xjf gmp-4.2.4.tar.bz2 || exit 1
cd gmp-4.2.4 || exit 1
rm -rf build
mkdir build || exit 1
cd build || exit 1
../configure --prefix=$BASE_DIR/cross-tools/mingw-w64 || exit 1
make || exit 1
make install || exit 1

echo "BUILD MPFR"
cd $BASE_DIR/cross-tools/source || exit 1
tar -xjf mpfr-2.3.2.tar.bz2 || exit 1
cd mpfr-2.3.2 || exit 1
rm -rf build
mkdir build || exit 1
cd build || exit 1
../configure --prefix=$BASE_DIR/cross-tools/mingw-w64 \
        --with-gmp=$BASE_DIR/cross-tools/mingw-w64 || exit 1
make || exit 1
make install || exit 1

echo "BUILD BINUTILS"
cd $BASE_DIR/cross-tools/source || exit 1
tar -xjf binutils-2.19.tar.bz2 || exit 1
cd binutils-2.19 || exit 1
rm -rf build
mkdir build || exit 1
cd build || exit 1
../configure --target=x86_64-pc-mingw32 \
        --prefix=$BASE_DIR/cross-tools/mingw-w64 \
        --with-sysroot=$BASE_DIR/cross-tools/mingw-w64 \
        --disable-nls --with-gcc --with-gnu-as --with-gnu-ld --disable-gdbtk \
        --without-x --disable-shared || exit 1
make CFLAGS="-O2 -fno-exceptions" LDFLAGS="-s" all-host || exit 1
make install-host || exit 1
cd $BASE_DIR || exit 1

# copy include headers across
cd $BASE_DIR/cross-tools/source || exit 1
tar -xjf mingw-w64-snapshot-20081115.tar.bz2 || exit 1
cd $BASE_DIR || exit 1
cp -r cross-tools/source/trunk/mingw-w64-headers/include 
cross-tools/mingw-w64/x86_64-pc-mingw32/include || exit 1
ln -s x86_64-pc-mingw32 cross-tools/mingw-w64/mingw || exit 1

echo "BUILD GCC 1"
# do initial gcc build
cd $BASE_DIR/cross-tools/source || exit 1
tar -xjf gcc-core-4.3.2.tar.bz2 || exit 1
tar -xjf gcc-g++-4.3.2.tar.bz2 || exit 1
cd gcc-4.3.2 || exit 1
rm -rf build
mkdir build || exit 1
cd build || exit 1
../configure --target=x86_64-pc-mingw32 \
        --prefix=$BASE_DIR/cross-tools/mingw-w64 \
        --with-sysroot=$BASE_DIR/cross-tools/mingw-w64 \
        --with-headers=$BASE_DIR/cross-tools/mingw-w64/include \
        --with-gmp=$BASE_DIR/cross-tools/mingw-w64 \
        --with-mpfr=$BASE_DIR/cross-tools/mingw-w64 \
        --with-gcc --with-gnu-ld --with-gnu-as \
        --enable-threads --disable-nls --enable-languages=c,c++ \
        --disable-win32-registry --disable-shared --enable-sjlj-exceptions \
        --enable-libgcj --disable-java-awt --without-x --enable-java-gc=boehm \
        --disable-libgcj-debug --enable-interpreter \
        --enable-hash-synchronization --enable-libstdcxx-debug || exit 1
make all-gcc || exit 1
make install-gcc || exit 1

export 
PATH="$PATH:$BASE_DIR/cross-tools/mingw-w64/mingw:$BASE_DIR/cross-tools/mingw-w64/bin"

echo "BUILD MINGW64"
# do the mingw build
cd $BASE_DIR/cross-tools/source/trunk/mingw-w64-crt || exit 1
rm -rf build
mkdir build || exit 1
cd build || exit 1
../configure --host=x86_64-pc-mingw32 \
        --prefix=$BASE_DIR/cross-tools/mingw-w64 \
        --with-sysroot=$BASE_DIR/cross-tools/mingw-w64 || exit 1
make || exit 1
make install || exit 1
cd $BASE_DIR || exit 1

echo "BUILD GCC 2"
# do final gcc build
cd $BASE_DIR/cross-tools/source/gcc-4.3.2/build || exit 1
make CFLAGS="-O2" CXXFLAGS="-O2" GCJFLAGS="-O2" LDFLAGS="-s" DEBUG_FLAGS="-g0" 
|| exit 1
make install || exit 1

# Now the 64 bit tool chain should be complete!

# src/win32/README.mingw in bacula says that we need to do the following:
cd cross-tools/mingw-w64/bin
for i in x86_64-pc-mingw32-*
do
    ln -s $i ${i##x86_64-pc-}
done
cd -

exit 0
#!/bin/sh

BASE_DIR="$1"
if [ -z "$BASE_DIR" ] ; then
        echo "No base directory passed to $0"
        exit 1
fi

cd $BASE_DIR || exit 1
rm -rf cross-tools/mingw-w64
mkdir -p cross-tools/mingw-w64 || exit 1
cd cross-tools/mingw-w64 || exit 1
tar -xzf $BASE_DIR/cross-tools/source/w32api-3.7.tar.gz || exit 1
tar -xzf $BASE_DIR/cross-tools/source/opengl-devel.tar.gz || exit 1
tar -xzf $BASE_DIR/cross-tools/source/directx-devel.tar.gz || exit 1

cd $BASE_DIR/cross-tools/source || exit 1
tar -xjf mingw-w64-src-4.4.0-1.tar.bz2 || exit 1
cd binutils/src || exit 1
mkdir build || exit 1
cd build || exit 1
../configure --target=x86_64-pc-mingw32 \
        --prefix=$BASE_DIR/cross-tools/mingw-w64 \
        --with-sysroot=$BASE_DIR/cross-tools/mingw-w64 || exit 1
make || exit 1
make install || exit 1
cd $BASE_DIR || exit 1

# copy include headers across
cp -r cross-tools/source/mingw/mingw-w64-headers/include 
cross-tools/mingw-w64/x86_64-pc-mingw32/include || exit 1
ln -s x86_64-pc-mingw32 cross-tools/mingw-w64/mingw || exit 1

# do initial gcc build
cd cross-tools/source/gcc/gcc || exit 1
mkdir build || exit 1
cd build || exit 1
../configure --target=x86_64-pc-mingw32 \
        --prefix=$BASE_DIR/cross-tools/mingw-w64 \
        --with-sysroot=$BASE_DIR/cross-tools/mingw-w64 || exit 1
make all-gcc || exit 1
make install-gcc || exit 1
cd $BASE_DIR || exit 1

# do the crt build
orig_path="$PATH"
export 
PATH="$orig_path:$BASE_DIR/cross-tools/mingw-w64/mingw:$BASE_DIR/cross-tools/mingw-w64/bin"
cd cross-tools/source/mingw/mingw-w64-crt || exit 1
mkdir build || exit 1
cd build || exit 1
../configure --host=x86_64-pc-mingw32 \
        --prefix=$BASE_DIR/cross-tools/mingw-w64 \
        --with-sysroot=$BASE_DIR/cross-tools/mingw-w64 || exit 1
make || exit 1
make install || exit 1
cd $BASE_DIR || exit 1

# do the final gcc build
cd cross-tools/source/gcc/gcc/build || exit 1
make || exit 1
make install || exit 1
cd $BASE_DIR || exit 1

# Reset the PATH, just in case.
export PATH="$orig_path"

# Now the 64 bit tool chain should be complete!

# src/win32/README.mingw in bacula says that we need to do the following:
cd cross-tools/mingw-w64/bin
for i in x86_64-pc-mingw32-*
do
    ln -s $i ${i##x86_64-pc-}
done
cd -

exit 0
#!/bin/sh
#
#  This file is driven by the parameters that are defined in
#    the file External-mingw-w64
#

usage()
{
   echo "usage: $0 [-h] [-C] [<dependency 1>] [<dependency 2>] ..."
   echo "       -h      Displays this usage"
   echo "       -C      Clobbers (overwrites) the source code by "
   echo "               reextracting the archive and reapplying the"
   echo "               patches."
   echo ""
   echo "<dependency N> 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/mingw32-gcc ]
then
   cd ${TOP_DIR}/cross-tools/mingw-w64/bin
   BIN_DIR=`pwd`
elif [ -e /mingw/bin/mingw32-gcc ] 
then
   BIN_DIR=/mingw/bin
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}
env

[ ! -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 No ${ARCHIVE}
      exit 1
      #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-linux --target=x86_64-pc-mingw32 \
                       --prefix=${DEPPKG_DIR} \
                       --enable-utf8 \
                       --enable-unicode-properties >make.log 2>&1 || exit 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-linux --target=x86_64-pc-mingw32 
--enable-mingw --prefix=${DEPPKG_DIR} || exit 1
   > 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.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 \
                       threads \
                       mingw64 > make.log 2>&1
                       #zlib-dynamic \
                       #--with-zlib-include=${DEPPKG_DIR}/include \

   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
   do_make Makefile all
   echo Installing openssl
   do_make Makefile install_sw
}


process_stab2cv()
{
   if get_source "${URL_STAB2CV}" "${DIR_STAB2CV}" "${MKD_STAB2CV}"
   then
           # echo Patching stab2cv
           # >patch.log
           # do_patch stab2cv.patch
           echo Configuring stab2cv
           ./configure --prefix=${DEPPKG_DIR}/tools \
                --host=x86_64-pc-linux --target=x86_64-pc-mingw32 \
                >make.log 2>&1
   fi
   echo Building stab2cv
   do_make Makefile
   echo Installing stab2cv
   do_make Makefile install
}

process_scons()
{
   get_source "${URL_SCONS}" "${DIR_SCONS}" "${MKD_SCONS}"
   echo "Installing scons"
   if python setup.py install --prefix=${DEPPKG_DIR}/scons > make.log 2>&1
   then
           :
   else
           echo "Make failed - Check `pwd`/make.log"
           exit 1
   fi
}

process_nsis()
{
   get_source "${URL_NSIS_BIN}" "${DIR_NSIS_BIN}" "${MKD_NSIS_BIN}"
   cd ..
   rm -rf ../nsis
   mv nsis-2.17 ../nsis
   if get_source "${URL_NSIS_SRC}" "${DIR_NSIS_SRC}" "${MKD_NSIS_SRC}"
   then
           echo "Patching nsis"
           >patch.log
           do_patch nsis.patch
   fi
   echo "Building nsis"
   if ../../scons/bin/scons SKIPSTUBS=all SKIPPLUGINS=all SKIPUTILS=all 
SKIPMISC=all NSIS_CONFIG_LOG=yes \
           PREFIX=${DEPPKG_DIR}/nsis PREFIX_BIN=${DEPPKG_DIR}/nsis/Bin \
           PREFIX_CONF=${DEPPKG_DIR}/nsis PREFIX_DATA=${DEPPKG_DIR}/nsis \
           PREFIX_DOC=${DEPPKG_DIR}/nsis/Docs 2>&1 | tee make.log | parse_output
   then
           :
   else
           echo "Scons failed - Check `pwd`/make.log"
           exit 1
   fi
   echo "Installing nsis"
   cp -p build/release/makensis/makensis ../../nsis
}

process_sed()
{
   if get_source "${URL_SED}" "${DIR_SED}" "${MKD_SED}"
   then
           echo Patching sed
           >patch.log
           do_patch sed.patch
           echo Configuring sed
           ./configure --host=x86_64-pc-linux --target=x86_64-pc-mingw32 \
                       --prefix=${DEPPKG_DIR} \
                       --disable-nls >make.log 2>&1
   fi
   echo Building sed
   do_make Makefile all
   echo Installing sed
   do_make Makefile install
}

process_cmd_utils()
{
   if get_source "${URL_CMD_UTILS}" "${DIR_CMD_UTILS}" "${MKD_CMD_UTILS}"
   then
           # echo Patching cmd-utils
           # >patch.log
           # do_patch cmd-utils.patch
           echo Configuring cmd-utils
           ./configure --host=x86_64-pc-linux --target=x86_64-pc-mingw32 \
                       --prefix=${DEPPKG_DIR} \
                       >make.log 2>&1
   fi
   echo Building cmd-utils
   do_make Makefile
   echo Installing cmd-utils
   do_make Makefile install
}

process_curl()
{
        if get_source "${URL_CURL}" "${DIR_CURL}" "${MKD_CURL}"
        then
                # echo Patching curl
                # >patch.log
                # do_patch curl.patch
                echo Configuring curl
                ./configure --host=x86_64-pc-linux --target=x86_64-pc-mingw32 \
                            --with-ssl=${DEPPKG_DIR} \
                            --prefix=${DEPPKG_DIR} \
                            --disable-shared \
                            --with-random=/dev/urandom \
                            >make.log 2>&1 || exit 1
        fi
        echo Building libcurl
        cd lib
        do_make Makefile.m32 mingw32-ssl-zlib SSL=1
        echo Building libcurl
        cd ../src
        do_make Makefile.m32 mingw32-ssl-zlib SSL=1
        echo Installing curl
        cd ..
        do_make Makefile install
}

if [ "$#" -eq 0 ]
then
   process_zlib
   process_pcre
   process_pthreads
   process_openssl
   process_stab2cv
   process_scons
   process_nsis
   process_sed
   process_cmd_utils
   process_curl
else
   for dependency in "$@"
   do
      eval "process_${dependency}"
   done
fi
#vss
#Need to download from Microsoft
------------------------------------------------------------------------------
_______________________________________________
Bacula-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bacula-devel

Reply via email to