From 3ecbf133909e4f3106d02056f0a5ec650d293984 Mon Sep 17 00:00:00 2001 From: psychon Date: Fri, 7 Jan 2011 15:01:08 +0000 Subject: [PATCH] Use autoheader This commit adds a zncconfig.h to ZNC that is automatically generated by configure. This is done because the -DPACKAGE_STRING=\"znc\ 0.097\" that configure adds to CXXFLAGS breaks znc-buildmod. This means that we have to include zncconfig.h as the very first header in every C++ file that is compiled. This commit kinda cheats and instead adds this include as the very first thing to all header files we have. This should hopefully mean that modules don't have to include this. Because Csocket includes defines.h too late, this commit causes znc to divert from upstream Csocket once again. :( git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2250 726aef4b-f618-498e-8847-2d620e286838 --- Buffer.h | 1 + Chan.h | 1 + Client.h | 1 + Csocket.h | 3 + DCCBounce.h | 1 + DCCSock.h | 1 + FileUtils.h | 1 + HTTPSock.h | 1 + IRCSock.h | 1 + Listener.h | 1 + MD5.h | 1 + Makefile.in | 2 +- Modules.h | 1 + Nick.h | 1 + SHA256.h | 2 + Server.h | 1 + Socket.h | 1 + Template.h | 1 + User.h | 1 + Utils.h | 1 + WebModules.h | 1 + ZNCString.h | 1 + configure | 201 +++++++++++++++++++++++++++++++++++--------- configure.in | 4 + main.h | 2 + modules/Makefile.in | 2 +- znc.h | 1 + 27 files changed, 194 insertions(+), 42 deletions(-) diff --git a/Buffer.h b/Buffer.h index 3049887e..d016feee 100644 --- a/Buffer.h +++ b/Buffer.h @@ -9,6 +9,7 @@ #ifndef _BUFFER_H #define _BUFFER_H +#include "zncconfig.h" #include "ZNCString.h" #include diff --git a/Chan.h b/Chan.h index 87b60bb2..2571da0d 100644 --- a/Chan.h +++ b/Chan.h @@ -9,6 +9,7 @@ #ifndef _CHAN_H #define _CHAN_H +#include "zncconfig.h" #include "FileUtils.h" #include "Nick.h" #include "ZNCString.h" diff --git a/Client.h b/Client.h index c147776b..06199d82 100644 --- a/Client.h +++ b/Client.h @@ -9,6 +9,7 @@ #ifndef _CLIENT_H #define _CLIENT_H +#include "zncconfig.h" #include "Socket.h" #include "Utils.h" #include "main.h" diff --git a/Csocket.h b/Csocket.h index f4de85c6..a91f34c9 100644 --- a/Csocket.h +++ b/Csocket.h @@ -34,6 +34,9 @@ #ifndef _HAS_CSOCKET_ #define _HAS_CSOCKET_ + +#include "zncconfig.h" + #include #include #include diff --git a/DCCBounce.h b/DCCBounce.h index f4324e09..3e334d88 100644 --- a/DCCBounce.h +++ b/DCCBounce.h @@ -9,6 +9,7 @@ #ifndef _DCCBOUNCE_H #define _DCCBOUNCE_H +#include "zncconfig.h" #include "Socket.h" class CUser; diff --git a/DCCSock.h b/DCCSock.h index 6ca31125..0e2e6c3e 100644 --- a/DCCSock.h +++ b/DCCSock.h @@ -9,6 +9,7 @@ #ifndef _DCCSOCK_H #define _DCCSOCK_H +#include "zncconfig.h" #include "FileUtils.h" // Forward Declarations diff --git a/FileUtils.h b/FileUtils.h index 482bc09f..d50203fd 100644 --- a/FileUtils.h +++ b/FileUtils.h @@ -9,6 +9,7 @@ #ifndef _FILEUTILS_H #define _FILEUTILS_H +#include "zncconfig.h" #include "Socket.h" #include "ZNCString.h" #include diff --git a/HTTPSock.h b/HTTPSock.h index 90ca9c7f..c09ae721 100644 --- a/HTTPSock.h +++ b/HTTPSock.h @@ -9,6 +9,7 @@ #ifndef _HTTPSOCK_H #define _HTTPSOCK_H +#include "zncconfig.h" #include "Socket.h" class CModule; diff --git a/IRCSock.h b/IRCSock.h index ea832d89..6c5c35cb 100644 --- a/IRCSock.h +++ b/IRCSock.h @@ -9,6 +9,7 @@ #ifndef _IRCSOCK_H #define _IRCSOCK_H +#include "zncconfig.h" #include "Socket.h" #include "Nick.h" diff --git a/Listener.h b/Listener.h index 28550411..4e28b28a 100644 --- a/Listener.h +++ b/Listener.h @@ -9,6 +9,7 @@ #ifndef _LISTENER_H #define _LISTENER_H +#include "zncconfig.h" #include "znc.h" // Forward Declarations diff --git a/MD5.h b/MD5.h index a44c1396..dcdb5b83 100644 --- a/MD5.h +++ b/MD5.h @@ -3,6 +3,7 @@ #ifndef _MD5_H #define _MD5_H +#include "zncconfig.h" #include using std::string; diff --git a/Makefile.in b/Makefile.in index b1b1270f..e8e2e5f2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -15,7 +15,7 @@ includedir := @includedir@ sbindir := @sbindir@ localstatedir := @localstatedir@ CXX := @CXX@ -CXXFLAGS := @DEFS@ @CPPFLAGS@ @CXXFLAGS@ +CXXFLAGS := @DEFS@ @CPPFLAGS@ @CXXFLAGS@ -I. LDFLAGS := @LDFLAGS@ LIBS := @LIBS@ LIBZNC := @LIBZNC@ diff --git a/Modules.h b/Modules.h index 472a04b2..3f779f9c 100644 --- a/Modules.h +++ b/Modules.h @@ -9,6 +9,7 @@ #ifndef _MODULES_H #define _MODULES_H +#include "zncconfig.h" #include "WebModules.h" #include "FileUtils.h" #include "Utils.h" diff --git a/Nick.h b/Nick.h index d93a14b8..abd63a0d 100644 --- a/Nick.h +++ b/Nick.h @@ -9,6 +9,7 @@ #ifndef _NICK_H #define _NICK_H +#include "zncconfig.h" #include "ZNCString.h" #include #include diff --git a/SHA256.h b/SHA256.h index cdf001f4..673fb6b7 100644 --- a/SHA256.h +++ b/SHA256.h @@ -37,6 +37,8 @@ #define SHA256_DIGEST_SIZE ( 256 / 8) #define SHA256_BLOCK_SIZE ( 512 / 8) +#include "zncconfig.h" + // C99 defines stdint.h which defines a uint32_t and uint8_t type. // But the other kids didn't want to play with poor little Solaris 9 and so he // just defines these in inttypes.h which is also part of C99 and is supposed to diff --git a/Server.h b/Server.h index 01b1242c..49cfb211 100644 --- a/Server.h +++ b/Server.h @@ -9,6 +9,7 @@ #ifndef _SERVER_H #define _SERVER_H +#include "zncconfig.h" #include "ZNCString.h" class CServer { diff --git a/Socket.h b/Socket.h index 51b934a7..f8bb5669 100644 --- a/Socket.h +++ b/Socket.h @@ -9,6 +9,7 @@ #ifndef SOCKET_H #define SOCKET_H +#include "zncconfig.h" #include "Csocket.h" class CModule; diff --git a/Template.h b/Template.h index e215e814..3ffb4390 100644 --- a/Template.h +++ b/Template.h @@ -9,6 +9,7 @@ #ifndef _TEMPLATE_H #define _TEMPLATE_H +#include "zncconfig.h" #include "Utils.h" #include diff --git a/User.h b/User.h index 1a0cc33e..eb521027 100644 --- a/User.h +++ b/User.h @@ -9,6 +9,7 @@ #ifndef _USER_H #define _USER_H +#include "zncconfig.h" #include "Buffer.h" #include "FileUtils.h" #include "Modules.h" diff --git a/Utils.h b/Utils.h index 6f926c06..67401564 100644 --- a/Utils.h +++ b/Utils.h @@ -9,6 +9,7 @@ #ifndef _UTILS_H #define _UTILS_H +#include "zncconfig.h" #include "ZNCString.h" #include #include diff --git a/WebModules.h b/WebModules.h index 9eb8a504..5c9b9c61 100644 --- a/WebModules.h +++ b/WebModules.h @@ -9,6 +9,7 @@ #ifndef _WEBMODULES_H #define _WEBMODULES_H +#include "zncconfig.h" #include "Client.h" #include "Template.h" #include "HTTPSock.h" diff --git a/ZNCString.h b/ZNCString.h index 18560120..ff96a471 100644 --- a/ZNCString.h +++ b/ZNCString.h @@ -9,6 +9,7 @@ #ifndef ZNCSTRING_H #define ZNCSTRING_H +#include "zncconfig.h" #include #include #include diff --git a/configure b/configure index b969d6c5..eb194cb3 100755 --- a/configure +++ b/configure @@ -1936,6 +1936,10 @@ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +ac_config_headers="$ac_config_headers zncconfig.h" + + + @@ -4347,43 +4351,7 @@ test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -# -# If the first sed substitution is executed (which looks for macros that -# take arguments), then branch to the quote section. Otherwise, -# look for a macro that doesn't take arguments. -ac_script=' -:mline -/\\$/{ - N - s,\\\n,, - b mline -} -t clear -:clear -s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g -t quote -s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g -t quote -b any -:quote -s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g -s/\[/\\&/g -s/\]/\\&/g -s/\$/$$/g -H -:any -${ - g - s/^\n// - s/\n/ /g - p -} -' -DEFS=`sed -n "$ac_script" confdefs.h` - +DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= @@ -4828,11 +4796,15 @@ case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" +config_headers="$ac_config_headers" _ACEOF @@ -4853,10 +4825,15 @@ Usage: $0 [OPTION]... [TAG]... --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE Configuration files: $config_files +Configuration headers: +$config_headers + Report bugs to the package provider." _ACEOF @@ -4918,7 +4895,18 @@ do esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; - --he | --h | --help | --hel | -h ) + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) @@ -4974,6 +4962,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 for ac_config_target in $ac_config_targets do case $ac_config_target in + "zncconfig.h") CONFIG_HEADERS="$CONFIG_HEADERS zncconfig.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "znc-config") CONFIG_FILES="$CONFIG_FILES znc-config" ;; "znc-buildmod") CONFIG_FILES="$CONFIG_FILES znc-buildmod" ;; @@ -4993,6 +4982,7 @@ done # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree @@ -5178,8 +5168,116 @@ fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF -eval set X " :F $CONFIG_FILES " +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_t=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_t"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do @@ -5391,7 +5489,30 @@ which seems to be undefined. Please make sure it is defined" >&2;} esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; - + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" + } >"$tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi + ;; esac diff --git a/configure.in b/configure.in index e0fa38e1..f0b6b928 100644 --- a/configure.in +++ b/configure.in @@ -2,6 +2,10 @@ dnl Keep the version number in sync with main.h! AC_INIT([znc], [0.097]) AC_CONFIG_SRCDIR([znc.cpp]) AC_LANG([C++]) +AC_CONFIG_HEADERS([zncconfig.h]) +AH_TOP([#ifndef ZNCCONFIG_H +#define ZNCCONFIG_H]) +AH_BOTTOM([#endif /* ZNCCONFIG_H */]) AC_DEFUN([ZNC_AUTO_FAIL], [ # This looks better in the summary at the end diff --git a/main.h b/main.h index a144ff45..61765f41 100644 --- a/main.h +++ b/main.h @@ -9,6 +9,8 @@ #ifndef _MAIN_H #define _MAIN_H +#include "zncconfig.h" + // The following defines are for #if comparison (preprocessor only likes ints) #define VERSION_MAJOR 0 #define VERSION_MINOR 97 diff --git a/modules/Makefile.in b/modules/Makefile.in index 77822f85..c959794e 100644 --- a/modules/Makefile.in +++ b/modules/Makefile.in @@ -17,7 +17,7 @@ sbindir := @sbindir@ localstatedir := @localstatedir@ CXX := @CXX@ # CXXFLAGS are for the main binary, so don't use them here, use MODFLAGS instead -MODFLAGS := @DEFS@ @CPPFLAGS@ @MODFLAGS@ -I$(srcdir)/.. +MODFLAGS := @DEFS@ @CPPFLAGS@ @MODFLAGS@ -I$(srcdir)/.. -I.. MODLINK := @MODLINK@ LDFLAGS := @LDFLAGS@ # LIBS are not and should not be used in here. diff --git a/znc.h b/znc.h index 9858aa78..1b7c7d64 100644 --- a/znc.h +++ b/znc.h @@ -9,6 +9,7 @@ #ifndef _ZNC_H #define _ZNC_H +#include "zncconfig.h" #include "Client.h" #include "FileUtils.h" #include "Modules.h"