#!/bin/bash

CROSS_DEST_DIR=/opt/W64-cross-compile/lib
CROSS_COMPILER_DIR=/usr/x86_64-w64-mingw32/lib
CROSS_GCC_DIR=/usr/lib/gcc/x86_64-w64-mingw32/10-win32

cp -v $CROSS_COMPILER_DIR/zlib1.dll ./

# copy dll dependencys
copy_dependency() {
	local I
	for I in `strings $1 | grep -i '\.dll$' | grep -e "^lib"`
	do
		if [ -e ./$I ]
		then
			echo "File Exist"
			
		elif [ -e $CROSS_COMPILER_DIR/$I ] 
		then
			cp -v $CROSS_COMPILER_DIR/$I ./
			copy_dependency $CROSS_COMPILER_DIR/$I
			
		elif [ -e $CROSS_GCC_DIR/$I ] 
		then
			cp -v $CROSS_GCC_DIR/$I ./
			copy_dependency $CROSS_GCC_DIR/$I
			
		elif [ -e $CROSS_DEST_DIR/$I ] 
		then
			cp -v $CROSS_DEST_DIR/$I ./
			copy_dependency $CROSS_DEST_DIR/$I
		fi
		
	done
}

copy_dependency simpleskycam.exe

