#!/bin/bash
#====some defaults====
QMAKE_BIN=qmake
WHICH=which
NO_OPENSSL=0
NO_FFMPEG=0
if uname -a | grep -iq Darwin; then
DEFAULT_LIBS="/Library/Frameworks"
QMAKE_PARAMS="-spec macx-g++"
else
DEFAULT_LIBS="PREFIX/lib"
QMAKE_PARAMS=""
fi
# the directory of this script (the root)
PROJECT_ROOT=`dirname $0`
PROJECT_ROOT=`(cd "$relpath"; /bin/pwd)`
TESTDIR=$PROJECT_ROOT/config.tests
CONFIG_LOG=$PROJECT_ROOT/config.log
# Define some colors for neat output
C_RED='\e[1;31m'
C_BLUE='\e[1;34m'
C_GREEN='\e[1;32m'
C_CYAN='\e[1;36m'
C_NONE='\e[0m' # No Color
#====parse configure options====
echo "QXT_stability += unknown" > config.in
while (( $# > 0 )); do
if [ $1 == "-qmake-bin" ]; then
QMAKE_BIN=$2; shift
elif [ $1 == "-bootstrap" ]; then
echo "CONFIG += bootstrap" >> config.in; shift
elif [ $1 == "-nomake" ]; then
echo "QXT_BUILD -= $2" >> config.in; shift
elif [ $1 == "-prefix" ]; then
echo "QXTINSTALLDIR = $2" >> config.in; shift
elif [ $1 == "-libdir" ]; then
echo "target.path = $2" >> config.in; shift
elif [ $1 == "-docdir" ]; then
echo "docs.path = $2" >> config.in; shift
elif [ $1 == "-headerdir" ]; then
echo "include.path = $2" >> config.in; shift
elif [ $1 == "-bindir" ]; then
echo "bin.path = $2" >> config.in; shift
elif [ $1 == "-static" ]; then
echo "CONFIG += static staticlib" >> config.in
elif [ $1 == "-debug" ]; then
echo "CONFIG += debug" >> config.in
elif [ $1 == "-release" ]; then
echo "CONFIG += release" >> config.in
elif [ $1 == "-no-openssl" ]; then
echo "QXT_LIBS -= openssl" >> config.in
NO_OPENSSL=1
elif [ $1 == "-help" ] || [ $1 == "--help" ]; then
echo "Usage: configure [-prefix
] [-libdir ] [-docdir ]"
echo " [-bindir ] [-headerdir ] [-qmake-bin ]"
echo " [-static] [-debug] [-release] [-no-openssl] [-nomake ]"
echo
echo "Installation options:"
echo
echo "-prefix ....... This will install everything relative to "
echo " default: /usr/local/Qxt"
echo "-libdir ....... Libraries will be installed to "
echo " default: $DEFAULT_LIBS"
echo "-docdir ....... Documentation will be installed to "
echo " default: PREFIX/share/doc"
echo "-bindir ....... Executables will be installed to "
echo " default: PREFIX/bin"
echo "-headerdir .... Include files will be installed to "
echo " default: PREFIX/include"
echo "-qmake-bin ... Specifies the path to the qmake executable"
echo " default: search the system path"
echo "-static ............. Compile Qxt as a static library"
echo "-debug .............. Build Qxt with debugging symbols"
echo "-release ............ Build Qxt without debugging support"
echo "-no-openssl ......... Do not link to OpenSSL"
echo "-nomake .... Do not compile the specified module"
echo " options: network gui sql media web designer"
echo "-bootstrap .......... That should not be needed for release versions."
echo " warning: will only work on bash > 3.2"
rm config.in
exit
else
echo "Unrecognized configure option: $1"
rm config.in
exit
fi
shift
done
#====begin some autodetection====
>$CONFIG_LOG
# qmake?
if ! $WHICH $QMAKE_BIN >>$CONFIG_LOG 2>&1; then
echo >&2 "You don't seem to have 'qmake' in your PATH."
echo >&2 "Cannot proceed."
exit 1
fi
# find a make command
if [ -z "$MAKE" ]; then
MAKE=
for mk in gmake make; do
if "$WHICH" $mk | grep -qv "no "; then
MAKE=`$WHICH $mk`
break
fi
done
if [ -z "$MAKE" ]; then
echo >&2 "You don't seem to have 'make' or 'gmake' in your PATH."
echo >&2 "Cannot proceed."
exit 1
fi
fi
configtest()
{
echo -en "checking for $1\t"
echo -e " \n\n $1\n" >>$CONFIG_LOG
cd $TESTDIR/$1
$QMAKE_BIN $QMAKE_PARAMS >>$CONFIG_LOG 2>&1
echo -n "."
$MAKE clean >>$CONFIG_LOG 2>&1
[ -f ./$1 ] && rm ./$1
echo -n "."
$MAKE >>$CONFIG_LOG 2>&1
echo -n "."
if ./$1 >>$CONFIG_LOG 2>&1; then
echo -e >&2 " [${C_GREEN}success${C_NONE}] "
echo "DEFINES+=HAVE_$2">>$PROJECT_ROOT/config.in
else
echo -e >&2 " [${C_RED}failure${C_NONE}] "
fi
}
configtest qt4 QT
if [[ "$NO_OPENSSL" == "0" ]]; then
configtest openssl OPENSSL
fi
#configtest curses CURSES
configtest fcgi FCGI
#====finaly running qmake====
echo "autodetection finished. running qmake."
cd $PROJECT_ROOT
[ -f config.pri ] && mv config.pri config.pri.bak
mv config.in config.pri
$QMAKE_BIN $QMAKE_PARAMS -recursive 2>>$CONFIG_LOG
echo -e >&2 "${C_CYAN}configure finished. run $MAKE now.${C_NONE}\n"