MINOR: initcall: apply initcall to all register_build_opts() calls

Most register_build_opts() calls use static strings. These ones were
replaced with a trivial REGISTER_BUILD_OPTS() statement adding the string
and its call to the STG_REGISTER section. A dedicated section could be
made for this if needed, but there are very few such calls for this to
be worth it. The calls made with computed strings however, like those
which retrieve OpenSSL's version or zlib's version, were moved to a
dedicated function to guarantee they are called late in the process.
For example, the SSL call probably requires that SSL_library_init()
has been called first.
diff --git a/include/types/global.h b/include/types/global.h
index 24eeb0c..85f5d25 100644
--- a/include/types/global.h
+++ b/include/types/global.h
@@ -25,8 +25,9 @@
 #include <netinet/in.h>
 
 #include <common/config.h>
-#include <common/standard.h>
+#include <common/initcall.h>
 #include <common/hathreads.h>
+#include <common/standard.h>
 
 #include <types/listener.h>
 #include <types/proxy.h>
@@ -246,6 +247,10 @@
 
 void mworker_accept_wrapper(int fd);
 
+/* simplified way to declare static build options in a file */
+#define REGISTER_BUILD_OPTS(str) \
+	INITCALL2(STG_REGISTER, hap_register_build_opts, (str), 0)
+
 #endif /* _TYPES_GLOBAL_H */
 
 /*
diff --git a/src/51d.c b/src/51d.c
index d537964..d709ec0 100644
--- a/src/51d.c
+++ b/src/51d.c
@@ -5,6 +5,7 @@
 #include <common/buffer.h>
 #include <common/errors.h>
 #include <common/initcall.h>
+#include <types/global.h>
 #include <proto/arg.h>
 #include <proto/http_fetch.h>
 #include <proto/log.h>
@@ -689,8 +690,8 @@
 __attribute__((constructor))
 static void __51d_init(void)
 {
-	/* register sample fetch and conversion keywords */
-	hap_register_build_opts("Built with 51Degrees support.", 0);
 	hap_register_post_check(init_51degrees);
 	hap_register_post_deinit(deinit_51degrees);
 }
+
+REGISTER_BUILD_OPTS("Built with 51Degrees support.");
diff --git a/src/auth.c b/src/auth.c
index 2f9cc4f..8d1da3e 100644
--- a/src/auth.c
+++ b/src/auth.c
@@ -29,6 +29,7 @@
 #include <common/config.h>
 #include <common/errors.h>
 #include <common/hathreads.h>
+#include <common/initcall.h>
 
 #include <proto/acl.h>
 #include <proto/log.h>
@@ -313,8 +314,4 @@
 	return NULL;
 }
 
-__attribute__((constructor))
-static void __auth_init(void)
-{
-	hap_register_build_opts("Encrypted password support via crypt(3): yes", 0);
-}
+REGISTER_BUILD_OPTS("Encrypted password support via crypt(3): yes");
diff --git a/src/compression.c b/src/compression.c
index af44f4d..218a284 100644
--- a/src/compression.c
+++ b/src/compression.c
@@ -705,9 +705,6 @@
 __attribute__((constructor))
 static void __comp_fetch_init(void)
 {
-	char *ptr = NULL;
-	int i;
-
 #ifdef USE_SLZ
 	slz_make_crc_table();
 	slz_prepare_dist_table();
@@ -720,6 +717,13 @@
 #if defined(USE_ZLIB) && defined(DEFAULT_MAXZLIBMEM)
 	global.maxzlibmem = DEFAULT_MAXZLIBMEM * 1024U * 1024U;
 #endif
+}
+
+static void comp_register_build_opts(void)
+{
+	char *ptr = NULL;
+	int i;
+
 #ifdef USE_ZLIB
 	memprintf(&ptr, "Built with zlib version : " ZLIB_VERSION);
 	memprintf(&ptr, "%s\nRunning on zlib version : %s", ptr, zlibVersion());
@@ -738,3 +742,5 @@
 
 	hap_register_build_opts(ptr, 1);
 }
