test/configure

changeset 0
38775db5fdf5
child 2
14a4b7f0bc74
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/configure	Mon Feb 04 15:09:39 2019 +0100
@@ -0,0 +1,588 @@
+#!/bin/sh
+
+PREFIX=/usr
+EPREFIX=$PREFIX
+
+BINDIR=
+SBINDIR=
+LIBDIR=
+LIBEXECDIR=
+DATADIR=
+SYSCONFDIR=
+SHAREDSTATEDIR=
+LOCALSTATEDIR=
+INCLUDEDIR=
+INFODIR=
+MANDIR=
+
+OS=`uname -s`
+OS_VERSION=`uname -r`
+
+TEMP_DIR=".tmp-`uname -n`"
+mkdir -p $TEMP_DIR
+if [ $? -ne 0 ]; then
+	echo "Cannot create tmp dir"
+	echo "Abort"
+fi
+touch $TEMP_DIR/options
+touch $TEMP_DIR/features
+
+# features
+FEATURE_DB=on
+
+# help text
+printhelp()
+{
+	echo "Usage: $0 [OPTIONS]..."
+	cat << __EOF__
+Installation directories:
+  --prefix=PREFIX         path prefix for architecture-independent files
+                          [/usr]
+  --exec-prefix=EPREFIX   path prefix for architecture-dependent files
+                          [PREFIX]
+
+  --bindir=DIR            user executables [EPREFIX/bin]
+  --sbindir=DIR           system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR        program executables [EPREFIX/libexec]
+  --sysconfdir=DIR        system configuration files [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --libdir=DIR            object code libraries [EPREFIX/lib]
+  --includedir=DIR        C header files [PREFIX/include]
+  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR           info documentation [DATAROOTDIR/info]
+  --mandir=DIR            man documentation [DATAROOTDIR/man]
+
+Options:
+  --toolkit=(gtk3|cli|gtk2|wpf)
+
+Optional Features:
+  --disable-db
+  --enable-gui
+
+__EOF__
+}
+
+#
+# parse arguments 
+#
+for ARG in $@
+do
+    if [[ $ARG == --prefix=* ]]; then
+        PREFIX=${ARG:9}
+    elif [[ $ARG = --exec-prefix=* ]]; then
+    	EPREFIX=${ARG:14}
+    elif [[ $ARG = --bindir=* ]]; then
+    	BINDIR=${ARG:9}
+    elif [[ $ARG = --sbindir=* ]]; then
+    	SBINDIR=${ARG:10}
+    elif [[ $ARG = --libdir=* ]]; then
+    	LIBDIR=${ARG:9}
+    elif [[ $ARG = --libexecdir=* ]]; then
+    	LIBEXECDIR=${ARG:13}
+    elif [[ $ARG = --datadir=* ]]; then
+    	DATADIR=${ARG:10}
+    elif [[ $ARG = --sysconfdir=* ]]; then
+    	SYSCONFDIR=${ARG:13}
+    elif [[ $ARG = --sharedstatedir=* ]]; then
+    	SHAREDSTATEDIR=${ARG:17}
+    elif [[ $ARG = --localstatedir=* ]]; then
+    	LOCALSTATEDIR=${ARG:16}
+    elif [[ $ARG = --includedir=* ]]; then
+    	INCLUDEDIR=${ARG:12}
+    elif [[ $ARG = --infodir=* ]]; then
+    	INFODIR=${ARG:10}
+    elif [[ $ARG = --mandir=* ]]; then
+    	MANDIR=${ARG:9}
+    elif [ $ARG = "--help" ]; then
+		printhelp
+        exit 0	
+    elif [[ $ARG == --toolkit=* ]]; then
+    	OPT_TOOLKIT=${ARG:10}
+    elif [[ $ARG == --enable-db ]]; then
+    	FEATURE_DB=on
+    elif [[ $ARG == --disable-db ]]; then
+    	unset FEATURE_DB
+    elif [[ $ARG == --enable-gui ]]; then
+    	FEATURE_GUI=on
+    elif [[ $ARG == --disable-gui ]]; then
+    	unset FEATURE_GUI
+    fi
+done
+
+# set dir variables
+if [ -z $BINDIR ]; then
+	BINDIR=$EPREFIX/bin
+fi
+if [ -z $SBINDIR ]; then
+	SBINDIR=$EPREFIX/sbin
+fi
+if [ -z $LIBDIR ]; then
+	LIBDIRDIR=$EPREFIX/lib
+fi
+if [ -z $LIBEXEC ]; then
+	LIBExECDIR=$EPREFIX/libexec
+fi
+if [ -z $DATADIR ]; then
+	DATADIR=$PREFIX/share
+fi
+if [ -z $SYSCONFDIR]; then
+	SYSCONFDIR=$PREFIX/etc
+fi
+if [ -z $SHAREDSTATEDIR ]; then
+	SHAREDSTATEDIR=$PREFIX/com
+fi
+if [ -z $LOCALSTATEDIR ]; then
+	LOCALSTATEDIR=$PREFIX/var
+fi
+if [ -z $INCLUDEDIR ]; then
+	INCLUDEDIR=$PREFIX/include
+fi
+if [ -z $INFODIR ]; then
+	INFODIR=$PREFIX/info
+fi
+if [ -z $MANDIR ]; then
+	MANDIR=$PREFIX/man
+fi
+
+which pkg-config > /dev/null
+if [ $? -ne 0 ]; then
+    PKG_CONFIG=pkg-config
+else
+    PKG_CONFIG=false
+fi
+
+# Simple uname based platform detection
+# $PLATFORM is used for platform dependent dependency selection
+printf "detect platform... "
+if [ $OS = SunOS ]; then
+    PLATFORM="solaris sunos unix svr4"
+fi
+if [ $OS = Linux ]; then
+    PLATFORM="linux unix"
+fi
+if [ $OS = FreeBSD ]; then
+    PLATFORM="freebsd bsd unix"
+fi
+if [ $OS = Darwin ]; then
+    PLATFORM="macos osx bsd unix"
+fi
+echo $OS | grep "MINGW" > /dev/null
+if [ $? -eq 0 ]; then
+    PLATFORM="windows mingw"
+fi
+
+if [ -z "$PLATFORM" ]; then
+    PLATFORM="unix"
+fi
+
+for p in $PLATFORM
+do
+	PLATFORM_NAME=$p
+	break
+done
+echo $PLATFORM_NAME
+
+isplatform()
+{
+    for p in $PLATFORM
+    do
+        if [ $p = $1 ]; then
+            return 0
+        fi
+    done
+    return 1
+}
+
+# generate config.mk and config.h
+cat > $TEMP_DIR/config.mk << __EOF__
+#
+# config.mk generated by configure
+#
+__EOF__
+
+echo > $TEMP_DIR/make.mk
+
+ENV_CFLAGS=$CFLAGS
+ENV_LDFLAGS=$LDFLAGS
+ENV_CXXFLAGS=$CXXFLAGS
+
+# Toolchain detection
+# this will insert make vars to config.mk
+source make/toolchain.sh
+
+# add user specified flags to config.mk
+echo >> $TEMP_DIR/config.mk
+if [[ ! -z ${ENV_CFLAGS} ]]; then
+    echo "CFLAGS += $ENV_CFLAGS" >> $TEMP_DIR/config.mk
+fi
+if [[ ! -z ${ENV_CXXFLAGS} ]]; then
+    echo "CXXFLAGS += $ENV_CXXFLAGS" >> $TEMP_DIR/config.mk
+fi
+if [[ ! -z ${ENV_LDFLAGS} ]]; then
+    echo "LDFLAGS += $ENV_LDFLAGS" >> $TEMP_DIR/config.mk
+fi
+
+#
+# DEPENDENCIES
+#
+
+dependency_qt4()
+{
+    printf "checking for qt4... "
+    # dependency qt4 
+    while true
+    do
+        which qmake-qt4 > /dev/null
+        if [ $? -ne 0 ]; then
+        	break
+        fi
+        echo yes
+        return 0
+    done
+	
+	echo no
+	return 1
+}
+dependency_curl()
+{
+    printf "checking for curl... "
+    # dependency curl platform="windows"
+    while true
+    do
+    	if ! isplatform "windows"; then
+            break
+        fi
+        CFLAGS+="-I/mingw/include"    
+        LDFLAGS+="-lcurl"    
+        echo yes
+        return 0
+    done
+	
+    # dependency curl platform="macos"
+    while true
+    do
+    	if ! isplatform "macos"; then
+            break
+        fi
+        curl-config --cflags > /dev/null
+        if [ $? -eq 0 ]; then
+            CFLAGS+=" `curl-config --cflags`"
+        else
+            break
+        fi
+        curl-config --ldflags > /dev/null
+        if [ $? -eq 0 ]; then
+            LDFLAGS+=" `curl-config --ldflags`"
+        else
+            break
+        fi
+        echo yes
+        return 0
+    done
+	
+    # dependency curl 
+    while true
+    do
+        if [ -z "PKG_CONFIG" ]; then
+        	break
+        fi
+        if ! pkg-config libcurl ; then
+            break
+        fi
+        CFLAGS+=" `pkg-config --cflags libcurl`"
+        LDFLAGS+=" `pkg-config --libs libcurl`"
+        echo yes
+        return 0
+    done
+	
+	echo no
+	return 1
+}
+dependency_sqlite()
+{
+    printf "checking for sqlite... "
+    # dependency sqlite 
+    while true
+    do
+        if [ -z "PKG_CONFIG" ]; then
+        	break
+        fi
+        if ! pkg-config sqlite3 ; then
+            break
+        fi
+        CFLAGS+=" `pkg-config --cflags sqlite3`"
+        LDFLAGS+=" `pkg-config --libs sqlite3`"
+        echo yes
+        return 0
+    done
+	
+	echo no
+	return 1
+}
+dependency_test()
+{
+    printf "checking for test... "
+    # dependency test 
+    while true
+    do
+        CFLAGS+="-DTEST"    
+        echo yes
+        return 0
+    done
+	
+	echo no
+	return 1
+}
+dependency_gtk2()
+{
+    printf "checking for gtk2... "
+    # dependency gtk2 
+    while true
+    do
+        if [ -z "PKG_CONFIG" ]; then
+        	break
+        fi
+        if ! pkg-config gtk+-2.0 ; then
+            break
+        fi
+        CFLAGS+=" `pkg-config --cflags gtk+-2.0`"
+        LDFLAGS+=" `pkg-config --libs gtk+-2.0`"
+        echo yes
+        return 0
+    done
+	
+	echo no
+	return 1
+}
+dependency_gtk3()
+{
+    printf "checking for gtk3... "
+    # dependency gtk3 
+    while true
+    do
+        if [ -z "PKG_CONFIG" ]; then
+        	break
+        fi
+        if ! pkg-config gtk+-5.0 ; then
+            break
+        fi
+        CFLAGS+=" `pkg-config --cflags gtk+-5.0`"
+        LDFLAGS+=" `pkg-config --libs gtk+-5.0`"
+        echo yes
+        return 0
+    done
+	
+	echo no
+	return 1
+}
+dependency_libxml2()
+{
+    printf "checking for libxml2... "
+    # dependency libxml2 
+    while true
+    do
+        if [ -z "PKG_CONFIG" ]; then
+        	break
+        fi
+        if ! pkg-config libxml-2.0 ; then
+            break
+        fi
+        CFLAGS+=" `pkg-config --cflags libxml-2.0`"
+        LDFLAGS+=" `pkg-config --libs libxml-2.0`"
+        echo yes
+        return 0
+    done
+	
+	echo no
+	return 1
+}
+
+DEPENDENCIES_FAILED=
+ERROR=0
+
+#
+# OPTION VALUES
+#
+checkopt_toolkit_gtk3()
+{
+	VERR=0
+	dependency_gtk3
+	if [ $? -ne 0 ]; then
+		VERR=1
+	fi
+	if [ $VERR -ne 0 ]; then
+		return 1
+	fi
+		CFLAGS+=" -Da=b"
+	cat >> $TEMP_DIR/make.mk << __EOF__
+UIOBJ += graphics_cairo.o
+
+__EOF__
+	return 0
+}
+checkopt_toolkit_cli()
+{
+	VERR=0
+	dependency_curl
+	if [ $? -ne 0 ]; then
+		VERR=1
+	fi
+	dependency_test
+	if [ $? -ne 0 ]; then
+		VERR=1
+	fi
+	if [ $VERR -ne 0 ]; then
+		return 1
+	fi
+	return 0
+}
+checkopt_toolkit_gtk2()
+{
+	VERR=0
+	dependency_gtk2
+	if [ $? -ne 0 ]; then
+		VERR=1
+	fi
+	if [ $VERR -ne 0 ]; then
+		return 1
+	fi
+	return 0
+}
+checkopt_toolkit_wpf()
+{
+	VERR=0
+	dependency_test
+	if [ $? -ne 0 ]; then
+		VERR=1
+	fi
+	if [ $VERR -ne 0 ]; then
+		return 1
+	fi
+	return 0
+}
+
+#
+# TARGETS
+#
+CFLAGS=
+CXXFLAGS=
+LDFLAGS=
+
+# Target: dav
+CFLAGS=
+LDFLAGS=
+CXXFLAGS=
+
+dependency_curl
+if [ $? -ne 0 ]; then
+	DEPENDENCIES_FAILED+="curl "
+	ERROR=1
+fi
+dependency_libxml2
+if [ $? -ne 0 ]; then
+	DEPENDENCIES_FAILED+="libxml2 "
+	ERROR=1
+fi
+dependency_test
+if [ $? -ne 0 ]; then
+	DEPENDENCIES_FAILED+="test "
+	ERROR=1
+fi
+
+# Option: --toolkit
+if [ -z $OPT_TOOLKIT ]; then
+	SAVED_ERROR=$ERROR
+	SAVED_DEPENDENCIES_FAILED=$DEPENDENCIES_FAILED
+	ERROR=0
+	while true
+	do
+		if isplatform "windows"; then
+		checkopt_toolkit_wpf
+		if [ $? -eq 0 ]; then
+			echo "  toolkit: wpf" >> $TEMP_DIR/options
+			ERROR=0
+			break
+		fi
+		fi
+		checkopt_toolkit_gtk3
+		if [ $? -eq 0 ]; then
+			echo "  toolkit: gtk3" >> $TEMP_DIR/options
+			ERROR=0
+			break
+		fi
+		checkopt_toolkit_gtk2
+		if [ $? -eq 0 ]; then
+			echo "  toolkit: gtk2" >> $TEMP_DIR/options
+			ERROR=0
+			break
+		fi
+		break
+	done
+	if [ $ERROR -ne 0 ]; then
+		SAVED_ERROR=1
+	fi
+	ERROR=$SAVED_ERROR
+	DEPENDENCIES_FAILED=$SAVED_DEPENDENCIES_FAILED=
+else
+	if false; then
+		false
+	elif [ $OPT_TOOLKIT = "gtk3" ]; then
+		echo "  toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
+		checkopt_toolkit_gtk3
+		if [ $? -ne 0 ]; then
+			ERROR=1
+		fi
+	elif [ $OPT_TOOLKIT = "cli" ]; then
+		echo "  toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
+		checkopt_toolkit_cli
+		if [ $? -ne 0 ]; then
+			ERROR=1
+		fi
+	elif [ $OPT_TOOLKIT = "gtk2" ]; then
+		echo "  toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
+		checkopt_toolkit_gtk2
+		if [ $? -ne 0 ]; then
+			ERROR=1
+		fi
+	elif [ $OPT_TOOLKIT = "wpf" ]; then
+		echo "  toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
+		checkopt_toolkit_wpf
+		if [ $? -ne 0 ]; then
+			ERROR=1
+		fi
+	fi
+fi
+
+echo >> $TEMP_DIR/config.mk
+if [[ ! -z ${CFLAGS} ]]; then
+    echo "DAV_CFLAGS  += $CFLAGS" >> $TEMP_DIR/config.mk
+fi
+if [[ ! -z ${CXXFLAGS} ]]; then
+    echo "DAV_CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk
+fi
+if [[ ! -z ${LDFLAGS} ]]; then
+    echo "DAV_LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk
+fi
+
+if [ $ERROR -ne 0 ]; then
+	echo
+	echo "Error: Unresolved dependencies"
+	echo $DEPENCIES_FAILED
+	rm -Rf $TEMP_DIR
+	exit 1
+fi
+
+echo "configure finished"
+echo
+echo "Build Config:"
+echo "  PREFIX:    $PREFIX"
+echo "  TOOLCHAIN: $TOOLCHAIN_NAME"
+echo "Options:"
+cat $TEMP_DIR/options
+echo
+cat $TEMP_DIR/config.mk $TEMP_DIR/make.mk > config.mk
+rm -Rf $TEMP_DIR
+
+

mercurial