configure

changeset 158
4bde241c49b1
parent 156
62f1a55535e7
child 159
84a6e7a7b457
--- a/configure	Mon Feb 04 17:49:50 2019 +0100
+++ b/configure	Sat Nov 14 20:58:20 2020 +0100
@@ -1,5 +1,6 @@
 #!/bin/sh
 
+
 PREFIX=/usr
 EPREFIX=$PREFIX
 
@@ -64,77 +65,63 @@
 #
 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}
-    fi
+    case "$ARG" in
+		"--prefix="*)         PREFIX=${ARG#--prefix=} ;;
+		"--exec-prefix="*)    EPREFIX=${ARG#--exec-prefix=} ;;
+		"--bindir="*)         BINDIR=${ARG#----bindir=} ;;
+		"--sbindir="*)        SBINDIR=${ARG#--sbindir=} ;;
+		"--libdir="*)         LIBDIR=${ARG#--libdir=} ;;
+		"--libexecdir="*)     LIBEXECDIR=${ARG#--libexecdir=} ;;
+		"--datadir="*)        DATADIR=${ARG#--datadir=} ;;
+		"--sysconfdir="*)     SYSCONFDIR=${ARG#--sysconfdir=} ;;
+		"--sharedstatedir="*) SHAREDSTATEDIR=${ARG#--sharedstatedir=} ;;
+		"--localstatedir="*)  LOCALSTATEDIR=${ARG#--localstatedir=} ;;
+		"--includedir="*)     INCLUDEDIR=${ARG#--includedir=} ;;
+		"--infodir="*)        INFODIR=${ARG#--infodir=} ;;
+		"--mandir"*)          MANDIR=${ARG#--mandir} ;;
+		"--help"*) printhelp; exit 1 ;;
+    	"--toolkit="*) OPT_TOOLKIT={ARG#toolkit=} ;;
+		"-"*) echo "unknown option: $ARG"; exit 1 ;;
+	esac
 done
 
 # set dir variables
-if [ -z $BINDIR ]; then
+if [ -z "$BINDIR" ]; then
 	BINDIR=$EPREFIX/bin
 fi
-if [ -z $SBINDIR ]; then
+if [ -z "$SBINDIR" ]; then
 	SBINDIR=$EPREFIX/sbin
 fi
-if [ -z $LIBDIR ]; then
-	LIBDIRDIR=$EPREFIX/lib
+if [ -z "$LIBDIR" ]; then
+	LIBDIR=$EPREFIX/lib
 fi
-if [ -z $LIBEXEC ]; then
-	LIBExECDIR=$EPREFIX/libexec
+if [ -z "$LIBEXEC" ]; then
+	LIBEXECDIR=$EPREFIX/libexec
 fi
-if [ -z $DATADIR ]; then
+if [ -z "$DATADIR" ]; then
 	DATADIR=$PREFIX/share
 fi
-if [ -z $SYSCONFDIR]; then
+if [ -z "$SYSCONFDIR" ]; then
 	SYSCONFDIR=$PREFIX/etc
 fi
-if [ -z $SHAREDSTATEDIR ]; then
+if [ -z "$SHAREDSTATEDIR" ]; then
 	SHAREDSTATEDIR=$PREFIX/com
 fi
-if [ -z $LOCALSTATEDIR ]; then
+if [ -z "$LOCALSTATEDIR" ]; then
 	LOCALSTATEDIR=$PREFIX/var
 fi
-if [ -z $INCLUDEDIR ]; then
+if [ -z "$INCLUDEDIR" ]; then
 	INCLUDEDIR=$PREFIX/include
 fi
-if [ -z $INFODIR ]; then
+if [ -z "$INFODIR" ]; then
 	INFODIR=$PREFIX/info
 fi
-if [ -z $MANDIR ]; then
+if [ -z "$MANDIR" ]; then
 	MANDIR=$PREFIX/man
 fi
 
 which pkg-config > /dev/null
