Source

RedBoxApp / configure

Full commit
#! /bin/bash

##Force 32 bits compilation on OSX
#if [ "$(uname -s)" == "Darwin" ]; then
#	export HOSTTYPE=i386
#	export CFLAGS="-arch ${HOSTTYPE}"
#fi

#Checks

CMAKE=$(which cmake)
if [ "${CMAKE}" == "" ]; then
	echo "CMake is not correctly installed and is necessary to build this project." && exit 1
fi

LIBBUILDTOOL=$(which libbuildtool)
if [ "${LIBBUILDTOOL}" == "" ]; then
	echo "libbuildtool is not correctly installed and is necessary to build the dependencies of this project." && exit 1
fi

# Help function
function print_help() {
	#@ function print_help
	#@ Prints help.

	cat <<EOHELP
Usage: $0 <options>

OPTIONS
    -t | --target <name>   Configure the project for the <name> target.
                           Currently supported targets:
                           - SDL (default)
                           - QT
                           - iphoneOS 
                             You must specify a sdk version like this:
                                 './configure -t iphoneOS 4.3' 
                             where 4.3 is the sdk version number.
                           - iphoneSimulator 
                             You must specify a sdk version like this:
                                 './configure -t iphoneSimulator 4.3' 
                             where 4.3 is the sdk version number.
    
    --projectname <name>   Sets the projects's name so it is different 
                           than RedBoxApp. This will also set appname to
                           this name if not overriden with --appname.

    --appname <name>       Sets the binary's name so it is different than
                           RedBoxApp.

    --compile-both         Configures RedBoxApp to also include RedBox in 
                           the project. This is mainly used for RedBox 
                           developpers who wants to have one project file.

    -G |--build-system | --generator Specify which Cmake generator to use	
EOHELP
}


# Initializing parameters array
params=""

# Parameters parsing
while [ $# -gt 0 ];do
	case "$1" in
		"--help"|"-h"|"-?")
			print_help
			exit 0
			;;
		"--projectname")
			shift;
			echo '>>' Application name: ${1}
			export PROJECT_NAME=$1
			;;
		"--appname")
			shift;
			echo '>>' Application name: ${1}
			export BINARY_NAME=$1
			;;
		"--compile-both")
			echo '>>' Compiling RedBox with RedBoxApp
			params=( ${params[@]} "-DINCLUDE_REDBOX=1" )
			;;
		"--target"|"-t")
			shift;
			target=$1
			if [ "${target}" == "iphoneOS" -o "${target}" == "iphoneSimulator" ] ; then
				target=iphone
				shift;
				if [ "${1}" == "" ]; then
					echo "This target need a sdk version number. See ./configure --help for usage." && exit 1
				fi
				export SDKVER="${1}"
			fi
			;;
		*)
			# Keeping unknown parameters
			params=( "${params[@]-}" "${1}" )
		esac
	shift;
done

#Defining default target, if not set
if [ -z "${target}" ]; then
	target="SDL"
fi
#Adding target to cache entries.
params=( ${params[@]} "-D${target}=1" )
params=( ${params[@]} "-DCURRENT_PLATFORM=${target}" )

mkdir -p build
cp ./script/CMake/Makefile/Makefile .

configurePath="./script/CMake/configureScript"

if [[ "${target}" == "iphoneOS" ]]; then
	"${configurePath}/configure-iphone" "${params[@]}"
elif [[ "${target}" == "iphoneSimulator" ]]; then
	"${configurePath}/configure-iphone-simulator" "${params[@]}"
else
	"${configurePath}/configure-current" "${params[@]}"
fi