#!/usr/bin/perl

$QTDIR=$ENV{QTDIR};
$base=`pwd`;

# Directory structure
system("rm -rf usr-ipaq/lib/qt/*/*");
system("mkdir -p usr-ipaq/lib/qt/etc/fonts");
system("mkdir -p usr-ipaq/lib/qt/apps");
system("mkdir -p usr-ipaq/lib/qt/bin");
system("mkdir -p usr-ipaq/lib/qt/docs");
system("mkdir -p usr-ipaq/lib/qt/lib");
system("mkdir -p usr-ipaq/lib/qt/pics");
system("mkdir -p usr-ipaq/lib/qt/video");

# The app
#system("cp single/qpe usr-ipaq/lib/qt/bin/");
system("cp -r bin usr-ipaq/lib/qt/");
system("cp -a $QTDIR/lib/libqte.so* usr-ipaq/lib/");
system("cp -a $QTDIR/lib/libqpe.so* usr-ipaq/lib/");

# Media
system("cp -r  apps usr-ipaq/lib/qt");
system("cp -a  docs usr-ipaq/lib/qt");
system("cp -r  pics usr-ipaq/lib/qt");
system("cp -r  i18n usr-ipaq/lib/qt; rm usr-ipaq/lib/qt/i18n/*/*.po");
system("cp -r video usr-ipaq/lib/qt");
system("cp -r sounds usr-ipaq/lib/qt");

# This is for future use when a library will need to be included
# Library
# system("cd usr-ipaq/lib/qt/lib ; ".
#    "cp -r $QTDIR/lib/libqte.so.2.2 ./ ; ".
#    "ln -s libqte.so.2.2 libqte.so.2 ; ".
#    "ln -s libqte.so.2.2 libqte.so ; ".
#    "cd -");

# Fonts
system("cp  $QTDIR/etc/fonts/fontdir ".
    "$QTDIR/etc/fonts/helvetica_* ".
    "$QTDIR/etc/fonts/fixed_* ".
    "$QTDIR/etc/fonts/micro_* ".
    "$QTDIR/etc/fonts/smallsmooth_* ".
    "$QTDIR/etc/fonts/cyberbit_120_50_t10.qpf ".
    "$QTDIR/etc/fonts/smoothtimes_{170,100}_50*.qpf ".
    "usr-ipaq/lib/qt/etc/fonts/");
system("mkdir -p usr-ipaq/lib/qt/etc/dict/");

# IM files
system("cp etc/dict/*dawg* usr-ipaq/lib/qt/etc/dict/");
system("cp -r etc/qimpen usr-ipaq/lib/qt/etc/");

# Themery
system("cp -r etc/colors usr-ipaq/lib/qt/etc/");

# Clean
system("find usr-ipaq -name CVS | xargs rm -r");
system("find usr-ipaq -name '*~' | xargs rm ");