---
name: "qt"
suites:
- "precise"
architectures:
- "amd64"
packages: 
- "mingw-w64"
- "g++-mingw-w64"
- "zip"
- "unzip"
- "faketime"
reference_datetime: "2011-01-30 00:00:00"
remotes: []
files:
- "qt-everywhere-opensource-src-4.8.5.tar.gz"
- "bitcoin08-deps-win32-gitian-r12.zip"
script: |
  #
  HOST=i686-w64-mingw32
  INSTDIR="$HOME/qt/"
  # Integrity Check
  echo "eb728f8268831dc4373be6403b7dd5d5dde03c169ad6882f9a8cb560df6aa138  qt-everywhere-opensource-src-4.8.5.tar.gz"  | sha256sum -c
  #
  mkdir $INSTDIR
  mkdir -p $INSTDIR/host/bin
  #
  # Need mingw-compiled openssl from bitcoin-deps:
  unzip bitcoin08-deps-win32-gitian-r12.zip
  DEPSDIR=`pwd`
  #
  tar xzf qt-everywhere-opensource-src-4.8.5.tar.gz
  cd qt-everywhere-opensource-src-4.8.5
  sed 's/$TODAY/2011-01-30/' -i configure
  sed "s/i686-pc-mingw32-/$HOST-/" -i mkspecs/unsupported/win32-g++-cross/qmake.conf
  sed --posix "s|QMAKE_CFLAGS\t\t= -pipe|QMAKE_CFLAGS\t\t= -pipe -isystem /usr/$HOST/include/ -frandom-seed=qtbuild|" -i mkspecs/unsupported/win32-g++-cross/qmake.conf
  sed 's/QMAKE_CXXFLAGS_EXCEPTIONS_ON = -fexceptions -mthreads/QMAKE_CXXFLAGS_EXCEPTIONS_ON = -fexceptions/' -i mkspecs/unsupported/win32-g++-cross/qmake.conf
  sed 's/QMAKE_LFLAGS_EXCEPTIONS_ON = -mthreads/QMAKE_LFLAGS_EXCEPTIONS_ON = -lmingwthrd/' -i mkspecs/unsupported/win32-g++-cross/qmake.conf
  sed --posix "s/QMAKE_MOC\t\t= $HOST-moc/QMAKE_MOC\t\t= moc/" -i mkspecs/unsupported/win32-g++-cross/qmake.conf
  sed --posix "s/QMAKE_RCC\t\t= $HOST-rcc/QMAKE_RCC\t\t= rcc/" -i mkspecs/unsupported/win32-g++-cross/qmake.conf
  sed --posix "s/QMAKE_UIC\t\t= $HOST-uic/QMAKE_UIC\t\t= uic/" -i mkspecs/unsupported/win32-g++-cross/qmake.conf
  # ar adds timestamps to every object file included in the static library
  # providing -D as ar argument is supposed to solve it, but doesn't work as qmake strips off the arguments and adds -M to pass a script...
  # which somehow cannot be combined with other flags.
  # use faketime only for ar, as it confuses make/qmake into hanging sometimes
  sed --posix "s|QMAKE_LIB\t\t= $HOST-ar -ru|QMAKE_LIB\t\t= $HOME/ar -Dr|" -i mkspecs/unsupported/win32-g++-cross/qmake.conf
  echo '#!/bin/bash' > $HOME/ar
  echo 'export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1' >> $HOME/ar
  echo "$HOST-ar \"\$@\"" >> $HOME/ar
  chmod +x $HOME/ar
  #export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1
  export FAKETIME=$REFERENCE_DATETIME
  export TZ=UTC
  # Compile static libraries, and use statically linked openssl (-openssl-linked):
  OPENSSL_LIBS="-L$DEPSDIR/lib -lssl -lcrypto -lgdi32" ./configure -prefix $INSTDIR -bindir $INSTDIR/host/bin -I $DEPSDIR/include  -confirm-license -release -opensource -static -no-qt3support -xplatform unsupported/win32-g++-cross -no-multimedia -no-audio-backend -no-phonon -no-phonon-backend -no-declarative -no-script -no-scripttools -no-javascript-jit -no-webkit -no-svg -no-xmlpatterns -no-sql-sqlite -no-nis -no-cups -no-iconv -no-dbus -no-gif -no-libtiff -no-opengl -nomake examples -nomake demos -nomake docs -no-feature-style-plastique -no-feature-style-cleanlooks -no-feature-style-motif -no-feature-style-cde -no-feature-style-windowsce -no-feature-style-windowsmobile -no-feature-style-s60 -openssl-linked
  find . -name *.prl | xargs -l sed 's|/\.||' -i
  find . -name *.prl | xargs -l sed 's|/$||' -i
  make $MAKEOPTS install
  cd $INSTDIR
  find . -name *.prl | xargs -l sed 's|/$||' -i

  # as zip stores file timestamps, use faketime to intercept stat calls to set dates for all files to reference date
  export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1
  zip -r $OUTDIR/qt-win32-4.8.5-gitian-r7.zip *
