diff --git a/src/haproxy.c b/src/haproxy.c index bf7dfc1d4..4de12cd08 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -402,29 +402,6 @@ static void display_build_opts() printf("Built without OpenSSL support (USE_OPENSSL not set)\n"); #endif -#ifdef USE_PCRE - printf("Built with PCRE version : %s\n", (HAP_XSTRING(Z PCRE_PRERELEASE)[1] == 0)? - HAP_XSTRING(PCRE_MAJOR.PCRE_MINOR PCRE_DATE) : - HAP_XSTRING(PCRE_MAJOR.PCRE_MINOR) HAP_XSTRING(PCRE_PRERELEASE PCRE_DATE)); - printf("Running on PCRE version : %s", pcre_version()); - printf("\nPCRE library supports JIT : "); -#ifdef USE_PCRE_JIT - { - int r; - pcre_config(PCRE_CONFIG_JIT, &r); - if (r) - printf("yes"); - else - printf("no (libpcre build without JIT?)"); - } -#else - printf("no (USE_PCRE_JIT not set)"); -#endif - printf("\n"); -#else - printf("Built without PCRE support (using libc's regex instead)\n"); -#endif - list_for_each_entry(item, &build_opts_list, list) { puts(item->str); } diff --git a/src/regex.c b/src/regex.c index be4fe5b24..dd7719405 100644 --- a/src/regex.c +++ b/src/regex.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -326,6 +327,34 @@ int regex_comp(const char *str, struct my_regex *regex, int cs, int cap, char ** return 1; } +__attribute__((constructor)) +static void __regex_init(void) +{ + char *ptr = NULL; + +#ifdef USE_PCRE + memprintf(&ptr, "Built with PCRE version : %s", (HAP_XSTRING(Z PCRE_PRERELEASE)[1] == 0)? + HAP_XSTRING(PCRE_MAJOR.PCRE_MINOR PCRE_DATE) : + HAP_XSTRING(PCRE_MAJOR.PCRE_MINOR) HAP_XSTRING(PCRE_PRERELEASE PCRE_DATE)); + memprintf(&ptr, "%s\nRunning on PCRE version : %s", ptr, pcre_version()); + + memprintf(&ptr, "%s\nPCRE library supports JIT : %s", ptr, +#ifdef USE_PCRE_JIT + ({ + int r; + pcre_config(PCRE_CONFIG_JIT, &r); + r ? "yes" : "no (libpcre build without JIT?)"; + }) +#else + "no (USE_PCRE_JIT not set)" +#endif + ); +#else + memprintf(&ptr, "Built without PCRE support (using libc's regex instead)"); +#endif + hap_register_build_opts(ptr, 1); +} + /* * Local variables: * c-indent-level: 8