#!/bin/sh

w32_rnd=/home/igor2/w32-rnd
dst=/tmp/pcb-rnd-w32

# create pack frame
mkdir -p $dst/bin $dst/cache $dst/lib/pcb-rnd/plugins $dst/share/doc $dst/share/man/man1

copy_pcb_rnd() {
	# temp install pcb-rnd
	itmp=/tmp/pcb-rnd.itmp
	(cd src && make install DESTDIR=$itmp)
	(cd footprint && make install DESTDIR=$itmp)
	(cd doc && make install DESTDIR=$itmp)
	(cd util && make install DESTDIR=$itmp)

	# copy pcb-rnd into the pack
	cp $itmp/usr/local/bin/*.exe $dst/bin
	cp -R $itmp/usr/local/share/doc/pcb-rnd $dst/share/doc
	cp $itmp/usr/local/share/man/man1/pcb-rnd.1 $dst/share/man/man1/pcb-rnd.1
	cp -R $itmp/usr/local/share/pcb-rnd $dst/share/pcb-rnd
	cp util/*.scm $dst/lib/pcb-rnd/

	# temporary for config files:
	cp $itmp/usr/local/etc/pcb-rnd/* $dst/share/pcb-rnd
}

admin() {
	# copy the licenses into the pack
	cp -R $w32_rnd/license $dst/
	mkdir -p $dst/license/pcb-rnd
	cp COPYING AUTHORS README $dst/license/pcb-rnd
	echo "pcb-rnd is a modular PCB layout editor.

This is the official windows binaries pack.

pcb-rnd is an open source, free software; for more information on
licensing terms, please read files in license/pcb-rnd. pcb-rnd depends
on 3rd party free software libraries shipped in this pack, the license
terms for those can be found in license/.

pcb-rnd is hosted at http://repo.hu/projects/pcb-rnd
Source code for pcb-rnd: svn://repo.hu/pcb-rnd/trunk
Source code for the 3rd party libs: svn://repo.hu/hidlib.w32/trunk

** THERE IS NO GIT SUPPORT ** - do not make pull requests, don't
send git URLs. pcb-rnd is hosted in svn on repo.hu and
the only one way to contribute is using the above repository.

Contact:
	email: http://repo.hu/projects/pcb-rnd/contact.html
	chat & IRC:  http://repo.hu/projects/pcb-rnd/irc.html



How to install an run pcb-rnd on windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Please read the details in the file share/doc/pcb-rnd/INSTALL.win32.html

Please do not forget to send me a mail so I know the user count on windows is
not zero.


" > $dst/README.txt

	(
	echo -n "pcb-rnd windows pack "
	date "+%Y-%m-%d"
	echo ""
	echo "svn:"
	svn info | grep "^Revision\|^URL"
	) > $dst/VERSION.txt
}


copy_dlls()
{
	local dlls r
	cp -R $w32_rnd/usr/local/lib/gdk-pixbuf-* $dst/lib

	r="$w32_rnd/usr/local/bin"
	dlls="
$r/libgcc_s_sjlj-*.dll
$r/libgobject-*.dll
$r/im-ti-et.dll
$r/libfribidi-*.dll
$r/libpango-*.dll
$r/libgdk-*.dll
$r/im-am-et.dll
$r/im-inuktitut.dll
$r/libpango*.dll
$r/libglib-*.dll
$r/libgio-*.dll
$r/libcairo-gobject-*.dll
$r/im-viqr.dll
$r/im-ime.dll
$r/libgthread-*.dll
$r/libgailutil-*.dll
$r/libcairo-*.dll
$r/libfreetype-*.dll
$r/gdk-pixbuf-query-loaders.exe
$r/libgettextlib-*.dll
$r/libpixman-*.dll
$r/im-multipress.dll
$r/im-ipa.dll
$r/libcharset-*.dll
$r/libpangocairo-*.dll
$r/libpixmap.dll
$r/libffi-*.dll
$r/libgail.dll
$r/libpng*.dll
$r/libgettextsrc-*.dll
$r/libatk-*.dll
$r/libgtk-*.dll
$r/busybox.exe
$r/libcairo-script-interpreter-*.dll
$r/libwimp.dll
$r/im-cedilla.dll
$r/libiconv-*.dll
$r/im-cyrillic-translit.dll
$r/libgdk_pixbuf-*.dll
$r/im-thai.dll
$r/im-ti-er.dll
$r/libgmodule-*.dll
$r/libgettextpo-*.dll
$r/libintl-*.dll
$r/libjpeg*.dll
$r/libturbojpeg*.dll
$r/libgd-*.dll
$r/libxml2-*.dll
"
for n in $dlls
do
	cp $n $dst/bin
done

for n in sh.exe awk.exe
do
	cp $dst/bin/busybox.exe $dst/bin/$n
done

cp /usr/lib/gcc/i686-w64-mingw32/*-win32/libgcc_s_sjlj-*.dll $dst/bin
cp $dst/bin/libintl-*.dll $dst/bin/libgnuintl-3.dll


}


copy_pcb_rnd
admin
copy_dlls
