#!/bin/sh

NAME="[vorbis]"
WORKING_DIR="vorbis/libvorbis-1.3.5"

source ./build_common.sh

if [ $DO_CLEAN -eq 1 ]
then
	make clean
	check_result $? "cleaning build"
fi

if [ $DO_BUILD -eq 1 ]
then
	# configure
	./configure --with-ogg-libraries=${TEMP_DIR}/vorbisdeps/lib --with-ogg-includes=${TARGET_INC_DIR}/libogg/include
	check_result $? "configure"

	# compile
	make -j8
	check_result $? "make"
		
	# copy lib
	find "lib/.libs" -name "*.dll" -exec cp -a {} ${TARGET_BIN_DIR} \;
	check_result $? "copying library"

	# copy headers
	HEADER_DIR="${TARGET_INC_DIR}/libvorbis/include/vorbis"
	mkdir -p ${HEADER_DIR}
	check_result $? "create header dir"
	find "include/vorbis" -name "*.h" -exec cp -a {} ${HEADER_DIR} \;
	check_result $? "copying headers"

	echo "${NAME} Finished building ${NAME}"
fi
