#!/bin/sh

INIT_DIR=`pwd`

if [ $# -le 1 ]; then
	echo Usage: compile_libraries platform location
	exit 1
fi

ISE_PLATFORM=$1; export ISE_PLATFORM

. $INIT_DIR/set_aliases

remtrace Compile the Eiffel libraries C code for $ISE_PLATFORM in $2
remtrace with ISE_EIFFEL set to $ISE_EIFFEL
remtrace with ISE_LIBRARY set to $ISE_LIBRARY

if [ -d $2/library/cURL ]; then
	remtrace cURL
	cd $2/library/cURL/Clib
	default_make
fi
if [ -d $2/library/net ]; then
	remtrace net
	cd $2/library/net/Clib
	default_make
	mac_ranlib $2/library/net/spec/$ISE_PLATFORM/lib/libnet.a
fi
if [ -d $2/library/vision2 ]; then
	remtrace vision2
	# Compile GTK C implementation
	cd $2/library/vision2/Clib
	default_make

	if [ ! -z "$INCLUDE_GTK2" ]; then
		cd $2/library/vision2/implementation/gtk/Clib
		default_make
	fi
	if [ ! -z "$INCLUDE_GTK3" ]; then
		cd $2/library/vision2/implementation/gtk3/Clib
		default_make
	fi
fi

if [ -d $2/examples/base/beep/Clib ]; then
	remtrace beep example
	cd $2/examples/base/beep/Clib
	default_make
fi

# Compile IL Emitter Clib implementation
if [ -d $2/framework/dotnet/il_emitter/Clib ]; then
	remtrace IL Emitter Clib
	cd $2/framework/dotnet/il_emitter/Clib
	default_make
else
	if [ -d $2/framework ]; then
		#report error only if framework exists (i.e not for ISE_EIFFEL)
		remtrace IL Emitter Clib: directory not found "$2/framework/dotnet/il_emitter/Clib"
	fi
fi

cd $2
