#!/bin/bash

if [ "$(uname)" == "Darwin" ]; then
	FILE=xerces-c-3.1.1
	[ ! -f $FILE.tar -a -f $FILE.tar.gz ] && gunzip $FILE.tar.gz
	[ ! -d $FILE-0 -a -f $FILE.tar ] && tar xvf $FILE.tar
	cd $FILE
	./configure CFLAGS="-arch x86_64" CXXFLAGS="-arch x86_64"
	make
	sudo make install
elif [ "$(uname)" == "Linux" ]; then
	FILE=xerces-c-src_2_8_0
	[ ! -f $FILE.tar -a -f $FILE.tar.gz ] && gunzip $FILE.tar.gz
	[ ! -d $FILE-0 -a -f $FILE.tar ] && tar xvf $FILE.tar
	cd $FILE
	export XERCESCROOT=`pwd`
	cd src/xercesc
	./runConfigure -plinux -cgcc -xg++ -minmem -nsocket -tnative -rpthread
	make
	cd ../..
	sudo cp -r include/xercesc /usr/include
	chmod -R a+rx /usr/include/xercesc
	sudo cp -f lib/* /usr/lib
	chmod -R a+rx /usr/lib/*xerces*
	sudo /sbin/ldconfig
fi
