diff options
| author | cyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-12-17 20:18:40 +0000 |
|---|---|---|
| committer | cyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-12-17 20:18:40 +0000 |
| commit | 81b7aa657110db03ceb861d8206fc6e805ede9c8 (patch) | |
| tree | 8437f5ce65de3e27e5e02196711bd770aa86b7f5 | |
| parent | fd45a3ad4219bffcf2f68fcc1dce3ff33b531b89 (diff) | |
Massive cleanup of the CMakeLists.txt files to finalize them.
Edited configuration scripts for *nix and Windows to use CMake as well as support both in-source and out-of-source builds.
Changed directory structure for *nix to match Windows to remove some conditionals in both CMake and Anope itself.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1841 5417fbe8-f217-4b02-8779-1006273d7864
| -rw-r--r-- | .BANNER | 2 | ||||
| -rw-r--r-- | CMakeLists.txt | 322 | ||||
| -rwxr-xr-x | Config | 203 | ||||
| -rw-r--r-- | data/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | include/CMakeLists.txt | 96 | ||||
| -rw-r--r-- | include/extern.h | 2 | ||||
| -rw-r--r-- | include/modules.h | 2 | ||||
| -rw-r--r-- | include/sysconf.h.cmake | 6 | ||||
| -rw-r--r-- | install.js | 775 | ||||
| -rw-r--r-- | lang/CMakeLists.txt | 102 | ||||
| -rw-r--r-- | src/CMakeLists.txt | 201 | ||||
| -rw-r--r-- | src/bin/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | src/core/CMakeLists.txt | 73 | ||||
| -rw-r--r-- | src/init.c | 6 | ||||
| -rw-r--r-- | src/main.c | 77 | ||||
| -rw-r--r-- | src/modulemanager.cpp | 6 | ||||
| -rw-r--r-- | src/modules.c | 7 | ||||
| -rw-r--r-- | src/modules/CMakeLists.txt | 67 | ||||
| -rw-r--r-- | src/protocol/CMakeLists.txt | 67 | ||||
| -rw-r--r-- | src/tools/CMakeLists.txt | 68 | ||||
| -rw-r--r-- | src/win32.rc.cmake | 6 |
21 files changed, 696 insertions, 1400 deletions
@@ -9,7 +9,7 @@ CURVER This program will help you to compile your Services, and ask you questions regarding the compile-time settings of it during the -process. For more options type ./Config --help +process. For more options type SOURCE_DIR/Config --help Anope is a set of Services for IRC networks that allows users to manage their nicks and channels in a secure and efficient way, diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e5205998..4d3ea3c1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,113 +1,115 @@ +# This usage of CMake requires at least version 2.6 (I don't know if it'll work with earlier versions) cmake_minimum_required(VERSION 2.6) -# # If the user specifies -DCMAKE_BUILD_TYPE on the command line, take their definition # and dump it in the cache along with proper documentation, otherwise set CMAKE_BUILD_TYPE # to Debug prior to calling PROJECT() -# -if(NOT WIN32 OR NOT MSVC) +# Only do this if not using Visual Studio +if(NOT MSVC) if(CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") else(CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE DEBUG CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") endif(CMAKE_BUILD_TYPE) -endif(NOT WIN32 OR NOT MSVC) +endif(NOT MSVC) +# Set the project as C++ primarily, but have C enabled for the checks required later project(Anope CXX) enable_language(C) +# If running under MinGW, we have to force the resource compiler settings (hopefully this will be fixed in a later version of CMake) if(MINGW) set(CMAKE_RC_COMPILER_INIT windres) - #message(STATUS "CMAKE_RC_OUTPUT_EXTENSION: ${CMAKE_RC_OUTPUT_EXTENSION}") enable_language(RC) - #message(STATUS "CMAKE_RC_OUTPUT_EXTENSION: ${CMAKE_RC_OUTPUT_EXTENSION}") - #set(CMAKE_RC_OUTPUT_EXTENSION .o) - #message(STATUS "CMAKE_RC_OUTPUT_EXTENSION: ${CMAKE_RC_OUTPUT_EXTENSION}") set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> <SOURCE>") endif(MINGW) +# Include the checking functions used later in this CMakeLists.txt include(CheckFunctionExists) include(CheckIncludeFile) include(CheckTypeSize) include(CheckCXXCompilerFlag) include(CheckLibraryExists) -if(NOT WIN32) - option(USE_RUN_CC_PL "Use run-cc.pl for building" OFF) -endif(NOT WIN32) +# Add an optional variable for using run-cc.pl for building, Perl will be checked later regardless of this setting +option(USE_RUN_CC_PL "Use run-cc.pl for building" OFF) -if(WIN32 AND MSVC) +# If using Visual Studio, set the C++ flags accordingly +if(MSVC) + # Remove the default exception handling flags, also remove default warning level flag string(REPLACE "/EHsc " "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) string(REPLACE "/GX " "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) - set(CXXFLAGS "${CXXFLAGS} /W4 /EHs /RTC1 /D_WIN32 /DMSVCPP /I${Anope_SOURCE_DIR}/include /I${Anope_BINARY_DIR}/include /I${Anope_BINARY_DIR}/lang") + string(REPLACE "/W3 " "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) + # Set the compile flags to have warnings on the max setting (but disable a few annoying ones), exception handling turned on, the proper defines, and the include directories + set(CXXFLAGS "${CXXFLAGS} /W4 /wd4251 /wd4706 /wd4800 /EHs /D_WIN32 /DMSVCPP /I\"${Anope_SOURCE_DIR}/include\" /I\"${Anope_BINARY_DIR}/include\" /I\"${Anope_BINARY_DIR}/lang\"") + # Set the module-specific compile flags to include a define for module compiling set(MODULE_CXXFLAGS "${CXXFLAGS} /DMODULE_COMPILE") -else(WIN32 AND MSVC) +# Otherwise, we're not using Visual Studio +else(MSVC) + # Set the compile flags to have all warnings on (including shadowed variables) and the include directories set(CXXFLAGS "${CXXFLAGS} -Wall -Wshadow -I${Anope_SOURCE_DIR}/include -I${Anope_BINARY_DIR}/include -I${Anope_BINARY_DIR}/lang") + # If on a *nix system, also set the compile flags to remove GNU extensions (favor ISO C++) as well as reject non-ISO C++ code, also remove all leading underscores in exported symbols if(UNIX) set(CXXFLAGS "${CXXFLAGS} -ansi -pedantic -fno-leading-underscore") + # Set the module-specific compile flags to the same setting as the compile flags + set(MODULE_CXXFLAGS "${CXXFLAGS}") + # If we aren't on a *nix system, set the compile flags to include a define for Windows else(UNIX) set(CXXFLAGS "${CXXFLAGS} -D_WIN32") + # Also, if we are building under MinGW, add another define for MinGW if(MINGW) set(CXXFLAGS "${CXXFLAGS} -DMINGW") endif(MINGW) + # Set the module-specific compile flags to include a define for module compiling + set(MODULE_CXXFLAGS "${CXXFLAGS} -DMODULE_COMPILE") endif(UNIX) - set(MODULE_CXXFLAGS "${CXXFLAGS}") -endif(WIN32 AND MSVC) -#message(STATUS "CMAKE_CXX_CREATE_SHARED_MODULE: ${CMAKE_CXX_CREATE_SHARED_MODULE}") -#if(CMAKE_BUILD_TYPE) -# set(CXXFLAGS "${CXXFLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}") -#endif(CMAKE_BUILD_TYPE) +endif(MSVC) +# If CMake has found that the given system requires a special library for dl* calls, include it with the linker flags if(CMAKE_DL_LIBS) set(LDFLAGS "${LDFLAGS} ${CMAKE_DL_LIBS}") endif(CMAKE_DL_LIBS) + +# Under MinGW, the -shared flag isn't properly set in the module-specific linker flags, add it from the C flags for shared libraries if(MINGW) - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -Wl,--enable-auto-import -Wl,--export-all-symbols") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}") endif(MINGW) -#set(MY_COMPILER ${CMAKE_CXX_COMPILER}) -#set(MY_COMP_ARG) +# Under Windows, we set the executable name for Anope to be anope if(WIN32) set(PROGRAM_NAME anope) +# Under *nix, we set the executable name for Anope to be services else(WIN32) set(PROGRAM_NAME services) - #set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> ${CXXFLAGS} <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> ${LDFLAGS}") - #set(CMAKE_CXX_CREATE_SHARED_MODULE "<CMAKE_CXX_COMPILER> ${CXXFLAGS} <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> ${LDFLAGS}") endif(WIN32) -if(NOT WIN32 OR NOT MSVC) +# If we are not using Visual Studio, we'll run the following checks +if(NOT MSVC) + # Check if the C++ compiler can accept the -pipe flag, and add it to the compile flags if it works check_cxx_compiler_flag(-pipe HAVE_PIPE_FLAG) if(HAVE_PIPE_FLAG) set(CXXFLAGS "${CXXFLAGS} -pipe") endif(HAVE_PIPE_FLAG) + # The following are additional library checks, they are not required for Windows if(NOT WIN32) - check_library_exists(nsl inet_ntoa "" HAVE_NSL_LIB) - if(HAVE_NSL_LIB) - set(LDFLAGS "${LDFLAGS} -lnsl") - endif(HAVE_NSL_LIB) + # Check if socket is within the socket library (if the library exists), and add it to the linker flags if needed check_library_exists(socket socket "" HAVE_SOCKET_LIB) if(HAVE_SOCKET_LIB) set(LDFLAGS "${LDFLAGS} -lsocket") endif(HAVE_SOCKET_LIB) - check_library_exists(resolv res_query "" HAVE_RESOLV_LIB) - if(HAVE_RESOLV_LIB) - set(LDFLAGS "${LDFLAGS} -lresolv") - endif(HAVE_RESOLV_LIB) - check_library_exists(bsd revoke "" HAVE_BSD_LIB) - if(HAVE_BSD_LIB) - set(LDFLAGS "${LDFLAGS} -lbsd") - endif(HAVE_BSD_LIB) endif(NOT WIN32) + # Check if va_list can be copied as an array, and if it can, set the flag for it try_run(RUN_VA_LIST_AS_ARRAY COMPILE_VA_LIST_AS_ARRAY ${Anope_SOURCE_DIR} ${Anope_SOURCE_DIR}/va_list_check.c ) if(COMPILE_VA_LIST_AS_ARRAY AND NOT RUN_VA_LIST_AS_ARRAY) set(HAVE_VA_LIST_AS_ARRAY 1) endif(COMPILE_VA_LIST_AS_ARRAY AND NOT RUN_VA_LIST_AS_ARRAY) -endif(NOT WIN32 OR NOT MSVC) +endif(NOT MSVC) +# If DEFUMASK wasn't passed to CMake, set a default depending on if RUNGROUP was passed in or not if(NOT DEFUMASK) if(RUNGROUP) set(DEFUMASK "007") @@ -115,18 +117,24 @@ if(NOT DEFUMASK) set(DEFUMASK "077") endif(RUNGROUP) endif(NOT DEFUMASK) + +# Check for the existance of the following include files check_include_file(sys/types.h HAVE_SYS_TYPES_H) check_include_file(execinfo.h HAVE_BACKTRACE) +check_include_file(strings.h HAVE_STRINGS_H) +check_include_file(sys/select.h HAVE_SYS_SELECT_H) + +# Check for the existance of the following functions check_function_exists(gethostbyname HAVE_GETHOSTBYNAME) check_function_exists(gettimeofday HAVE_GETTIMEOFDAY) check_function_exists(setgrent HAVE_SETGRENT) check_function_exists(strcasecmp HAVE_STRCASECMP) check_function_exists(stricmp HAVE_STRICMP) -check_include_file(strings.h HAVE_STRINGS_H) check_function_exists(strlcat HAVE_STRLCAT) check_function_exists(strlcpy HAVE_STRLCPY) -check_include_file(sys/select.h HAVE_SYS_SELECT_H) check_function_exists(umask HAVE_UMASK) + +# Check for the existance of the following types check_type_size(uint8_t UINT8_T) check_type_size(u_int8_t U_INT8_T) check_type_size(int16_t INT16_T) @@ -136,155 +144,148 @@ check_type_size(int32_t INT32_T) check_type_size(uint32_t UINT32_T) check_type_size(u_int32_t U_INT32_T) +# Strip the leading and trailing spaces from the compile flags if(CXXFLAGS) string(STRIP ${CXXFLAGS} CXXFLAGS) endif(CXXFLAGS) +# Strip the leading and trailing spaces from the linker flags if(LDFLAGS) string(STRIP ${LDFLAGS} LDFLAGS) endif(LDFLAGS) -#if(NOT WIN32) - find_program(GREP grep) - find_program(SH sh) - find_program(CHGRP chgrp) - find_program(CHMOD chmod) - #message(STATUS "grep: ${GREP}") - find_program(PERL perl) - if(PERL) - if(USE_RUN_CC_PL) - #set(MY_COMPILER ${Anope_SOURCE_DIR}/run-cc.pl) - #set(MY_COMP_ARG ${CMAKE_CXX_COMPILER}) - set(CMAKE_CXX_COMPILE_OBJECT "${Anope_SOURCE_DIR}/run-cc.pl ${CMAKE_CXX_COMPILE_OBJECT}") - set(CMAKE_CXX_LINK_EXECUTABLE "${Anope_SOURCE_DIR}/run-cc.pl ${CMAKE_CXX_LINK_EXECUTABLE}") - set(CMAKE_CXX_CREATE_SHARED_MODULE "${Anope_SOURCE_DIR}/run-cc.pl ${CMAKE_CXX_CREATE_SHARED_MODULE}") - endif(USE_RUN_CC_PL) - endif(PERL) -#endif(NOT WIN32) - -#set(CMAKE_BUILD_TYPE DEBUG) -#message(STATUS "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}: ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}") -#message(STATUS "CMAKE_CXX_COMPILE_OBJECT: ${CMAKE_CXX_COMPILE_OBJECT}") -#set(CMAKE_CXX_COMPILE_OBJECT "${Anope_SOURCE_DIR}/run-cc.pl <CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>") -#message(STATUS "CMAKE_CXX_COMPILE_OBJECT: ${CMAKE_CXX_COMPILE_OBJECT}") -# CMAKE_CXX_COMPILE_OBJECT: <CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE> -# CMAKE_CXX_CREATE_SHARED_LIBRARY: <CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES> -# CMAKE_CXX_CREATE_SHARED_MODULE: <CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES> -# CMAKE_CXX_FLAGS_DEBUG: -g -# CMAKE_CXX_FLAGS_RELEASE: -O3 -DNDEBUG -# CMAKE_CXX_LINK_EXECUTABLE: <CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -# CMAKE_CXX_OUTPUT_EXTENSION: .o -# CMAKE_SHARED_LIBRARY_CXX_FLAGS: -fPIC -# CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS: -shared -# CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG: -Wl,-soname, - -if(NOT BINDIR) - set(BINDIR "$ENV{HOME}/services") -endif(NOT BINDIR) - -if(DATADIR) - set(SERVICES_DIR "${DATADIR}") -else(DATADIR) - set(SERVICES_DIR "$ENV{HOME}/services") - #set(MODULE_PATH "$ENV{HOME}/services/modules/") - #set(DATADIR "${SERVICES_DIR}") -endif(DATADIR) -if(WIN32) - set(SERVICES_DIR "${SERVICES_DIR}/data") -endif(WIN32) -if(NOT DATADIR) - set(DATADIR "${SERVICES_DIR}") -endif(NOT DATADIR) - -#set(SERVICES_BINARY "") - +# Search for the following programs +find_program(GREP grep) +find_program(SH sh) +find_program(CHGRP chgrp) +find_program(CHMOD chmod) +find_program(PERL perl) + +# If perl is included on the system and the user wants to use run-cc.pl, change the commands for compiling and linking +if(PERL AND USE_RUN_CC_PL) + set(CMAKE_CXX_COMPILE_OBJECT "${PERL} ${Anope_SOURCE_DIR}/run-cc.pl ${CMAKE_CXX_COMPILE_OBJECT}") + set(CMAKE_CXX_LINK_EXECUTABLE "${PERL} ${Anope_SOURCE_DIR}/run-cc.pl ${CMAKE_CXX_LINK_EXECUTABLE}") + set(CMAKE_CXX_CREATE_SHARED_MODULE "${PERL} ${Anope_SOURCE_DIR}/run-cc.pl ${CMAKE_CXX_CREATE_SHARED_MODULE}") +endif(PERL AND USE_RUN_CC_PL) + +# If a INSTDIR wasn't passed in to CMake, set the default to the services directory under the user's home directory +if(NOT INSTDIR) + set(INSTDIR "$ENV{HOME}/services") +endif(NOT INSTDIR) + +# Set Anope's data install location to be the data directory under the install directory +set(DATADIR "${INSTDIR}/data") + +# Only process Anope's version on Windows, it's needed for win32.rc as well as version branding at link time if(WIN32) + # Find all lines in version.log that start with VERSION_ file(STRINGS ${Anope_SOURCE_DIR}/version.log VERSIONS REGEX "^VERSION_") - message(STATUS "VERSIONS: ${VERSIONS}") + # Iterate through the strings found foreach(VERSION_STR ${VERSIONS}) + # Get the length of the string string(LENGTH ${VERSION_STR} VERSION_LEN) + # Subtract 16 from the string's length (8 for VERSION_, 5 more for the type, 2 for the space and leading quote, 1 for the trailing quote) math(EXPR VERSION_NUM_LEN "${VERSION_LEN} - 16") + # Extract the type from the string string(SUBSTRING ${VERSION_STR} 8 5 VERSION_TYPE) + # Extract the actual value from the string string(SUBSTRING ${VERSION_STR} 15 ${VERSION_NUM_LEN} VERSION) - #message(STATUS "VERSION_TYPE: ${VERSION_TYPE} - VERSION: ${VERSION}") + # Set the version type to the value extract from above set(VERSION_${VERSION_TYPE} ${VERSION}) - #message(STATUS "VERSION_${VERSION_TYPE}: ${VERSION_${VERSION_TYPE}}") endforeach(VERSION_STR ${VERSIONS}) + # Set the version variables based on what was found above set(VERSION_COMMA "${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_BUILD}") set(VERSION_DOTTED "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_BUILD}") set(VERSION_FULL "${VERSION_DOTTED}${VERSION_EXTRA}") - if(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") - set(FILEFLAGS "VS_FF_DEBUG") - else(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") - set(FILEFLAGS "0x0L") - endif(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") - + # Generate the win32.rc file using the above variables configure_file(${Anope_SOURCE_DIR}/src/win32.rc.cmake ${Anope_BINARY_DIR}/src/win32.rc) endif(WIN32) +# Calculate dependencies for each header +# I would've done this inside the CMakeLists.txt for the include directory, but since it's added AFTER everything else, it won't help... + +# Firstly, find all the header files file(GLOB_RECURSE ALL_HEADERS "*.h") +# Iterate through the headers foreach(HEADER ${ALL_HEADERS}) + # Don't process the file if it's in an obsolete directory if(NOT HEADER MATCHES ".*obsolete.*") list(APPEND TMP_HEADERS ${HEADER}) + # In addition, also set up a variable to store the fullpath of the header, in a variable prefixed with just the header's filename for easy access later get_filename_component(HEADER_FILENAME ${HEADER} NAME) set(${HEADER_FILENAME}_FULLPATH ${HEADER}) endif(NOT HEADER MATCHES ".*obsolete.*") endforeach(HEADER) +# Set the list of headers to be all the non-obsolete ones, then sort the list set(ALL_HEADERS ${TMP_HEADERS}) list(SORT ALL_HEADERS) -message(STATUS "ALL_HEADERS: ${ALL_HEADERS}") -# Calculate dependencies for each header -# I would've done this inside the CMakeLists.txt for the include directory, but since it's added AFTER everything else, it won't help... +# This function will take a #include line and extract the filename minus the quotes +function(extract_include_filename INCLUDE FILENAME) + # Strip away leading and trailing whitespace from the line + string(STRIP ${INCLUDE} INCLUDE_STRIPPED) + # Find the filename including the quotes, it should be at the end of the line after whitespace was stripped + string(REGEX MATCH "\".*\"$" FILE ${INCLUDE_STRIPPED}) + # Get the length of the filename with quotes + string(LENGTH ${FILE} FILENAME_LEN) + # Subtract 2 from this length, for the quotes + math(EXPR FILENAME_LEN "${FILENAME_LEN} - 2") + # Overwrite the filename with a version sans quotes + string(SUBSTRING ${FILE} 1 ${FILENAME_LEN} FILE) + # Set the filename to the the given variable + set(${FILENAME} "${FILE}" PARENT_SCOPE) +endfunction(extract_include_filename) # Preparse step 1: get filenames sans paths +# Iterate through the headers foreach(HEADER ${ALL_HEADERS}) + # Find all the lines in the current header that have any form of #include on them, regardless of whitespace file(STRINGS ${HEADER} INCLUDES REGEX "^[ \t]*#[ \t]*include[ \t]*\".*\"[ \t]*$") - message(STATUS "${HEADER}'s includes: ${INCLUDES}") + # Get the filename only of the header we just checked get_filename_component(HEADER_FILENAME ${HEADER} NAME) + # Iterate through the strings containing #include (if any) foreach(INCLUDE ${INCLUDES}) - string(STRIP ${INCLUDE} INCLUDE) - string(REGEX MATCH "\".*\"$" FILENAME ${INCLUDE}) - string(LENGTH ${FILENAME} FILENAME_LEN) - math(EXPR FILENAME_LEN "${FILENAME_LEN} - 2") - string(SUBSTRING ${FILENAME} 1 ${FILENAME_LEN} FILENAME) - message(STATUS "INCLUDE FILENAME: ${FILENAME}") + # Extract the filename from the #include line + extract_include_filename(${INCLUDE} FILENAME) + # Append this filename to the list of headers for the header we are checking list(APPEND ${HEADER_FILENAME}_HEADERS ${FILENAME}) endforeach(INCLUDE) - if(${HEADER_FILENAME}_HEADERS) - message(STATUS "${HEADER_FILENAME}_HEADERS: ${${HEADER_FILENAME}_HEADERS}") - endif(${HEADER_FILENAME}_HEADERS) endforeach(HEADER) # Preparse step 2: for every header from above that had includes, recursively find the headers each header relies on +# Iterate through the headers (again) foreach(HEADER ${ALL_HEADERS}) + # Get the filename only of the current header get_filename_component(HEADER_FILENAME ${HEADER} NAME) + # If there were any include, we'll be checking them if(${HEADER_FILENAME}_HEADERS) + # Set the variables, old for all previously found headers, new for all newly found headers set(OLD_HEADERS) set(HEADERS ${${HEADER_FILENAME}_HEADERS}) set(NEW_HEADERS) - #message(STATUS "Before start of WHILE() for ${HEADER_FILENAME} - ${HEADERS}") + # Loop as long as there are still headers to be parsed while(HEADERS) + # Iterate through the list of the current headers foreach(CURR_HEADER ${HEADERS}) - #message(STATUS "CURR_HEADER: ${CURR_HEADER}") + # If that header has headers it relies on, we'll add them to the list of new headers if(${CURR_HEADER}_HEADERS) - #message(STATUS "${CURR_HEADER}_HEADERS: ${${CURR_HEADER}_HEADERS}") - #message(STATUS "NEW_HEADERS BEFORE: ${NEW_HEADERS}") foreach(CURR_HEADERS_HEADER ${${CURR_HEADER}_HEADERS}) list(APPEND NEW_HEADERS ${CURR_HEADERS_HEADER}) endforeach(CURR_HEADERS_HEADER) - #message(STATUS "NEW_HEADERS AFTER: ${NEW_HEADERS}") endif(${CURR_HEADER}_HEADERS) endforeach(CURR_HEADER) - #message(STATUS "NEW_HEADERS: ${NEW_HEADERS}") + # Append the headers we checked to the old headers list(APPEND OLD_HEADERS ${HEADERS}) + # Set the headers to check to the new headers (it may be empty and that'll exit the loop) set(HEADERS ${NEW_HEADERS}) + # Erase the new headers set(NEW_HEADERS) endwhile(HEADERS) + # OLD_HEADERS will now contain all headers that the current header relies on, remove duplicate headers from the list and sort the list list(REMOVE_DUPLICATES OLD_HEADERS) list(SORT OLD_HEADERS) - message(STATUS "${HEADER_FILENAME}'s OLD_HEADERS: ${OLD_HEADERS}") + # Set the current header's list of headers to the cleaned up list from above set(${HEADER_FILENAME}_HEADERS ${OLD_HEADERS}) endif(${HEADER_FILENAME}_HEADERS) endforeach(HEADER) @@ -295,82 +296,63 @@ set(language.h_FULLPATH ${Anope_BINARY_DIR}/lang/language.h) set(sysconf.h_FULLPATH ${Anope_BINARY_DIR}/include/sysconf.h) set(version.h_FULLPATH ${Anope_BINARY_DIR}/include/version.h) -# Final step: Replace the filename in each header's dependency list with full paths (MOVE TO OTHER CMakeLists.txt LATER!) -#foreach(HEADER ${ALL_HEADERS}) -# get_filename_component(HEADER_FILENAME ${HEADER} NAME) -# if(${HEADER_FILENAME}_HEADERS) -# set(NEW_HEADERS) -# foreach(CURR_HEADER ${${HEADER_FILENAME}_HEADERS}) -# list(APPEND NEW_HEADERS ${${CURR_HEADER}_FULLPATH}) -# endforeach(CURR_HEADER) -# message(STATUS "${HEADER_FILENAME}'s NEW_HEADERS: ${NEW_HEADERS}") -# set(${HEADER_FILENAME}_HEADERS ${NEW_HEADERS}) -# endif(${HEADER_FILENAME}_HEADERS) -#endforeach(HEADER) - +# This function is used in most of the src (sub)directories to calculate the header file dependencies for the given source file function(calculate_depends SRC) + # Find all the lines in the given source file that have any form of #include on them, regardless of whitespace file(STRINGS ${SRC} INCLUDES REGEX "^[ \t]*#[ \t]*include[ \t]*\".*\"[ \t]*$") - #message(STATUS "${SRC}'s includes: ${INCLUDES}") - #get_filename_component(HEADER_FILENAME ${HEADER} NAME) + # Reset the list of headers to empty set(HEADERS) + # Iterate through the strings containing #include (if any) foreach(INCLUDE ${INCLUDES}) - string(STRIP ${INCLUDE} INCLUDE) - string(REGEX MATCH "\".*\"$" FILENAME ${INCLUDE}) - string(LENGTH ${FILENAME} FILENAME_LEN) - math(EXPR FILENAME_LEN "${FILENAME_LEN} - 2") - string(SUBSTRING ${FILENAME} 1 ${FILENAME_LEN} FILENAME) - #message(STATUS "INCLUDE FILENAME: ${FILENAME}") - #list(APPEND ${HEADER_FILENAME}_HEADERS ${FILENAME}) + # Extract the filename from the #include line + extract_include_filename(${INCLUDE} FILENAME) + # Append the filename to the list of headers list(APPEND HEADERS ${FILENAME}) endforeach(INCLUDE) - #message(STATUS "${SRC}'s HEADERS: ${HEADERS}") + # Set the list of new headers to empty (this will store all the headers that the above list depends on) set(NEW_HEADERS) + # Iterate through the list of headers foreach(HEADER ${HEADERS}) - #message(STATUS "HEADER: ${HEADER} - ${HEADERS}_HEADERS: ${${HEADERS}_HEADERS}") + # If the current header has it's own headers to depend on, append those to the list of new headers if(${HEADER}_HEADERS) list(APPEND NEW_HEADERS ${${HEADER}_HEADERS}) endif(${HEADER}_HEADERS) endforeach(HEADER) + # If there were new headers, append them to the list of headers if(NEW_HEADERS) list(APPEND HEADERS ${NEW_HEADERS}) endif(NEW_HEADERS) + # If after all the above there is a list of header, we'll process them, converting them to full paths if(HEADERS) + # Remove duplicate headers from the list and sort the list list(REMOVE_DUPLICATES HEADERS) list(SORT HEADERS) - #message(STATUS "${SRC}'s HEADERS after NEW_HEADERS: ${HEADERS}") + # Set the list of full path headers to empty set(HEADERS_FULL) + # Iterate through the list of headers foreach(HEADER ${HEADERS}) - get_filename_component(HEADER_FILENAME ${HEADER} NAME) - list(APPEND HEADERS_FULL ${${HEADER_FILENAME}_FULLPATH}) + # Append the full path of the header to the full path headers list + list(APPEND HEADERS_FULL ${${HEADER}_FULLPATH}) endforeach(HEADER) - #message(STATUS "${SRC}'s HEADERS_FULL: ${HEADERS_FULL}") + # Set the given source file to depend on the headers given set_source_files_properties(${SRC} PROPERTIES OBJECT_DEPENDS "${HEADERS_FULL}") - list(APPEND ${PROGRAM_NAME}_HEADERS ${HEADERS_FULL}) endif(HEADERS) endfunction(calculate_depends) +# Go into the following directories and run their CMakeLists.txt as well add_subdirectory(data) add_subdirectory(lang) add_subdirectory(src) add_subdirectory(include) -#message("[in root] SERVICES_BIN: ${SERVICES_BIN}") - -#if(BINDIR) -# set(SERVICES_BIN "${BINDIR}/${SERVICES_BINARY}") -#else(BINDIR) -# set(SERVICES_BIN "$ENV{HOME}/services/${SERVICES_BINARY}") -# set(BINDIR "$ENV{HOME}/services") -#endif(BINDIR) - +# At install time, create the following additional directories install(CODE "file(MAKE_DIRECTORY \"${DATADIR}/backups\")") install(CODE "file(MAKE_DIRECTORY \"${DATADIR}/logs\")") install(CODE "file(MAKE_DIRECTORY \"${DATADIR}/modules/runtime\")") -if(NOT WIN32) - if(RUNGROUP) - install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${DATADIR}/backups\")") - install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${DATADIR}/logs\")") - install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${DATADIR}/modules/runtime\")") - install(CODE "execute_process(COMMAND ${CHGRP} -R ${RUNGROUP} \"${DATADIR}\")") - endif(RUNGROUP) -endif(NOT WIN32) +# On non-Windows platforms, if RUNGROUP is set, change the permissions of the below directories, as well as the group of the data directory +if(NOT WIN32 AND RUNGROUP) + install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${DATADIR}/backups\")") + install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${DATADIR}/logs\")") + install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${DATADIR}/modules/runtime\")") + install(CODE "execute_process(COMMAND ${CHGRP} -R ${RUNGROUP} \"${DATADIR}\")") +endif(NOT WIN32 AND RUNGROUP) @@ -2,7 +2,7 @@ # # Configuration script for Services. # -# Anope (c) 2003-2007 Anope team +# Anope (c) 2003-2008 Anope team # Contact us at dev@anope.org # # This program is free but copyrighted software; see the file COPYING for @@ -26,10 +26,10 @@ exists () { # because some shells don't have test -e } Load_Cache () { - if [ -f config.cache -a -r config.cache -a ! "$IGNORE_CACHE" ] ; then - echo "Using defaults from config.cache. To ignore, ./Config -nocache" + if [ -f $SOURCE_DIR/config.cache -a -r $SOURCE_DIR/config.cache -a ! "$IGNORE_CACHE" ] ; then + echo "Using defaults from config.cache. To ignore, $SOURCE_DIR/Config -nocache" echo "" - . config.cache + . $SOURCE_DIR/config.cache CAN_QUICK="yes" else CAN_QUICK="no" @@ -37,20 +37,15 @@ Load_Cache () { } Run_CMake () { - WITH_BIN="" - WITH_DATA="" + WITH_INST="" WITH_RUN="" WITH_PERM="" BUILD_TYPE="" RUN_CC_PL="" + GEN_TYPE="" - if [ "$BINDEST" != "" ] ; then - WITH_BIN="-DBINDIR:STRING=$BINDEST" - WITH_DATA="-DDATADIR:STRING=$DATDEST" - fi - - if [ "$DATDEST" != "" ] ; then - WITH_DATA="-DDATADIR:STRING=$DATDEST" + if [ "$INSTDEST" != "" ] ; then + WITH_INST="-DINSTDIR:STRING=$INSTDEST" fi if [ "$RUNGROUP" != "" ] ; then @@ -73,21 +68,30 @@ Run_CMake () { RUN_CC_PL="-DUSE_RUN_CC_PL:BOOLEAN=OFF" fi - echo "cmake $WITH_BIN $WITH_DATA $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL ." + case `uname -s` in + MINGW*) + GEN_TYPE="-G\"MSYS Makefiles\"" + ;; + esac + + echo "cmake $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL $SOURCE_DIR" - cmake $WITH_BIN $WITH_DATA $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL . + cmake $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL $SOURCE_DIR + + echo "" + echo "Now run make to build Anope." } ECHO2SUF='' if [ "`echo -n a ; echo -n b`" = "ab" ] ; then ECHO2='echo -n' elif [ "`echo 'a\c' ; echo 'b\c'`" = "ab" ] ; then - ECHO2='echo' ; ECHO2SUF='\c' + ECHO2='echo' ; ECHO2SUF='\c' elif [ "`printf 'a' 2>&1 ; printf 'b' 2>&1`" = "ab" ] ; then - ECHO2='printf "%s"' + ECHO2='printf "%s"' else - # oh well... - ECHO2='echo' + # oh well... + ECHO2='echo' fi export ECHO2 ECHO2SUF @@ -95,53 +99,61 @@ export ECHO2 ECHO2SUF # Init values ########################################################################### -BINDEST=$HOME/services -DATDEST=$HOME/services +INSTDEST=$HOME/services RUNGROUP= UMASK= DEBUG="no" USE_RUN_CC_PL="no" CAN_QUICK="no" +SOURCE_DIR=`dirname $0` ########################################################################### # Check out the options ########################################################################### while [ $# -ge 1 ] ; do - if [ $1 = "--help" ] ; then - echo "Config utility for Anope" - echo "------------------------" - echo "Syntax: ./Config [options]" - echo "-nocache Ignore settings saved in config.cache" - echo "-nointro Skip intro (disclaimer, etc)" - echo "-quick Skip questions, go straight to cmake" - exit 0 - elif [ $1 = "-nocache" ] ; then - IGNORE_CACHE="1" - elif [ $1 = "-nointro" ] ; then - NO_INTRO="1" - elif [ $1 = "-quick" -o $1 = "-q" ] ; then - Load_Cache - if [ "$CAN_QUICK" = "yes" ] ; then - Run_CMake - else - echo "" - echo "Can't find cache file (config.cache), aborting..." - fi - exit 0 + if [ $1 = "--help" ] ; then + echo "Config utility for Anope" + echo "------------------------" + echo "Syntax: ./Config [options]" + echo "-nocache Ignore settings saved in config.cache" + echo "-nointro Skip intro (disclaimer, etc)" + echo "-quick Skip questions, go straight to cmake" + exit 0 + elif [ $1 = "-nocache" ] ; then + IGNORE_CACHE="1" + elif [ $1 = "-nointro" ] ; then + NO_INTRO="1" + elif [ $1 = "-quick" -o $1 = "-q" ] ; then + Load_Cache + if [ "$CAN_QUICK" = "yes" ] ; then + Run_CMake + else + echo "" + echo "Can't find cache file (config.cache), aborting..." fi - shift 1 + exit 0 + fi + shift 1 done ########################################################################### if [ ! "$NO_INTRO" ] ; then - clear - . ./version.log - cat .BANNER | sed "s/CURVER/$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH$VERSION_EXTRA/" | more - echo "" + case `uname -s` in + MINGW*) + PAGER=less + ;; + *) + PAGER=more + clear + ;; + esac + . $SOURCE_DIR/version.log + cat $SOURCE_DIR/.BANNER | sed "s/CURVER/$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH$VERSION_EXTRA/" | sed "s@SOURCE_DIR@$SOURCE_DIR@" | $PAGER + echo "" else - echo "" + echo "" fi echo "Beginning Services configuration." @@ -152,7 +164,7 @@ echo "" ########################################################################### if [ ! "$IGNORE_CACHE" ] ; then - Load_Cache + Load_Cache fi # Ask the user anything we need to know ahead of time. @@ -165,10 +177,10 @@ ok=0 echo "Note: press Return for the default, or enter a new value." echo "In what directory do you want the binaries to be installed?" while [ $ok -eq 0 ] ; do - echo2 "[$BINDEST] " + echo2 "[$INSTDEST] " if read INPUT ; then : ; else echo "" ; exit 1 ; fi if [ ! "$INPUT" ] ; then - INPUT=$BINDEST + INPUT=$INSTDEST fi if [ ! -d "$INPUT" ] ; then if exists "$INPUT" ; then @@ -189,46 +201,12 @@ while [ $ok -eq 0 ] ; do ok=1 fi done -BINDEST=$INPUT -DATDEST=$INPUT +INSTDEST=$INPUT echo "" #### -ok=0 -echo "Where do you want the data files to be installed?" -while [ $ok -eq 0 ] ; do - echo2 "[$DATDEST] " - if read INPUT ; then : ; else echo "" ; exit 1 ; fi - if [ ! "$INPUT" ] ; then - INPUT=$DATDEST - fi - if [ ! -d "$INPUT" ] ; then - if exists "$INPUT" ; then - echo "$INPUT exists, but is not a directory!" - else - echo "$INPUT does not exist. Create it?" - echo2 "[y] " - read YN - if [ "$YN" != "n" ] ; then - if mkdir -p $INPUT ; then - ok=1 - fi - fi - fi - elif exists "$INPUT/include/services.h" ; then - echo "You cannot use the Services source directory as a target directory." - else - ok=1 - fi -done -DATDEST=$INPUT -echo "" - -#### - - OLD_RUNGROUP="$RUNGROUP" if [ "$RUNGROUP" ] ; then echo "Which group should all Services data files be owned by? (If Services" @@ -242,41 +220,41 @@ fi echo2 "[$RUNGROUP] " if read INPUT ; then : ; else echo "" ; exit 1 ; fi if [ "$INPUT" ] ; then - if [ "$INPUT" = "none" ] ; then |
