]> granicus.if.org Git - postgis/commitdiff
Wagyu build improvements
authorRaúl Marín Rodríguez <rmrodriguez@carto.com>
Tue, 12 Feb 2019 11:34:13 +0000 (11:34 +0000)
committerRaúl Marín Rodríguez <rmrodriguez@carto.com>
Tue, 12 Feb 2019 11:34:13 +0000 (11:34 +0000)
Use same compiler as postgresql (adds extra -x cxx)
Pass the C++ standard library to postgres when linking wagyu

Closes #4321
Closes https://github.com/postgis/postgis/pull/371

git-svn-id: http://svn.osgeo.org/postgis/trunk@17250 b70326c6-7e19-0410-871a-916f4a2858ee

configure.ac
deps/wagyu/Makefile.in
doc/installation.xml
postgis/Makefile.in

index 107248d66c7aae0cad0a42b9b9897e8c892ca8e9..796bd0cc880d9e19e59a045a4ed2a37ca10c072f 100644 (file)
@@ -1483,11 +1483,51 @@ if test "x$HAVE_PROTOBUF" = "xyes"; then
             WAGYU_LIB=libwagyu.la
             AC_SUBST([WAGYU_LIB])
 
+            dnl ============================================================
+            dnl We force  to use the same compiler as Postgresql
+            dnl ============================================================
+            CXX_SAVE="$CXX"
+            CC_SAVE="$CC"
+            CFLAGS_SAVE="$CFLAGS"
+            CXXFLAGS_SAVE="$CXXFLAGS"
+            CPPFLAGS_SAVE="$CPPFLAGS_SAVE"
+
+            WAGYU_CXX=`"$PG_CONFIG" --cc`
+            CPPFLAGS="-x c++"
+            CFLAGS=""
+            CXX="$WAGYU_CXX"
             AC_PROG_CXX
             AX_CXX_COMPILE_STDCXX(11, noext, mandatory)
+            WAGYU_CXX="$CXX -x c++"
+
+            dnl ============================================================
+            dnl Check if we can declare the c++ stdlib
+            dnl ============================================================
+            CC="$WAGYU_CXX"
+
+            AC_CHECK_LIB(c++, main, [HAVE_CPP=yes], [HAVE_CPP=no])
+            AC_CHECK_LIB(stdc++, main, [HAVE_STDCPP=yes], [HAVE_STDCPP=no])
+
+            if test "x$HAVE_CPP" = "xyes"; then
+                WAGYU_LDFLAGS="-lc++"
+            elif test "x$HAVE_STDCPP" = "xyes"; then
+                WAGYU_LDFLAGS="-lstdc++"
+            else
+                AC_MSG_WARN("Could not find a C++ standard library")
+                WAGYU_LDFLAGS=""
+            fi
+
+            CXX="$CXX_SAVE"
+            CC="$CC_SAVE"
+            CFLAGS="$CFLAGS_SAVE"
+            CXXFLAGS="$CXXFLAGS_SAVE"
+            CPPFLAGS="$CPPFLAGS_SAVE"
 
             AC_DEFINE([HAVE_WAGYU], [1], [Define to 1 if wagyu is being built])
             AC_SUBST([HAVE_WAGYU])
+            AC_SUBST([WAGYU_CXX])
+            AC_SUBST([WAGYU_LDFLAGS])
+
             DEPS_MAKEFILE_LIST="$DEPS_MAKEFILE_LIST
                     deps/wagyu/Makefile"
     fi
@@ -1555,7 +1595,7 @@ AC_MSG_RESULT()
 AC_MSG_RESULT([ -------------- Compiler Info ------------- ])
 AC_MSG_RESULT([  C compiler:           ${CC} ${CFLAGS}])
 if test "x$HAVE_WAGYU" = "xyes"; then
-    AC_MSG_RESULT([  C++ compiler:         ${CXX} ${CXXFLAGS}])
+    AC_MSG_RESULT([  C++ compiler (Wagyu): ${WAGYU_CXX} ${CXXFLAGS}])
 fi
 AC_MSG_RESULT([  CPPFLAGS:             $CPPFLAGS])
 AC_MSG_RESULT([  SQL preprocessor:     ${SQLPP}])
@@ -1674,4 +1714,4 @@ if test ! -z "$PKG_CONFIG"; then
         AC_MSG_WARN([ | Alternatively, you may set the environment variables PCRE_CFLAGS and     |])
         AC_MSG_WARN([ | PCRE_LIBS to avoid the need to call pkg-config.                          |])
     fi
-fi
\ No newline at end of file
+fi
index 1e3d1a4bcca43ca27262d3ca5b3b1ed5e114c61c..03d227911e6f27002f397c76d9c924f82642fb80 100644 (file)
@@ -22,8 +22,8 @@
 # *
 # **********************************************************************/
 
-CXX = @CXX@
-CXXFLAGS =-I../../liblwgeom -Iinclude @CPPFLAGS@ @WARNFLAGS@ @CXXFLAGS@ @PICFLAGS@
+CXX = @WAGYU_CXX@
+CXXFLAGS =-I../../liblwgeom -Iinclude @CPPFLAGS@ @CXXFLAGS@ @PICFLAGS@
 LDFLAGS = @LDFLAGS@
 top_builddir = @top_builddir@
 libdir = @libdir@
index 53d280a1106c1b740789036ea2003eebd605671c..96dcddf8865f076e958f4a71a9fe6d67158f41e6 100644 (file)
@@ -241,7 +241,7 @@ psql -d yourdatabase -f sfcgal_comments.sql
                          To enable ST_AsMVT protobuf-c library (for usage) and the protoc-c compiler (for building) are required.
                                Also, pkg-config is required to verify the correct minimum version of protobuf-c.
                                See <ulink url="https://github.com/protobuf-c/protobuf-c">protobuf-c</ulink>.
-                To use Wagyu to validate MVT polygons faster, a c++11 compiler is required. It will use the CXX and CXXFLAGS and needs <varname>--with-wagyu</varname> to be passed during configure.
+                To use Wagyu to validate MVT polygons faster, a c++11 compiler is required. It requires <varname>--with-wagyu</varname> to be passed during configure; and it will use CXXFLAGS and the same compiler as the PostgreSQL installation.
                        </para>
                </listitem>
 
index 133bc3d83c3e18befdf1b4822dba33b38157a92b..974633817f6cce568a3fd8821c1ff588c66d5b30 100644 (file)
@@ -63,7 +63,7 @@ endif
 WAGYU_LIBPATH = ../deps/wagyu/@WAGYU_LIB@
 ifeq (@HAVE_WAGYU@,yes)
 WAYGU_INCLUDE += -I../deps/wagyu
-WAYGU_LIB = $(WAGYU_LIBPATH)
+WAYGU_LIB = $(WAGYU_LIBPATH) @WAGYU_LDFLAGS@
 WAGYU_DEP = $(WAGYU_LIBPATH)
 endif