changeset 304:ad3c46016584

Added install directives for cmake; also allow default directory to seek for extensions and configuration files
author Sebastien Decugis <sdecugis@nict.go.jp>
date Fri, 14 May 2010 17:26:53 +0900
parents 32ba9cf7ba87
children 61f78fdbacc2
files CMakeLists.txt INSTALL INSTALL.Ubuntu cmake/Modules/CMakeUserUseBison.cmake cmake/Modules/CMakeUserUseFlex.cmake cmake/Modules/FindGnuTLS.cmake cmake/Modules/FindPostgreSQL.cmake extensions/CMakeLists.txt extensions/_sample/CMakeLists.txt extensions/acl_wl/CMakeLists.txt extensions/app_acct/CMakeLists.txt extensions/app_radgw/CMakeLists.txt extensions/app_radgw/rgw_conf.y extensions/dbg_monitor/CMakeLists.txt extensions/dbg_rt/CMakeLists.txt extensions/dict_eap/CMakeLists.txt extensions/dict_nasreq/CMakeLists.txt extensions/rt_default/CMakeLists.txt extensions/test_acct/CMakeLists.txt extensions/test_app/CMakeLists.txt extensions/test_rt_any/CMakeLists.txt freeDiameter/CMakeLists.txt freeDiameter/config.c freeDiameter/fD.h freeDiameter/fdd.y freeDiameter/main.c freeDiameter/tests/CMakeLists.txt include/freeDiameter/CMakeLists.txt include/freeDiameter/freeDiameter-host.h.in include/freeDiameter/libfreeDiameter.h libfreeDiameter/CMakeLists.txt
diffstat 31 files changed, 320 insertions(+), 88 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Fri May 14 10:42:49 2010 +0900
+++ b/CMakeLists.txt	Fri May 14 17:26:53 2010 +0900
@@ -47,13 +47,13 @@
 SUBDIRS(libfreeDiameter)
 SUBDIRS(freeDiameter)
 
-# Do we build the extensions?
-OPTION(IGNORE_ALL_EXTENSIONS "Ignore the extensions completly?")
-IF(NOT IGNORE_ALL_EXTENSIONS)
-	SUBDIRS(extensions)
-ENDIF(NOT IGNORE_ALL_EXTENSIONS)
+# Extensions (there is no point in freeDiameter without any extension)
+SUBDIRS(extensions)
+
 
-# The documentation to install
+####
+## INSTALL section ##
+
 INSTALL(FILES README LICENSE doc/freediameter.conf.sample
 	DESTINATION doc
 	COMPONENT freeDiameter-doc)
--- a/INSTALL	Fri May 14 10:42:49 2010 +0900
+++ b/INSTALL	Fri May 14 17:26:53 2010 +0900
@@ -2,18 +2,24 @@
 to generate the Makefiles for your platform. You can also select which extensions must be built.
 
 Building in a separate directory is recommended:
-mkdir build
-cd build
-cmake ../
-make
+# mkdir build
+# cd build
+# cmake ../
+# make
+
+Note: instead of passing options on the command line, you can use a CMake front-end (for example ccmake or cmake-gui)
+or edit the CCmakeCache.txt file directly. If your cmake installation is recent, you can also do:
+# mkdir build
+# cd build
+# cmake ../
+# make edit_cache
+# make
+
 
 You can enable the unary tests by doing:
-cmake -DSKIP_TESTS:BOOL=OFF ../
-make
-make tests
-
-Note: instead of passing options on the command line, you can use a CMake front-end (for example ccmake or cmake-gui)
-or edit the CCmakeCache.txt file directly.
+# cmake -DSKIP_TESTS:BOOL=OFF ../
+# make
+# make tests
 
 Note that there are dependencies on external tools that may not be enforced by the configure script.
 See the specific INSTALL.distro files matching your situation.
--- a/INSTALL.Ubuntu	Fri May 14 10:42:49 2010 +0900
+++ b/INSTALL.Ubuntu	Fri May 14 17:26:53 2010 +0900
@@ -52,3 +52,5 @@
 9) (OPTION) Check the software has a correct basic behavior on your environment. -- only if you did not disable the tests in step 6
 # make test
 
+
+
--- a/cmake/Modules/CMakeUserUseBison.cmake	Fri May 14 10:42:49 2010 +0900
+++ b/cmake/Modules/CMakeUserUseBison.cmake	Fri May 14 17:26:53 2010 +0900
@@ -25,6 +25,7 @@
  IF(BISON_EXECUTABLE)
    MESSAGE(STATUS "Looking for bison -- ${BISON_EXECUTABLE}")
  ENDIF(BISON_EXECUTABLE)
+ MARK_AS_ADVANCED(BISON_EXECUTABLE)
 ENDIF(NOT BISON_EXECUTABLE)
 
 IF(BISON_EXECUTABLE)
--- a/cmake/Modules/CMakeUserUseFlex.cmake	Fri May 14 10:42:49 2010 +0900
+++ b/cmake/Modules/CMakeUserUseFlex.cmake	Fri May 14 17:26:53 2010 +0900
@@ -15,6 +15,7 @@
   IF(FLEX_EXECUTABLE)
     MESSAGE(STATUS "Looking for flex -- ${FLEX_EXECUTABLE}")
   ENDIF(FLEX_EXECUTABLE)
