#!/bin/bash


# Building the .pro file using qmake

rm -f qrc_resources.cpp mediaSearch.pro Makefile

qmake -project -o mediaSearch
cat >mediaSearch.tmp <<EOF
RESOURCES = resources.qrc
QT += widgets
CONFIG += console
CONFIG += -no-pie
CODECFORSRC = UTF-8
;LIBS += "-ltag"
EOF


cat mediaSearch.pro >>mediaSearch.tmp
mv mediaSearch.tmp mediaSearch.pro


# Building the Makefile file using qmake

qmake -o Makefile



make


export DESTINATION=${1:-"."}

if [ $DESTINATION != "." ]; then
    mv mediaSearch $DESTINATION
fi


# Get rid of the Makefile so there is no confusion.  It will be generated again the next time we build.

rm Makefile
