#!/bin/csh

set NAME = TransferDemo

if ($2 == "") then
	echo ""
	echo "usage: $0 <Installed-Path> <arch-to-remove>"
	echo "where <arch> is the architecture type to REMOVE, e.g., 'm68k', 'i386' or 'none'"
	echo "example: $0 MyApp.app i386"
	echo ""
	echo "FAILED (invalid arguments)"
	exit 1
endif

echo ""

# fuj here...
if(-e /bin/lipo) then
	set LIPO = /bin/lipo
else
	set LIPO = echo
endif

if($2 != "none") then
	echo "removing architecture <$2> from <$1/$NAME.app>"
	
	foreach x ($NAME transfer_local transfer_outgoing)
		echo suctioning: $1/$NAME.app/$x
		$LIPO $1/$NAME.app/$x -remove $2 -output $1/$NAME.app/$x
	end
			
	echo thinning out the bundles...
	foreach x (`find $1/$NAME.app -name '*.'$2 -print`)
		echo removing: $x
		rm -rf $x
	end
endif

chmod u+s $1/$NAME.app/transfer_local

echo expanding MANUAL...
(cd $1/$NAME.app/English.lproj; tar fx MANUAL.tar; rm MANUAL.tar)

if(-e /usr/bin/ixbuild) then
	echo indexing MANUAL...
	(cd $1/$NAME.app/English.lproj/MANUAL; ixbuild -cr .)
endif

echo "OK"

exit 0
