configure

changeset 385
a1f4cb076d2f
parent 287
a171da778817
child 453
4586d534f9b5
--- a/configure	Tue Aug 13 22:14:32 2019 +0200
+++ b/configure	Sat Sep 24 16:26:10 2022 +0200
@@ -57,7 +57,7 @@
   --mandir=DIR            man documentation [DATAROOTDIR/man]
 
 Optional Features:
-  --enable-pg
+  --enable-postgresql
 
 __EOF__
 }
@@ -67,40 +67,25 @@
 #
 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 == --enable-pg ]]; then
-    	FEATURE_PG=on
-    elif [[ $ARG == --disable-pg ]]; then
-    	unset FEATURE_PG
-    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 ;;
+		"--enable-postgresql") FEATURE_POSTGRESQL=on ;;
+		"--disable-postgresql") unset FEATURE_POSTGRESQL ;;
+		"-"*) echo "unknown option: $ARG"; exit 1 ;;
+	esac
 done
 
 # set dir variables
@@ -265,6 +250,13 @@
         fi
         CFLAGS="$CFLAGS `$PKG_CONFIG --cflags libpq`"
         LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs libpq`"
+		cat >> $TEMP_DIR/make.mk << __EOF__
+# Dependency: libpq		
+CFLAGS += -DENABLE_POSTGRESQL
+PLUGINS += postgresql
+TEST_PLUGIN_LDFLAGS += -lwspgtest
+
+__EOF__
 		echo yes
         return 0
     done
@@ -291,6 +283,14 @@
         return 0
     done
 	
+    # dependency openssl 
+    while true
+    do
+        LDFLAGS="$LDFLAGS -lssl -lcrypto"    
+		echo yes
+        return 0
+    done
+	
 	echo no
 	return 1
 }
@@ -359,7 +359,7 @@
     while true
     do
         
-        CFLAGS="$CFLAGS -DBSD"    
+        CFLAGS="$CFLAGS -DBSD -I/usr/local/include"    
         LDFLAGS="$LDFLAGS -lpthread -lm -lldap"    
 		cat >> $TEMP_DIR/make.mk << __EOF__
 # platform dependend source files
@@ -469,6 +469,8 @@
 	ERROR=1
 fi
 
+# Features
+
 
 echo >> $TEMP_DIR/config.mk
 if [ ! -z "${CFLAGS}" ]; then
@@ -481,10 +483,41 @@
     echo "LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk
 fi
 
+# Target: postgresql
+CFLAGS=
+LDFLAGS=
+CXXFLAGS=
+
+
+# Features
+if [ ! -z "$FEATURE_POSTGRESQL" ]; then
+	# check dependency
+	dependency_libpq
+	if [ $? -ne 0 ]; then
+		# "auto" features can fail and are just disabled in this case
+		if [ $FEATURE_POSTGRESQL != "auto" ]; then
+			DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libpq "
+			ERROR=1
+		fi
+	fi
+fi
+
+
+echo >> $TEMP_DIR/config.mk
+if [ ! -z "${CFLAGS}" ]; then
+    echo "POSTGRESQL_CFLAGS  += $CFLAGS" >> $TEMP_DIR/config.mk
+fi
+if [ ! -z "${CXXFLAGS}" ]; then
+    echo "POSTGRESQL_CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk
+fi
+if [ ! -z "${LDFLAGS}" ]; then
+    echo "POSTGRESQL_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