+
+INITCALL0(STG_REGISTER, comp_register_build_opts);
diff --git a/src/da.c b/src/da.c
index c1c07e3..ee3d9af 100644
--- a/src/da.c
+++ b/src/da.c
@@ -4,6 +4,7 @@
 #include <common/errors.h>
 #include <common/http.h>
 #include <common/initcall.h>
+#include <types/global.h>
 #include <proto/arg.h>
 #include <proto/http_fetch.h>
 #include <proto/log.h>
@@ -398,8 +399,8 @@
 __attribute__((constructor))
 static void __da_init(void)
 {
-	/* register sample fetch and format conversion keywords */
-	hap_register_build_opts("Built with DeviceAtlas support.", 0);
 	hap_register_post_check(init_deviceatlas);
 	hap_register_post_deinit(deinit_deviceatlas);
 }
+
+REGISTER_BUILD_OPTS("Built with DeviceAtlas support.");
diff --git a/src/hathreads.c b/src/hathreads.c
index eb3eb59..d9128a7 100644
--- a/src/hathreads.c
+++ b/src/hathreads.c
@@ -17,6 +17,7 @@
 #include <common/cfgparse.h>
 #include <common/hathreads.h>
 #include <common/standard.h>
+#include <types/global.h>
 #include <proto/fd.h>
 
 
@@ -110,7 +111,6 @@
 #if defined(DEBUG_THREAD) || defined(DEBUG_FULL)
 	memset(lock_stats, 0, sizeof(lock_stats));
 #endif
-	hap_register_build_opts("Built with multi-threading support.", 0);
 }
 
 #endif // USE_THREAD
@@ -148,3 +148,5 @@
 #endif
 	return nbthread;
 }
+
+REGISTER_BUILD_OPTS("Built with multi-threading support.");
diff --git a/src/hlua.c b/src/hlua.c
index 820ddf5..294b6b3 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -8210,8 +8210,15 @@
 __attribute__((constructor))
 static void __hlua_init(void)
 {
+	cfg_register_postparser("hlua", hlua_check_config);
+}
+
+static void hlua_register_build_options(void)
+{
 	char *ptr = NULL;
+
 	memprintf(&ptr, "Built with Lua version : %s", LUA_RELEASE);
 	hap_register_build_opts(ptr, 1);
-	cfg_register_postparser("hlua", hlua_check_config);
 }
+
+INITCALL0(STG_REGISTER, hlua_register_build_options);
diff --git a/src/namespace.c b/src/namespace.c
index 72f5079..8a2e5a7 100644
--- a/src/namespace.c
+++ b/src/namespace.c
@@ -106,8 +106,4 @@
 	return sock;
 }
 
-__attribute__((constructor))
-static void __ns_init(void)
-{
-	hap_register_build_opts("Built with network namespace support.", 0);
-}
+REGISTER_BUILD_OPTS("Built with network namespace support.");
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 2692668..0c531e6 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -2032,30 +2032,26 @@
 
 INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_actions);
 
