Added variables that are used when installing instead of relative paths.

This commit is contained in:
Markus Makela 2015-04-25 06:53:59 +03:00
parent eec053924c
commit df9bc65430
17 changed files with 122 additions and 100 deletions

View File

@ -37,7 +37,6 @@ if(NOT CURL_FOUND)
message(FATAL_ERROR "Failed to locate dependency: libcurl")
endif()
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/modules)
# Make sure the release notes for this release are present if it is a stable one
if(${MAXSCALE_VERSION} MATCHES "-stable")
@ -47,6 +46,7 @@ if(${MAXSCALE_VERSION} MATCHES "-stable")
message(FATAL_ERROR "Could not find the release notes for this stable release: ${MAXSCALE_VERSION_NUMERIC}")
endif()
endif()
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/${MAXSCALE_MODULE_INSTALL}:${CMAKE_INSTALL_PREFIX}/${MAXSCALE_LIBRARY_INSTALL})
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/server/include)
configure_file(${CMAKE_SOURCE_DIR}/server/include/version.h.in ${CMAKE_BINARY_DIR}/server/include/version.h)
@ -127,7 +127,7 @@ if(NOT WITHOUT_MAXADMIN)
add_subdirectory(client)
endif()
# Generate text versions of some documents
execute_process(COMMAND perl ${CMAKE_SOURCE_DIR}/Documentation/format.pl
${CMAKE_SOURCE_DIR}/Documentation/Changelog.md
${CMAKE_BINARY_DIR}/Changelog.txt)
@ -138,28 +138,17 @@ execute_process(COMMAND perl ${CMAKE_SOURCE_DIR}/Documentation/format.pl
${CMAKE_SOURCE_DIR}/Documentation/Upgrading-To-MaxScale-1.1.0.md
${CMAKE_BINARY_DIR}/UpgradingToMaxScale110.txt)
message(STATUS "Installing MaxScale to: ${CMAKE_INSTALL_PREFIX}/")
if(PACKAGE)
install(FILES server/MaxScale_template.cnf DESTINATION /etc)
install(FILES server/MaxScale_BinlogServer_template.cnf DESTINATION /etc)
install(FILES ${CMAKE_SOURCE_DIR}/COPYRIGHT DESTINATION /usr/share/maxscale)
install(FILES ${CMAKE_SOURCE_DIR}/README DESTINATION /usr/share/maxscale)
install(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION /usr/share/maxscale)
install(FILES ${CMAKE_BINARY_DIR}/Changelog.txt DESTINATION /usr/share/maxscale)
install(FILES ${CMAKE_BINARY_DIR}/ReleaseNotes.txt DESTINATION /usr/share/maxscale)
install(FILES ${CMAKE_BINARY_DIR}/UpgradingToMaxScale110.txt DESTINATION /usr/share/maxscale)
else()
install(FILES ${CMAKE_BINARY_DIR}/Changelog.txt DESTINATION .)
install(FILES ${CMAKE_BINARY_DIR}/ReleaseNotes.txt DESTINATION .)
install(FILES ${CMAKE_BINARY_DIR}/UpgradingToMaxScale110.txt DESTINATION .)
install(FILES server/MaxScale_template.cnf DESTINATION etc)
install(FILES server/MaxScale_BinlogServer_template.cnf DESTINATION etc)
install(FILES ${ERRMSG} DESTINATION mysql)
install(FILES ${CMAKE_SOURCE_DIR}/COPYRIGHT DESTINATION .)
install(FILES ${CMAKE_SOURCE_DIR}/README DESTINATION .)
install(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION .)
endif()
install(FILES ${CMAKE_BINARY_DIR}/Changelog.txt DESTINATION ${MAXSCALE_SHARE_DIR})
install(FILES ${CMAKE_BINARY_DIR}/ReleaseNotes.txt DESTINATION ${MAXSCALE_SHARE_DIR})
install(FILES ${CMAKE_BINARY_DIR}/UpgradingToMaxScale110.txt DESTINATION ${MAXSCALE_SHARE_DIR})
install(FILES server/MaxScale_template.cnf DESTINATION ${MAXSCALE_CONFIG_DIR})
install(FILES server/MaxScale_BinlogServer_template.cnf DESTINATION ${MAXSCALE_CONFIG_DIR})
install(FILES ${ERRMSG} DESTINATION ${MAXSCALE_LANG_DIR})
install(FILES ${CMAKE_SOURCE_DIR}/COPYRIGHT DESTINATION ${MAXSCALE_SHARE_DIR})
install(FILES ${CMAKE_SOURCE_DIR}/README DESTINATION ${MAXSCALE_SHARE_DIR})
install(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION ${MAXSCALE_SHARE_DIR})
# Install startup scripts and ldconfig files
if(WITH_SCRIPTS)
configure_file(${CMAKE_SOURCE_DIR}/maxscale.conf.in ${CMAKE_BINARY_DIR}/maxscale.conf @ONLY)