+ MARK_AS_ADVANCED(FLEX_EXECUTABLE)
 ENDIF(NOT FLEX_EXECUTABLE) 
 
 IF(FLEX_EXECUTABLE)
--- a/cmake/Modules/FindGnuTLS.cmake	Fri May 14 10:42:49 2010 +0900
+++ b/cmake/Modules/FindGnuTLS.cmake	Fri May 14 17:26:53 2010 +0900
@@ -34,4 +34,4 @@
 
 # Lastly make it so that the GNUTLS_LIBRARY and GNUTLS_INCLUDE_DIR variables
 # only show up under the advanced options in the gui cmake applications.
-MARK_AS_ADVANCED( GNUTLS_LIBRARIES GNUTLS_INCLUDE_DIRS )
+MARK_AS_ADVANCED( GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR )
--- a/cmake/Modules/FindPostgreSQL.cmake	Fri May 14 10:42:49 2010 +0900
+++ b/cmake/Modules/FindPostgreSQL.cmake	Fri May 14 17:26:53 2010 +0900
@@ -33,4 +33,4 @@
 
 # Lastly make it so that the POSTGRESQL_LIBRARY and POSTGRESQL_INCLUDE_DIR variables
 # only show up under the advanced options in the gui cmake applications.
-MARK_AS_ADVANCED( POSTGRESQL_LIBRARIES POSTGRESQL_INCLUDE_DIR )
+MARK_AS_ADVANCED( POSTGRESQL_LIBRARY POSTGRESQL_INCLUDE_DIR )
--- a/extensions/CMakeLists.txt	Fri May 14 10:42:49 2010 +0900
+++ b/extensions/CMakeLists.txt	Fri May 14 17:26:53 2010 +0900
@@ -19,6 +19,7 @@
 If ( NOT GCRYPT_INCLUDE_DIR )
 	MESSAGE(SEND_ERROR "Unable to find gcrypt.h, please install libgcrypt-dev or equivalent")
 Endif ( NOT GCRYPT_INCLUDE_DIR )
+MARK_AS_ADVANCED(GCRYPT_INCLUDE_DIR)
 INCLUDE_DIRECTORIES(${GCRYPT_INCLUDE_DIR})
 
 ###########################
@@ -76,11 +77,6 @@
 ####
 # Debug & test extensions
 
-OPTION(BUILD_SAMPLE "Build sample.fdx? (Simple extension to demonstrate extension mechanism, for developpers only)" OFF)
-	IF (BUILD_SAMPLE)
-	   SUBDIRS(_sample)
-	ENDIF (BUILD_SAMPLE)
-
 OPTION(BUILD_DBG_MONITOR "Build dbg_monitor.fdx? (display periodical debug information on the console)" OFF)
 	IF (BUILD_DBG_MONITOR)
 	   SUBDIRS(dbg_monitor)
@@ -91,17 +87,26 @@
  	   SUBDIRS(dbg_rt)
  	ENDIF (BUILD_DBG_RT)
 
-OPTION(BUILD_TEST_ACCT "Build test_acct.fdx? (Receive Accounting-Requests and display the data, but no storage)" OFF)
-	IF (BUILD_TEST_ACCT)
-	   SUBDIRS(test_acct)
-	ENDIF (BUILD_TEST_ACCT)
-
 OPTION(BUILD_TEST_APP "Build test_app.fdx? (Testing application to send dummy message to another peer, for testing purpose only)" OFF)
  	IF (BUILD_TEST_APP)
  	   SUBDIRS(test_app)
  	ENDIF (BUILD_TEST_APP)
 
-OPTION(BUILD_TEST_RT_ANY "Build test_rt_any.fdx? (Routing extension randomly sending message to any peer available, for testing purpose only)" OFF)
- 	IF (BUILD_TEST_RT_ANY)
- 	   SUBDIRS(test_rt_any)
- 	ENDIF (BUILD_TEST_RT_ANY)
+# The following extension have very little use except for specific tests, so we disable them except in Debug configurations.
+IF (CMAKE_BUILD_TYPE MATCHES "Debug")
+	OPTION(BUILD_SAMPLE "Build sample.fdx? (Simple extension to demonstrate extension mechanism, for developpers only)" OFF)
+		IF (BUILD_SAMPLE)
+		   SUBDIRS(_sample)
+		ENDIF (BUILD_SAMPLE)
+
+	OPTION(BUILD_TEST_ACCT "Build test_acct.fdx? (Receive Accounting-Requests and display the data, but no storage)" OFF)
+		IF (BUILD_TEST_ACCT)
+		   SUBDIRS(test_acct)
+		ENDIF (BUILD_TEST_ACCT)
+		
+	OPTION(BUILD_TEST_RT_ANY "Build test_rt_any.fdx? (Routing extension randomly sending message to any peer available, for testing purpose only)" OFF)
+ 		IF (BUILD_TEST_RT_ANY)
+ 		   SUBDIRS(test_rt_any)
+ 		ENDIF (BUILD_TEST_RT_ANY)
+ENDIF (CMAKE_BUILD_TYPE MATCHES "Debug")
+
--- a/extensions/_sample/CMakeLists.txt	Fri May 14 10:42:49 2010 +0900
+++ b/extensions/_sample/CMakeLists.txt	Fri May 14 17:26:53 2010 +0900
@@ -2,10 +2,21 @@
 PROJECT("Sample extension" C)
 
 # Overwrite the debug level for the extension code if configured
