Commit fda7d5ff authored by Sebastien Decugis's avatar Sebastien Decugis
Browse files

Added install directives for cmake; also allow default directory to seek for...

Added install directives for cmake; also allow default directory to seek for extensions and configuration files
parent 80b2064a
......@@ -47,13 +47,13 @@ SUBDIRS(include/freeDiameter)
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)
####
## INSTALL section ##
# The documentation to install
INSTALL(FILES README LICENSE doc/freediameter.conf.sample
DESTINATION doc
COMPONENT freeDiameter-doc)
......@@ -2,18 +2,24 @@ This package uses CMake (cmake.org) as building system. You'll need the cmake to
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
You can enable the unary tests by doing:
cmake -DSKIP_TESTS:BOOL=OFF ../
make
make tests
# 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.
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 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.
......
......@@ -52,3 +52,5 @@ Step by step instructions (with no prerequisite):
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
......@@ -25,6 +25,7 @@ IF(NOT BISON_EXECUTABLE)
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)
......
......@@ -15,6 +15,7 @@ IF(NOT FLEX_EXECUTABLE)
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)
......
......@@ -34,4 +34,4 @@ ENDIF(GNUTLS_FOUND)
# 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 )
......@@ -33,4 +33,4 @@ ENDIF(POSTGRESQL_FOUND)
# 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 )
......@@ -19,6 +19,7 @@ find_path(GCRYPT_INCLUDE_DIR NAMES gcrypt.h)
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 @@ OPTION(BUILD_ACL_WL "Build acl_wl? (White-list of remote connecting peers)" ON)
####
# 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 @@ OPTION(BUILD_DBG_RT "Build dbg_rt.fdx? (Routing extension for debugging the rout
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")
......@@ -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)
......@@ -17,10 +17,22 @@ SET( ACL_WL_SRC
)
# 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)
......@@ -28,3 +28,12 @@ SET( APP_ACCT_SRC_GEN
# 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)
......@@ -3,10 +3,13 @@ PROJECT("RADIUS/Diameter extensible gateway application for freeDiameter" C)
# 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 @@ MACRO(RGWX_ADD_PLUGIN PLGNAME)
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 @@ OPTION(BUILD_RGWX_ECHODROP "Build 'echo/drop' plugin? (drop specific RADIUS attr
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.
......@@ -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 @@ void yyerror (YYLTYPE *ploc, char * conffile, char const *s)
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 @@ static char * plgconffile = NULL;
%token <integer> INTEGER
%token <ss> IP
%type <string> FILENAME
%type <string> FINDFILEEXT
/* simple tokens */
%token DISABLED
......@@ -196,14 +179,30 @@ conffile: /* empty grammar is OK */
/* -------------------------------------- */
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 @@ plugin: {
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 ) ) {
......
# 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)
......@@ -3,3 +3,11 @@ PROJECT("Routing module debug extension" C)
# 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)
......@@ -3,3 +3,11 @@ PROJECT("Diameter EAP (RFC4072) dictionary definitions" C)
# 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)
......@@ -3,3 +3,11 @@ PROJECT("Diameter NASREQ (RFC4005) dictionary definitions" C)
# 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)
......@@ -31,10 +31,23 @@ SET( RT_DEFAULT_SRC
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)
......@@ -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)
......@@ -20,3 +20,12 @@ SET( APP_TEST_SRC
# 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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment