#!/bin/ch
// script to build chopencv-$(version).tar.gz and chopencv-$(version)-win32-binary.tar.gz
// It is assumed the parent dir is $(version) such as v2.5.0
string_t version;
string_t cwd;

if(_argc!= 2) {
  printf("Usage: buildzip.ch version\nExample: buildzip.ch 2.0.0\n");
  exit(-1);
} 
version = _argv[1];

cd ../
cwd = _cwd;            // the current working directory

// build chopencv-$(version).tar.gz
cp -r  $(version) chopencv-$(version)
rm -f  chopencv-$(version)/readme_bin.txt
cd chopencv-$(version)
make rmpkg
make clean
cd $cwd
tar -cf chopencv-$(version).tar chopencv-$(version)
gzip -f chopencv-$(version).tar
rm -rf chopencv-$(version)

// chopencv-$(version)-win32-binary.tar.gz
mkdir chopencv-$(version)-win32-binary
cp -r       $(version)/chopencv        chopencv-$(version)-win32-binary
cp          $(version)/Makefile        chopencv-$(version)-win32-binary/Makefile
cp          $(version)/buildzip.ch     chopencv-$(version)-win32-binary/buildzip.ch
unix2dos -n $(version)/license         chopencv-$(version)-win32-binary/license.txt
unix2dos -n $(version)/readme_bin.txt  chopencv-$(version)-win32-binary/readme.txt
rm -f chopencv-$(version)-win32-binary.zip 
zip -rq chopencv-$(version)-win32-binary.zip chopencv-$(version)-win32-binary
rm -rf chopencv-$(version)-win32-binary

echo done!