View File

@ -7,4 +7,4 @@ if(HIST)
else()
message(STATUS "Could not find editline library. MaxAdmin will be built without it.")
endif()
install(TARGETS maxadmin DESTINATION bin)
install(TARGETS maxadmin DESTINATION ${MAXSCALE_EXECUTABLE_INSTALL})

View File

@ -3,7 +3,7 @@ if(LOG_DEBUG)
endif()
add_library(log_manager SHARED log_manager.cc)
target_link_libraries(log_manager pthread aio stdc++)
install(TARGETS log_manager DESTINATION lib)
install(TARGETS log_manager DESTINATION ${MAXSCALE_LIBRARY_INSTALL})
if(BUILD_TESTS)
add_subdirectory(test)
endif()
endif()

View File

@ -74,6 +74,34 @@ macro(set_variables)
# Build extra tools
set(BUILD_TOOLS FALSE CACHE BOOL "Build extra utility tools")
# Change installation directories to standard locations for packages
if(PACKAGE)
set(MAXSCALE_MODULE_INSTALL /lib64/maxscale CACHE PATH "Module installation path")
set(MAXSCALE_LIBRARY_INSTALL /lib64/maxscale CACHE PATH "Library installation path")
message(STATUS "Installing MaxScale modules to: ${MAXSCALE_MODULE_INSTALL}/")
set(MAXSCALE_EXECUTABLE_INSTALL /bin CACHE PATH "Executable installation path")
message(STATUS "Installing MaxScale binaries to: ${MAXSCALE_EXECUTABLE_INSTALL}/")
set(MAXSCALE_CONFIG_DIR /etc CACHE PATH "Configuration file installation path")
set(MAXSCALE_DOC_DIR /usr/share/maxscale/doc CACHE PATH "Documentation installation path")
set(MAXSCALE_LOG_DIR /var/log/maxscale CACHE PATH "Log file directory")
message(STATUS "MaxScale log directory: ${MAXSCALE_LOG_DIR}/")
set(MAXSCALE_CACHE_DIR /var/cache/maxscale CACHE PATH "Service cache file directory")
set(MAXSCALE_LANG_DIR /var/cache/maxscale CACHE PATH "Language file directory(errmsg.sys)")
set(MAXSCALE_SHARE_DIR /usr/share/maxscale CACHE PATH "Share file installation path")
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MAXSCALE_MODULE_DIR}:${MAXSCALE_LIBRARY_DIR})
else()
message(STATUS "Installing MaxScale to: ${CMAKE_INSTALL_PREFIX}/")
set(MAXSCALE_MODULE_INSTALL lib64/maxscale CACHE PATH "Module installation path")
set(MAXSCALE_LIBRARY_INSTALL lib64/maxscale CACHE PATH "Library installation path")
set(MAXSCALE_EXECUTABLE_INSTALL bin CACHE PATH "Executable installation path")
set(MAXSCALE_CONFIG_DIR etc CACHE PATH "Configuration file installation path")
set(MAXSCALE_DOC_DIR doc CACHE PATH "Documentation installation path")
set(MAXSCALE_LOG_DIR log CACHE PATH "Log file directory")
set(MAXSCALE_CACHE_DIR cache CACHE PATH "Service cache file directory")
set(MAXSCALE_LANG_DIR cache CACHE PATH "Log file directory")
set(MAXSCALE_SHARE_DIR . CACHE PATH "Share file installation path")
endif()
endmacro()
macro(check_deps)

