#!/bin/sh -e

# This script builds and packages the Windows and Android versions,
# and the Generic, iPhone, and Android skins packages, and the Upstream
# source package.
# It should be run in a Cygwin bash shell (under MS Windows, obviously).

mkdir -p packages

# Build Windows version

cd windows
cmd /c build-all.bat
cd ..
rm -rf Free42Windows
mkdir Free42Windows
cp windows/README.txt Free42Windows
cp windows/ReleaseBinary/Free42Binary.exe Free42Windows
cp windows/ReleaseDecimal/Free42Decimal.exe Free42Windows
zip -r packages/Free42Windows.zip Free42Windows
rm -rf Free42Windows

# Source package, and Windows/Unix skins packages
mkdir tmp
cd tmp
svn checkout svn://macmini/free42/trunk free42
find . -type d -name .svn -prune -exec rm -rf {} \;
zip -j ../packages/Free42Skins.zip free42/skins/*
zip -j ../packages/Free42iPhoneSkins.zip free42/iphoneskins/*
zip -j ../packages/Free42AndroidSkins.zip free42/androidskins/*
tar cvfz ../packages/free42.tgz free42
cd ..
rm -rf tmp

# "Upstream" source package, for Fedora or other Linux distros
# Has all non-Linux versions, and all skins containing the HP logo, removed
cd upstream
sh ./build-upstream
cd ..

# Wrap it all up...
cd util
cc -o txt2html txt2html.c
cd ..
util/txt2html "Free42 HISTORY" <HISTORY >history.html
util/txt2html "Free42 TODO" <TODO >todo.html
mv history.html todo.html packages
