]> granicus.if.org Git - postgis/commitdiff
#3837, --enable-debug to set PARANOIA level
authorPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 8 Sep 2017 19:20:46 +0000 (19:20 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 8 Sep 2017 19:20:46 +0000 (19:20 +0000)
This required some re-working of the protobuf sections,
for reasons that aren't clear. However, hopefully that
re-working will also fix things for others. Basically,
the pkg-config portions seemed to only work by accident
for the folks who wrote them initially, so they are
improved, and the use of --without is more strongly
enforced in the conditional blocks

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

configure.ac
liblwgeom/lwgeom.c
liblwgeom/lwgeom_api.c
liblwgeom/lwgeom_geos.c
liblwgeom/lwgeom_geos_split.c
liblwgeom/ptarray.c
libpgcommon/lwgeom_pg.c
postgis_config.h.in

index 8448ef622cdee71490eb7422e8a50fa075e9cb4d..eb819ba24ba02942858f880872f98d2db749a937 100644 (file)
@@ -857,7 +857,7 @@ AC_ARG_WITH([json],
        [AS_HELP_STRING([--without-json], [build without json-c support])],
        [CHECK_JSON="$withval"], [])
 
-if test "$CHECK_JSON" != "no"; then dnl {
+if test "$CHECK_JSON" != "no"; then 
 
 AC_ARG_WITH([jsondir],
        [AS_HELP_STRING([--with-jsondir=PATH], [specify the json-c installation directory])],
@@ -903,7 +903,7 @@ AC_SUBST([JSON_CPPFLAGS])
 AC_SUBST([JSON_LDFLAGS])
 AC_SUBST([HAVE_JSON])
 
-fi dnl }
+fi 
 
 
 dnl ===========================================================================
@@ -927,62 +927,76 @@ AC_ARG_WITH([protobuf],
        [AS_HELP_STRING([--without-protobuf], [build without protobuf-c support])],
        [CHECK_PROTOBUF="$withval"], [])
 
-if test "$CHECK_PROTOBUF" != "no"; then dnl {
-
-AC_ARG_WITH([protobufdir],
-       [AS_HELP_STRING([--with-protobufdir=PATH], [specify the protobuf-c installation directory])],
-       [PROTOBUFDIR="$withval"], [PROTOBUFDIR=])
-
-if test ! "x$PROTOBUFDIR" = "x"; then
-       dnl Make sure that the directory exists
-       if test "x$PROTOBUFDIR" = "xyes"; then
-               AC_MSG_ERROR([you must specify a parameter to --with-protobufdir, e.g. --with-protobufdir=/path/to])
-       else
-               AC_MSG_RESULT([Using user-specified protobuf-c directory: $PROTOBUFDIR])
-
-               dnl Add the include directory to PROTOBUF_CPPFLAGS
-               PROTOBUF_CPPFLAGS="-I$PROTOBUFDIR/include"
-               PROTOBUF_LDFLAGS="-L$PROTOBUFDIR/lib"
-       fi
-fi
-
-dnl Check that we can find the protobuf/protobuf.h header file
-CPPFLAGS_SAVE="$CPPFLAGS"
-CPPFLAGS="$PROTOBUF_CPPFLAGS"
-AC_CHECK_HEADER([protobuf-c/protobuf-c.h], [HAVE_PROTOBUF=yes], [])
-CPPFLAGS="$CPPFLAGS_SAVE"
-
-dnl Ensure we can link against libprotobuf-c
-LIBS_SAVE="$LIBS"
-LIBS="$PROTOBUF_LDFLAGS"
-AC_CHECK_LIB([protobuf-c], [protobuf_c_message_check], [HAVE_PROTOBUF=yes; PROTOBUF_LDFLAGS="${PROTOBUF_LDFLAGS} -lprotobuf-c"], [HAVE_PROTOBUF=no])
-LIBS="$LIBS_SAVE"
+dnl User didn't turn off protobuf support so...
+if test "$CHECK_PROTOBUF" != "no"; then 
+
+    AC_ARG_WITH([protobufdir],
+       [AS_HELP_STRING([--with-protobufdir=PATH], [specify the protobuf-c installation directory])],
+       [PROTOBUFDIR="$withval"], [PROTOBUFDIR=])
+
+    dnl User specified the directory to find protobuf in, check that and
+    dnl fail if it doesn't work
+    if test ! "x$PROTOBUFDIR" = "x"; then
+       dnl Make sure that the directory exists
+       if test "x$PROTOBUFDIR" = "xyes"; then
+               AC_MSG_ERROR([you must specify a parameter to --with-protobufdir, e.g. --with-protobufdir=/path/to])
+       else
+               AC_MSG_RESULT([Using user-specified protobuf-c directory: $PROTOBUFDIR])
+
+               dnl Add the include directory to PROTOBUF_CPPFLAGS
+               PROTOBUF_CPPFLAGS="-I$PROTOBUFDIR/include"
+               PROTOBUF_LDFLAGS="-L$PROTOBUFDIR/lib"
+       fi
+        
+        dnl Check that we can find the protobuf/protobuf.h header file
+        CPPFLAGS_SAVE="$CPPFLAGS"
+        CPPFLAGS="$PROTOBUF_CPPFLAGS"
+        AC_CHECK_HEADER([protobuf-c/protobuf-c.h], [], 
+                   AC_MSG_ERROR([unable to find $PROTOBUFDIR/include/protobuf-c/protobuf-c.h])
+        )
+        CPPFLAGS="$CPPFLAGS_SAVE"
+
+        dnl Ensure we can link against libprotobuf-c
+        LIBS_SAVE="$LIBS"
+        LIBS="$PROTOBUF_LDFLAGS"
+        AC_CHECK_LIB([protobuf-c], [protobuf_c_message_check], [], 
+            AC_MSG_ERROR([unable to link protobuf-c from $PROTOBUFDIR/lib])
+        )
+        HAVE_PROTOBUF=yes
+        PROTOBUF_LDFLAGS="-L$PROTOBUFDIR/lib -lprotobuf-c"
+        LIBS="$LIBS_SAVE"
+
+    dnl No user-specified protobuf dir, try to find one using pkg-config  
+    else
+        if test "$PKG_CONFIG" = "no"; then
+               AC_MSG_WARN([Cannot find pkg-config, disabling protobuf support.])
+               HAVE_PROTOBUF=no
+        else
+               dnl Ensure libprotobuf-c is of minimum required version
+               PKG_CHECK_MODULES([PROTOBUFC], [libprotobuf-c >= 1.1.0], [
+                    HAVE_PROTOBUF=yes; 
+                    PROTOBUF_CPPFLAGS=$PROTOBUFC_CFLAGS;
+                    PROTOBUF_LDFLAGS=$PROTOBUFC_LIBS
+                ], 
+                [HAVE_PROTOBUF=no])
+        fi
+    fi
 
-if test "$PKG_CONFIG" = "no"; then
-       AC_MSG_WARN([Cannot find pkg-config, disabling protobuf support.])
-       HAVE_PROTOBUF=no
-else
-       dnl Ensure libprotobuf-c is of minimum required version
-       PKG_CHECK_MODULES([PROTOBUFC], [libprotobuf-c >= 1.1.0], [HAVE_PROTOBUF=yes], [HAVE_PROTOBUF=no])
-fi
+    if test "$HAVE_PROTOBUF" = "yes"; then
+       AC_PATH_PROG(PROTOCC, protoc-c)
+       if test "x$PROTOCC" = "x"; then
+         AC_MSG_WARN([Protobuf compiler missing, disabling protobuf support.])
+         HAVE_PROTOBUF=no
+       else
+         AC_DEFINE([HAVE_LIBPROTOBUF], [1], [Define to 1 if libprotobuf-c is present])
+       fi
+    fi
 
-if test "$HAVE_PROTOBUF" = "yes"; then
-       AC_PATH_PROG(PROTOCC, protoc-c)
-       if test "x$PROTOCC" = "x"; then
-         AC_MSG_WARN([Protobuf compiler missing, disabling protobuf support.])
-         HAVE_PROTOBUF=no
-       else
-         AC_DEFINE([HAVE_LIBPROTOBUF], 1, [Define to 1 if libprotobuf-c is present])
-       fi
+    AC_SUBST([PROTOBUF_CPPFLAGS])
+    AC_SUBST([PROTOBUF_LDFLAGS])
+    AC_SUBST([HAVE_PROTOBUF])
 fi
 
-AC_SUBST([PROTOBUF_CPPFLAGS])
-AC_SUBST([PROTOBUF_LDFLAGS])
-AC_SUBST([HAVE_PROTOBUF])
-
-fi dnl }
-
-
 
 dnl ===========================================================================
 dnl Detect GTK+2.0 for GUI
@@ -1019,24 +1033,20 @@ AC_SUBST([IGE_MAC_LIBS])
 
 
 dnl ===========================================================================
-dnl Allow the user to enable debugging with --enable-debug
-dnl
-dnl Currently we default to debug level 4. See DEBUG for more information.
+dnl Allow the developer to turn on expensive checks and debugging flags
+dnl with --enable-debug
 dnl
 
-AC_ARG_ENABLE([debug], AC_HELP_STRING([--enable-debug], [Enable verbose debugging messages]),
-       [POSTGIS_DEBUG_LEVEL=4], [POSTGIS_DEBUG_LEVEL=0])
-
-AC_DEFINE_UNQUOTED([POSTGIS_DEBUG_LEVEL], [$POSTGIS_DEBUG_LEVEL], [PostGIS library debug level (0=disabled)])
-
-dnl ===========================================================================
-dnl Allow the user to enable GEOS profiling with --enable-profile
-dnl
+AC_ARG_ENABLE([debug], AC_HELP_STRING([--enable-debug], [Enable debugging code and flags]),
+       [ENABLE_DEBUG=1], [ENABLE_DEBUG=0])
 
-AC_ARG_ENABLE([profile], AC_HELP_STRING([--enable-profile], [Enable GEOS profiling messages]),
-       [POSTGIS_PROFILE=1], [POSTGIS_PROFILE=0])
+if test $ENABLE_DEBUG -eq 1; then
+    AC_DEFINE_UNQUOTED([PARANOIA_LEVEL], [10], [Enable use of memory checks])
+    CFLAGS="$CFLAGS -g"
+else
+    AC_DEFINE_UNQUOTED([PARANOIA_LEVEL], [0], [Disable use of memory checks])
+fi
 
-AC_DEFINE_UNQUOTED([POSTGIS_PROFILE], [$POSTGIS_PROFILE], [Enable GEOS profiling (0=disabled)])
 
 dnl ===========================================================================
 dnl Define version macros
index fb2e26ccdee81984760bfb462a2060d9f1371c20..6748915f41ba93297cfaf14f5816f0b047d9f573 100644 (file)
@@ -1516,11 +1516,6 @@ void lwgeom_swap_ordinates(LWGEOM *in, LWORD o1, LWORD o2)
        LWPOLY *poly;
        int i;
 
-#if PARANOIA_LEVEL > 0
-  assert(o1 < 4);
-  assert(o2 < 4);
-#endif
-
        if ( (!in) || lwgeom_is_empty(in) ) return;
 
   /* TODO: check for lwgeom NOT having the specified dimension ? */
index a3fe27774bee014c317fb1412051d02ee2f21295..83aab7ef6fd2e4b1363052f47298f6c9521f90a5 100644 (file)
 #include <assert.h>
 #include "../postgis_svn_revision.h"
 
-/*
- * Lower this to reduce integrity checks
- */
-#define PARANOIA_LEVEL 1
-
 const char *
 lwgeom_version()
 {
index 4a4cdd014ec37da156e5bfd8f91b9ae46a848bf2..dde69595a13fce107e7f57d73780925a52e6b26b 100644 (file)
@@ -1247,7 +1247,7 @@ LWGEOM_GEOS_buildArea(const GEOSGeometry* geom_in)
    * We should now have a collection
    */
 #if PARANOIA_LEVEL > 0
-  if ( GEOSGeometryTypeId(geos_result) != COLLECTIONTYPE )
+  if ( GEOSGeomTypeId(geos_result) != COLLECTIONTYPE )
   {
     GEOSGeom_destroy(geos_result);
     lwerror("Unexpected return from GEOSpolygonize");
index 246610bb61c81e37e8e03d7d86db05c13e4d44fd..3447aed0ebc6d3f829b1e0044de804605ea00f5b 100644 (file)
@@ -419,7 +419,7 @@ lwpoly_split_by_line(const LWPOLY* lwpoly_in, const LWLINE* blade_in)
        }
 
 #if PARANOIA_LEVEL > 0
-       if ( GEOSGeometryTypeId(polygons) != COLLECTIONTYPE )
+       if ( GEOSGeomTypeId(polygons) != COLLECTIONTYPE )
        {
                GEOSGeom_destroy(g1);
                GEOSGeom_destroy(g2);
index d2b0403f3312b086765da43017a87a47132ac9bb..102b2c1bd98e6ba6f383cc7f97f9851b63c5cfc3 100644 (file)
@@ -391,11 +391,6 @@ ptarray_swap_ordinates(POINTARRAY *pa, LWORD o1, LWORD o2)
        double d, *dp1, *dp2;
        POINT4D p;
 
-#if PARANOIA_LEVEL > 0
-  assert(o1 < 4);
-  assert(o2 < 4);
-#endif
-
   dp1 = ((double*)&p)+(unsigned)o1;
   dp2 = ((double*)&p)+(unsigned)o2;
        for (i=0 ; i < pa->npoints ; i++)
index 5f800c6a76802dff9ce5b8cc1f6dfff649c65f41..f5d84a605c00706e9277a9cdf0b56b2b032a3d56 100644 (file)
@@ -29,8 +29,6 @@
 #include <stdlib.h>
 #include <stdarg.h>
 
-#define PARANOIA_LEVEL 1
-
 #define PGC_ERRMSG_MAXLEN 256
 
 /**
index d4ffab56e2e7edcaf05764e4429a18c215bbc6e1..47b057852c57d298f008bb77cec03862926688fd 100644 (file)
@@ -3,6 +3,13 @@
 
 #include "postgis_svn_revision.h"
 
+/* Manually manipulate the POSTGIS_DEBUG_LEVEL, it is not affected by the  
+   configure process */
+#define POSTGIS_DEBUG_LEVEL 0
+
+/* Define to 1 to enable memory checks in pointarray management. */
+#undef PARANOIA_LEVEL
+
 /* Define to 1 if translation of program messages to the user's native
    language is requested. */
 #undef ENABLE_NLS
 /* PostGIS build date */
 #undef POSTGIS_BUILD_DATE
 
-/* PostGIS library debug level (0=disabled) */
-#undef POSTGIS_DEBUG_LEVEL
-
 /* SFCGAL library version at buil time */
 #undef POSTGIS_SFCGAL_VERSION
 
 /* PostgreSQL server version */
 #undef POSTGIS_PGSQL_VERSION
 
-/* Enable GEOS profiling (0=disabled) */
-#undef POSTGIS_PROFILE
-
 /* PROJ library version */
 #undef POSTGIS_PROJ_VERSION