add '--enable-debug' configure option to build with EMIT_ASN_DEBUG

... which in turn causes all the ASN_DEBUG() to be turned into
fprintf(stderr, ...) statements, once the user application decides
to set 'asn_debug = 1' somewhere in its code.

The next step would be to make _ASN_DECODE_FAILED / _ASN_ENCODE_FAILED
no longer depend on ASN_DEBUG (which it currently does)
This commit is contained in:
Harald Welte 2015-12-18 15:37:17 +01:00
parent 41b85d5597
commit a37b06d735
4 changed files with 13 additions and 0 deletions

View File

@ -28,6 +28,10 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
CFLAGS="$saved_CFLAGS"
AC_SUBST(SYMBOL_VISIBILITY)
AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], [Buld the library with EMIT_ASN_DEBUG enabled])],
[build_debug="$enableval"], [build_debug="no"])
AM_CONDITIONAL(BUILD_DEBUG, test "x$build_debug" = "xyes")
AC_OUTPUT(
libasn1c.pc
src/Makefile

View File

@ -21,6 +21,8 @@
#include <stdarg.h> /* For va_start */
#include <stddef.h> /* for offsetof and ptrdiff_t */
extern int asn_debug;
#ifdef _WIN32
#include <malloc.h>

View File

@ -5,6 +5,9 @@ LIBVERSION=1:0:0
AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include/asn1c
AM_CFLAGS = -fPIC -Wall $(LIBOSMOCORE_CFLAGS)
if BUILD_DEBUG
AM_CFLAGS += -DEMIT_ASN_DEBUG=1
endif
lib_LTLIBRARIES = libasn1c.la

View File

@ -6,6 +6,10 @@
#include <asn_codecs_prim.h>
#include <errno.h>
#if EMIT_ASN_DEBUG == 1
int asn_debug = 0;
#endif
/*
* Decode an always-primitive type.
*/