CLEANUP: regex: use the build options list to report the regex type
This removes 3 #ifdef from haproxy.c.
diff --git a/src/haproxy.c b/src/haproxy.c
index bf7dfc1..4de12cd 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -402,29 +402,6 @@
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 be4fe5b..dd77194 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -14,6 +14,7 @@
#include <stdlib.h>
#include <string.h>
+#include <types/global.h>
#include <common/config.h>
#include <common/defaults.h>
#include <common/regex.h>
@@ -326,6 +327,34 @@
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