-OPTION(DEBUG_LEVEL__SAMPLE "Overwrite debug level for the extension _sample if defined" OFF)
+OPTION(DEBUG_LEVEL__SAMPLE "Overwrite debug level for the extension _sample if defined (valid values: FULL, ANNOYING, CALL...)" OFF)
 IF (DEBUG_LEVEL__SAMPLE)
      ADD_DEFINITIONS(-DTRACE_LEVEL=${DEBUG_LEVEL__SAMPLE})
 ENDIF (DEBUG_LEVEL__SAMPLE)
+IF (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
+  MARK_AS_ADVANCED(DEBUG_LEVEL__SAMPLE)
+ENDIF (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
 
 # Compile as a module
 FD_ADD_EXTENSION(dbg_sample sample.c fini.c)
+
+
+####
+## INSTALL section ##
+
+INSTALL(TARGETS dbg_sample
+	LIBRARY DESTINATION ${DEFAULT_EXTENSIONS_PATH}
+	COMPONENT freeDiameter-debug-tools)
--- a/extensions/acl_wl/CMakeLists.txt	Fri May 14 10:42:49 2010 +0900
+++ b/extensions/acl_wl/CMakeLists.txt	Fri May 14 17:26:53 2010 +0900
@@ -17,10 +17,22 @@
 )
 
 # Overwrite the debug level for the extension code if configured
-OPTION(DEBUG_LEVEL_ACL_WL "Overwrite debug level for the extension acl_wl if defined" OFF)
+OPTION(DEBUG_LEVEL_ACL_WL "Overwrite debug level for the extension acl_wl if defined (valid values: FULL, ANNOYING, CALL...)" OFF)
 IF (DEBUG_LEVEL_ACL_WL)
      ADD_DEFINITIONS(-DTRACE_LEVEL=${DEBUG_LEVEL_ACL_WL})
 ENDIF (DEBUG_LEVEL_ACL_WL)
+IF (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
+  MARK_AS_ADVANCED(DEBUG_LEVEL_ACL_WL)
+ENDIF (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
 
 # Compile as a module
 FD_ADD_EXTENSION(acl_wl ${ACL_WL_SRC})
+
+
+####
+## INSTALL section ##
+
+# We install with the daemon component because it is a base feature.
+INSTALL(TARGETS acl_wl
+	LIBRARY DESTINATION ${DEFAULT_EXTENSIONS_PATH}
+	COMPONENT freeDiameter-daemon)
--- a/extensions/app_acct/CMakeLists.txt	Fri May 14 10:42:49 2010 +0900
+++ b/extensions/app_acct/CMakeLists.txt	Fri May 14 17:26:53 2010 +0900
@@ -28,3 +28,12 @@
 # Compile as a module
 FD_ADD_EXTENSION(app_acct ${APP_ACCT_SRC} ${APP_ACCT_SRC_GEN})
 TARGET_LINK_LIBRARIES(app_acct ${POSTGRESQL_LIBRARIES})
+
+
+####
+## INSTALL section ##
+
+INSTALL(TARGETS app_acct
+	LIBRARY DESTINATION ${DEFAULT_EXTENSIONS_PATH}
+	COMPONENT freeDiameter-accounting-server)
+
--- a/extensions/app_radgw/CMakeLists.txt	Fri May 14 10:42:49 2010 +0900
+++ b/extensions/app_radgw/CMakeLists.txt	Fri May 14 17:26:53 2010 +0900
@@ -3,10 +3,13 @@
 
 
 # Overwrite the debug level for the extension code if configured
-OPTION(DEBUG_LEVEL_APP_RADGW "Overwrite debug level for the extension app_radgw if defined" OFF)
+OPTION(DEBUG_LEVEL_APP_RADGW "Overwrite debug level for the extension app_radgw if defined (valid values: FULL, ANNOYING, CALL...)" OFF)
 IF (DEBUG_LEVEL_APP_RADGW)
      ADD_DEFINITIONS(-DTRACE_LEVEL=${DEBUG_LEVEL_APP_RADGW})
 ENDIF (DEBUG_LEVEL_APP_RADGW)
+IF (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
+  MARK_AS_ADVANCED(DEBUG_LEVEL_APP_RADGW)
+ENDIF (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
 
 
 ########### Utility library #############
@@ -64,6 +67,9 @@
   SET_TARGET_PROPERTIES(${PLGNAME} PROPERTIES PREFIX "" )
   SET_TARGET_PROPERTIES(${PLGNAME} PROPERTIES SUFFIX ".rgwx" )
   TARGET_LINK_LIBRARIES(${PLGNAME} rgw_common)
+  INSTALL(TARGETS ${PLGNAME}
+	LIBRARY DESTINATION ${DEFAULT_EXTENSIONS_PATH}
+	COMPONENT freeDiameter-radius-gateway)
 ENDMACRO(RGWX_ADD_PLUGIN)
 
 
@@ -102,3 +108,13 @@
   	   SET_SOURCE_FILES_PROPERTIES(lex.rgwx_echodrop.c rgwx_echodrop.tab.c PROPERTIES COMPILE_FLAGS "-I ${CMAKE_CURRENT_SOURCE_DIR}")
  	   RGWX_ADD_PLUGIN(echodrop ${RG_COMMON_HEADER} rgwx_echodrop.h rgwx_echodrop.c lex.rgwx_echodrop.c rgwx_echodrop.tab.c rgwx_echodrop.tab.h )
   	ENDIF (BUILD_RGWX_ECHODROP)
+	
+	
+####
+## INSTALL section ##
+
+INSTALL(TARGETS app_radgw
+	LIBRARY DESTINATION ${DEFAULT_EXTENSIONS_PATH}
+	COMPONENT freeDiameter-radius-gateway)
+
+# Note that all compiled plugins are added by the RGWX_ADD_PLUGIN macro in the component freeDiameter-radius-gateway as well.
--- a/extensions/app_radgw/rgw_conf.y	Fri May 14 10:42:49 2010 +0900
+++ b/extensions/app_radgw/rgw_conf.y	Fri May 14 17:26:53 2010 +0900
@@ -52,7 +52,6 @@
 #include "rgw.h"
 #include "rgw_conf.tab.h"	/* bison is not smart enough to define the YYLTYPE before including this code, so... */
 
-#include <sys/stat.h>
 #include <sys/socket.h>
 #include <arpa/inet.h>
 #include <netdb.h>
@@ -98,22 +97,6 @@
 		fd_log_debug("%s:%d.%d : %s\n", conffile, ploc->first_line, ploc->first_column, s);
 }
 
-/* This function checks a string value is a valid filename */
-static int is_valid_file( char * candidate ) 
-{
-	int ret;
-	struct stat buffer;
-	
-	ret = stat(candidate, &buffer);
-	if (ret != 0) {
-		fd_log_debug("Error on file '%s': %s.\n", candidate, strerror(errno));
-		return 0;
-	}
-
-	/* Ok this candidate is valid */
-	return 1;
-}
-
 /* Very simple byte stack management */
 static unsigned char * buf = NULL;
 static size_t buf_sz = 0;
@@ -160,7 +143,7 @@
 %token <integer> INTEGER
 %token <ss>	IP
 
-%type <string>	FILENAME
+%type <string>	FINDFILEEXT
 
 /* simple tokens */
 %token		DISABLED
@@ -196,14 +179,30 @@
 
 				
 /* -------------------------------------- */
-FILENAME:		QSTRING
+FINDFILEEXT:		QSTRING
 			{
-				/* Verify this is a valid file */
-				if (!is_valid_file($1)) {
-					yyerror (&yylloc, conffile, "Error on file name, aborting...");
+				char * fname = $1;
+				FILE * fd;
+				
+				/* First, check if the file exists */
+				fd = fopen(fname, "r");
+				if ((fd == NULL) && (*fname != '/')) {
+					char * bkp = fname;
+					CHECK_MALLOC_DO( fname = malloc( strlen(bkp) + strlen(DEFAULT_EXTENSIONS_PATH) + 2 ),
+						{ yyerror (&yylloc, conffile, "Not enough memory"); YYERROR; } );
+					sprintf(fname, DEFAULT_EXTENSIONS_PATH "/%s", bkp);
+					free(bkp);
+					fd = fopen(fname, "r");
+				}
+				if (fd == NULL) {
+					int ret = errno;
+					TRACE_DEBUG(INFO, "Unable to open file %s for reading: %s\n", fname, strerror(ret));
+					yyerror (&yylloc, conffile, "Error adding plugin"); 
 					YYERROR;
 				}
-				$$ = $1;
+				fclose(fd);
+				
+				$$ = fname;
 			}
 			;
 /* -------------------------------------- */
@@ -213,7 +212,7 @@
 				port = RGW_PLG_TYPE_AUTH | RGW_PLG_TYPE_ACCT ;
 				free(plgconffile); plgconffile = NULL;
 			}
-			PLG_PREFIX '=' FILENAME plg_attributes ';'
+			PLG_PREFIX '=' FINDFILEEXT plg_attributes ';'
 			{
 				/* Add this extension in the list */
 				if ( rgw_plg_add( $4, plgconffile, port, &buf, buf_sz ) ) {
--- a/extensions/dbg_monitor/CMakeLists.txt	Fri May 14 10:42:49 2010 +0900
+++ b/extensions/dbg_monitor/CMakeLists.txt	Fri May 14 17:26:53 2010 +0900
@@ -1,3 +1,12 @@
 # Monitoring extension
 PROJECT("Monitor extension" C)
 FD_ADD_EXTENSION(dbg_monitor dbg_monitor.c)
+
+
+####
+## INSTALL section ##
+
+INSTALL(TARGETS dbg_monitor
+	LIBRARY DESTINATION ${DEFAULT_EXTENSIONS_PATH}
+	COMPONENT freeDiameter-debug-tools)
+
--- a/extensions/dbg_rt/CMakeLists.txt	Fri May 14 10:42:49 2010 +0900
+++ b/extensions/dbg_rt/CMakeLists.txt	Fri May 14 17:26:53 2010 +0900
@@ -3,3 +3,11 @@
 
 # Compile as a module
 FD_ADD_EXTENSION(dbg_rt dbg_rt.c)
+
+
+####
+## INSTALL section ##
+
+INSTALL(TARGETS dbg_rt
+	LIBRARY DESTINATION ${DEFAULT_EXTENSIONS_PATH}
+	COMPONENT freeDiameter-debug-tools)
--- a/extensions/dict_eap/CMakeLists.txt	Fri May 14 10:42:49 2010 +0900
+++ b/extensions/dict_eap/CMakeLists.txt	Fri May 14 17:26:53 2010 +0900
@@ -3,3 +3,11 @@
 
 # Compile as a module
 FD_ADD_EXTENSION(dict_eap dict_eap.c)
+
+
+####
+## INSTALL section ##
+
+INSTALL(TARGETS dict_eap
+	LIBRARY DESTINATION ${DEFAULT_EXTENSIONS_PATH}
+	COMPONENT freeDiameter-dictionary-RFC4072)
--- a/extensions/dict_nasreq/CMakeLists.txt	Fri May 14 10:42:49 2010 +0900
+++ b/extensions/dict_nasreq/CMakeLists.txt	Fri May 14 17:26:53 2010 +0900
@@ -3,3 +3,11 @@
 
 # Compile as a module
 FD_ADD_EXTENSION(dict_nasreq dict_nasreq.c)
+
+
+####
+## INSTALL section ##
+
+INSTALL(TARGETS dict_nasreq
+	LIBRARY DESTINATION ${DEFAULT_EXTENSIONS_PATH}
+	COMPONENT freeDiameter-dictionary-RFC4005)
--- a/extensions/rt_default/CMakeLists.txt	Fri May 14 10:42:49 2010 +0900
+++ b/extensions/rt_default/CMakeLists.txt	Fri May 14 17:26:53 2010 +0900
@@ -31,10 +31,23 @@
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
 
 # Overwrite the debug level for the extension code if configured, example: cmake -DDEBUG_LEVEL_RT_DEFAULT:STATIC=CALL ...
-OPTION(DEBUG_LEVEL_RT_DEFAULT "Overwrite debug level for the extension rt_default if defined" OFF)
+OPTION(DEBUG_LEVEL_RT_DEFAULT "Overwrite debug level for the extension rt_default if defined (valid values: FULL, ANNOYING, CALL...)" OFF)
 IF (DEBUG_LEVEL_RT_DEFAULT)
      ADD_DEFINITIONS(-DTRACE_LEVEL=${DEBUG_LEVEL_RT_DEFAULT})
 ENDIF (DEBUG_LEVEL_RT_DEFAULT)
+IF (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
+  MARK_AS_ADVANCED(DEBUG_LEVEL_RT_DEFAULT)
+ENDIF (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
 
 # Compile these files as a freeDiameter extension
 FD_ADD_EXTENSION(rt_default ${RT_DEFAULT_SRC})
+
+
+####
+## INSTALL section ##
+
+# We install with the daemon component because it is a base feature.
+INSTALL(TARGETS rt_default
+	LIBRARY DESTINATION ${DEFAULT_EXTENSIONS_PATH}
+	COMPONENT freeDiameter-daemon)
+
--- a/extensions/test_acct/CMakeLists.txt	Fri May 14 10:42:49 2010 +0900
+++ b/extensions/test_acct/CMakeLists.txt	Fri May 14 17:26:53 2010 +0900
@@ -2,3 +2,12 @@
 PROJECT("Accounting dummy server" C)
 
 FD_ADD_EXTENSION(test_acct test_acct.c)
+
+
+####
+## INSTALL section ##
+
+INSTALL(TARGETS test_acct
+	LIBRARY DESTINATION ${DEFAULT_EXTENSIONS_PATH}
+	COMPONENT freeDiameter-debug-tools)
+
--- a/extensions/test_app/CMakeLists.txt	Fri May 14 10:42:49 2010 +0900
+++ b/extensions/test_app/CMakeLists.txt	Fri May 14 17:26:53 2010 +0900
@@ -20,3 +20,12 @@
 
 # Compile as a module
 FD_ADD_EXTENSION(test_app ${APP_TEST_SRC})
+
+
+####
+## INSTALL section ##
+
+INSTALL(TARGETS test_app
+	LIBRARY DESTINATION ${DEFAULT_EXTENSIONS_PATH}
+	COMPONENT freeDiameter-debug-tools)
+
--- a/extensions/test_rt_any/CMakeLists.txt	Fri May 14 10:42:49 2010 +0900
+++ b/extensions/test_rt_any/CMakeLists.txt	Fri May 14 17:26:53 2010 +0900
@@ -3,3 +3,11 @@
 
 # Compile as a module
 FD_ADD_EXTENSION(test_rt_any test_rt_any.c)
+
+
+####
+## INSTALL section ##
+
+INSTALL(TARGETS test_rt_any
+	LIBRARY DESTINATION ${DEFAULT_EXTENSIONS_PATH}
+	COMPONENT freeDiameter-debug-tools)
--- a/freeDiameter/CMakeLists.txt	Fri May 14 10:42:49 2010 +0900
+++ b/freeDiameter/CMakeLists.txt	Fri May 14 17:26:53 2010 +0900
@@ -51,6 +51,7 @@
 If ( NOT GCRYPT_INCLUDE_DIR )
 	MESSAGE(SEND_ERROR "Unable to find gcrypt.h, please install libgcrypt-dev or equivalent")
 Endif ( NOT GCRYPT_INCLUDE_DIR )
+MARK_AS_ADVANCED(GCRYPT_INCLUDE_DIR)
 INCLUDE_DIRECTORIES(${GCRYPT_INCLUDE_DIR})
 
 # Building the executable
@@ -63,17 +64,23 @@
 LINK_DIRECTORIES(${CURRENT_BINARY_DIR}/../libfreeDiameter)
 TARGET_LINK_LIBRARIES(freeDiameterd libfreeDiameter ${FD_LIBS})
 
-# The daemon is to be installed as part of the freeDiameter-daemon component.
-INSTALL(TARGETS freeDiameterd
-	RUNTIME DESTINATION bin
-	COMPONENT freeDiameter-daemon)
-
 # Save the list of files, if needed
 SET(FD_COMMON_SRC ${FD_COMMON_SRC} PARENT_SCOPE)
 SET(FD_COMMON_GEN_SRC ${FD_COMMON_GEN_SRC} PARENT_SCOPE)
 
 # The unary tests directory
-OPTION(SKIP_TESTS "Skip compilation of the tests?" OFF)
+OPTION(SKIP_TESTS "Skip compilation of the tests?" ON)
 IF ( NOT SKIP_TESTS )
 	SUBDIRS(tests)
 ENDIF ( NOT SKIP_TESTS )
+IF (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
+  MARK_AS_ADVANCED(SKIP_TESTS)
+ENDIF (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
+
+
+####
+## INSTALL section ##
+
+INSTALL(TARGETS freeDiameterd
+	RUNTIME DESTINATION bin
+	COMPONENT freeDiameter-daemon)
--- a/freeDiameter/config.c	Fri May 14 10:42:49 2010 +0900
+++ b/freeDiameter/config.c	Fri May 14 17:26:53 2010 +0900
@@ -34,6 +34,7 @@
 *********************************************************************************************************/
 
 #include "fD.h"
+#include <sys/stat.h>
 
 /* Configuration management */
 
@@ -50,7 +51,6 @@
 	TRACE_ENTRY();
 	
 	fd_g_config->cnf_eyec = EYEC_CONFIG;
-	fd_g_config->cnf_file = DEFAULT_CONF_FILE;
 	
 	fd_g_config->cnf_timer_tc = 30;
 	fd_g_config->cnf_timer_tw = 30;
@@ -144,9 +144,18 @@
 {
 	extern FILE * fddin;
 	
-	TRACE_DEBUG (FULL, "Parsing configuration file: %s", fd_g_config->cnf_file);
+	/* Attempt to find the configuration file */
+	if (!fd_g_config->cnf_file)
+		fd_g_config->cnf_file = FD_DEFAULT_CONF_FILENAME;
 	
 	fddin = fopen(fd_g_config->cnf_file, "r");
+	if ((fddin == NULL) && (*fd_g_config->cnf_file != '/')) {
+		/* We got a relative path, attempt to add the default directory prefix */
+		char * bkp = fd_g_config->cnf_file;
+		CHECK_MALLOC( fd_g_config->cnf_file = malloc(strlen(bkp) + strlen(DEFAULT_CONF_PATH) + 2) ); /* we will not free it, but not important */
+		sprintf( fd_g_config->cnf_file, DEFAULT_CONF_PATH "/%s", bkp );
+		fddin = fopen(fd_g_config->cnf_file, "r");
+	}
 	if (fddin == NULL) {
 		int ret = errno;
 		fprintf(stderr, "Unable to open configuration file %s for reading: %s\n", fd_g_config->cnf_file, strerror(ret));
@@ -154,6 +163,7 @@
 	}
 	
 	/* call yacc parser */
+	TRACE_DEBUG (FULL, "Parsing configuration file: %s", fd_g_config->cnf_file);
 	CHECK_FCT(  fddparse(fd_g_config)  );
 	
 	/* close the file */
--- a/freeDiameter/fD.h	Fri May 14 10:42:49 2010 +0900
+++ b/freeDiameter/fD.h	Fri May 14 17:26:53 2010 +0900
@@ -41,6 +41,10 @@
 #include <freeDiameter/freeDiameter-host.h>
 #include <freeDiameter/freeDiameter.h>
 
+#ifndef FD_DEFAULT_CONF_FILENAME
+#define FD_DEFAULT_CONF_FILENAME "freeDiameter.conf"
+#endif /* FD_DEFAULT_CONF_FILENAME */
+
 #ifdef DISABLE_SCTP
 #undef IPPROTO_SCTP
 #define IPPROTO_SCTP	(2 = 4) /* some compilation error to spot the references */
--- a/freeDiameter/fdd.y	Fri May 14 10:42:49 2010 +0900
+++ b/freeDiameter/fdd.y	Fri May 14 17:26:53 2010 +0900
@@ -308,7 +308,52 @@
 
 loadext:		LOADEXT '=' QSTRING extconf ';'
 			{
-				CHECK_FCT_DO( fd_ext_add( $3, $4 ),
+				char * fname;
+				char * cfname;
+				FILE * fd;
+				
+				/* Try and open the extension file */
+				fname = $3;
+				fd = fopen(fname, "r");
+				if ((fd == NULL) && (*fname != '/')) {
+					char * bkp = fname;
+					CHECK_MALLOC_DO( fname = malloc( strlen(bkp) + strlen(DEFAULT_EXTENSIONS_PATH) + 2 ),
+						{ yyerror (&yylloc, conf, "Not enough memory"); YYERROR; } );
+					sprintf(fname, DEFAULT_EXTENSIONS_PATH "/%s", bkp);
+					free(bkp);
+					fd = fopen(fname, "r");
+				}
+				if (fd == NULL) {
+					int ret = errno;
+					TRACE_DEBUG(INFO, "Unable to open extension file %s for reading: %s\n", fname, strerror(ret));
+					yyerror (&yylloc, conf, "Error adding extension"); 
+					YYERROR;
+				}
+				fclose(fd);
+				
+				/* Try and open the configuration file (optional) */
+				cfname = $4;
+				if (cfname) {
+					fd = fopen(cfname, "r");
+					if ((fd == NULL) && (*cfname != '/')) {
+						char * test;
+						CHECK_MALLOC_DO( test = malloc( strlen(cfname) + strlen(DEFAULT_CONF_PATH) + 2 ),
+							{ yyerror (&yylloc, conf, "Not enough memory"); YYERROR; } );
+						sprintf(test, DEFAULT_CONF_PATH "/%s", cfname);
+						fd = fopen(test, "r");
+						if (fd) {
+							free(cfname);
+							cfname=test;
+						} else {
+							/* This is not an error, we allow an extension to wait for something else than a real conf file. */
+							free(test);
+						}
+					}
+					if (fd)
+						fclose(fd);
+				}
+				
+				CHECK_FCT_DO( fd_ext_add( fname, cfname ),
 					{ yyerror (&yylloc, conf, "Error adding extension"); YYERROR; } );
 			}
 			;
--- a/freeDiameter/main.c	Fri May 14 10:42:49 2010 +0900
+++ b/freeDiameter/main.c	Fri May 14 17:26:53 2010 +0900
@@ -309,7 +309,7 @@
 	printf( "  -h, --help             Print help and exit\n"
   		"  -V, --version          Print version and exit\n"
   		"  -c, --config=filename  Read configuration from this file instead of the \n"
-		"                           default location (%s).\n", DEFAULT_CONF_FILE);
+		"                           default location (" DEFAULT_CONF_PATH "/" FD_DEFAULT_CONF_FILENAME ").\n");
  	printf( "\nDebug:\n"
   		"  These options are mostly useful for developers\n"
   		"  -l, --dbglocale        Set the locale for error messages\n"
--- a/freeDiameter/tests/CMakeLists.txt	Fri May 14 10:42:49 2010 +0900
+++ b/freeDiameter/tests/CMakeLists.txt	Fri May 14 17:26:53 2010 +0900
@@ -109,3 +109,9 @@
    TARGET_LINK_LIBRARIES(${TEST} fDcore ${FD_LIBS} ${${TEST}_ADDITIONAL_LIB})
    ADD_TEST(${TEST} ${EXECUTABLE_OUTPUT_PATH}/${TEST})
 ENDFOREACH( TEST )
+
+
+####
+## INSTALL section ##
+
+# we do not install the tests
--- a/include/freeDiameter/CMakeLists.txt	Fri May 14 10:42:49 2010 +0900
+++ b/include/freeDiameter/CMakeLists.txt	Fri May 14 17:26:53 2010 +0900
@@ -5,19 +5,25 @@
 ########################
 # Configurable parameters
 
-# Name of the default configuration file
-OPTION(DEFAULT_CONF_FILE "Default path to configuration file?" OFF)
+# The default directory for configuration files
+SET(DEFAULT_CONF_PATH ${CMAKE_INSTALL_PREFIX}/etc/freeDiameter CACHE PATH "Default location of freeDiameter configuration files")
+
+# The default directory for extension files
+SET(DEFAULT_EXTENSIONS_PATH ${CMAKE_INSTALL_PREFIX}/lib/fdx CACHE PATH "Default location of freeDiameter extensions")
 
 # Disable SCTP support completly ?
 OPTION(DISABLE_SCTP "Disable SCTP support?" OFF)
 IF (NOT DISABLE_SCTP)
 	OPTION(DEBUG_SCTP "Verbose SCTP (for debug)?" OFF)
 	OPTION(SCTP_USE_MAPPED_ADDRESSES "Use v6-mapped v4 addresses in SCTP (workaround some SCTP limitations)?" OFF)
+ELSE (NOT DISABLE_SCTP)
+	MESSAGE(STATUS "Disabled SCTP support.")
 ENDIF (NOT DISABLE_SCTP)
 
 # Find TODO items in the code easily ?
 OPTION(ERRORS_ON_TODO "(development) Generate compilation errors on TODO items ?" OFF)
 
+MARK_AS_ADVANCED(DISABLE_SCTP DEBUG_SCTP SCTP_USE_MAPPED_ADDRESSES ERRORS_ON_TODO)
 
 ########################
 # System checks 
@@ -89,14 +95,22 @@
 # malloc.h ?
 CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H)
 
-# The default configuration file name
-IF (NOT DEFAULT_CONF_FILE)
-   SET(DEFAULT_CONF_FILE "freeDiameter.conf")
-ENDIF (NOT DEFAULT_CONF_FILE)
 ##########################
 
 # Generate the host.h file
 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/freeDiameter-host.h.in ${CMAKE_CURRENT_BINARY_DIR}/freeDiameter-host.h)
 
-# Save the FD_LIBS for parent scope
+# Save some variables for the other directories
 SET(FD_LIBS ${FD_LIBS} PARENT_SCOPE)
+SET(DEFAULT_CONF_PATH ${DEFAULT_CONF_PATH} PARENT_SCOPE)
+SET(DEFAULT_EXTENSIONS_PATH ${DEFAULT_EXTENSIONS_PATH} PARENT_SCOPE)
+
+
+####
+## INSTALL section ##
+
+# The headers from this directory are required to develop new extensions for freeDiameter.
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/freeDiameter-host.h libfreeDiameter.h freeDiameter.h extension.h
+	DESTINATION include/freeDiameter
+	COMPONENT freeDiameter-dev)
+
--- a/include/freeDiameter/freeDiameter-host.h.in	Fri May 14 10:42:49 2010 +0900
+++ b/include/freeDiameter/freeDiameter-host.h.in	Fri May 14 17:26:53 2010 +0900
@@ -69,7 +69,7 @@
 /* PACKAGE_HG_REVISION */
 #cmakedefine FD_PROJECT_COPYRIGHT "@FD_PROJECT_COPYRIGHT@"
 
-#cmakedefine DEFAULT_CONF_FILE "@DEFAULT_CONF_FILE@"
-
+#cmakedefine DEFAULT_CONF_PATH "@DEFAULT_CONF_PATH@"
+#cmakedefine DEFAULT_EXTENSIONS_PATH "@DEFAULT_EXTENSIONS_PATH@"
 
 #endif /* FD_IS_CONFIG */
--- a/include/freeDiameter/libfreeDiameter.h	Fri May 14 10:42:49 2010 +0900
+++ b/include/freeDiameter/libfreeDiameter.h	Fri May 14 17:26:53 2010 +0900
@@ -223,11 +223,20 @@
 	}															\
 }
 #else /* DEBUG */
-/* Do not print thread, function, ... only the message itself in this case. */
-#define TRACE_DEBUG(level,format,args... ) {		\
-	if ( TRACE_BOOL(level) ) {			\
-		fd_log_debug(format "\n", ## args); 	\
-	}						\
+/* Do not print thread, function, ... only the message itself in this case, unless the debug level is set > FULL. */
+#define TRACE_DEBUG(level,format,args... ) {												\
+	if ( TRACE_BOOL(level) ) {													\
+		if (fd_g_debug_lvl > FULL) {												\
+			char __buf[25];													\
+			char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");					\
+			fd_log_debug("\t | tid:%-20s\t%s\tin %s@%s:%d\n"								\
+				  "\t%s|%*s" format "\n",  										\
+						__thn, fd_log_time(NULL, __buf, sizeof(__buf)), __PRETTY_FUNCTION__, __FILE__, __LINE__,\
+						(level < FULL)?"@":" ",level, "", ## args); 						\
+		} else {														\
+			fd_log_debug(format "\n", ## args); 										\
+		}															\
+	}																\
 }
 #endif /* DEBUG */
 
--- a/libfreeDiameter/CMakeLists.txt	Fri May 14 10:42:49 2010 +0900
+++ b/libfreeDiameter/CMakeLists.txt	Fri May 14 17:26:53 2010 +0900
@@ -25,11 +25,14 @@
 # The library itself needs other libraries 
 TARGET_LINK_LIBRARIES(libfreeDiameter ${FD_LIBS})
 
-# The library is to be installed as part of the freeDiameter-common component.
+# Save the list of files for testcases in the daemon's directory
+SET(LFD_SRC ${LFD_SRC} PARENT_SCOPE)
+
+
+####
+## INSTALL section ##
+
 INSTALL(TARGETS libfreeDiameter
 	LIBRARY DESTINATION lib
 	COMPONENT freeDiameter-common)
 
-# Save the list of files for testcases in the daemon's directory
-SET(LFD_SRC ${LFD_SRC} PARENT_SCOPE)
-
"Welcome to our mercurial repository"