#!/bin/sh

NAME="[ogg]"
WORKING_DIR="ogg/libogg-1.3.2"

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
	check_result $? "configure"

	# compile
	make -j8
	check_result $? "make"
	
	# copy lib
	cp -a "src/.libs/libogg-0.dll" ${TARGET_BIN_DIR}
	check_result $? "copying library"
	
	# copy shared lib for vorbis
	VORBISDEPS_DIR=${TEMP_DIR}/vorbisdeps/lib
	mkdir -p ${VORBISDEPS_DIR}
	check_result $? "create vorbisdeps dir"
	cp -a "src/.libs/libogg.dll.a" ${VORBISDEPS_DIR}
	check_result $? "copying link-library"

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

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