-__attribute__((constructor))
-static void __tcp_protocol_init(void)
-{
-	hap_register_build_opts("Built with transparent proxy support using:"
+REGISTER_BUILD_OPTS("Built with transparent proxy support using:"
 #if defined(IP_TRANSPARENT)
-	       " IP_TRANSPARENT"
+		    " IP_TRANSPARENT"
 #endif
 #if defined(IPV6_TRANSPARENT)
-	       " IPV6_TRANSPARENT"
+		    " IPV6_TRANSPARENT"
 #endif
 #if defined(IP_FREEBIND)
-	       " IP_FREEBIND"
+		    " IP_FREEBIND"
 #endif
 #if defined(IP_BINDANY)
-	       " IP_BINDANY"
+		    " IP_BINDANY"
 #endif
 #if defined(IPV6_BINDANY)
-	       " IPV6_BINDANY"
+		    " IPV6_BINDANY"
 #endif
 #if defined(SO_BINDANY)
-	       " SO_BINDANY"
+		    " SO_BINDANY"
 #endif
-		"", 0);
-}
+		    "");
 
 
 /*
diff --git a/src/regex.c b/src/regex.c
index f3f74c3..713f0c9 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -411,8 +411,7 @@
 	return 1;
 }
 
-__attribute__((constructor))
-static void __regex_init(void)
+static void regex_register_build_options(void)
 {
 	char *ptr = NULL;
 
@@ -458,6 +457,8 @@
 	hap_register_build_opts(ptr, 1);
 }
 
+INITCALL0(STG_REGISTER, regex_register_build_options);
+
 /*
  * Local variables:
  *  c-indent-level: 8
diff --git a/src/ssl_sock.c b/src/ssl_sock.c
index 3be4b2a..86d4f22 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -9251,9 +9251,6 @@
 __attribute__((constructor))
 static void __ssl_sock_init(void)
 {
-	char *ptr;
-	int i;
-
 	STACK_OF(SSL_COMP)* cm;
 
 	if (global_ssl.listen_default_ciphers)
@@ -9287,8 +9284,27 @@
 #if (defined SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB && TLS_TICKETS_NO > 0)
 	hap_register_post_check(tlskeys_finalize_config);
 #endif
+
+	global.ssl_session_max_cost   = SSL_SESSION_MAX_COST;
+	global.ssl_handshake_max_cost = SSL_HANDSHAKE_MAX_COST;
+
+#ifndef OPENSSL_NO_DH
+	ssl_dh_ptr_index = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
+	hap_register_post_deinit(ssl_free_dh);
+#endif
+#ifndef OPENSSL_NO_ENGINE
+	hap_register_post_deinit(ssl_free_engines);
+#endif
+	/* Load SSL string for the verbose & debug mode. */
+	ERR_load_SSL_strings();
+}
 
-	ptr = NULL;
+/* Compute and register the version string */
+static void ssl_register_build_options()
+{
+	char *ptr = NULL;
+	int i;
+
 	memprintf(&ptr, "Built with OpenSSL version : "
 #ifdef OPENSSL_IS_BORINGSSL
 		"BoringSSL");
@@ -9326,20 +9342,10 @@
 			memprintf(&ptr, "%s %s", ptr, methodVersions[i].name);
 
 	hap_register_build_opts(ptr, 1);
+}
 
-	global.ssl_session_max_cost   = SSL_SESSION_MAX_COST;
-	global.ssl_handshake_max_cost = SSL_HANDSHAKE_MAX_COST;
+INITCALL0(STG_REGISTER, ssl_register_build_options);
 
-#ifndef OPENSSL_NO_DH
-	ssl_dh_ptr_index = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
-	hap_register_post_deinit(ssl_free_dh);
-#endif
-#ifndef OPENSSL_NO_ENGINE
-	hap_register_post_deinit(ssl_free_engines);
-#endif
-	/* Load SSL string for the verbose & debug mode. */
-	ERR_load_SSL_strings();
-}
 
 #ifndef OPENSSL_NO_ENGINE
 void ssl_free_engines(void) {
diff --git a/src/wurfl.c b/src/wurfl.c
index eb1fb47..cd6abef 100644
--- a/src/wurfl.c
+++ b/src/wurfl.c
@@ -6,6 +6,7 @@
 #include <common/buffer.h>
 #include <common/errors.h>
 #include <common/initcall.h>
+#include <types/global.h>
 #include <proto/arg.h>
 #include <proto/log.h>
 #include <proto/proto_http.h>
@@ -693,8 +694,6 @@
 __attribute__((constructor))
 static void __wurfl_init(void)
 {
-	/* register sample fetch and format conversion keywords */
-	hap_register_build_opts("Built with WURFL support.", 0);
 	hap_register_post_check(ha_wurfl_init);
 	hap_register_post_deinit(ha_wurfl_deinit);
 }
@@ -802,3 +801,5 @@
 	ha_wurfl_log("WURFL: retrieve header request returns [%s]\n", ((ha_wurfl_header_t *)wh)->header_value);
 	return ((ha_wurfl_header_t *)wh)->header_value;
 }
+
+REGISTER_BUILD_OPTS("Built with WURFL support.");