1#!/bin/sh
2#
3# Copyright (C) 2000-2018 Kern Sibbald
4# License: BSD 2-Clause; see file LICENSE-FOSS
5#
6#
7#  This file is driven by the parameters that are defined in
8#    the file External-mingw32
9#
10
11usage()
12{
13   echo "usage: $0 [-h] [-C] [<dependency 1>] [<dependency 2>] ..."
14   echo "       -h      Displays this usage"
15   echo "       -C      Clobbers (overwrites) the source code by "
16   echo "               reextracting the archive and reapplying the"
17   echo "               patches."
18   echo "       -A      Rebuild everything (wipes out most of depkgs)"
19   echo ""
20   echo "<dependency N> Optional dependency, If none are given then all"
21   echo "               of them will be built."
22   echo ""
23   echo "Valid dependencies are:"
24   grep -v '^#' < External-mingw32 | cut -d'|' -f1 | cut -d'_' -f1 | tr A-Z a-z | sort -u | awk '{ print "        " $1 }'
25}
26
27CLOBBER_SOURCE=
28CLOBBER_ALL=
29
30while getopts "hHCA" opt; do
31   case ${opt} in
32   H|h|\?) usage;exit 1;;
33   C)      CLOBBER_SOURCE=true;;
34   A)      CLOBBER_ALL=true;;
35   esac
36done
37
38[ ${OPTIND} -gt 1 ] && shift `expr ${OPTIND} - 1`
39
40cwd=`pwd`
41cd `dirname $0`
42SCRIPT_DIR=`pwd`
43
44cd ../../..
45TOP_DIR=`pwd`
46TOP_DIR=${DEPKGS:-${TOP_DIR}}
47
48if [ -e ${TOP_DIR}/cross-tools/mingw32/bin/mingw32-gcc ]; then
49   cd ${TOP_DIR}/cross-tools/mingw32/bin
50   BIN_DIR=`pwd`
51   BASE=mingw32
52elif [ -e /mingw/bin/mingw32-gcc ]; then
53   BIN_DIR=/mingw/bin
54   BASE=mingw32
55
56elif which i686-w64-mingw32-gcc > /dev/null; then
57   BIN_DIR=
58   BASE=i686-w64-mingw32
59
60else
61   echo "The GCC cross compiler is not installed."
62   echo "You must run build-win32-cross-tools first"
63   exit 1
64fi
65
66[ ! -e ${TOP_DIR}/depkgs-mingw32 ] && mkdir ${TOP_DIR}/depkgs-mingw32
67cd ${TOP_DIR}/depkgs-mingw32
68DEPPKG_DIR=`pwd`
69
70if [ "${CLOBBER_ALL}" = "true" ]
71then
72   echo "Clobbering ${DEPPKG_DIR}"
73   echo "rm -rf bin include info lib man qt-out/ share src tools"
74   rm -rf bin include info lib man qt-out/ share src tools
75fi
76
77export PATH=${BIN_DIR}:${PATH}
78
79[ ! -e bin ] && mkdir bin
80[ ! -e src ] && mkdir src
81[ ! -e include ] && mkdir include
82[ ! -e lib ] && mkdir lib
83
84OLD_IFS=${IFS};IFS="|";
85while read package url dir mkd; do
86#  echo "Got package ${package}"
87   case ${package} in
88   \#*) ;;
89   *) eval "URL_${package}=${url};DIR_${package}=${dir};MKD_${package}=${mkd}";;
90        esac
91done < ${SCRIPT_DIR}/External-mingw32
92IFS=${OLD_IFS};unset OLD_IFS
93
94
95get_source()
96{
97   URL=$1
98   SRC_DIR=$2
99   MAKE_DIR=$3
100   echo "Processing ${URL}"
101   ARCHIVE=`basename ${URL}`
102
103   case ${ARCHIVE} in
104   *.tar.gz)       ARCHIVER="tar xzf";    [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.tar\.gz'`;;
105   *.tar.bz2)      ARCHIVER="tar xjf";    [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.tar\.bz2'`;;
106   *.zip)          ARCHIVER="unzip -q";   [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.zip'`;;
107   *.exe)          ARCHIVER="";           [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.zip'`;;
108   *.xz)       ARCHIVER="tar xf";    [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.tar\.xz'`;;
109   *)              echo Unsupported archive type - $ARCHIVE; exit 1;;
110   esac
111
112   cd ${DEPPKG_DIR}/src
113
114   if [ ! -e "${ARCHIVE}" ]
115   then
116      echo Downloading "${URL}"
117      if wget --passive-ftp "${URL}"
118      then
119         :
120      else
121         echo Unable to download ${ARCHIVE}
122         exit 1
123      fi
124   fi
125
126   [ -z "${ARCHIVER}" ] && return 0
127
128   if [ ! -e "${SRC_DIR}" -o "${CLOBBER_SOURCE}" = "true" ]
129   then
130      rm -rf ${SRC_DIR}
131      echo Extracting ${ARCHIVE}
132      if [ "${MAKE_DIR}" = "true" ]
133      then
134         mkdir ${SRC_DIR}
135         cd ${SRC_DIR}
136         ${ARCHIVER} ../${ARCHIVE} > ../${ARCHIVE}.log 2>&1
137      else
138         ${ARCHIVER} ${ARCHIVE} > ${ARCHIVE}.log 2>&1
139         cd ${SRC_DIR}
140      fi
141      return 0
142   fi
143
144   cd ${SRC_DIR}
145   return 1
146}
147
148parse_output()
149{
150   sed -ne '/\\$/N' -e 's/\\\n//' -e 's/\t\+/ /g' -e 's/ \+/ /g' \
151       -e '/ error: /p' \
152       -e "s%.*Entering directory[ ]\\+.${DEPPKG_DIR}/\\([^ ]\+\).%Entering \\1%p" \
153       -e "s%.*Leaving directory[ ]\\+.${DEPPKG_DIR}/\\([^ ]\+.\).%Leaving \\1%p" \
154       -e '/gcc \|g\+\+ \|ar /!d' \
155       -e 's/ \(\.\.\/\)\+/ /g' \
156       -e 's/.* \([^ ]\+\(\.c\|\.cpp\|\.cc\|\.cxx\)\)\( .*\|\)$/Compiling \1/p' \
157       -e 's/.* \([^ ]\+\.s\)\( .*\|\)$/Assembling \1/p' \
158       -e 's/.*ar [^ ]\+ \([^ ]\+\)\(\( [^ ]\+\.o\)\+\)/Updating \1 -\2/p' \
159       -e 's/.* -o \([^ ]\+\)\( .*\|\)$/Linking \1/p'
160}
161
162do_patch()
163{
164   PATCH_FILE=${SCRIPT_DIR}/patches/$1; shift
165
166   if patch -f -p0 "$@" >>patch.log < ${PATCH_FILE}
167   then
168      :
169   else
170      echo "Patch failed - Check `pwd`/patch.log" > /dev/tty
171      exit 1
172   fi
173}
174
175do_make()
176{
177   if make -f "$@" 2>&1
178   then
179      :
180   else
181      echo "Make failed - Check `pwd`/make.log" > /dev/tty
182      exit 1
183   fi | tee -a make.log | parse_output
184}
185
186process_lzo()
187{
188   if get_source "${URL_LZO}" "${DIR_LZO}" "${MKD_LZO}"
189   then
190       true
191   fi
192   echo Building lzo
193   ./configure --host=$BASE --prefix=${DEPPKG_DIR}/
194   echo Installing lzo
195   do_make Makefile  PREFIX=${DEPPKG_DIR}/ all
196   do_make Makefile  PREFIX=${DEPPKG_DIR}/ install
197}
198
199process_zlib()
200{
201   if get_source "${URL_ZLIB}" "${DIR_ZLIB}" "${MKD_ZLIB}"
202   then
203        true
204   fi
205   echo Building zlib
206   > make.log
207   do_make win32/Makefile.gcc PREFIX=${BASE}-  DESTDIR=${DEPPKG_DIR}/ all
208   echo Installing zlib
209   do_make win32/Makefile.gcc PREFIX=${BASE}-  DESTDIR=${DEPPKG_DIR}/ LIBRARY_PATH=lib BINARY_PATH=bin INCLUDE_PATH=include SHARED_MODE=1 install
210}
211
212
213process_pcre()
214{
215   if get_source "${URL_PCRE}" "${DIR_PCRE}" "${MKD_PCRE}"
216   then
217           echo Patching PCRE
218           >patch.log
219           do_patch pcre.patch
220           echo Configuring PCRE
221           ./configure CC_FOR_BUILD=gcc \
222                       CXX_FOR_BUILD=g++ \
223                       --host=$BASE \
224                       --prefix=${DEPPKG_DIR} \
225                       --enable-utf8 \
226                       --enable-unicode-properties >make.log 2>&1
227   fi
228   echo Building PCRE
229   do_make Makefile PREFIX=${DEPPKG_DIR} all
230   echo Installing PCRE
231   do_make Makefile PREFIX=${DEPPKG_DIR} install
232}
233
234process_db()
235{
236   if get_source "${URL_DB}" "${DIR_DB}" "${MKD_DB}"
237   then
238          echo No Patch
239   fi
240   cd build_unix
241   ../dist/configure --host=$BASE --enable-mingw --prefix=${DEPPKG_DIR}
242   > make.log
243   echo Building DB
244   do_make Makefile
245   echo Installing DB
246   do_make Makefile install_setup install_include install_lib
247}
248
249process_pthreads()
250{
251   if get_source "${URL_PTHREADS}" "${DIR_PTHREADS}" "${MKD_PTHREADS}"
252   then
253      sed -i '140 s/INLINE//' pthread_mutex_consistent.c
254   fi
255   echo Building pthreads
256   > make.log
257   do_make GNUmakefile CROSS=${BASE}- clean GCE
258   echo Installing pthreads
259   rm -rf ${DEPPKG_DIR}/include/pthreads
260   mkdir ${DEPPKG_DIR}/include/pthreads
261   cp -p *.h ${DEPPKG_DIR}/include/pthreads
262   cp -p *.dll ${DEPPKG_DIR}/bin
263   cp -p *.a ${DEPPKG_DIR}/lib
264}
265
266process_openssl()
267{
268   if get_source "${URL_OPENSSL}" "${DIR_OPENSSL}" "${MKD_OPENSSL}"
269   then
270        true
271   fi
272   echo Configuring openssl
273   CROSS_COMPILE=${BASE}- ./Configure --prefix=${DEPPKG_DIR} \
274                       shared zlib-dynamic \
275                       threads \
276                       --with-zlib-include=${DEPPKG_DIR}/include \
277                       mingw > make.log 2>&1
278   do_make Makefile all
279   echo Installing openssl
280   do_make Makefile install_sw
281   mkdir -p ${DEPPKG_DIR}/ssl
282   cp -f apps/openssl.cnf ${DEPPKG_DIR}/ssl
283}
284
285process_mysql()
286{
287   get_source "${URL_MYSQL}" "${DIR_MYSQL}" "${DIR_MYSQL}" "${MKD_MYSQL}"
288   echo Converting mysql lib file
289   if [ -e ${BIN_DIR}/reimp ]
290   then
291           reimp --dlltool ${BIN_DIR}/${BASE}-dlltool --as ${BIN_DIR}/${BASE}-as lib/opt/libmysql.lib
292   else
293           ${BIN_DIR}/../mingw32/bin/reimp --dlltool ${BIN_DIR}/${BASE}-dlltool --as ${BIN_DIR}/${BASE}-as lib/opt/libmysql.lib
294   fi
295   echo Installing mysql
296   cp -p liblibmysql.a ../../lib/libmysql.a
297   rm -rf ../../include/mysql
298   mkdir ../../include/mysql
299   cp -p include/* ../../include/mysql 2>&1 | grep -v 'omitting directory'
300   cp -p lib/opt/libmysql.dll ../../bin
301}
302
303process_postgresql()
304{
305   if get_source "${URL_POSTGRESQL}" "${DIR_POSTGRESQL}" "${MKD_POSTGRESQL}"
306   then
307           echo Patching postgreSQL
308           >patch.log
309           do_patch postgresql.patch
310
311           # We need a native version of zic to build the timezone tables.
312           echo Configuring postgreSQL to build native zic
313           ./configure > make.log 2>&1
314
315           echo Building native zic
316           cd src/timezone
317           do_make Makefile >> make.log 2>&1
318           cp zic ../..
319           cd ../..
320           do_make GNUmakefile distclean >> make.log 2>&1
321
322           echo Configuring postgreSQL for MinGW32
323
324           ./configure --host=$BASE \
325                       --enable-shared \
326                       --enable-thread-safety \
327                       --prefix=${DEPPKG_DIR} \
328                       --with-includes=${DEPPKG_DIR}/include:${DEPPKG_DIR}/include/pthreads \
329                       --with-libraries=${DEPPKG_DIR}/lib >> make.log 2>&1
330   fi
331   echo Building postgreSQL
332   ZIC=`pwd`/zic
333   do_make GNUmakefile AR=$BASE-ar DLLTOOL=$BASE-dlltool DLLWRAP=$BASE-dllwrap WINDRES=$BASE-windres PTHREAD_LIBS=-lpthreadGCE ZIC=${ZIC}
334   echo Installing postgreSQL
335   do_make GNUmakefile AR=$BASE-ar DLLTOOL=$BASE-dlltool DLLWRAP=$BASE-dllwrap WINDRES=$BASE-windres PTHREAD_LIBS=-lpthreadGCE ZIC=${ZIC} install
336}
337
338process_sqlite()
339{
340   if get_source "${URL_SQLITE}" "${DIR_SQLITE}" "${MKD_SQLITE}"
341   then
342           echo Patching SQLite
343           >patch.log
344           do_patch sqlite.patch
345   fi
346   echo Building SQLite
347   [ ! -e bld ] && mkdir bld
348   cd bld
349   > make.log
350   do_make ../Makefile.mingw32 CROSSTOOLS=${BIN_DIR} TLIBS="-L${DEPPKG_DIR}/lib" TCL_FLAGS="-I${DEPPKG_DIR}/include"
351   echo Installing SQLite
352   cp -p sqlite3.exe ${DEPPKG_DIR}/bin
353   cp -p libsqlite3.a ${DEPPKG_DIR}/lib
354   cp -p sqlite3.h ${DEPPKG_DIR}/include
355}
356
357process_wx()
358{
359   if get_source "${URL_WX}" "${DIR_WX}" "${MKD_WX}"
360   then
361      echo Patching wxWidgets
362      >patch.log
363      cp build/msw/config.gcc build/msw/config.mingw32
364      do_patch wxWidgets.patch
365      find . -name makefile.gcc -exec sh -c "sed -f ${SCRIPT_DIR}/patches/wx.sed {} > \`echo {} | sed -e 's/\.gcc$/\.mingw32/'\`" \;
366   fi
367   echo Building wxWidgets
368   cd build/msw
369   > make.log
370   do_make makefile.mingw32 SHARED=1 VENDOR=bacula DEBUG_INFO=1
371   echo Installing wxWidgets
372   cd ../..
373   rm -rf ../../include/wx
374   mkdir ../../include/wx
375   cp -p include/wx/* ../../include/wx 2>&1 | grep -v 'omitting directory'
376   mkdir ../../include/wx/generic
377   cp -p include/wx/generic/* ../../include/wx/generic 2>&1 | grep -v 'omitting directory'
378   mkdir ../../include/wx/msw
379   cp -p include/wx/msw/* ../../include/wx/msw 2>&1 | grep -v 'omitting directory'
380   mkdir ../../include/wx/msw/ole
381   cp -p include/wx/msw/ole/* ../../include/wx/msw/ole 2>&1 | grep -v 'omitting directory'
382   cp -p lib/gcc_dll/*.dll ../../bin
383   rm -rf ../../lib/wx_dll
384   mkdir ../../lib/wx_dll
385   cp -p lib/gcc_dll/*.a ../../lib/wx_dll
386   mkdir ../../lib/wx_dll/msw
387   cp -p lib/gcc_dll/msw/* ../../lib/wx_dll/msw 2>&1 | grep -v 'omitting directory'
388   mkdir ../../lib/wx_dll/msw/wx
389   cp -p lib/gcc_dll/msw/wx/* ../../lib/wx_dll/msw/wx 2>&1 | grep -v 'omitting directory'
390   mkdir ../../lib/wx_dll/msw/wx/msw
391   cp -p lib/gcc_dll/msw/wx/msw/* ../../lib/wx_dll/msw/wx/msw 2>&1 | grep -v 'omitting directory'
392}
393
394process_scons()
395{
396   get_source "${URL_SCONS}" "${DIR_SCONS}" "${MKD_SCONS}"
397   echo "Installing scons"
398   if python setup.py install --prefix=${DEPPKG_DIR}/scons > make.log 2>&1
399   then
400           :
401   else
402           echo "Make failed - Check `pwd`/make.log"
403           exit 1
404   fi
405}
406
407process_nsis()
408{
409   get_source "${URL_NSIS_BIN}" "${DIR_NSIS_BIN}" "${MKD_NSIS_BIN}"
410   cd ..
411   rm -rf ../nsis
412   mv nsis-2.17 ../nsis
413   if get_source "${URL_NSIS_SRC}" "${DIR_NSIS_SRC}" "${MKD_NSIS_SRC}"
414   then
415           echo "Patching nsis"
416           >patch.log
417           do_patch nsis.patch
418   fi
419   echo "Building nsis"
420   if ../../scons/bin/scons SKIPSTUBS=all SKIPPLUGINS=all SKIPUTILS=all SKIPMISC=all \
421           PREFIX=${DEPPKG_DIR}/nsis PREFIX_BIN=${DEPPKG_DIR}/nsis/Bin \
422           PREFIX_CONF=${DEPPKG_DIR}/nsis PREFIX_DATA=${DEPPKG_DIR}/nsis \
423           PREFIX_DOC=${DEPPKG_DIR}/nsis/Docs 2>&1 | tee make.log | parse_output
424   then
425           :
426   else
427           echo "Scons failed - Check `pwd`/make.log"
428           exit 1
429   fi
430   echo "Installing nsis"
431   cp -p build/release/makensis/makensis ../../nsis
432}
433
434process_mtx()
435{
436   if get_source "${URL_MTX}" "${DIR_MTX}" "${MKD_MTX}"
437   then
438           echo Patching mtx
439           # We can't run configure in a cross-compile environment so we
440           # patch the files to the correct values
441           cp -f config.h.in config.h
442           cp -f Makefile.in Makefile
443           rm -f configure
444           >patch.log
445           do_patch mtx.patch
446   fi
447   echo Building mtx
448   do_make Makefile prefix=${DEPPKG_DIR} all
449   echo Installing mtx
450   do_make Makefile prefix=${DEPPKG_DIR} install
451}
452
453process_mt()
454{
455   if get_source "${URL_MT}" "${DIR_MT}" "${MKD_MT}"
456   then
457           echo "Patching mt"
458           >patch.log
459           do_patch mt.patch
460   fi
461   echo "Building mt"
462   do_make Makefile PREFIX=${DEPPKG_DIR} all
463   echo Installing mt
464   do_make Makefile PREFIX=${DEPPKG_DIR} install
465}
466
467process_sed()
468{
469   if get_source "${URL_SED}" "${DIR_SED}" "${MKD_SED}"
470   then
471           echo Patching sed
472           >patch.log
473           do_patch sed.patch
474           echo Configuring sed
475           ./configure --host=$BASE \
476                       --prefix=${DEPPKG_DIR} \
477                       --disable-nls >make.log 2>&1
478   fi
479   echo Building sed
480   do_make Makefile all
481   echo Installing sed
482   do_make Makefile install
483}
484
485process_stab2cv()
486{
487   if get_source "${URL_STAB2CV}" "${DIR_STAB2CV}" "${MKD_STAB2CV}"
488   then
489           echo Patching stab2cv
490           >patch.log
491           do_patch stab2cv.patch
492           echo Configuring stab2cv
493           ./configure --prefix=${DEPPKG_DIR}/tools \
494                       >make.log 2>&1
495   fi
496   echo Building stab2cv
497   do_make Makefile
498   echo Installing stab2cv
499   do_make Makefile install
500}
501
502process_cmd_utils()
503{
504   if get_source "${URL_CMD_UTILS}" "${DIR_CMD_UTILS}" "${MKD_CMD_UTILS}"
505   then
506           # echo Patching cmd-utils
507           # >patch.log
508           # do_patch cmd-utils.patch
509           sed -i "s:strrchr:NULL;//:" expr64/expr64.cpp
510           echo Configuring cmd-utils
511           ./configure --host=$BASE \
512                       --prefix=${DEPPKG_DIR} \
513                       >make.log 2>&1
514   fi
515   echo Building cmd-utils
516   do_make Makefile
517   echo Installing cmd-utils
518   do_make Makefile install
519}
520
521process_mkisofs()
522{
523   get_source "${URL_MKISOFS}" "${DIR_MKISOFS}" "${MKD_MKISOFS}"
524   echo Installing mkisofs
525   cp `basename ${URL_MKISOFS}` ${DEPPKG_DIR}/bin
526}
527
528process_dvd_rw_tools()
529{
530   if get_source "${URL_DVD_RW_TOOLS}" "${DIR_DVD_RW_TOOLS}" "${MKD_DVD_RW_TOOLS}"
531   then
532           echo Patching dvd+rw-tools
533           >patch.log
534           do_patch dvd+rw-tools.patch
535   fi
536   echo "Building dvd+rw-tools"
537   m4 -DOS=XMINGW32 Makefile.m4 | make -f - dvd+rw-tools >make.log 2>&1
538   echo "Installing dvd+rw-tools"
539   m4 -DOS=XMINGW32 Makefile.m4 | make -f - prefix=${DEPPKG_DIR} manprefix=${DEPPKG_DIR} install >>make.log 2>&1
540}
541
542process_qt5()
543{
544    if get_source "${URL_Qt5}" "${DIR_Qt5}" "${MKD_Qt5}"
545   then
546       echo Patching Qt5
547       do_patch qt5-qaction.patch
548    fi
549    if [ -f done ]; then
550        return
551    fi
552    export OPENSSL_LIBS="-lssl -lcrypto"
553    echo y | ./configure -xplatform win32-g++ -device-option CROSS_COMPILE=/usr/bin/i686-w64-mingw32- \
554                -prefix ${DEPPKG_DIR} -opensource  -no-compile-examples \
555                -no-openvg -no-sm -no-opengl -nomake examples -nomake tests \
556                -skip qtactiveqt -skip qtcharts -skip qtdoc -skip qtlocation \
557                -skip qtremoteobjects -skip qtserialbus -skip qtwebchannel \
558                -skip qtwebview -skip qtandroidextras -skip qtconnectivity \
559                -skip qtgamepad -skip qtmacextras -skip qtpurchasing -skip qtscript \
560                -skip qttranslations -skip qtwebengine -skip qtwinextras \
561                -skip qtdatavis3d -skip qtgraphicaleffects -skip qtmultimedia \
562                -skip qtquickcontrols -skip qtscxml -skip qtspeech \
563                -skip qtvirtualkeyboard -skip qtwebglplugin -skip qtx11extras \
564                -skip qt3d -skip qtcanvas3d -skip qtdeclarative \
565                -skip qtimageformats -skip qtquickcontrols2 \
566                -skip qtsensors -skip qtwayland -skip qtwebsockets -silent -openssl-linked \
567                -I $DEPPKG_DIR/include -L $DEPPKG_DIR/lib
568
569    make
570    make install
571
572    cd qtbase
573    cp -f ./plugins/platforms/qwindows.dll $DEPPKG_DIR/bin
574    cp -r ./plugins/platforms $DEPPKG_DIR/bin
575    cp -r ./plugins/platforms $DEPPKG_DIR/lib
576
577    cp -rf src/corelib ${DEPPKG_DIR}/src/
578    cp -rf src/gui ${DEPPKG_DIR}/src/
579    cd $DEPPKG_DIR/src
580}
581
582process_qt4()
583{
584   if get_source "${URL_Qt4}" "${DIR_Qt4}" "${MKD_Qt4}"
585   then
586      echo Patching Qt4
587      >patch.log
588      patch -p1 < ${SCRIPT_DIR}/patches/qt4-intrinsics.patch
589      patch -p1 < ${SCRIPT_DIR}/patches/qt4-widget-ui.patch
590      patch -p1 < ${SCRIPT_DIR}/patches/qt4-compilation-see.patch
591      patch -p1 < ${SCRIPT_DIR}/patches/qt4-compilation.patch
592   fi
593   echo "Configuring Qt4"
594   ./configure -opensource -confirm-license -fast -xplatform win32-g++-8.3 \
595   -device-option CROSS_COMPILE=i686-w64-mingw32- -device-option \
596   PKG_CONFIG='i686-w64-mingw32-pkg-config' -force-pkg-config -release \
597   -exceptions -shared -prefix ${DEPPKG_DIR}/qt-out -prefix-install -no-script \
598   -no-iconv -no-webkit -no-glib -no-gstreamer -no-phonon -no-phonon-backend \
599   -accessibility -no-reduce-exports -no-rpath -make libs -nomake demos \
600   -nomake docs -nomake examples -system-zlib -no-mitshm -no-libjpeg \
601   -no-libmng -no-libtiff -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci \
602   -no-sql-odbc -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 \
603   -no-sql-sqlite_symbian -no-sql-symsql -no-sql-tds -no-nis -no-cups -no-dbus \
604   -no-openvg -no-nas-sound -no-audio-backend -no-sm -no-opengl \
605   -no-javascript-jit -no-qt3support -nomake tools \
606   -no-xmlpatterns -no-multimedia -nomake tools -silent
607
608   make
609
610   echo "Installing Qt4"
611   rm -rf ${DEPPKG_DIR}/include/qt ${DEPPKG_DIR}/lib/qt
612   mkdir -p ${DEPPKG_DIR}/include/qt ${DEPPKG_DIR}/lib/qt
613   cp -rf include/* ${DEPPKG_DIR}/include/qt
614   cp -rf lib/* ${DEPPKG_DIR}/lib/qt
615   cp -rf src/corelib ${DEPPKG_DIR}/src/
616   cp -rf src/gui ${DEPPKG_DIR}/src/
617   cp -rf lib/QtCore4.dll lib/QtGui4.dll ${DEPPKG_DIR}/bin/
618   cp -rf lib/QtCore4.dll lib/QtGui4.dll ${DEPPKG_DIR}/lib/qt/
619}
620
621process_mingw()
622{
623   if test -f /usr/lib/gcc/$BASE/*posix/libstdc++-6.dll; then
624      echo "Installing MinGW libs"
625      cp /usr/lib/gcc/$BASE/*posix/libstdc++-6.dll ${DEPPKG_DIR}/bin
626      cp /usr/lib/gcc/$BASE/*posix/libgcc*dll ${DEPPKG_DIR}/bin
627   elif test -f /usr/lib/gcc/$BASE/*/libstdc++-6.dll; then
628      echo "Installing MinGW libs"
629      cp /usr/lib/gcc/$BASE/*/libstdc++-6.dll ${DEPPKG_DIR}/bin
630      cp /usr/lib/gcc/$BASE/*/libgcc*dll ${DEPPKG_DIR}/bin
631   elif test -f /usr/$BASE/lib/libstdc++-6.dll; then
632      echo "Installing MinGW libs"
633      cp /usr/$BASE/lib/libstdc++-6.dll ${DEPPKG_DIR}/bin
634      cp /usr/$BASE/lib/libgcc*dll ${DEPPKG_DIR}/bin
635   else
636      echo "ERROR: Unable to find $BASE on this system"
637   fi
638
639   if test -f /usr/$BASE/lib/libwinpthread-1.dll; then
640      cp /usr/$BASE/lib/libwinpthread-1.dll ${DEPPKG_DIR}/bin
641   fi
642}
643
644if [ "$#" -eq 0 ]
645then
646   process_mingw
647   process_lzo
648   process_zlib
649   #process_pthreads
650   process_openssl
651   process_stab2cv
652   process_sed
653   process_cmd_utils
654#   process_pcre
655#   process_mysql
656#   process_sqlite
657#   process_postgresql
658#   process_wx
659#   process_scons
660#   process_nsis
661#   process_mtx
662#   process_mt
663#   process_mkisofs
664#   process_dvd_rw_tools
665   process_qt5
666else
667   for dependency in "$@"
668   do
669      eval "process_${dependency}"
670   done
671fi
672#vss
673#Need to download from Microsoft
674