View File

@ -1,5 +1,5 @@
add_library(query_classifier SHARED query_classifier.cc)
install(TARGETS query_classifier DESTINATION lib)
install(TARGETS query_classifier COMPONENT lib DESTINATION ${MAXSCALE_LIBRARY_INSTALL})
if(BUILD_TESTS)
add_subdirectory(test)
endif()

View File

@ -18,15 +18,15 @@ if(WITH_TCMALLOC)
endif()
target_link_libraries(maxscale ${EMBEDDED_LIB} ${PCRE_LINK_FLAGS} ${CURL_LIBRARIES} log_manager utils ssl aio pthread crypt dl crypto inih z rt m stdc++)
install(TARGETS maxscale DESTINATION bin)
install(TARGETS maxscale DESTINATION ${MAXSCALE_EXECUTABLE_INSTALL})
add_executable(maxkeys maxkeys.c secrets.c utils.c)
target_link_libraries(maxkeys log_manager utils pthread crypt crypto)
install(TARGETS maxkeys DESTINATION bin)
install(TARGETS maxkeys DESTINATION ${MAXSCALE_EXECUTABLE_INSTALL})
add_executable(maxpasswd maxpasswd.c secrets.c utils.c)
target_link_libraries(maxpasswd log_manager utils pthread crypt crypto)
install(TARGETS maxpasswd DESTINATION bin)
install(TARGETS maxpasswd DESTINATION ${MAXSCALE_EXECUTABLE_INSTALL})
if(BUILD_TESTS)
add_subdirectory(test)

View File

@ -113,16 +113,6 @@ static char* server_options[] = {
const int num_elements = (sizeof(server_options) / sizeof(char *)) - 1;
const char* default_cnf_fname = "MaxScale.cnf";
const char* default_configdir = "/etc/";
const char* default_logdir = "/var/log/maxscale/";
const char* default_datadir = "/var/lib/maxscale/";
const char* default_moduledir = "/lib64/maxscale/modules/";
const char* default_cachedir = "/var/cache/maxscale/";
const char* default_langdir = "/usr/share/mysql/english/";
const char* default_piddir = "/var/run/maxscale/";
static char* server_groups[] = {
"embedded",
"server",
@ -1752,7 +1742,8 @@ int main(int argc, char **argv)
if(langdir == NULL)
langdir = strdup(default_langdir);
if(moduledir == NULL)
moduledir = strdup(default_moduledir);
/**
* Set a data directory for the mysqld library, we use
* a unique directory name to avoid clauses if multiple
@ -1786,33 +1777,35 @@ int main(int argc, char **argv)
if (!daemon_mode)
{
fprintf(stderr,
//"Home directory : %s"
"Configuration file : %s"
"\nLog directory : %s"
"\nData directory : %s\n\n",
//home_dir,
"Configuration file : %s\n"
"Log directory : %s\n"
"Data directory : %s\n"
"Module directory : %s\n\n",
cnf_file_path,
logdir,
datadir);
datadir,
moduledir);
}
/*
LOGIF(LM, (skygw_log_write_flush(
LOGFILE_MESSAGE,
"Home directory : %s",
home_dir)));
*/
LOGIF(LM, (skygw_log_write_flush(
LOGFILE_MESSAGE,
"Data directory : %s",
datadir)));
LOGIF(LM, (skygw_log_write_flush(
LOGFILE_MESSAGE,
"Log directory : %s/",
logdir)));
LOGIF(LM, (skygw_log_write_flush(
LOGFILE_MESSAGE,
"Configuration file : %s",
cnf_file_path)));
LOGIF(LM,
(skygw_log_write_flush(
LOGFILE_MESSAGE,
"Configuration file: %s",
cnf_file_path)));
LOGIF(LM,
(skygw_log_write_flush(
LOGFILE_MESSAGE,
"Log directory: %s/",
logdir)));
LOGIF(LM,
(skygw_log_write_flush(
LOGFILE_MESSAGE,
"Data directory: %s",
datadir)));
LOGIF(LM,
(skygw_log_write_flush(LOGFILE_MESSAGE,
"Module directory: %s",
moduledir)));
/*< Update the server options */
for (i = 0; server_options[i]; i++)
@ -2211,4 +2204,4 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons
}
return 1;
}
}