-if [ $? -ne 0 ]; then
+if [ $? -eq 0 ]; then
     PKG_CONFIG=pkg-config
 else
     PKG_CONFIG=false
@@ -181,12 +168,40 @@
     done
     return 1
 }
+isnotplatform()
+{
+    for p in $PLATFORM
+    do
+        if [ $p = $1 ]; then
+            return 1
+        fi
+    done
+    return 0
+}
 
 # generate config.mk and config.h
 cat > $TEMP_DIR/config.mk << __EOF__
 #
 # config.mk generated by configure
 #
+
+# general vars
+
+PREFIX=$PREFIX
+EPREFIX=$EPREFIX
+
+BINDIR=$BINDIR
+SBINDIR=$SBINDIR
+LIBDIR=$LIBDIR
+LIBEXECDIR=$LIBEXECDIR
+DATADIR=$DATADIR
+SYSCONFDIR=$SYSCONFDIR
+SHAREDSTATEDIR=$SHAREDSTATEDIR
+LOCALSTATEDIR=$LOCALSTATEDIR
+INCLUDEDIR=$INCLUDEDIR
+INFODIR=$INFODIR
+MANDIR=$MANDIR
+
 __EOF__
 
 echo > $TEMP_DIR/make.mk
@@ -197,17 +212,17 @@
 
 # Toolchain detection
 # this will insert make vars to config.mk
-source make/toolchain.sh
+. make/toolchain.sh
 
 # add user specified flags to config.mk
 echo >> $TEMP_DIR/config.mk
-if [[ ! -z ${ENV_CFLAGS} ]]; then
+if [ ! -z "${ENV_CFLAGS}" ]; then
     echo "CFLAGS += $ENV_CFLAGS" >> $TEMP_DIR/config.mk
 fi
-if [[ ! -z ${ENV_CXXFLAGS} ]]; then
+if [ ! -z "${ENV_CXXFLAGS}" ]; then
     echo "CXXFLAGS += $ENV_CXXFLAGS" >> $TEMP_DIR/config.mk
 fi
-if [[ ! -z ${ENV_LDFLAGS} ]]; then
+if [ ! -z "${ENV_LDFLAGS}" ]; then
     echo "LDFLAGS += $ENV_LDFLAGS" >> $TEMP_DIR/config.mk
 fi
 
@@ -223,19 +238,19 @@
     do
         qmake-qt4 -o - /dev/null | grep DEFINES\  > /dev/null
         if [ $? -eq 0 ]; then
-            CFLAGS+=" `qmake-qt4 -o - /dev/null | grep DEFINES\ `"
+            CFLAGS="$CFLAGS `qmake-qt4 -o - /dev/null | grep DEFINES\ `"
         else
             break
         fi
         qmake-qt4 -o - /dev/null | grep INCPATH\  > /dev/null
         if [ $? -eq 0 ]; then
-            CFLAGS+=" `qmake-qt4 -o - /dev/null | grep INCPATH\ `"
+            CFLAGS="$CFLAGS `qmake-qt4 -o - /dev/null | grep INCPATH\ `"
         else
             break
         fi
          > /dev/null
         if [ $? -eq 0 ]; then
-            LDFLAGS+=" ``"
+            LDFLAGS="$LDFLAGS ``"
         else
             break
         fi
@@ -243,7 +258,7 @@
         if [ $? -ne 0 ]; then
         	break
         fi
-        echo yes
+		echo yes
         return 0
     done
 	
@@ -256,17 +271,18 @@
     # dependency gtk2legacy 
     while true
     do
-        if [ -z "PKG_CONFIG" ]; then
+        if [ -z "$PKG_CONFIG" ]; then
         	break
         fi
-        if ! pkg-config gtk+-2.0 ; then
+		$PKG_CONFIG gtk+-2.0
+        if [ $? -ne 0 ] ; then
             break
         fi
