Fix building with `MBEDTLS_TEST_HOOKS` enabled

Fix building by adding `common.c` to the build scripts (both make and Cmake).

Also reworks the hook function pointer (also renamed to `err_add_hook`) to be
a static local to `common.c` with a setter function to set the pointer to a
checking function.

Signed-off-by: Chris Jones <christopher.jones@arm.com>
diff --git a/tests/suites/main_test.function b/tests/suites/main_test.function
index b35b143..09927fe 100644
--- a/tests/suites/main_test.function
+++ b/tests/suites/main_test.function
@@ -33,6 +33,10 @@
 #include "psa/crypto.h"
 #endif /* MBEDTLS_USE_PSA_CRYPTO */
 
+#if defined(MBEDTLS_TEST_HOOKS)
+#include "common.h"
+#endif
+
 /* Test code may use deprecated identifiers only if the preprocessor symbol
  * MBEDTLS_TEST_DEPRECATED is defined. When building tests, set
  * MBEDTLS_TEST_DEPRECATED explicitly if MBEDTLS_DEPRECATED_WARNING is
@@ -280,7 +284,7 @@
 int main( int argc, const char *argv[] )
 {
 #if defined(MBEDTLS_TEST_HOOKS)
-    mbedtls_test_err_add_hook = &mbedtls_test_err_add_check;
+    mbedtls_set_err_add_hook( &mbedtls_test_err_add_check );
 #endif
 
     int ret = mbedtls_test_platform_setup();