From: Florian Forster Date: Tue, 5 May 2009 18:15:35 +0000 (+0200) Subject: Restructure the --enable-standards option. X-Git-Tag: collectd-4.7.0~21 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=7bec4afe6cd99e3f3dd90dc9ba1e5ab7d4385d4a Restructure the --enable-standards option. On Debian GNU/Linux (testing) this works. Let's see how other systems hold up. --- diff --git a/configure.in b/configure.in index 45b8869d..115ee21d 100644 --- a/configure.in +++ b/configure.in @@ -67,13 +67,27 @@ fi if test "x$ac_system" = "xSolaris" then - CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS" + AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Define to enforce POSIX thread semantics under Solaris.]) fi # Where to install .pc files. pkgconfigdir="${libdir}/pkgconfig" AC_SUBST(pkgconfigdir) +# Check for standards compliance mode +AC_ARG_ENABLE(standards, + AS_HELP_STRING([--enable-standards], [Enable standards compliance mode]), + [enable_standards="$enableval"], + [enable_standards="no"]) +if test "x$enable_standards" = "xyes" +then + AC_DEFINE(_ISOC99_SOURCE, 1, [Define to enforce ISO C99 compliance.]) + AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Define to enforce POSIX.1-2001 compliance.]) + AC_DEFINE(_XOPEN_SOURCE, 600, [Define to enforce X/Open 6 (XSI) compliance.]) + AC_DEFINE(_REENTRANT, 1, [Define to enable reentrancy interfaces.]) +fi +AM_CONDITIONAL(BUILD_FEATURE_STANDARDS, test "x$enable_standards" = "xyes") + # # Checks for header files. # @@ -347,7 +361,7 @@ AC_CHECK_HEADERS(linux/un.h, [], [], #endif ]) -AC_CHECK_HEADERS(pwd.h grp.h sys/un.h ctype.h limits.h sys/quota.h xfs/xqm.h fs_info.h fshelp.h paths.h mntent.h mnttab.h sys/fstyp.h sys/fs_types.h sys/mntent.h sys/mnttab.h sys/statfs.h sys/statvfs.h sys/vfs.h sys/vfstab.h kvm.h wordexp.h) +AC_CHECK_HEADERS(pwd.h grp.h sys/un.h ctype.h limits.h xfs/xqm.h fs_info.h fshelp.h paths.h mntent.h mnttab.h sys/fstyp.h sys/fs_types.h sys/mntent.h sys/mnttab.h sys/statfs.h sys/statvfs.h sys/vfs.h sys/vfstab.h kvm.h wordexp.h) # For the dns plugin AC_CHECK_HEADERS(arpa/nameser.h) @@ -908,7 +922,8 @@ AC_CHECK_MEMBERS([struct kinfo_proc.kp_proc, struct kinfo_proc.kp_eproc], ]) AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [], -[#if HAVE_STDINT_H +[#define _BSD_SOURCE +#if HAVE_STDINT_H # include #endif #if HAVE_SYS_TYPES_H @@ -928,7 +943,8 @@ AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [], #endif ]) AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [], -[#if HAVE_STDINT_H +[#define _BSD_SOURCE +#if HAVE_STDINT_H # include #endif #if HAVE_SYS_TYPES_H @@ -3181,7 +3197,6 @@ collectd features:]) # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro. AC_COLLECTD([debug], [enable], [feature], [debugging]) AC_COLLECTD([daemon], [disable], [feature], [daemon mode]) -AC_COLLECTD([standards], [enable], [feature], [enable strict standards compliance mode]) AC_COLLECTD([getifaddrs],[enable], [feature], [getifaddrs under Linux]) dependency_error="no" diff --git a/src/Makefile.am b/src/Makefile.am index 9c0b8e9a..48967365 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -43,9 +43,6 @@ collectd_SOURCES = collectd.c collectd.h \ utils_tail.c utils_tail.h \ utils_threshold.c utils_threshold.h \ types_list.c types_list.h -if BUILD_FEATURE_STANDARDS -collectd_SOURCES += standards.h -endif collectd_CPPFLAGS = $(AM_CPPFLAGS) $(LTDLINCL) collectd_CFLAGS = $(AM_CFLAGS) diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c index 0c480a06..29e34a4c 100644 --- a/src/collectd-nagios.c +++ b/src/collectd-nagios.c @@ -23,11 +23,6 @@ # include "config.h" #endif -/* Set to C99 and POSIX code */ -#if COLLECT_STANDARDS -# include "standards.h" -#endif /* COLLECT_STANDARDS */ - #if !defined(__GNUC__) || !__GNUC__ # define __attribute__(x) /**/ #endif diff --git a/src/collectd.h b/src/collectd.h index 5a039199..18052ba3 100644 --- a/src/collectd.h +++ b/src/collectd.h @@ -26,11 +26,6 @@ # include "config.h" #endif -/* Set to C99 and POSIX code */ -#if COLLECT_STANDARDS -# include "standards.h" -#endif /* COLLECT_STANDARDS */ - #include #if HAVE_SYS_TYPES_H # include diff --git a/src/dns.c b/src/dns.c index 476b6ddb..8339377b 100644 --- a/src/dns.c +++ b/src/dns.c @@ -19,6 +19,8 @@ * Florian octo Forster **/ +#define _BSD_SOURCE + #include "collectd.h" #include "common.h" #include "plugin.h" diff --git a/src/exec.c b/src/exec.c index d2b2508d..44059856 100644 --- a/src/exec.c +++ b/src/exec.c @@ -23,6 +23,8 @@ * Peter Holik **/ +#define _BSD_SOURCE /* For setgroups */ + #include "collectd.h" #include "common.h" #include "plugin.h" diff --git a/src/iptables.c b/src/iptables.c index 3062a0cd..6f1030fb 100644 --- a/src/iptables.c +++ b/src/iptables.c @@ -29,6 +29,8 @@ #include "plugin.h" #include "configfile.h" +#include + #if OWN_LIBIPTC # include "libiptc/libiptc.h" # include "libiptc/libip6tc.h" diff --git a/src/libcollectdclient/client.c b/src/libcollectdclient/client.c index 134a5c4d..e90b3b00 100644 --- a/src/libcollectdclient/client.c +++ b/src/libcollectdclient/client.c @@ -23,11 +23,6 @@ # include "config.h" #endif -/* Set to C99 and POSIX code */ -#if COLLECT_STANDARDS -# include "standards.h" -#endif /* COLLECT_STANDARDS */ - #if !defined(__GNUC__) || !__GNUC__ # define __attribute__(x) /**/ #endif diff --git a/src/load.c b/src/load.c index b7372a10..cf5221b2 100644 --- a/src/load.c +++ b/src/load.c @@ -19,6 +19,8 @@ * Florian octo Forster **/ +#define _BSD_SOURCE + #include "collectd.h" #include "common.h" #include "plugin.h" diff --git a/src/memcached.c b/src/memcached.c index 3421f824..06cf2001 100644 --- a/src/memcached.c +++ b/src/memcached.c @@ -67,7 +67,8 @@ static int memcached_query_daemon (char *buffer, int buffer_size) /* {{{ */ memset (&serv_addr, 0, sizeof (serv_addr)); serv_addr.sun_family = AF_UNIX; - sstrncpy (serv_addr.sun_path, memcached_socket, sizeof (serv_addr.sun_path)); + sstrncpy (serv_addr.sun_path, memcached_socket, + sizeof (serv_addr.sun_path)); /* create our socket descriptor */ fd = socket (AF_UNIX, SOCK_STREAM, 0); @@ -80,7 +81,7 @@ static int memcached_query_daemon (char *buffer, int buffer_size) /* {{{ */ /* connect to the memcached daemon */ status = (ssize_t) connect (fd, (struct sockaddr *) &serv_addr, - SUN_LEN (&serv_addr)); + sizeof (serv_addr)); if (status != 0) { shutdown (fd, SHUT_RDWR); close (fd); diff --git a/src/network.c b/src/network.c index 67a7c3c5..274d2d82 100644 --- a/src/network.c +++ b/src/network.c @@ -19,6 +19,8 @@ * Florian octo Forster **/ +#define _BSD_SOURCE /* For struct ip_mreq */ + #include "collectd.h" #include "plugin.h" #include "common.h" diff --git a/src/ntpd.c b/src/ntpd.c index f51ef5ae..9d716adc 100644 --- a/src/ntpd.c +++ b/src/ntpd.c @@ -19,6 +19,8 @@ * Florian octo Forster **/ +#define _BSD_SOURCE /* For NI_MAXHOST */ + #include "collectd.h" #include "common.h" #include "plugin.h" diff --git a/src/standards.h b/src/standards.h deleted file mode 100644 index a01b4145..00000000 --- a/src/standards.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * collectd - src/collectd.h - * Copyright (C) 2009 Florian octo Forster - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; only version 2 of the License is applicable. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: - * Florian octo Forster - **/ - -#ifndef COLLECTD_STANDARDS_H -#define COLLECTD_STANDARDS_H 1 - -# ifndef _ISOC99_SOURCE -# define _ISOC99_SOURCE -# endif -# ifndef _POSIX_SOURCE -# define _POSIX_SOURCE -# endif -# ifndef _POSIX_C_SOURCE -# define _POSIX_C_SOURCE 200112L -# endif -# ifndef _XOPEN_SOURCE -# define _XOPEN_SOURCE 600 -# endif -# ifndef _REENTRANT -# define _REENTRANT -# endif - -#if 0 -/* Disable non-standard extensions */ -# ifdef _BSD_SOURCE -# undef _BSD_SOURCE -# endif -# ifdef _SVID_SOURCE -# undef _SVID_SOURCE -# endif -# ifdef _GNU_SOURCE -# undef _GNU_SOURCE -# endif -#endif /* 0 */ - -#endif /* COLLECTD_STANDARDS_H */ diff --git a/src/utils_dns.c b/src/utils_dns.c index b7dc7913..2348be24 100644 --- a/src/utils_dns.c +++ b/src/utils_dns.c @@ -33,6 +33,8 @@ * Florian octo Forster */ +#define _BSD_SOURCE + #include "collectd.h" #include "plugin.h" #include "common.h"