-        CFLAGS+=" `pkg-config --cflags gtk+-2.0`"
-        LDFLAGS+=" `pkg-config --libs gtk+-2.0`"
-        CFLAGS+="-DUI_GTK2 -DUI_GTK2LEGACY"    
-        LDFLAGS+="-lpthread"    
-        echo yes
+        CFLAGS="$CFLAGS `$PKG_CONFIG --cflags gtk+-2.0`"
+        LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs gtk+-2.0`"
+        CFLAGS="$CFLAGS -DUI_GTK2 -DUI_GTK2LEGACY"    
+        LDFLAGS="$LDFLAGS -lpthread"    
+		echo yes
         return 0
     done
 	
@@ -281,19 +297,19 @@
     do
         qmake-qt5 -o - /dev/null | grep DEFINES\  > /dev/null
         if [ $? -eq 0 ]; then
-            CFLAGS+=" `qmake-qt5 -o - /dev/null | grep DEFINES\ `"
+            CFLAGS="$CFLAGS `qmake-qt5 -o - /dev/null | grep DEFINES\ `"
         else
             break
         fi
         qmake-qt5 -o - /dev/null | grep INCPATH\  > /dev/null
         if [ $? -eq 0 ]; then
-            CFLAGS+=" `qmake-qt5 -o - /dev/null | grep INCPATH\ `"
+            CFLAGS="$CFLAGS `qmake-qt5 -o - /dev/null | grep INCPATH\ `"
         else
             break
         fi
          > /dev/null
         if [ $? -eq 0 ]; then
-            LDFLAGS+=" ``"
+            LDFLAGS="$LDFLAGS ``"
         else
             break
         fi
@@ -301,7 +317,7 @@
         if [ $? -ne 0 ]; then
         	break
         fi
-        echo yes
+		echo yes
         return 0
     done
 	
@@ -314,21 +330,22 @@
     # dependency gtk2 
     while true
     do
-        if [ -z "PKG_CONFIG" ]; then
+        if [ -z "$PKG_CONFIG" ]; then
         	break
         fi
-        if ! pkg-config gtk+-2.0 ; then
+		$PKG_CONFIG gtk+-2.0
+        if [ $? -ne 0 ] ; then
             break
         fi
-        CFLAGS+=" `pkg-config --cflags gtk+-2.0`"
-        LDFLAGS+=" `pkg-config --libs gtk+-2.0`"
-        CFLAGS+="-DUI_GTK2"    
-        LDFLAGS+="-lpthread"    
+        CFLAGS="$CFLAGS `$PKG_CONFIG --cflags gtk+-2.0`"
+        LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs gtk+-2.0`"
+        CFLAGS="$CFLAGS -DUI_GTK2"    
+        LDFLAGS="$LDFLAGS -lpthread"    
         pkg-config --atleast-version=2.20 gtk+-2.0 > /dev/null
         if [ $? -ne 0 ]; then
         	break
         fi
-        echo yes
+		echo yes
         return 0
     done
 	
@@ -341,17 +358,18 @@
     # dependency gtk3 
     while true
     do
-        if [ -z "PKG_CONFIG" ]; then
+        if [ -z "$PKG_CONFIG" ]; then
         	break
         fi
-        if ! pkg-config gtk+-3.0 ; then
+		$PKG_CONFIG gtk+-3.0
+        if [ $? -ne 0 ] ; then
             break
         fi
