##  Copyright (c) MediaArea.net SARL. All Rights Reserved.
 #
 #  Use of this source code is governed by a BSD-style license that can
 #  be found in the License.html file in the root of the source tree.
 ##

#! /bin/sh

#-----------------------------------------------------------------------
# $1=OS, $2=Platform, $3=so name, $4=so.0 name, $5=so.0.0.0 name
Release_DLL()
{

#-----------------------------------------------------------------------
# Clean up
test -e MediaInfo_DLL_$1_$2.tar     && rm    MediaInfo_DLL_$1_$2.tar
test -e MediaInfo_DLL_$1_$2.tar.bz2 && rm    MediaInfo_DLL_$1_$2.tar.bz2
test -d MediaInfo_DLL_$1_$2         && rm -r MediaInfo_DLL_$1_$2
mkdir   MediaInfo_DLL_$1_$2

#-----------------------------------------------------------------------
# Copying : so
cp -R ../Project/GNU/Library/.libs/libmediainfo.$3 MediaInfo_DLL_$1_$2/
cp -R ../Project/GNU/Library/.libs/libmediainfo.$4 MediaInfo_DLL_$1_$2/
cp ../Project/GNU/Library/.libs/libmediainfo.$5 MediaInfo_DLL_$1_$2/
cd MediaInfo_DLL_$1_$2
strip libmediainfo.$3
cd ..

#-----------------------------------------------------------------------
# Copying : Information file
cp ../License.html MediaInfo_DLL_$1_$2/
cp ../History_DLL.txt MediaInfo_DLL_$1_$2/History.txt
cp ../Changes.txt MediaInfo_DLL_$1_$2/
cp ReadMe_DLL_$1.txt MediaInfo_DLL_$1_$2/ReadMe.txt

#-----------------------------------------------------------------------
# Copying : Developpers, Documentation
cd ../Source/Doc
doxygen
cd ../../Release
mkdir MediaInfo_DLL_$1_$2/Developpers
cp ../Source/Doc/Documentation.html MediaInfo_DLL_$1_$2/Developpers/
mv ../Doc MediaInfo_DLL_$1_$2/Developpers/

#-----------------------------------------------------------------------
# Copying : Developpers, Source
mkdir -p MediaInfo_DLL_$1_$2/Developpers/Source/Example
cp ../Source/Example/HowToUse* MediaInfo_DLL_$1_$2/Developpers/Source/Example/
mkdir -p MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfo
cp ../Source/MediaInfo/MediaInfo.h MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfo/
cp ../Source/MediaInfo/MediaInfo_Const.h MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfo/
cp ../Source/MediaInfo/MediaInfo_Events.h MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfo/
cp ../Source/MediaInfo/MediaInfoList.h MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfo/
mkdir -p MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfoDLL
cp ../Source/MediaInfoDLL/MediaInfoDLL.h MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfoDLL/
cp ../Source/MediaInfoDLL/MediaInfoDLL_Static.h MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfoDLL/
cp ../Source/MediaInfoDLL/MediaInfoDLL.cs MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfoDLL/
cp ../Source/MediaInfoDLL/MediaInfoDLL.JNA.java MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfoDLL/
cp ../Source/MediaInfoDLL/MediaInfoDLL.JNI.java MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfoDLL/
cp ../Source/MediaInfoDLL/MediaInfoDLL.JNative.java MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfoDLL/
cp ../Source/MediaInfoDLL/MediaInfoDLL.py MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfoDLL/
cp ../Source/MediaInfoDLL/MediaInfoDLL3.py MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfoDLL/


#-----------------------------------------------------------------------
# Compressing Archive
mv MediaInfo_DLL_$1_$2 MediaInfoLib
if test "$3" = "dylib"; then
    #special case, should be put elsewhere
    codesign -f -s "Developer ID Application: MediaArea.net" --verbose MediaInfoLib/libmediainfo.dylib
fi
tar jcf MediaInfo_DLL_$1_$2.tar.bz2 MediaInfoLib
mv MediaInfoLib MediaInfo_DLL_$1_$2

#-----------------------------------------------------------------------
# Clean up
rm -r MediaInfo_DLL_$1_$2

}
