Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt	(revision 8)
+++ CMakeLists.txt	(revision 9)
@@ -23,4 +23,7 @@
 # All source code should be POSIX 200112L compatible, but some other extensions might be used, so:
 ADD_DEFINITIONS(-D_GNU_SOURCE)
+IF (CMAKE_BUILD_TYPE MATCHES "Debug")
+  SET(DEBUG 1)
+ENDIF (CMAKE_BUILD_TYPE MATCHES "Debug")
 
 # some subfolders use yacc and lex parsers
Index: doc/freediameter.conf.sample
===================================================================
--- doc/freediameter.conf.sample	(revision 8)
+++ doc/freediameter.conf.sample	(revision 9)
@@ -129,4 +129,4 @@
 TwTimer = 6;
 NoRelay;
-LoadExtension = "extensions/sample.so";
-LoadExtension = "extensions/sample.so":"conf/sample.conf";
+#LoadExtension = "extensions/sample.fdx";
+LoadExtension = "extensions/sample.fdx":"conf/sample.conf";
Index: extensions/CMakeLists.txt
===================================================================
--- extensions/CMakeLists.txt	(revision 8)
+++ extensions/CMakeLists.txt	(revision 9)
@@ -3,9 +3,13 @@
 # We want all resulting objects in the same folder
 SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})
-# And named fdext_XXX instead of libXXX.so
 
-#-- faire une macro ici!
-SET(FD_EXT_PREFIX "fdext_" PARENT_SCOPE)
-SET(FD_EXT_SUFFIX "" PARENT_SCOPE)
+# Use the macro FD_ADD_EXTENSION(name files...) to create an extension
+# It is equivalent to add_library with the appropriate parameters
+# and naming conventions (.fdx : FreeDiameter eXtension)
+MACRO(FD_ADD_EXTENSION EXTNAME)
+  ADD_LIBRARY(${EXTNAME} MODULE ${ARGN})
+  SET_TARGET_PROPERTIES(${EXTNAME} PROPERTIES PREFIX "" )
+  SET_TARGET_PROPERTIES(${EXTNAME} PROPERTIES SUFFIX ".fdx" )
+ENDMACRO(FD_ADD_EXTENSION)
 
 ###########################
Index: extensions/_sample/CMakeLists.txt
===================================================================
--- extensions/_sample/CMakeLists.txt	(revision 8)
+++ extensions/_sample/CMakeLists.txt	(revision 9)
@@ -3,7 +3,3 @@
 
 # Compile as a module
-ADD_LIBRARY(sample MODULE sample.c fini.c)
-
-# Comply to naming scheme
-SET_TARGET_PROPERTIES(sample PROPERTIES PREFIX "${FD_EXT_PREFIX}" )
-SET_TARGET_PROPERTIES(sample PROPERTIES SUFFIX "${FD_EXT_SUFFIX}" )
+FD_ADD_EXTENSION(sample sample.c fini.c)
Index: extensions/_sample/fini.c
===================================================================
--- extensions/_sample/fini.c	(revision 8)
+++ extensions/_sample/fini.c	(revision 9)
@@ -40,5 +40,5 @@
 void fd_ext_fini(void)
 {
-	log_debug("Extension is terminated... Bye!\n");
+	fd_log_debug("Extension is terminated... Bye!\n");
 	return ;
 }
Index: extensions/_sample/sample.c
===================================================================
--- extensions/_sample/sample.c	(revision 8)
+++ extensions/_sample/sample.c	(revision 9)
@@ -56,5 +56,5 @@
 	
 	/* Use the dictionary for test */
-	log_debug("Let's create that 'Example-AVP'...\n");
+	fd_log_debug("Let's create that 'Example-AVP'...\n");
 	{
 		struct dict_object * origin_host_avp = NULL;
@@ -79,5 +79,5 @@
 		CHECK_FCT( fd_dict_new ( fd_g_config->g_dict, DICT_RULE, &rule_data, example_avp_avp, NULL ));
 	}
-	log_debug("'Example-AVP' created without error\n");
+	fd_log_debug("'Example-AVP' created without error\n");
 	
 	return 0;
Index: freeDiameter/extensions.c
===================================================================
--- freeDiameter/extensions.c	(revision 8)
+++ freeDiameter/extensions.c	(revision 9)
@@ -97,5 +97,10 @@
 		
 		/* Load the extension */
+#ifndef DEBUG
 		ext->handler = dlopen(ext->filename, RTLD_LAZY | RTLD_GLOBAL);
+#else /* DEBUG */
+		/* We resolve immediatly so it's easier to find problems in ABI */
+		ext->handler = dlopen(ext->filename, RTLD_NOW | RTLD_GLOBAL);
+#endif /* DEBUG */
 		if (ext->handler == NULL) {
 			/* An error occured */
Index: freeDiameter/main.c
===================================================================
--- freeDiameter/main.c	(revision 8)
+++ freeDiameter/main.c	(revision 9)
@@ -247,5 +247,6 @@
 	
 	/* cleanups */
-	CHECK_FCT( fd_thr_term(&sig_th) );
+	CHECK_FCT_DO( fd_ext_fini(), /* continue */ );
+	CHECK_FCT_DO( fd_thr_term(&sig_th), /* continue */ );
 	
 	return ret;
Index: include/freeDiameter/freeDiameter-host.h.in
===================================================================
--- include/freeDiameter/freeDiameter-host.h.in	(revision 8)
+++ include/freeDiameter/freeDiameter-host.h.in	(revision 9)
@@ -46,4 +46,6 @@
 #cmakedefine DISABLE_SCTP
 
+#cmakedefine DEBUG
+
 #cmakedefine FD_PROJECT_BINARY "@FD_PROJECT_BINARY@"
 #cmakedefine FD_PROJECT_NAME "@FD_PROJECT_NAME@"
