Build system tweaks

Add configure-time controls for logging
Set some default compile-time warnings
This commit is contained in:
Daniel Drake 2007-10-13 15:52:50 +01:00 committed by Daniel Drake
parent 50e2de0730
commit 2995144310
5 changed files with 38 additions and 3 deletions

View file

@ -4,4 +4,5 @@ aclocal || exit 1
autoheader || exit 1
autoconf || exit 1
automake -a -c || exit 1
./configure --enable-maintainer-mode --enable-examples-build $*
./configure --enable-maintainer-mode --enable-examples-build \
--enable-debug-log $*

View file

@ -31,7 +31,26 @@ AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build],
[build_examples='no'])
AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"])
# Message logging
AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])],
[log_enabled=$enableval],
[log_enabled='yes'])
if test "x$log_enabled" != "xno"; then
AC_DEFINE([ENABLE_LOGGING], 1, [Message logging])
fi
AC_ARG_ENABLE([debug-log], [AS_HELP_STRING([--enable-debug-log],
[enable debug logging (default n)])],
[debug_log_enabled=$enableval],
[debug_log_enabled='no'])
if test "x$debug_log_enabled" != "xno"; then
AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Debug message logging])
fi
AC_DEFINE([API_EXPORTED], [__attribute__((visibility("default")))], [Default visibility])
AM_CFLAGS="-Werror-implicit-function-declaration -Wimplicit-int -Wunreachable-code -Wunused-function -Wunused-label -Wunused-value -Wunused-variable -Wnonnull -Wreturn-type -Wextra -Wshadow"
AC_SUBST(AM_CFLAGS)
AC_CONFIG_FILES([Makefile] [libfprint/Makefile] [examples/Makefile])
AC_OUTPUT

View file

@ -4,7 +4,7 @@ UPEKTS_SRC = drivers/upekts.c
DRIVER_SRC = $(UPEKTS_SRC)
libfprint_la_CFLAGS = -fvisibility=hidden $(LIBUSB_CFLAGS) $(GLIB_CFLAGS)
libfprint_la_CFLAGS = -fvisibility=hidden $(LIBUSB_CFLAGS) $(GLIB_CFLAGS) $(AM_CFLAGS)
libfprint_la_LDFLAGS = -version-info @lt_major@:@lt_revision@:@lt_age@
libfprint_la_LIBADD = $(LIBUSB_LIBS) $(GLIB_LIBS)

View file

@ -50,6 +50,10 @@ void fpi_log(enum fpi_log_level level, const char *component,
stream = stderr;
prefix = "debug";
break;
default:
stream = stderr;
prefix = "unknown";
break;
}
fprintf(stream, "%s:%s [%s] ", component ? component : "fp", prefix,
@ -74,7 +78,7 @@ static const struct fp_driver * const drivers[] = {
static void register_drivers(void)
{
int i;
unsigned int i;
for (i = 0; i < ARRAY_SIZE(drivers); i++)
register_driver(drivers[i]);

View file

@ -20,6 +20,8 @@
#ifndef __FPRINT_INTERNAL_H__
#define __FPRINT_INTERNAL_H__
#include <config.h>
#include <stdint.h>
#include <glib.h>
@ -53,9 +55,18 @@ void fpi_log(enum fpi_log_level, const char *component, const char *function,
#define FP_COMPONENT NULL
#endif
#ifdef ENABLE_LOGGING
#define _fpi_log(level, fmt...) fpi_log(level, FP_COMPONENT, __FUNCTION__, fmt)
#else
#define _fpi_log(level, fmt...)
#endif
#ifdef ENABLE_DEBUG_LOGGING
#define fp_dbg(fmt...) _fpi_log(LOG_LEVEL_DEBUG, fmt)
#else
#define fp_dbg(fmt...)
#endif
#define fp_info(fmt...) _fpi_log(LOG_LEVEL_INFO, fmt)
#define fp_warn(fmt...) _fpi_log(LOG_LEVEL_WARNING, fmt)
#define fp_err(fmt...) _fpi_log(LOG_LEVEL_ERROR, fmt)