From: Michael Altizer (mialtize) Date: Tue, 11 Jul 2017 16:57:07 +0000 (-0400) Subject: Merge pull request #948 in SNORT/snort3 from extrabuild to master X-Git-Tag: 3.0.0-239~23 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=88603d2e9fb35aa368be3810ed5391eefc77ac73;p=thirdparty%2Fsnort3.git Merge pull request #948 in SNORT/snort3 from extrabuild to master Squashed commit of the following: commit 4d7e8a276f0d2e0e901b548d781de6af83fd9d07 Author: Michael Altizer Date: Fri Jul 7 13:56:26 2017 -0400 build: Add support for appending EXTRABUILD to the BUILD string If EXTRABUILD is defined in the preprocessor flags, it will be appended to the BUILD string and reported in all such places that use it like snort -V. For example, if one configures with CPPFLAGS="-DEXTRABUILD=.1", the resulting snort -V output will look something like this: ,,_ -*> Snort++ <*- o" )~ Version 3.0.0-a4 (Build 236.1) from 2.9.8-383 '''' By Martin Roesch & The Snort Team --- diff --git a/src/framework/codec.h b/src/framework/codec.h index 28650ee2e..6f244cc8f 100644 --- a/src/framework/codec.h +++ b/src/framework/codec.h @@ -28,6 +28,7 @@ #include "framework/base_api.h" #include "framework/decode_data.h" +#include "utils/cpp_macros.h" struct TextLog; struct _daq_pkthdr; @@ -54,9 +55,7 @@ struct ICMPHdr; } // Used by root codecs to add their DLT to their HELP string -#define STRINGIFY(x) #x -#define ARG_STRINGIFY(x) STRINGIFY(x) -#define ADD_DLT(help, x) help " (DLT " ARG_STRINGIFY(x) ")" +#define ADD_DLT(help, x) help " (DLT " STRINGIFY_MX(x) ")" constexpr uint8_t MIN_TTL = 64; constexpr uint8_t MAX_TTL = 255; diff --git a/src/main/build.h b/src/main/build.h index 433e7830c..823dffdd7 100644 --- a/src/main/build.h +++ b/src/main/build.h @@ -1,6 +1,8 @@ #ifndef BUILD_H #define BUILD_H +#include "utils/cpp_macros.h" + //-----------------------------------------------// // ____ _ // // / ___| _ __ ___ _ __| |_ _ _ // @@ -10,7 +12,13 @@ // // //-----------------------------------------------// -#define BUILD "236" +#define BUILD_NUMBER 236 + +#ifndef EXTRABUILD +#define BUILD STRINGIFY_MX(BUILD_NUMBER) +#else +#define BUILD STRINGIFY_MX(PPCAT_MX(BUILD_NUMBER, EXTRABUILD)) +#endif #endif diff --git a/src/utils/cpp_macros.h b/src/utils/cpp_macros.h index c68f4627d..434721598 100644 --- a/src/utils/cpp_macros.h +++ b/src/utils/cpp_macros.h @@ -22,8 +22,40 @@ // Miscellaneous C preprocessor macros +// Turn x into a string literal without expanding macro definitions +// Example: +// #define BUILD 123 +// STRINGIFY(BUILD) +// Result: +// "BUILD" #define STRINGIFY(x) #x +// Turn x into a string literal after macro-expanding it +// Example: +// #define BUILD 123 +// STRINGIFY_MX(BUILD) +// Result: +// "123" +#define STRINGIFY_MX(x) STRINGIFY(x) + +// Concatenate preprocessor tokens x and y without expanding macro definitions +// Example: +// #define ice snow +// #define cream cone +// PPCAT(ice, cream) +// Result: +// icecream +#define PPCAT(x, y) x ## y + +// Concatenate preprocessor tokens x and y after macro-expanding them +// Example: +// #define ice snow +// #define cream cone +// PPCAT_MX(ice, cream) +// Result: +// snowcone +#define PPCAT_MX(x, y) PPCAT(x, y) + // Pair of macros to temporarily enable and then disable warnings for structures // being automatically padded. Currently implemented for Clang and GCC >= 5.0. #if defined(__clang__) && !defined(__ICC)