#/bin/sh
#TURGEN SYSTEM - DISTRIBUTION SCRIPT 1.0

#Basic configuration
VER_COMP=8.4.1
SRC_DIR=/home/michael/projects/turgen
DEST_BIN=/home/michael/turgen_system-${VER_COMP}.bin
DEST_SRC=/home/michael/turgen_system-${VER_COMP}.src
DEST_PARENT=/home/michael
IS_COMPILER="/mnt/win_d/Program Files/Inno Setup 5/ISCC.exe"



#Create binary distribution
#############################

#Remove any previous outputs 
rm -rf ${DEST_BIN}
mkdir ${DEST_BIN}
mkdir ${DEST_BIN}/doc
mkdir ${DEST_BIN}/pulses
rm ${DEST_PARENT}/turgen_system-${VER_COMP}.bin.tar
rm ${DEST_PARENT}/turgen_system-${VER_COMP}.bin.tar.bz2

#Copy basic files
cp ${SRC_DIR}/dist/turgen.jar ${DEST_BIN}
cp ${SRC_DIR}/plugins.list ${DEST_BIN}
cp ${SRC_DIR}/turgen.id ${DEST_BIN}
cp ${SRC_DIR}/ts.ico ${DEST_BIN}
cp ${SRC_DIR}/pulses/pulses.list ${DEST_BIN}/pulses

#Copy documentation
cp ${SRC_DIR}/doc/src/turgen_system_doc-${VER_COMP}.pdf ${DEST_BIN}/doc
cp ${SRC_DIR}/doc/COPYING ${DEST_BIN}/doc
cp ${SRC_DIR}/doc/CHANGES ${DEST_BIN}/doc

#Create archives
OLDDIR=`pwd`
cd ${DEST_PARENT}
tar --format=gnu -cvf turgen_system-${VER_COMP}.bin.tar turgen_system-${VER_COMP}.bin
bzip2 ${DEST_PARENT}/turgen_system-${VER_COMP}.bin.tar  
cd ${OLDDIR}

#
#Create source distribution

#Remove any previous outputs 
rm -rf ${DEST_SRC}
mkdir ${DEST_SRC}
mkdir ${DEST_SRC}/doc
mkdir ${DEST_SRC}/asm6502

rm ${DEST_PARENT}/turgen_system-${VER_COMP}.src.tar
rm ${DEST_PARENT}/turgen_system-${VER_COMP}.src.tar.bz2

#Copy basic sources
cp -r ${SRC_DIR}/src ${DEST_SRC}

#Copy Asm6502 sources
cp -r ${SRC_DIR}/src ${DEST_SRC}
cp -r ${SRC_DIR}/asm6502 ${DEST_SRC}

#Copy changelog and licence
cp ${SRC_DIR}/doc/COPYING ${DEST_SRC}
cp ${SRC_DIR}/doc/CHANGES ${DEST_SRC}

#Copy distribution scripts
cp ${SRC_DIR}/makedist.sh ${DEST_SRC}
cp ${SRC_DIR}/ts.iss ${DEST_SRC}

#Copy documentation sources
cp -r ${SRC_DIR}/doc/src ${DEST_SRC}/doc

#Create archives
OLDDIR=`pwd`
cd ${DEST_PARENT}
tar --format=gnu -cvf turgen_system-${VER_COMP}.src.tar turgen_system-${VER_COMP}.src
bzip2 ${DEST_PARENT}/turgen_system-${VER_COMP}.src.tar  
cd ${OLDDIR}


#Run Inno Setup
wine "${IS_COMPILER}" ts.iss

