#!/bin/sh

. /etc/profile
. /etc/flenv

gccdir=$mingwpath
libs="libpthread libpthreadGC2 libpthreadGCE2"
headers="pthread sched semaphore"

xremove(){
	pushd $gccdir/lib
		for filename in $libs
		do
			rm -f $filename.a > /dev/null 2>&1
		done
	popd
	pushd $gccdir/include
		for filename in $headers
		do
			rm -f $filename.h > /dev/null 2>&1
		done
	popd
}
xreplace(){
	xremove
	pushd $gccdir/lib
		for filename in $libs
		do
			cp -f $filename$1.a $filename.a > /dev/null 2>&1
		done
	popd
	pushd $gccdir/include
		for filename in $headers
		do
			cp -f $filename$1.h $filename.h > /dev/null 2>&1
		done
	popd
}

case $1 in
	static|s)
		xreplace '.flstatic'
		echo "pthread is now for fl-static."
		;;
	dll|d)
		xreplace '.org'
		echo "pthread is now for dll."
		;;
	disable)
		xremove
		echo "pthread is now disabled."
		;;
	*)
		echo "usage1: $0 static"
		echo "usage2: $0 dll"
		exit 1
esac