View File

@ -147,7 +147,6 @@ MODULE_INFO *mod_info = NULL;
if (access(fname, F_OK) == -1)
{
//home = get_maxscale_home ();
snprintf(fname, MAXPATHLEN+1,"%s/lib%s.so", get_moduledir(), module);
if (access(fname, F_OK) == -1)

View File

@ -1,3 +1,5 @@
#ifndef _GW_HG
#define _GW_HG
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
@ -16,9 +18,19 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdbool.h>
/** Default file locations */
static const char* default_cnf_fname = "MaxScale.cnf";
static const char* default_configdir = "/etc/";
static const char* default_logdir = "/var/log/maxscale/";
static const char* default_datadir = "/var/cache/maxscale/";
static const char* default_moduledir = "/lib64/maxscale/";
static const char* default_cachedir = "/var/cache/maxscale/";
static const char* default_langdir = "/usr/share/mysql/english/"; /*< This is where the MariaDB
* server installs errmsg.sys */
static const char* default_piddir = "/var/run/maxscale/";
#define EXIT_FAILURE 1
// network buffer is 32K
@ -65,4 +77,5 @@ int gw_write(DCB *dcb, const void *buf, size_t nbytes);
int gw_getsockerrno(int fd);
int parse_bindconfig(char *, unsigned short, struct sockaddr_in *);
int setipaddress(struct in_addr *, char *);
char* get_moduledir();
char* get_moduledir();
#endif

View File

@ -3,41 +3,41 @@ if(BUILD_RABBITMQ)
include_directories(${RABBITMQ_HEADERS})
add_library(mqfilter SHARED mqfilter.c)
target_link_libraries(mqfilter query_classifier log_manager utils ${RABBITMQ_LIBRARIES})
install(TARGETS mqfilter DESTINATION modules)
install(TARGETS mqfilter DESTINATION ${MAXSCALE_MODULE_INSTALL})
endif()
add_library(regexfilter SHARED regexfilter.c)
target_link_libraries(regexfilter log_manager utils)
install(TARGETS regexfilter DESTINATION modules)
install(TARGETS regexfilter DESTINATION ${MAXSCALE_MODULE_INSTALL})
add_library(testfilter SHARED testfilter.c)
target_link_libraries(testfilter log_manager utils)
install(TARGETS testfilter DESTINATION modules)
install(TARGETS testfilter DESTINATION ${MAXSCALE_MODULE_INSTALL})
add_library(qlafilter SHARED qlafilter.c)
target_link_libraries(qlafilter log_manager utils)
install(TARGETS qlafilter DESTINATION modules)
install(TARGETS qlafilter DESTINATION ${MAXSCALE_MODULE_INSTALL})
add_library(tee SHARED tee.c)
target_link_libraries(tee log_manager utils)
install(TARGETS tee DESTINATION modules)
install(TARGETS tee DESTINATION ${MAXSCALE_MODULE_INSTALL})
add_library(topfilter SHARED topfilter.c)
target_link_libraries(topfilter log_manager utils)
install(TARGETS topfilter DESTINATION modules)
install(TARGETS topfilter DESTINATION ${MAXSCALE_MODULE_INSTALL})
add_library(dbfwfilter SHARED dbfwfilter.c)
target_link_libraries(dbfwfilter log_manager utils query_classifier)
install(TARGETS dbfwfilter DESTINATION modules)
install(TARGETS dbfwfilter DESTINATION ${MAXSCALE_MODULE_INSTALL})
add_library(namedserverfilter SHARED namedserverfilter.c)
target_link_libraries(namedserverfilter log_manager utils)
install(TARGETS namedserverfilter DESTINATION modules)
install(TARGETS namedserverfilter DESTINATION ${MAXSCALE_MODULE_INSTALL})
if(BUILD_SLAVELAG)
add_library(slavelag SHARED slavelag.c)
target_link_libraries(slavelag log_manager utils query_classifier)
install(TARGETS slavelag DESTINATION modules)
install(TARGETS slavelag DESTINATION ${MAXSCALE_MODULE_INSTALL})
endif()
if(BUILD_TOOLS)

View File

@ -1,4 +1,4 @@
add_library(hintfilter SHARED hintfilter.c hintparser.c)
set_target_properties(hintfilter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib)
target_link_libraries(hintfilter ssl log_manager utils)
install(TARGETS hintfilter DESTINATION modules)
install(TARGETS hintfilter DESTINATION ${MAXSCALE_MODULE_INSTALL})

View File

@ -1,16 +1,16 @@
add_library(mysqlmon SHARED mysql_mon.c)
target_link_libraries(mysqlmon log_manager utils)
install(TARGETS mysqlmon DESTINATION modules)
install(TARGETS mysqlmon DESTINATION ${MAXSCALE_MODULE_INSTALL})
add_library(galeramon SHARED galera_mon.c)
target_link_libraries(galeramon log_manager utils)
install(TARGETS galeramon DESTINATION modules)
install(TARGETS galeramon DESTINATION ${MAXSCALE_MODULE_INSTALL})
add_library(ndbclustermon SHARED ndbcluster_mon.c)
target_link_libraries(ndbclustermon log_manager utils)
install(TARGETS ndbclustermon DESTINATION modules)
install(TARGETS ndbclustermon DESTINATION ${MAXSCALE_MODULE_INSTALL})
if(BUILD_MMMON)
add_library(mmmon SHARED mm_mon.c)
target_link_libraries(mmmon log_manager utils)
install(TARGETS mmmon DESTINATION modules)
install(TARGETS mmmon DESTINATION ${MAXSCALE_MODULE_INSTALL})
endif()

View File

@ -1,27 +1,27 @@
add_library(MySQLClient SHARED mysql_client.c mysql_common.c)
target_link_libraries(MySQLClient log_manager utils)
install(TARGETS MySQLClient DESTINATION modules)
install(TARGETS MySQLClient DESTINATION ${MAXSCALE_MODULE_INSTALL})
add_library(MySQLBackend SHARED mysql_backend.c mysql_common.c)
target_link_libraries(MySQLBackend log_manager utils)
install(TARGETS MySQLBackend DESTINATION modules)
install(TARGETS MySQLBackend DESTINATION ${MAXSCALE_MODULE_INSTALL})
add_library(telnetd SHARED telnetd.c)
target_link_libraries(telnetd log_manager utils)
install(TARGETS telnetd DESTINATION modules)
install(TARGETS telnetd DESTINATION ${MAXSCALE_MODULE_INSTALL})
add_library(HTTPD SHARED httpd.c)
target_link_libraries(HTTPD log_manager utils)
install(TARGETS HTTPD DESTINATION modules)
install(TARGETS HTTPD DESTINATION ${MAXSCALE_MODULE_INSTALL})
if(BUILD_TESTS)
add_library(testprotocol SHARED testprotocol.c)
install(TARGETS testprotocol DESTINATION modules)
install(TARGETS testprotocol DESTINATION ${MAXSCALE_MODULE_INSTALL})
endif()
add_library(maxscaled SHARED maxscaled.c)
target_link_libraries(maxscaled log_manager utils)
install(TARGETS maxscaled DESTINATION modules)
install(TARGETS maxscaled DESTINATION ${MAXSCALE_MODULE_INSTALL})

View File

@ -2,28 +2,28 @@ if(BUILD_TESTS)
add_subdirectory(test)
add_library(testroute SHARED testroute.c)
target_link_libraries(testroute log_manager utils)
install(TARGETS testroute DESTINATION modules)
install(TARGETS testroute DESTINATION ${MAXSCALE_MODULE_INSTALL})
endif()
add_library(schemarouter SHARED schemarouter/schemarouter.c)
target_link_libraries(schemarouter log_manager utils query_classifier)
install(TARGETS schemarouter DESTINATION modules)
install(TARGETS schemarouter DESTINATION ${MAXSCALE_MODULE_INSTALL})
add_library(shardrouter SHARED schemarouter/shardrouter.c)
target_link_libraries(shardrouter log_manager utils query_classifier)
install(TARGETS shardrouter DESTINATION modules)
install(TARGETS shardrouter DESTINATION ${MAXSCALE_MODULE_INSTALL})
add_library(readconnroute SHARED readconnroute.c)
target_link_libraries(readconnroute log_manager utils)
install(TARGETS readconnroute DESTINATION modules)
install(TARGETS readconnroute DESTINATION ${MAXSCALE_MODULE_INSTALL})
add_library(debugcli SHARED debugcli.c debugcmd.c)
target_link_libraries(debugcli log_manager utils)
install(TARGETS debugcli DESTINATION modules)
install(TARGETS debugcli DESTINATION ${MAXSCALE_MODULE_INSTALL})
add_library(cli SHARED cli.c debugcmd.c)
target_link_libraries(cli log_manager utils)
install(TARGETS cli DESTINATION modules)
install(TARGETS cli DESTINATION ${MAXSCALE_MODULE_INSTALL})
add_subdirectory(readwritesplit)
add_subdirectory(schemarouter/test)

View File

@ -1,4 +1,4 @@
add_library(binlogrouter SHARED blr.c blr_master.c blr_cache.c blr_slave.c blr_file.c)
set_target_properties(binlogrouter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib)
set_target_properties(binlogrouter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MAXSCALE_MODULE_INSTALL}:${MAXSCALE_LIBRARY_INSTALL})
target_link_libraries(binlogrouter ssl pthread log_manager)
install(TARGETS binlogrouter DESTINATION modules)
install(TARGETS binlogrouter DESTINATION ${MAXSCALE_MODULE_INSTALL})

View File

@ -1,4 +1,4 @@
add_library(maxinfo SHARED maxinfo.c maxinfo_parse.c maxinfo_error.c maxinfo_exec.c)
set_target_properties(maxinfo PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib)
set_target_properties(maxinfo PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MAXSCALE_MODULE_INSTALL}:MAXSCALE_LIBRARY_INSTALL)
target_link_libraries(maxinfo pthread log_manager)
install(TARGETS maxinfo DESTINATION modules)
install(TARGETS maxinfo DESTINATION ${MAXSCALE_MODULE_INSTALL})

View File

@ -1,6 +1,6 @@
add_library(readwritesplit SHARED readwritesplit.c)
target_link_libraries(readwritesplit ssl pthread log_manager utils query_classifier)
install(TARGETS readwritesplit DESTINATION modules)
install(TARGETS readwritesplit DESTINATION ${MAXSCALE_MODULE_INSTALL})
if(BUILD_TESTS)
add_subdirectory(test)
endif()