-        CFLAGS+=" `pkg-config --cflags gtk+-3.0`"
-        LDFLAGS+=" `pkg-config --libs gtk+-3.0`"
-        CFLAGS+="-DUI_GTK3"    
-        LDFLAGS+="-lpthread"    
-        echo yes
+        CFLAGS="$CFLAGS `$PKG_CONFIG --cflags gtk+-3.0`"
+        LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs gtk+-3.0`"
+        CFLAGS="$CFLAGS -DUI_GTK3"    
+        LDFLAGS="$LDFLAGS -lpthread"    
+		echo yes
         return 0
     done
 	
@@ -364,9 +382,9 @@
     # dependency motif 
     while true
     do
-        CFLAGS+="-DUI_MOTIF"    
-        LDFLAGS+="-lXm -lXt -lX11 -lpthread"    
-        echo yes
+        CFLAGS="$CFLAGS -DUI_MOTIF"    
+        LDFLAGS="$LDFLAGS -lXm -lXt -lX11 -lpthread"    
+		echo yes
         return 0
     done
 	
@@ -379,11 +397,11 @@
     # dependency wpf platform="windows"
     while true
     do
-    	if ! isplatform "windows"; then
+    	if isnotplatform "windows"; then
             break
         fi
-        CFLAGS+="-DUI_WPF"    
-        echo yes
+        CFLAGS="$CFLAGS -DUI_WPF"    
+		echo yes
         return 0
     done
 	
@@ -396,12 +414,12 @@
     # dependency cocoa platform="macos"
     while true
     do
-    	if ! isplatform "macos"; then
+    	if isnotplatform "macos"; then
             break
         fi
-        CFLAGS+="-DUI_COCOA"    
-        LDFLAGS+="-lobjc -framework Cocoa"    
-        echo yes
+        CFLAGS="$CFLAGS -DUI_COCOA"    
+        LDFLAGS="$LDFLAGS -lobjc -framework Cocoa"    
+		echo yes
         return 0
     done
 	
@@ -411,6 +429,64 @@
 
 DEPENDENCIES_FAILED=
 ERROR=0
+# general dependencies
+CFLAGS=
+LDFLAGS=
+while true
+do
+    if isnotplatform "macos"; then
+        break
+    fi
+    while true
+    do
+        
+		cat >> $TEMP_DIR/make.mk << __EOF__
+OBJ_EXT = o
+LIB_EXT = a
+PACKAGE_SCRIPT = package_osx.sh
+
+__EOF__
+        
+        break
+    done
+    
+    break
+done
+while true
+do
+    if isnotplatform "unix"; then
+        break
+    fi
+    if isplatform "macos"; then
+        break
+    fi
+    while true
+    do
+        
+		cat >> $TEMP_DIR/make.mk << __EOF__
+OBJ_EXT = o
+LIB_EXT = a
+PACKAGE_SCRIPT = package_unix.sh
+
+__EOF__
+        
+        break
+    done
+    
+    break
+done
+
+# add general dependency flags to config.mk
+echo >> $TEMP_DIR/config.mk
+if [ ! -z "${CFLAGS}" ]; then
+    echo "CFLAGS += $CFLAGS" >> $TEMP_DIR/config.mk
+fi
+if [ ! -z "${CXXFLAGS}" ]; then
+    echo "CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk
+fi
+if [ ! -z "${LDFLAGS}" ]; then
+    echo "LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk
+fi
 
 #
 # OPTION VALUES
@@ -530,6 +606,8 @@
 CXXFLAGS=
 
 
+# Features
+
 # Option: --toolkit
 if [ -z $OPT_TOOLKIT ]; then
 	SAVED_ERROR=$ERROR
@@ -633,20 +711,20 @@
 fi
 
 echo >> $TEMP_DIR/config.mk
-if [[ ! -z ${CFLAGS} ]]; then
+if [ ! -z "${CFLAGS}" ]; then
     echo "TK_CFLAGS  += $CFLAGS" >> $TEMP_DIR/config.mk
 fi
-if [[ ! -z ${CXXFLAGS} ]]; then
+if [ ! -z "${CXXFLAGS}" ]; then
     echo "TK_CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk
 fi
-if [[ ! -z ${LDFLAGS} ]]; then
+if [ ! -z "${LDFLAGS}" ]; then
     echo "TK_LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk
 fi
 
 if [ $ERROR -ne 0 ]; then
 	echo
 	echo "Error: Unresolved dependencies"
-	echo $DEPENCIES_FAILED
+	echo $DEPENDENCIES_FAILED
 	rm -Rf $TEMP_DIR
 	exit 1
 fi

mercurial