From: Martin Ling Date: Tue, 24 Mar 2015 23:15:32 +0000 (+0000) Subject: Generate a config.h rather than passing defines on command line. X-Git-Tag: libserialport-0.1.1~82 X-Git-Url: https://sigrok.org/gitweb/?a=commitdiff_plain;h=7c081505e5ccdfc6178855d65499121ef1e58e53;hp=7c1101dc083533c36df135e78f8e9174b4caf08d;p=libserialport.git Generate a config.h rather than passing defines on command line. Fixes bug #553. --- diff --git a/.gitignore b/.gitignore index 93961f5..1dfa716 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ Makefile.in aclocal.m4 autom4te.cache/ autostuff/ +config.h.in +config.h config.log config.status configure @@ -13,5 +15,6 @@ libserialport.la libserialport.pc libserialport.h libtool +stamp-h1 *.o *.lo diff --git a/autogen.sh b/autogen.sh index 4267387..ae39631 100755 --- a/autogen.sh +++ b/autogen.sh @@ -55,6 +55,7 @@ fi echo "Generating build system..." ${LIBTOOLIZE} --install --copy --quiet || exit 1 aclocal ${ACLOCAL_DIR} || exit 1 +autoheader || exit 1 automake --add-missing --copy || exit 1 autoconf || exit 1 diff --git a/configure.ac b/configure.ac index 4cd1278..86d4eb6 100644 --- a/configure.ac +++ b/configure.ac @@ -29,6 +29,7 @@ m4_define([sp_package_version], [sp_package_version_major.sp_package_version_min AC_INIT([libserialport], [sp_package_version], [martin-libserialport@earth.li], [libserialport], [http://sigrok.org/wiki/Libserialport]) +AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([autostuff]) AC_CONFIG_AUX_DIR([autostuff]) @@ -111,8 +112,8 @@ mingw* | cygwin*) AM_CONDITIONAL([WIN32], false) AM_CONDITIONAL([MACOSX], false) AM_CONDITIONAL([FREEBSD], false) - AC_DEFINE(NO_ENUMERATION) - AC_DEFINE(NO_PORT_METADATA) + AC_DEFINE(NO_ENUMERATION,,[Enumeration is unsupported]) + AC_DEFINE(NO_PORT_METADATA,,[Port metadata is unavailable]) esac AC_SUBST(SP_PKGLIBS) @@ -122,12 +123,22 @@ AC_SUBST(SP_LIBS) AC_TYPE_SIZE_T # Check for specific termios structures. -AC_CHECK_TYPE([struct termios2], [AC_DEFINE(HAVE_TERMIOS2, 1)], [], [[#include ]]) -AC_CHECK_TYPE([struct termiox], [AC_DEFINE(HAVE_TERMIOX, 1)], [], [[#include ]]) +AC_CHECK_TYPE([struct termios2], + [AC_DEFINE(HAVE_TERMIOS2, 1, + [struct termios2 is available.])], + [], [[#include ]]) +AC_CHECK_TYPE([struct termiox], + [AC_DEFINE(HAVE_TERMIOX, 1, + [struct termiox is available.])], + [], [[#include ]]) AC_CHECK_MEMBERS([struct termios.c_ispeed, struct termios.c_ospeed], - [AC_DEFINE(HAVE_TERMIOS_SPEED, 1)], [], [[#include ]]) + [AC_DEFINE(HAVE_TERMIOS_SPEED, 1, + [struct termios has c_ispeed/c_ospeed.])], + [], [[#include ]]) AC_CHECK_MEMBERS([struct termios2.c_ispeed, struct termios2.c_ospeed], - [AC_DEFINE(HAVE_TERMIOS2_SPEED, 1)], [], [[#include ]]) + [AC_DEFINE(HAVE_TERMIOS2_SPEED, 1, + [struct termios2 has c_ispeed/c_ospeed.])], + [], [[#include ]]) # Check for the BOTHER definition, needed for setting arbitrary baud rates. # We can't just #ifdef BOTHER in the code, because of the separation between @@ -141,14 +152,18 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #error BOTHER is not defined #endif ]])], -[AC_DEFINE(HAVE_BOTHER, 1) +[AC_DEFINE(HAVE_BOTHER, 1, [BOTHER macro is available]) AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) # Check for serial_struct. -AC_CHECK_TYPE([struct serial_struct], [AC_DEFINE(HAVE_SERIAL_STRUCT, 1)], +AC_CHECK_TYPE([struct serial_struct], + [AC_DEFINE(HAVE_SERIAL_STRUCT, 1, + [struct serial is available.])], [], [[#include ]]) saved="$CFLAGS"; CFLAGS="$CFLAGS -Werror" +AC_DEFINE(SP_API,,[Macro preceding public API functions]) +AC_DEFINE(SP_PRIV,,[Macro preceding private functions]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ __attribute__((visibility("hidden"))) void foo(void) { } ]])], diff --git a/libserialport_internal.h b/libserialport_internal.h index 28c3076..9d8e41f 100644 --- a/libserialport_internal.h +++ b/libserialport_internal.h @@ -18,6 +18,8 @@ * along with this program. If not, see . */ +#include "config.h" + #ifdef __linux__ #define _BSD_SOURCE // for timeradd, timersub, timercmp #endif