#!/bin/sh

NAME="[pcre]"
WORKING_DIR="pcre/pcre-8.38"

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

	# compile
	make -j8
	check_result $? "make"
	make -j8 install
	check_result $? "make install"
	
	# copy lib
	cp -a ".libs/libpcre-1.dll" ${TARGET_BIN_DIR}
	check_result $? "copying library"

	# add to ceguideps
	mkdir -p "${TEMP_DIR}/ceguideps/lib"
	check_result $? "create lib dir"
	mkdir -p "${TEMP_DIR}/ceguideps/include"
	check_result $? "create include dir"
	
	cp -a ".libs/libpcre.dll.a" "${TEMP_DIR}/ceguideps/lib"
	check_result $? "copy lib"
	cp -a "pcre.h" "${TEMP_DIR}/ceguideps/include"
	check_result $? "copy includes"

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