1
0
mirror of https://github.com/anope/anope.git synced 2026-07-08 11:23:13 +02:00

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
This commit is contained in:
cyberbotx
2008-12-17 20:18:40 +00:00
parent fd45a3ad42
commit 81b7aa6571
21 changed files with 696 additions and 1400 deletions
+1 -1
View File
@@ -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,
+159 -177
View File
@@ -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)
# 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)
#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 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(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 "")
# 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)
file(GLOB_RECURSE ALL_HEADERS "*.h")
foreach(HEADER ${ALL_HEADERS})
if(NOT HEADER MATCHES ".*obsolete.*")
list(APPEND TMP_HEADERS ${HEADER})
get_filename_component(HEADER_FILENAME ${HEADER} NAME)
set(${HEADER_FILENAME}_FULLPATH ${HEADER})
endif(NOT HEADER MATCHES ".*obsolete.*")
endforeach(HEADER)
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...
# Preparse step 1: get filenames sans paths
# 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)
# 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)
+91 -112
View File
@@ -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
cmake $WITH_BIN $WITH_DATA $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL .
echo "cmake $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL $SOURCE_DIR"
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
RUNGROUP=""
else
RUNGROUP="$INPUT"
fi
if [ "$INPUT" = "none" ] ; then
RUNGROUP=""
else
RUNGROUP="$INPUT"
fi
fi
echo ""
####
if [ ! "$UMASK" -o "$RUNGROUP" != "$OLD_RUNGROUP" ] ; then
if [ "$RUNGROUP" ] ; then
UMASK=007
else
UMASK=077
fi
if [ "$RUNGROUP" ] ; then
UMASK=007
else
UMASK=077
fi
fi
ok=0
echo "What should the default umask for data files be (in octal)?"
echo "(077 = only accessible by owner; 007 = accessible by owner and group)"
while [ $ok -eq 0 ] ; do
echo2 "[$UMASK] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
if [ ! "$INPUT" ] ; then
INPUT=$UMASK
fi
if [ `echo "$INPUT" | grep -c '[^0-7]'` -gt 0 ] ; then
echo "$UMASK is not a valid octal number!"
else
if [ "`echo $INPUT | cut -c1`" != "0" ] ; then
INPUT=0$INPUT
fi
ok=1
echo2 "[$UMASK] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
if [ ! "$INPUT" ] ; then
INPUT=$UMASK
fi
if [ `echo "$INPUT" | grep -c '[^0-7]'` -gt 0 ] ; then
echo "$UMASK is not a valid octal number!"
else
if [ "`echo $INPUT | cut -c1`" != "0" ] ; then
INPUT=0$INPUT
fi
ok=1
fi
done
UMASK=$INPUT
echo ""
@@ -309,6 +287,8 @@ echo "You can optionally have the build run through run-cc.pl, which will"
echo "cause warnings and errors (if any) to be colored yellow and run,"
echo "respectively. This relies on Perl being installed, so if you say yes"
echo "to this without Perl, the option will be ignored."
echo "NOTE: If you are using MinGW, it is NOT recommended to say yes to"
echo "this, it may fail."
echo "Would you like to utilize run-cc.pl?"
echo2 "[$TEMP_YN] "
read YN
@@ -329,9 +309,8 @@ echo ""
echo2 "Saving configuration results in config.cache... "
cat <<EOT >config.cache
BINDEST="$BINDEST"
DATDEST="$DATDEST"
cat <<EOT >$SOURCE_DIR/config.cache
INSTDEST="$INSTDEST"
RUNGROUP="$RUNGROUP"
UMASK=$UMASK
DEBUG="$DEBUG"
@@ -341,7 +320,7 @@ echo "done."
################################################################################
# Build the configure string
# Build the CMake string
################################################################################
Run_CMake
+2 -1
View File
@@ -1,5 +1,6 @@
# Only install example.chk and example.conf from this directory
# NOTE: I would've had this just find all files in the directory, but that would include files not needed (like this file)
set(DATA example.chk example.conf)
install(FILES ${DATA}
DESTINATION "${DATADIR}"
)
+15 -81
View File
@@ -1,89 +1,23 @@
# NOTE: Need a better dependency system here!
set(HEADERS_REL commands.h extern.h messages.h module.h modules.h pseudo.h services.h)
set(commands.h_HEADERS modules.h)
set(extern.h_HEADERS slist.h)
set(messages.h_HEADERS modules.h)
set(module.h_HEADERS services.h commands.h ${Anope_BINARY_DIR}/lang/language.h modules.h ${CMAKE_CURRENT_BINARY_DIR}/version.h)
set(modules.h_HEADERS services.h)
set(pseudo.h_HEADERS commands.h ${Anope_BINARY_DIR}/lang/language.h timeout.h encrypt.h datafiles.h slist.h)
set(services.h_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/sysconf.h config.h sockets.h defs.h slist.h events.h bots.h account.h regchannel.h users.h extern.h configreader.h)
if(WIN32)
# If we are building for Visual Studio OR if the system we are on doesn't have sh (which would be odd on a *nix system...), we'll build a C++ program to create version.h
if(MSVC OR NOT SH)
# Set version.sh.c to use C++ as well as set it's compile flags
set_source_files_properties(version.sh.c PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
add_executable(version.sh version.sh.c)
set_target_properties(version.sh PROPERTIES LINK_FLAGS "${LDFLAGS}")
# Generate version_sh executable to create version.h from the contents of version.sh, setting it's linker flags as well
add_executable(version_sh version.sh.c)
set_target_properties(version_sh PROPERTIES LINK_FLAGS "${LDFLAGS}")
# Generate version.h from the above executable and the version.log file from the main source directory, with dependencies to the given headers and all source files in the main Anope build
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.h
COMMAND version.sh ${Anope_SOURCE_DIR}/version.log ${CMAKE_CURRENT_SOURCE_DIR}/version.sh ${CMAKE_CURRENT_BINARY_DIR}/version.h
MAIN_DEPENDENCY version.sh DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/services.h ${CMAKE_CURRENT_SOURCE_DIR}/pseudo.h ${CMAKE_CURRENT_SOURCE_DIR}/messages.h ${SRC_SRCS}
COMMAND version_sh ${Anope_SOURCE_DIR}/version.log ${CMAKE_CURRENT_SOURCE_DIR}/version.sh ${CMAKE_CURRENT_BINARY_DIR}/version.h
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/version.sh DEPENDS version_sh ${CMAKE_CURRENT_SOURCE_DIR}/services.h ${CMAKE_CURRENT_SOURCE_DIR}/pseudo.h ${CMAKE_CURRENT_SOURCE_DIR}/messages.h ${SRC_SRCS}
)
else(WIN32)
# For any non-Visual Studio platforms that do have sh, we will run version.h through the version.h shell script
else(MSVC OR NOT SH)
# Generate version.h from version.sh and the version.log file from the main source directory, with dependencies to the given headers and all source files in the main Anope build
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.h
#COMMAND ${CMAKE_COMMAND} -E copy ${Anope_SOURCE_DIR}/version.log ../
COMMAND ${SH} ${CMAKE_CURRENT_SOURCE_DIR}/version.sh ${Anope_SOURCE_DIR}/version.log ${CMAKE_CURRENT_BINARY_DIR}/version.h
#COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/version.h ${CMAKE_CURRENT_SOURCE_DIR}/
#COMMAND ${CMAKE_COMMAND} -E remove ../version.log
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/version.sh DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/services.h ${CMAKE_CURRENT_SOURCE_DIR}/pseudo.h ${CMAKE_CURRENT_SOURCE_DIR}/messages.h ${SRC_SRCS}
# MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/version.sh DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/services.h ${CMAKE_CURRENT_SOURCE_DIR}/pseudo.h ${CMAKE_CURRENT_SOURCE_DIR}/messages.h
)
endif(WIN32)
endif(MSVC OR NOT SH)
#foreach(HEADER ${HEADERS_REL})
# if(NOT WIN32)
# add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${HEADER}
# COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${CMAKE_CURRENT_SOURCE_DIR}/${HEADER}
# )
# endif(NOT WIN32)
# set(HEADERS_FULL ${HEADERS_FULL} ${CMAKE_CURRENT_SOURCE_DIR}/${HEADER})
# set(HEADERS)
# if(${HEADER}_HEADERS)
# foreach(HEADER_REL ${${HEADER}_HEADERS})
# string(SUBSTRING ${HEADER_REL} 0 1 FIRST_CHAR)
# string(SUBSTRING ${HEADER_REL} 1 1 SECOND_CHAR)
# if(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
# set(HEADERS ${HEADERS} ${HEADER_REL})
# else(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
# set(HEADERS ${HEADERS} ${Anope_SOURCE_DIR}/include/${HEADER_REL})
# endif(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
# endforeach(HEADER_REL)
# endif(${HEADER}_HEADERS)
# if(HEADERS)
# set_source_files_properties(${HEADER} PROPERTIES OBJECT_DEPENDS "${HEADERS}")
# endif(HEADERS)
#endforeach(HEADER)
#set(HEADERS_FULL ${HEADERS_FULL} ${CMAKE_CURRENT_BINARY_DIR}/version.h)
#message(STATUS "HEADERS_FULL: ${HEADERS_FULL}")
#add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/services.h
# COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${CMAKE_CURRENT_SOURCE_DIR}/services.h
# MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/extern.h DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sysconf.h ${CMAKE_CURRENT_SOURCE_DIR}/config.h
#)
#add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/extern.h
# COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${CMAKE_CURRENT_SOURCE_DIR}/extern.h
# MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/slist.h
#)
#add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/pseudo.h
# COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${CMAKE_CURRENT_SOURCE_DIR}/pseudo.h
# MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/timeout.h DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/commands.h ${CMAKE_CURRENT_SOURCE_DIR}/encrypt.h ${CMAKE_CURRENT_SOURCE_DIR}/datafiles.h ${CMAKE_CURRENT_SOURCE_DIR}/slist.h
#)
#add_dependencies(${CMAKE_CURRENT_SOURCE_DIR}/version.h src_srcs)
#add_custom_target(include_version_h ALL DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/version.h)
#add_custom_target(include_version_h DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/version.h)
#add_dependencies(include_version_h src_srcs)
#add_custom_target(include ALL)
#add_custom_target(include)
#add_custom_target(headers DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/version.h ${CMAKE_CURRENT_SOURCE_DIR}/services.h ${CMAKE_CURRENT_SOURCE_DIR}/extern.h ${CMAKE_CURRENT_SOURCE_DIR}/pseudo.h)
#add_custom_target(headers DEPENDS ${HEADERS_FULL})
if(ALL_HEADERS)
set_source_files_properties(${ALL_HEADERS} PROPERTIES HEADER_FILE_ONLY TRUE)
add_custom_target(headers DEPENDS ${ALL_HEADERS})
else(ALL_HEADERS)
add_custom_target(headers)
endif(ALL_HEADERS)
#add_dependencies(include include_version_h)
set(HEADERS_CLEAN ${CMAKE_CURRENT_BINARY_DIR}/version.h)
set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM yes ADDITIONAL_MAKE_CLEAN_FILES "${HEADERS_CLEAN}")
# Add a custom target to the above file
add_custom_target(headers DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/version.h)
+1 -1
View File
@@ -569,7 +569,7 @@ E const char version_build[];
E char *version_protocol;
E const char version_flags[];
E const char *services_dir;
E std::string services_dir;
E const char *log_filename;
E int debug;
E int readonly;
+1 -1
View File
@@ -34,7 +34,7 @@ typedef void * ano_module_t;
#define ano_modopen(file) dlopen(file, RTLD_LAZY)
#define ano_moderr() dlerror()
#define ano_modsym(file, symbol) dlsym(file, DL_PREFIX symbol)
#define ano_modsym(file, symbol) dlsym(file, symbol)
#define ano_modclose(file) dlclose(file)
/* We call dlerror() here because it clears the module error after being
* called. This previously read 'errno = 0', but that didn't work on
-6
View File
@@ -17,14 +17,8 @@
#cmakedefine HAVE_SYS_SELECT_H 1
#cmakedefine HAVE_UMASK 1
#cmakedefine HAVE_VA_LIST_AS_ARRAY 1
// Temporary, change elsewhere to be SERVICES_DIR/modules/
#define MODULE_PATH "@SERVICES_DIR@/modules/"
#cmakedefine RUNGROUP "@RUNGROUP@"
#cmakedefine SERVICES_BIN "@SERVICES_BIN@"
#cmakedefine SERVICES_DIR "@SERVICES_DIR@"
// Temporary, remove from here later as well as elsewhere in the code
#define DL_PREFIX ""
#cmakedefine HAVE_UINT8_T 1
#cmakedefine HAVE_U_INT8_T 1
+224 -537
View File
@@ -15,553 +15,240 @@
var anopeVersion = "Unknown";
var vMaj, vMin, vPat, vBuild, vExtra;
var drivesToCheck = ['C', 'D', 'E', 'F', 'G', 'H'];
var installerResponses = new Array();
var softwareVersions = {
'Compiler' : false,
'MySQLDB' : false
};
var installerQuestions = [
{
'question' : [
'Do you want to compile Anope with MySQL Support?',
'NOTE: You will need to have installed MySQL 3.23 or Above'
],
'short' : 'Enable MySQL Support?',
'options' : [
'yes',
'no'
],
'default_answer' : 'no',
'store_answer' : function (answer) {
if (answer == 'yes') {
if (!findMySQL()) {
WScript.Echo("\nERROR: Cannot find MySQL - See error messages above for details.\n");
return false;
}
}
installerResponses['MySQL DB Support'] = answer;
return true;
},
'commit_config' : function() {
if (installerResponses['MySQL DB Support'] == 'yes') {
f.WriteLine("USE_MYSQL=1");
f.WriteLine("MYSQL_LIB=\""+softwareVersions['MySQLDB'].installedDrive+":\\"+softwareVersions['MySQLDB'].libpaths[0]+"\"");
f.WriteLine("MYSQL_INC=\""+softwareVersions['MySQLDB'].installedDrive+":\\"+softwareVersions['MySQLDB'].incpaths[0]+"\"");
f.WriteLine("LIBS=$(LIBS) /LIBPATH:$(MYSQL_LIB)");
f.WriteLine("MYSQL_LIB_PATH=/LIBPATH:$(MYSQL_LIB)");
f.WriteLine("BASE_CFLAGS=$(BASE_CFLAGS) /I $(MYSQL_INC)");
f.WriteLine("MYSQL_INC_PATH=/I $(MYSQL_INC)");
f.WriteLine("BASE_CFLAGS=/D $(BASE_CFLAGS)");
f.WriteLine("MYPASQL_BUILD=$(CC) /LD $(MYSQL_INC_PATH) src\\mypasql.c /link $(MYSQL_LIB_PATH) $(LFLAGS) /DEF:src\mypasql.def libmysql.lib zlib.lib ws2_32.lib advapi32.lib /NODEFAULTLIB:LIBCMTD.lib");
f.WriteLine("LIBS=$(LIBS) libmysql.lib zlib.lib");
}
else {
f.WriteLine("USE_MYSQL=0");
}
}
},
];
var buildPackages = [
{
'name' : 'Microsoft Visual Studio 2008 (New PSDK)',
'libpaths' : [
'Program Files\\Microsoft Visual Studio 9.0\\VC\\Lib',
'Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Lib'
],
'incpaths' : [
'Program Files\\Microsoft Visual Studio 9.0\\VC\\Include',
'Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Include'
],
'nmake' : [
'Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Bin',
],
'additional_switches' : [ '/w' ],
'installedDrive' : 'C'
},
{
'name' : 'Microsoft Visual Studio 2008 (64bit) (New PSDK)',
'libpaths' : [
'Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\Lib',
'Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Lib'
],
'incpaths' : [
'Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\Include',
'Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Include'
],
'nmake' : [
'Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Bin',
],
'additional_switches' : [ '/w' ],
'installedDrive' : 'C'
},
{
'name' : 'Microsoft Visual Studio 2005 (New PSDK)',
'libpaths' : [
'Program Files\\Microsoft Visual Studio 8\\VC\\Lib',
'Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Lib'
],
'incpaths' : [
'Program Files\\Microsoft Visual Studio 8\\VC\\Include',
'Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Include'
],
'nmake' : [
'Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Bin',
''
],
'additional_switches' : [
'/w'
],
'installedDrive' : 'C'
},
{
'name' : 'Microsoft Visual Studio 2005 (Old PSDK)',
'libpaths' : [
'Program Files\\Microsoft Visual Studio 8\\VC\\Lib',
'Program Files\\Microsoft Platform SDK\\Lib'
],
'incpaths' : [
'Program Files\\Microsoft Visual Studio 8\\VC\\Include',
'Program Files\\Microsoft Platform SDK\\Include'
],
'nmake' : [
'Program Files\\Microsoft Platform SDK\\Bin',
''
],
'additional_switches' : [
'/w'
],
'installedDrive' : 'C'
},
{
'name' : 'Microsoft Visual Studio .NET 2003',
'libpaths' : [
'Program Files\\Microsoft Visual Studio .NET 2003\\VC7\\Lib',
'Program Files\\Microsoft Visual Studio .NET 2003\\VC7\\PlatformSDK\\Lib'
],
'incpaths' : [
'Program Files\\Microsoft Visual Studio .NET 2003\\VC7\\Include',
'Program Files\\Microsoft Visual Studio .NET 2003\\VC7\\PlatformSDK\\Include'
],
'nmake' : [
'Program Files\\Microsoft Visual Studio .NET 2003\\VC7\\Bin',
''
],
'additional_switches' : false,
'installedDrive' : 'C'
},
{
'name' : 'Microsoft Visual Studio 98',
'libpaths' : [
'Program Files\\Microsoft Visual Studio\\VC98\\Lib'
],
'incpaths' : [
'Program Files\\Microsoft Visual Studio\\VC98\\Include'
],
'nmake' : [
'Program Files\\Microsoft Visual Studio\\VC98\\Bin',
''
],
'additional_switches' : [
'/QIfist'
],
'installedDrive' : 'C'
}
];
var mysqlVersions = [
{
'name' : 'MySQL 5.1',
'libpaths' : [
'Program Files\\MySQL\\MySQL Server 5.1\\Lib\\opt'
],
'incpaths' : [
'Program Files\\MySQL\\MySQL Server 5.1\\Include'
],
'dllfile' : 'Program Files\\MySQL\\MySQL Server 5.1\\bin\\libmsyql.dll',
'installedDrive' : 'C'
},
{
'name' : 'MySQL 5.0',
'libpaths' : [
'Program Files\\MySQL\\MySQL Server 5.0\\Lib\\opt'
],
'incpaths' : [
'Program Files\\MySQL\\MySQL Server 5.0\\Include'
],
'dllfile' : 'Program Files\\MySQL\\MySQL Server 5.0\\Bin\\libmysql.dll',
'installedDrive' : 'C'
},
{
'name' : 'MySQL 4.1',
'libpaths' : [
'Program Files\\MySQL\\MySQL Server 4.1\\Lib\\opt'
],
'incpaths' : [
'Program Files\\MySQL\\MySQL Server 4.1\\Include'
],
'dllfile' : 'Program Files\\MySQL\\MySQL Server 4.1\\Bin\\libmysql.dll',
'installedDrive' : 'C'
},
{
'name' : 'MySQL 4.0',
'libpaths' : [
'Program Files\\MySQL\\MySQL Server 4.0\\Lib\\opt'
],
'incpaths' : [
'Program Files\\MySQL\\MySQL Server 4.0\\Include'
],
'dllfile' : 'Program Files\\MySQL\\MySQL Server 4.0\\Bin\\libmysql.dll',
'installedDrive' : 'C'
},
{
'name' : 'MySQL 3.23 or older (or other default path)',
'libpaths' : [
'mysql\\lib\\opt'
],
'incpaths' : [
'mysql\\include'
],
'dllfile' : 'mysql\\Bin\\libmysql.dll',
'installedDrive' : 'C'
}
];
var bannerReplacements = [
{
'findtext' : /CURVER/g,
'replacement' : function() { FindAnopeVersion(); return anopeVersion; }
},
{
'findtext' : / For more options type .\/Config --help/g,
'replacement' : function() { return ''; }
}
];
var fso = WScript.CreateObject("Scripting.FileSystemObject");
var x, y, z;
if (fso.FileExists('.BANNER')) {
var bannerStream = fso.OpenTextFile(".BANNER");
var bannerText = bannerStream.ReadAll();
bannerStream.close();
for (x in bannerReplacements) {
var thisReplacement = bannerReplacements[x];
bannerText = bannerText.replace(thisReplacement['findtext'], thisReplacement['replacement']);
}
WScript.Echo(bannerText+"\n");
}
else {
WScript.Echo("ERROR: Cannot find banner file!\n");
}
WScript.Echo("Press Enter to Begin...");
InstallerInput();
WScript.Echo("");
for (x in installerQuestions) {
var thisQuestion = installerQuestions[x];
var validResponse = false;
var validOpts = new Array();
while (!validResponse) {
for (y in thisQuestion.question) {
var qLine = thisQuestion.question[y];
WScript.Echo(qLine);
}
WScript.Echo('');
var choiceLine = '';
for (y in thisQuestion.options) {
choiceLine += thisQuestion.options[y] + ', ';
validOpts[thisQuestion.options[y]] = true;
}
choiceLine = choiceLine.substring(0, choiceLine.length - 2);
WScript.Echo("Available Options: "+choiceLine);
WScript.Echo("Default Answer: "+thisQuestion.default_answer+"\n");
WScript.Echo(thisQuestion.short);
var inputValue = InstallerInput().toLowerCase();
if (!inputValue) {
inputValue = thisQuestion.default_answer;
}
if (!validOpts[inputValue]) {
WScript.Echo("ERROR: Invalid option '"+inputValue+"'\n");
}
else if (thisQuestion.store_answer(inputValue)) {
validResponse = true;
}
}
WScript.Echo("");
}
if (!findCompiler()) {
WScript.Echo("\nERROR: No suitable build tools were found!");
WScript.Echo("Please ensure you have downloaded and installed a version of Visual C++ and/or PlatformSDK.\n");
WScript.Echo("For more information on the tools needed to build Anope on Windows, see:\nhttp://windows.anope.org\n");
}
else {
WScript.Echo("\nBuild tools were found successfully!\n");
WScript.Echo("\nAnope will be compiled with the following options:\n");
for (x in installerResponses) {
var thisResponse = installerResponses[x];
WScript.Echo("\t"+x+":\t\t["+thisResponse.toUpperCase()+"]");
}
for (x in softwareVersions) {
var thisVer = softwareVersions[x];
if (!thisVer) {
WScript.Echo("\t"+x+" Version:\t\tNot Enabled");
}
else {
WScript.Echo("\t"+x+" Version:\t\t"+thisVer.name);
}
}
WScript.Echo("\tAnope Version:\t\t\t"+anopeVersion);
WScript.Echo("\nTo continue, please press Enter...");
InstallerInput();
var f = fso.OpenTextFile("Makefile.inc.win32", 2);
f.WriteLine("#");
f.WriteLine("# Generated by install.js");
f.WriteLine("#");
if (typeof(softwareVersions['Compiler'].additional_switches) !== 'boolean') {
var switch_line = '';
for (x in softwareVersions['Compiler'].additional_switches) {
switch_line += softwareVersions['Compiler'].additional_switches[x]+" ";
}
f.WriteLine("VC6="+switch_line);
}
var path_line = '';
for (x in softwareVersions['Compiler'].libpaths) {
path_line += "/LIBPATH:\""+softwareVersions['Compiler'].installedDrive+":\\"+softwareVersions['Compiler'].libpaths[x]+"\" ";
}
f.WriteLine("LIBPATH="+path_line);
path_line = '';
var path_line_rc = '';
for (x in softwareVersions['Compiler'].incpaths) {
path_line += "/I \""+softwareVersions['Compiler'].installedDrive+":\\"+softwareVersions['Compiler'].incpaths[x]+"\" ";
path_line_rc += "/i \""+softwareVersions['Compiler'].installedDrive+":\\"+softwareVersions['Compiler'].incpaths[x]+"\" ";
}
f.WriteLine("INCFLAGS="+path_line);
f.WriteLine("VERSION="+anopeVersion);
f.WriteLine("PROGRAM=anope.exe");
f.WriteLine("DATDEST=data");
f.WriteLine("CC=cl");
f.WriteLine("RC=rc");
f.WriteLine("MAKE=nmake -f Makefile.win32");
f.WriteLine("BASE_CFLAGS=$(VC6) /Zi /MD /TP /GR /EHs $(INCFLAGS)");
f.WriteLine("RC_FLAGS="+path_line_rc);
f.WriteLine("LIBS=wsock32.lib advapi32.lib /NODEFAULTLIB:libcmtd.lib");
f.WriteLine("LFLAGS=$(LIBPATH)");
for (x in installerQuestions) {
var thisQuestion = installerQuestions[x];
thisQuestion.commit_config();
}
f.WriteLine("MORE_CFLAGS = /I\"../include\"");
f.WriteLine("CFLAGS = /nologo $(CDEFS) $(BASE_CFLAGS) $(MORE_CFLAGS)");
f.close();
generateRC();
WScript.Echo("\nConfiguration Complete!");
WScript.Echo("-----------------------\n");
WScript.Echo("Anope has been configured to your system. To compile, simply type:");
WScript.Echo("nmake -f Makefile.win32\n");
WScript.Echo("If you update Anope, you should run this script again to ensure\nall available options are set.\n");
}
// Fin.
// -----------------------------------------------------------------
// Functions
function FindAnopeVersion() {
if (!fso.FileExists('version.log')) {
anopeVersion = 'Unknown';
return;
}
var versionLog = fso.OpenTextFile("version.log");
while (!versionLog.atEndOfStream) {
var versionLine = versionLog.readline();
var thisMatch = versionLine.replace('\n', '');
while (thisMatch.match(/\"/g)) {
thisMatch = thisMatch.replace('"', '');
{
'question' : [
'In what directory do you want Anope to be installed?'
],
'short' : 'Install directory:',
'default_answer' : '',
'store_answer' : function(answer) {
if (!answer) {
WScript.Echo("You must give a directory!\n");
return false;
}
versionLine = thisMatch;
if (versionLine.match(/VERSION_MAJOR=/g)) {
vMaj = versionLine.replace('VERSION_MAJOR=', '');
continue;
}
if (versionLine.match(/VERSION_MINOR=/g)) {
vMin = versionLine.replace('VERSION_MINOR=', '');
continue;
}
if (versionLine.match(/VERSION_PATCH=/g)) {
vPat = versionLine.replace('VERSION_PATCH=', '');
continue;
}
if (versionLine.match(/VERSION_EXTRA=/g)) {
vExtra = versionLine.replace('VERSION_EXTRA=', '');
continue;
}
if (versionLine.match(/VERSION_BUILD=/g)) {
vBuild = versionLine.replace('VERSION_BUILD=', '');
continue;
}
}
versionLog.close();
anopeVersion = vMaj+"."+vMin+"."+vPat+"."+vBuild+vExtra;
return;
}
function InstallerInput() {
var input = WScript.StdIn.Readline();
return input;
}
function findMySQL() {
WScript.Echo("\nLooking for MySQL...\n");
var installedDrive = "";
for (x in mysqlVersions) {
var thisSQLVer = mysqlVersions[x];
WScript.Echo("Looking for: "+thisSQLVer.name+"...");
if (!(installedDrive = findFile("libmysql.lib", thisSQLVer.libpaths))) {
WScript.Echo("ERROR: Cannot find libmysql.lib - This version is probably not installed...\n");
continue;
}
if (!findFile("mysql.h", thisSQLVer.incpaths)) {
WScript.Echo("ERROR: Cannot find mysql.h - Half of this version of MySQL is installed (strange)...\n");
continue;
}
WScript.Echo("SUCCESS: "+thisSQLVer.name+" is installed, and is complete!\n");
thisSQLVer.installedDrive = installedDrive;
softwareVersions.MySQLDB = thisSQLVer;
return true;
}
return false;
}
function findCompiler() {
WScript.Echo("\nLooking for a suitable compiler...\n");
var noPSDK = false;
var installedDrive = "";
for (x in buildPackages) {
var thisPack = buildPackages[x];
WScript.Echo("Looking for: "+thisPack.name+"...");
if (!(installedDrive = findFile("MSVCRT.lib", thisPack.libpaths))) {
WScript.Echo("ERROR: Cannot find MSVCRT.lib - This version is probably not installed...\n");
continue;
}
if (!findFile("wsock32.lib", thisPack.libpaths)) {
WScript.Echo("ERROR: Cannot find wsock32.lib - Probably missing PlatformSDK...\n");
noPSDK = true;
continue;
}
if (!findFile("advapi32.lib", thisPack.libpaths)) {
WScript.Echo("ERROR: Cannot find advapi32.lib - Probably missing PlatformSDK...\n");
noPSDK = true;
continue;
}
if (!findFile("stdio.h", thisPack.incpaths)) {
WScript.Echo("ERROR: Cannot find stdio.h - Missing core header files...\n");
continue;
}
if (!findFile("windows.h", thisPack.incpaths)) {
WScript.Echo("ERROR: Cannot find windows.h - Probably missing PlatformSDK headers...\n");
noPSDK = true;
continue;
}
if (!findFile("nmake.exe", thisPack.nmake)) {
WScript.Echo("ERROR: Cannot find a copy of nmake.exe...\n");
WScript.Echo("In order to compile Anope, you need a working copy of nmake.exe on your system.");
WScript.Echo("A freely available copy can be downloaded from the url below.");
WScript.Echo("nmake.exe is also available in the PlatformSDK which can be freely downloaded from Microsoft.\n");
WScript.Echo("nmake.exe:\nhttp://download.microsoft.com/download/vc15/patch/1.52/w95/en-us/nmake15.exe\n");
break;
}
WScript.Echo("SUCCESS: "+thisPack.name+" was found, and is complete!");
thisPack.installedDrive = installedDrive;
softwareVersions.Compiler = thisPack;
return true;
}
if (noPSDK) {
WScript.Echo("Some of the build tools were detected on your computer, but the essential PlatformSDK components were missing.");
WScript.Echo("You will need to download the PlatformSDK from the URL below, ensuring that the Core Windows files, and Debugging Tools are installed.");
WScript.Echo("For more details on installing the PlatformSDK, visit http://windows.anope.org\n");
WScript.Echo("PSDK: http://download.microsoft.com/download/a/5/f/a5f0d781-e201-4ab6-8c6a-9bb4efed1e1a/PSDK-x86.exe\n");
}
return false;
}
function findFile(fileName, arrayOfPaths) {
for (z in arrayOfPaths) {
var thisPath = arrayOfPaths[z];
for (y in drivesToCheck) {
var thisDrive = drivesToCheck[y];
if (fso.FileExists(thisDrive+":\\"+thisPath+"\\"+fileName)) {
return thisDrive;
}
}
if (!fso.FolderExists(answer)) {
if (fso.FileExists(answer)) {
WScript.Echo(answer + " exists, but is not a directory!\n");
return false;
}
WScript.Echo(answer + " does not exist. Create it ([yes]/no)?\n");
var inputValue = InstallerInput().toLowerCase();
if (!inputValue) {
inputValue = 'yes';
}
if (inputValue != 'no') {
fso.CreateFolder(answer);
}
}
else if (fso.FileExists(answer + '\\include\\services.h')) {
WScript.Echo("You cannot use the Anope source directory as a target directory.\n");
return false;
}
installerResponses['Install Directory'] = answer.replace(/\\/g, '/');
return true;
},
'cmake_argument' : function() {
return '-DINSTDIR:STRING=' + installerResponses['Install Directory'];
}
return false;
}
},
{
'question' : [
'Would you like to build using NMake instead of using Visual Studio?',
'NOTE: If you decide to use NMake, you must be in an environment where',
' NMake can function, such as the Visual Studio command line.',
' If you say yes to this while not in an environment that can run',
' NMake, it can cause the CMake configuration to enter an endless',
' loop.'
],
'short' : 'Use NMake?',
'options' : [
'yes',
'no'
],
'default_answer' : 'no',
'store_answer' : function(answer) {
installerResponses['Use NMake'] = answer;
return true;
},
'cmake_argument' : function() {
if (installerResponses['Use NMake'] == 'yes') return '-G"NMake Makefiles"';
else return '';
}
},
{
'question' : [
'Would you like to build a debug version of Anope?'
],
'short' : 'Build debug?',
'options' : [
'yes',
'no'
],
'default_answer' : 'no',
'store_answer' : function(answer) {
installerResponses['Debug'] = answer;
return true;
},
'cmake_argument' : function() {
if (installerResponses['Debug'] == 'msvc') return '';
else if (installerResponses['Debug'] == 'yes') return '-DCMAKE_BUILD_TYPE:STRING=DEBUG';
else return '-DCMAKE_BUILD_TYPE:STRING=RELEASE';
}
},
];
function generateRC() {
var version_matches = [
{
'find' : /VERSION_COMMA/g,
'replacement' : vMaj+","+vMin+","+vPat+","+vBuild
},
var bannerReplacements = [
{
'findtext' : /CURVER/g,
'replacement' : function() { FindAnopeVersion(); return anopeVersion; }
},
{
'findtext' : / For more options type SOURCE_DIR\/Config --help/g,
'replacement' : function() { return ''; }
}
];
{
'find' : /VERSION_FULL/g,
'replacement' : anopeVersion
},
var ScriptPath = WScript.ScriptFullName.substr(0, WScript.ScriptFullName.length - WScript.ScriptName.length);
{
'find' : /VERSION_DOTTED/g,
'replacement' : vMaj+"."+vMin+"."+vPat+"."+vBuild
}
];
var fso = WScript.CreateObject('Scripting.FileSystemObject');
var x, y, z;
var template = fso.OpenTextFile("src/win32.rc.template", 1);
var output = fso.OpenTextFile("src/win32.rc", 2, true);
if (!template) {
WScript.Echo("ERROR: Unable to generate win32.rc file - Couldn't open source file..");
}
if (!output) {
WScript.Echo("ERROR: Unable to generate win32.rc file - Couldn't open output file..");
}
var templateText = template.ReadAll();
template.close();
if (fso.FileExists(ScriptPath + '.BANNER')) {
var bannerStream = fso.OpenTextFile(ScriptPath + '.BANNER');
var bannerText = bannerStream.ReadAll();
bannerStream.close();
for (x in version_matches) {
var thisVerStr = version_matches[x];
while (templateText.match(thisVerStr.find)) {
templateText = templateText.replace(thisVerStr.find, thisVerStr.replacement);
}
}
for (x in bannerReplacements) {
var thisReplacement = bannerReplacements[x];
bannerText = bannerText.replace(thisReplacement['findtext'], thisReplacement['replacement']);
}
output.WriteLine(templateText);
output.close();
}
WScript.Echo(bannerText + "\n");
}
else {
WScript.Echo("ERROR: Cannot find banner file!\n");
}
WScript.Echo('Press Enter to Begin...');
InstallerInput();
WScript.Echo('');
for (x in installerQuestions) {
var thisQuestion = installerQuestions[x];
var validResponse = false;
var validOpts = new Array();
if (thisQuestion.short == 'Build debug?' && installerResponses['Use NMake'] == 'no') {
installerResponses['Debug'] = 'msvc';
continue;
}
while (!validResponse) {
for (y in thisQuestion.question) {
var qLine = thisQuestion.question[y];
WScript.Echo(qLine);
}
WScript.Echo('');
var choiceLine = '';
if (thisQuestion.options) {
for (y in thisQuestion.options) {
choiceLine += thisQuestion.options[y] + ', ';
validOpts[thisQuestion.options[y]] = true;
}
choiceLine = choiceLine.substring(0, choiceLine.length - 2);
WScript.Echo('Available Options: ' + choiceLine);
}
if (thisQuestion.default_answer) WScript.Echo('Default Answer: ' + thisQuestion.default_answer + "\n");
WScript.Echo(thisQuestion.short);
var inputValue = InstallerInput().toLowerCase();
if (!inputValue) {
inputValue = thisQuestion.default_answer;
}
if (choiceLine && !validOpts[inputValue]) {
WScript.Echo("ERROR: Invalid option '" + inputValue + "'\n");
}
else if (thisQuestion.store_answer(inputValue)) {
validResponse = true;
}
}
WScript.Echo('');
}
WScript.Echo("\nAnope will be compiled with the following options:\n");
for (x in installerResponses) {
var thisResponse = installerResponses[x];
WScript.Echo("\t" + x + ":\t\t[" + thisResponse.toUpperCase() + "]");
}
WScript.Echo("\tAnope Version:\t\t\t" + anopeVersion);
WScript.Echo("\nTo continue, please press Enter...");
InstallerInput();
var cmake = 'cmake';
for (x in installerQuestions) {
var thisQuestion = installerQuestions[x];
cmake += ' ' + thisQuestion.cmake_argument();
}
cmake += ' ' + ScriptPath;
WScript.Echo(cmake + "\n");
var shell = WScript.CreateObject('WScript.Shell');
var cmake_shell = shell.exec('%comspec% /c ' + cmake);
while (!cmake_shell.StdOut.AtEndOfStream) {
var strLine = cmake_shell.StdOut.ReadLine();
WScript.Echo(strLine);
}
if (installerResponses['Use NMake'] == 'yes') WScript.Echo("\nTo compile Anope, run 'nmake'. To install, run 'nmake install'.\n");
else WScript.Echo("\nTo compile Anope, open Anope.sln and build the solution. To install,\ndo a build on the INSTALL project.\n");
WScript.Echo("If you update Anope, you should run this script again to ensure\nall available options are set.\n");
// -----------------------------------------------------------------
// Functions
function FindAnopeVersion() {
if (!fso.FileExists(ScriptPath + 'version.log')) {
anopeVersion = 'Unknown';
return;
}
var versionLog = fso.OpenTextFile(ScriptPath + 'version.log');
while (!versionLog.atEndOfStream) {
var versionLine = versionLog.readline();
var thisMatch = versionLine.replace('\n', '');
while (thisMatch.match(/\"/g)) {
thisMatch = thisMatch.replace('"', '');
}
versionLine = thisMatch;
if (versionLine.match(/VERSION_MAJOR=/g)) {
vMaj = versionLine.replace('VERSION_MAJOR=', '');
continue;
}
if (versionLine.match(/VERSION_MINOR=/g)) {
vMin = versionLine.replace('VERSION_MINOR=', '');
continue;
}
if (versionLine.match(/VERSION_PATCH=/g)) {
vPat = versionLine.replace('VERSION_PATCH=', '');
continue;
}
if (versionLine.match(/VERSION_EXTRA=/g)) {
vExtra = versionLine.replace('VERSION_EXTRA=', '');
continue;
}
if (versionLine.match(/VERSION_BUILD=/g)) {
vBuild = versionLine.replace('VERSION_BUILD=', '');
continue;
}
}
versionLog.close();
anopeVersion = vMaj + '.' + vMin + '.' + vPat + '.' + vBuild + vExtra;
return;
}
function InstallerInput() {
var input = WScript.StdIn.Readline();
return input;
}
+41 -61
View File
@@ -1,103 +1,83 @@
#if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
#else(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
# file(RELATIVE_PATH DIR ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DIR})
#endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
#add_custom_command(OUTPUT ${BUILD_DIR}/langcomp
# COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} langcomp.c -o ${BUILD_DIR}/langcomp
# MAIN_DEPENDENCY langcomp.c
#)
#add_custom_target(lang_langcomp DEPENDS ${BUILD_DIR}/langcomp)
# Set the source file for langcomp to use C++ as well as set it's compile flags
set_source_files_properties(langcomp.c PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
#add_executable(${BUILD_DIR}/langcomp langcomp.c)
# Generate langcomp and set it's linker flags
add_executable(langcomp langcomp.c)
set_target_properties(langcomp PROPERTIES LINK_FLAGS "${LDFLAGS}")
#set_target_properties(langcomp PROPERTIES COMPILE_FLAGS ${CXXFLAGS})
#set_target_properties(${BUILD_DIR}/langcomp PROPERTIES LINKER_LANGUAGE CXX)
#add_custom_command(OUTPUT ${BUILD_DIR}/index
# COMMAND ${GREP} '^[A-Z]' en_us.l > ${BUILD_DIR}/index
# MAIN_DEPENDENCY en_us.l
#)
if(WIN32)
# If grep or perl don't exist on the system, build langtool to generate index and language.h
if(NOT GREP OR NOT PERL)
# Set the source file for langtool to use C++ as well as set it's compile flags
set_source_files_properties(langtool.c PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
# Generate langtool and set it's linker flags
add_executable(langtool langtool.c)
set_target_properties(langtool PROPERTIES LINK_FLAGS "${LDFLAGS}")
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/index
COMMAND langtool index ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l ${CMAKE_CURRENT_BINARY_DIR}/index
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l DEPENDS langtool
)
else(WIN32)
endif(NOT GREP OR NOT PERL)
# If grep exists, use it to generate the index file
if(GREP)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/index
COMMAND ${GREP} '^[A-Z]' ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l > ${CMAKE_CURRENT_BINARY_DIR}/index
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l
)
endif(WIN32)
#add_custom_target(lang_index DEPENDS ${BUILD_DIR}/index)
# Otherwise, use langtool to generate the index file
else(GREP)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/index
COMMAND langtool index ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l ${CMAKE_CURRENT_BINARY_DIR}/index
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l DEPENDS langtool
)
endif(GREP)
#add_custom_target(language)
set(LANG_SRCS cat.l de.l en_us.l es.l fr.l gr.l hun.l it.l nl.l pl.l pt.l ru.l tr.l)
# Find all the *.l files within the current source directory, and sort the list
file(GLOB LANG_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.l")
list(SORT LANG_SRCS)
# Iterate through the language files
foreach(LANG_L ${LANG_SRCS})
# Convert the language file's extension to have no extension
STRING(REGEX REPLACE "\\.l$" "" LANG ${LANG_L})
#set(LANGS ${LANGS} ${BUILD_DIR}/${LANG})
set(LANGS ${LANGS} ${CMAKE_CURRENT_BINARY_DIR}/${LANG})
#add_custom_command(OUTPUT ${BUILD_DIR}/${LANG}
# COMMAND langcomp ${LANG_L}
# MAIN_DEPENDENCY ${LANG_L} DEPENDS langcomp ${BUILD_DIR}/index
#)
# Add the language file to the list of compiled language files
list(APPEND LANGS ${CMAKE_CURRENT_BINARY_DIR}/${LANG})
# Generate a compiled language file using langcomp, as well as having a dependency on the index file being generated
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${LANG}
#CMMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${LANG_L} ${CMAKE_CURRENT_BINARY_DIR}/
COMMAND langcomp ${CMAKE_CURRENT_SOURCE_DIR}/${LANG_L} ${CMAKE_CURRENT_BINARY_DIR}/${LANG}
#COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/${LANG_L}
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${LANG_L} DEPENDS langcomp ${CMAKE_CURRENT_BINARY_DIR}/index
)
#add_custom_target(lang_${LANG} ALL DEPENDS ${BUILD_DIR}/${LANG})
#add_custom_target(lang_${LANG} DEPENDS ${BUILD_DIR}/${LANG})
#add_dependencies(language lang_${LANG})
#add_dependencies(language ${BUILD_DIR}/${LANG})
endforeach(LANG_L)
#add_custom_command(OUTPUT ${BUILD_DIR}/language.h
# COMMAND ${PERL} -e < ${BUILD_DIR}/index > ${BUILD_DIR}/language.h 'print STDERR \"Generating language.h... \"\; $$i=0\; while \(<>\) { chop\; printf \"\#define %-32s %d\\n\", $$_, $$i++\; } print \"\\n\#define NUM_STRINGS $$i\\n\"\; print STDERR \"$$i strings\\n\"\;'
# COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/language.h ${Anope_SOURCE_DIR}/include/
# MAIN_DEPENDENCY ${BUILD_DIR}/index
#)
if(WIN32)
# If perl exists (and we aren't using Visual Studio, it hates this), use it to generate language.h
if(NOT MSVC AND PERL)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/language.h
COMMAND ${PERL} -e < ${CMAKE_CURRENT_BINARY_DIR}/index > ${CMAKE_CURRENT_BINARY_DIR}/language.h 'print STDERR \"Generating language.h... \"\; $$i=0\; while \(<>\) { chop\; printf \"\#define %-32s %d\\n\", $$_, $$i++\; } print \"\\n\#define NUM_STRINGS $$i\\n\"\; print STDERR \"$$i strings\\n\"\;'
MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/index
)
# Otherwise, use langtool to generate language.h
else(NOT MSVC AND PERL)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/language.h
COMMAND langtool language.h ${CMAKE_CURRENT_BINARY_DIR}/index ${CMAKE_CURRENT_BINARY_DIR}/language.h
MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/index DEPENDS langtool
)
else(WIN32)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/language.h
COMMAND ${PERL} -e < ${CMAKE_CURRENT_BINARY_DIR}/index > ${CMAKE_CURRENT_BINARY_DIR}/language.h 'print STDERR \"Generating language.h... \"\; $$i=0\; while \(<>\) { chop\; printf \"\#define %-32s %d\\n\", $$_, $$i++\; } print \"\\n\#define NUM_STRINGS $$i\\n\"\; print STDERR \"$$i strings\\n\"\;'
#COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/language.h ${Anope_SOURCE_DIR}/include/
MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/index
)
endif(WIN32)
#add_custom_target(lang_language_h DEPENDS ${BUILD_DIR}/language.h)
#add_dependencies(language lang_language_h)
#add_dependencies(language ${BUILD_DIR}/language.h)
#add_custom_target(language DEPENDS ${LANGS} ${BUILD_DIR}/language.h)
endif(NOT MSVC AND PERL)
# Add a custom target to depend on the language files and language.h
add_custom_target(language DEPENDS ${LANGS} ${CMAKE_CURRENT_BINARY_DIR}/language.h)
# If RUNGROUP was set, make the permissions be to have owner read/write as well as group read/write
if(RUNGROUP)
set(PERMS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE)
# Otherwise, only make the permissions be owner read/write
else(RUNGROUP)
set(PERMS OWNER_READ OWNER_WRITE)
endif(RUNGROUP)
# Set the language files to be installed to the languages directory under the data directory
install(FILES ${LANGS}
DESTINATION "${DATADIR}/languages"
PERMISSIONS ${PERMS}
)
# On non-Windows platforms, if RUNGROUP is set, change the permissions of the languages directory
if(NOT WIN32)
if(RUNGROUP)
#install(CODE "execute_process(COMMAND ${CHGRP} -R ${RUNGROUP} \"${DATADIR}/languages\")")
install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${DATADIR}/languages\")")
install(CODE "execute_process(COMMAND ${CHMOD} 2770 \"${DATADIR}/languages\")")
else(RUNGROUP)
install(CODE "execute_process(COMMAND ${CHMOD} 0700 \"${DATADIR}/languages\")")
endif(RUNGROUP)
+37 -164
View File
@@ -1,196 +1,69 @@
#if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
#else(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
# file(RELATIVE_PATH DIR ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DIR})
#endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
set(SRC_SRCS actions.c base64.c bots.cpp botserv.c channels.c chanserv.c
commands.c compat.c config.c configreader.cpp datafiles.c encrypt.c events.c
hashcomp.cpp helpserv.c hostserv.c init.c ircd.c language.c log.c mail.c
main.c memory.c memoserv.c messages.c misc.c module.cpp modulemanager.cpp
modules.c news.c nickserv.c operserv.c process.c send.c servers.c sessions.c
slist.c sockutil.c timeout.c users.c)
if(WIN32 AND MSVC)
set(SRC_SRCS ${SRC_SRCS} win32_memory.cpp)
endif(WIN32 AND MSVC)
# Find all the *.c and *.cpp files within the current source directory, and sort the list
file(GLOB SRC_SRCS_C RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c")
file(GLOB SRC_SRCS_CPP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
set(SRC_SRCS ${SRC_SRCS_C} ${SRC_SRCS_CPP})
# If not using Visual Studio, don't include win32_memory.cpp, it's only required by Visual Studio to override it's override of the new/delete operators
if(NOT MSVC)
list(REMOVE_ITEM SRC_SRCS win32_memory.cpp)
endif(NOT MSVC)
list(SORT SRC_SRCS)
# Set all the files to use C++ as well as set their compile flags (use the module-specific compile flags, though)
set_source_files_properties(${SRC_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
#add_custom_target(src_srcs DEPENDS ${SRC_SRCS})
set(actions.c_HEADERS services.h)
set(base64.c_HEADERS services.h)
set(bots.cpp_HEADERS services.h)
set(botserv.c_HEADERS services.h pseudo.h)
set(channels.c_HEADERS services.h ${Anope_BINARY_DIR}/lang/language.h)
set(chanserv.c_HEADERS services.h pseudo.h)
set(commands.c_HEADERS services.h commands.h ${Anope_BINARY_DIR}/lang/language.h)
set(compat.c_HEADERS services.h)
set(config.c_HEADERS services.h configreader.h hashcomp.h)
set(configreader.cpp_HEADERS services.h)
set(datafiles.c_HEADERS services.h datafiles.h)
set(encrypt.c_HEADERS services.h encrypt.h)
set(events.c_HEADERS modules.h ${Anope_BINARY_DIR}/lang/language.h ${Anope_BINARY_DIR}/include/version.h)
set(hashcomp.c_HEADERS hashcomp.h)
set(helpserv.c_HEADERS services.h pseudo.h)
set(hostserv.c_HEADERS services.h pseudo.h)
set(init.c_HEADERS services.h pseudo.h)
set(ircd.c_HEADERS services.h extern.h)
set(language.c_HEADERS services.h ${Anope_BINARY_DIR}/lang/language.h)
set(log.c_HEADERS services.h pseudo.h)
set(mail.c_HEADERS services.h ${Anope_BINARY_DIR}/lang/language.h)
set(main.c_HEADERS services.h timeout.h ${Anope_BINARY_DIR}/include/version.h datafiles.h modules.h)
set(memory.c_HEADERS services.h)
set(memoserv.c_HEADERS services.h pseudo.h)
set(messages.c_HEADERS services.h messages.h ${Anope_BINARY_DIR}/lang/language.h)
set(misc.c_HEADERS services.h ${Anope_BINARY_DIR}/lang/language.h hashcomp.h)
set(module.cpp_HEADERS modules.h ${Anope_BINARY_DIR}/lang/language.h ${Anope_BINARY_DIR}/include/version.h)
set(modulemanager.cpp_HEADERS modules.h ${Anope_BINARY_DIR}/lang/language.h ${Anope_BINARY_DIR}/include/version.h)
set(modules.c_HEADERS modules.h ${Anope_BINARY_DIR}/lang/language.h ${Anope_BINARY_DIR}/include/version.h)
set(news.c_HEADERS services.h pseudo.h)
set(nickserv.c_HEADERS services.h pseudo.h)
set(operserv.c_HEADERS services.h pseudo.h)
set(process.c_HEADERS services.h messages.h modules.h)
set(send.c_HEADERS services.h)
set(servers.c_HEADERS services.h)
set(sessions.c_HEADERS services.h pseudo.h)
set(slist.c_HEADERS services.h slist.h)
set(sockutil.c_HEADERS services.h)
set(timeout.c_HEADERS services.h pseudo.h)
set(users.c_HEADERS services.h)
set(${PROGRAM_NAME}_HEADERS)
# Iterate through all the source files
foreach(SRC ${SRC_SRCS})
#string(REGEX REPLACE "\\." "_" SRC_TARGET ${SRC})
#string(REGEX REPLACE "\\.cpp$" ".x" SRC_X ${SRC})
#string(REGEX REPLACE "\\.c$" ".o" SRC_O ${SRC_X})
#string(REGEX REPLACE "\\.x$" ".o" OBJ ${SRC_O})
#string(REGEX REPLACE "\\." "_" OBJ_TARGET ${OBJ})
#set(SRC_SRCS_FULL ${SRC_SRCS_FULL} ${CMAKE_CURRENT_SOURCE_DIR}/${SRC})
#set(SRC_OBJS ${SRC_OBJS} ${BUILD_DIR}/${OBJ})
#add_custom_command(OUTPUT ${BUILD_DIR}/${OBJ}
# COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} -I${Anope_SOURCE_DIR}/include -c ${SRC} -o ${BUILD_DIR}/${OBJ}
# MAIN_DEPENDENCY ${SRC}
#)
#add_custom_target(src_${OBJ_TARGET} DEPENDS ${BUILD_DIR}/${OBJ})
#add_custom_target(src_${SRC_TARGET} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${SRC})
#add_dependencies(src_srcs src_${SRC_TARGET})
#set(HEADERS)
#if(${SRC}_HEADERS)
# foreach(HEADER ${${SRC}_HEADERS})
# string(SUBSTRING ${HEADER} 0 1 FIRST_CHAR)
# string(SUBSTRING ${HEADER} 1 1 SECOND_CHAR)
# if(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
# set(HEADERS ${HEADERS} ${HEADER})
# else(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
# set(HEADERS ${HEADERS} ${Anope_SOURCE_DIR}/include/${HEADER})
# endif(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
# endforeach(HEADER)
#endif(${SRC}_HEADERS)
#file(STRINGS ${SRC} INCLUDES REGEX "^[ \t]*#[ \t]*include[ \t]*\".*\"[ \t]*$")
##message(STATUS "${SRC}'s includes: ${INCLUDES}")
##get_filename_component(HEADER_FILENAME ${HEADER} NAME)
#set(HEADERS)
#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})
# list(APPEND HEADERS ${FILENAME})
#endforeach(INCLUDE)
##message(STATUS "${SRC}'s HEADERS: ${HEADERS}")
#set(NEW_HEADERS)
#foreach(HEADER ${HEADERS})
# #message(STATUS "HEADER: ${HEADER} - ${HEADERS}_HEADERS: ${${HEADERS}_HEADERS}")
# if(${HEADER}_HEADERS)
# list(APPEND NEW_HEADERS ${${HEADER}_HEADERS})
# endif(${HEADER}_HEADERS)
#endforeach(HEADER)
#if(NEW_HEADERS)
# list(APPEND HEADERS ${NEW_HEADERS})
#endif(NEW_HEADERS)
#list(REMOVE_DUPLICATES HEADERS)
#list(SORT HEADERS)
#if(HEADERS)
# #message(STATUS "${SRC}'s HEADERS after NEW_HEADERS: ${HEADERS}")
# set(HEADERS_FULL)
# foreach(HEADER ${HEADERS})
# get_filename_component(HEADER_FILENAME ${HEADER} NAME)
# list(APPEND HEADERS_FULL ${${HEADER_FILENAME}_FULLPATH})
# endforeach(HEADER)
# #message(STATUS "${SRC}'s HEADERS_FULL: ${HEADERS_FULL}")
# set_source_files_properties(${SRC} PROPERTIES OBJECT_DEPENDS "${HEADERS_FULL}")
# list(APPEND ${PROGRAM_NAME}_HEADERS ${HEADERS_FULL})
#endif(HEADERS)
# Calculate the header file dependencies for the given source file
calculate_depends(${SRC})
get_source_file_property(HEADERS ${SRC} OBJECT_DEPENDS)
message(STATUS "${SRC}'s OBJECT_DEPENDS: ${HEADERS}")
endforeach(SRC)
#add_custom_target(src_srcs DEPENDS ${SRC_SRCS_FULL})
#add_custom_command(OUTPUT ${BUILD_DIR}/services
# COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} ${SRC_OBJS} -o ${BUILD_DIR}/services
# DEPENDS ${SRC_OBJS}
#)
#add_custom_target(src_services ALL DEPENDS ${BUILD_DIR}/services)
#add_custom_target(src_services DEPENDS ${BUILD_DIR}/services)
#add_custom_target(build ALL)
#add_dependencies(build language headers src_services)
# Under Windows, we also include a resource file to the build
if(WIN32)
# Make sure that the resource file is seen as an RC file to be compiled with a resource compiler, not a C++ compiler
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32.rc LANGUAGE RC)
set(SRC_SRCS ${SRC_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/win32.rc)
# Add the resource file to the list of sources
list(APPEND SRC_SRCS ${CMAKE_CURRENT_BINARY_DIR}/win32.rc)
# For MinGW, we have to change the compile flags
if(MINGW)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32.rc COMPILE_FLAGS "-DMINGW -Ocoff -I${Anope_SOURCE_DIR}/include")
#add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/win32.obj
# COMMAND ${CMAKE_RC_COMPILER} -DMINGW -I${Anope_SOURCE_DIR}/include -o ${CMAKE_CURRENT_BINARY_DIR}/win32.obj ${CMAKE_CURRENT_BINARY_DIR}/win32.rc
# MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/win32.rc
#)
#set(SRC_SRCS ${SRC_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/win32.obj)
set(RC_CFLAGS "-DMINGW -Ocoff -I${Anope_SOURCE_DIR}/include")
# If any sort of debugging is being enabled, add a _DEBUG define to the flags for the resource compiler
if(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
set(RC_CFLAGS "${RC_CFLAGS} -D_DEBUG")
endif(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32.rc COMPILE_FLAGS "${RC_CFLAGS}")
# For anything else, assumingly Visual Studio at this point, use a different set of compile flags
else(MINGW)
#set(SRC_SRCS ${SRC_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/win32.rc)
#set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32.rc LANGUAGE RC)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32.rc COMPILE_FLAGS "/i${Anope_SOURCE_DIR}/include")
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32.rc COMPILE_FLAGS "/i\"${Anope_SOURCE_DIR}/include\"")
endif(MINGW)
message(STATUS "CMAKE_RC_OUTPUT_EXTENSION: ${CMAKE_RC_OUTPUT_EXTENSION}")
endif(WIN32)
# Generate the Anope executable and set it's linker flags, also set it to export it's symbols even though it's not a module
add_executable(${PROGRAM_NAME} ${SRC_SRCS})
set(SERVICES_LDFLAGS "${LDFLAGS}")
if(WIN32 AND MSVC)
set(SERVICES_LDFLAGS "${SERVICES_LDFLAGS} /FIXED:NO")
endif(WIN32 AND MSVC)
set_target_properties(${PROGRAM_NAME} PROPERTIES LINK_FLAGS "${SERVICES_LDFLAGS}")
set_target_properties(${PROGRAM_NAME} PROPERTIES ENABLE_EXPORTS ON)
set_target_properties(${PROGRAM_NAME} PROPERTIES LINK_FLAGS "${LDFLAGS}" ENABLE_EXPORTS ON)
# On Windows, also link Anope to the wsock32 library, as well as set the version
if(WIN32)
target_link_libraries(${PROGRAM_NAME} wsock32)
set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
endif(WIN32)
#set_target_properties(services PROPERTIES COMPILE_FLAGS ${CXXFLAGS})
# Building the Anope executable requires the language files to be compiled first as well as the version.h header to be generated
add_dependencies(${PROGRAM_NAME} language headers)
# Get the filename of the Anope executable as it is in on this system
get_target_property(SERVICES_BINARY ${PROGRAM_NAME} LOCATION)
file(RELATIVE_PATH SERVICES_BINARY ${CMAKE_CURRENT_BINARY_DIR} ${SERVICES_BINARY})
set(SERVICES_BIN "${BINDIR}/${SERVICES_BINARY}")
message("[in src] SERVICES_BIN: ${SERVICES_BIN}")
get_filename_component(SERVICES_BINARY ${SERVICES_BINARY} NAME)
set(SERVICES_BIN "${SERVICES_BINARY}")
# Generate sysconf.h from the earlier configuration
configure_file(${Anope_SOURCE_DIR}/include/sysconf.h.cmake ${Anope_BINARY_DIR}/include/sysconf.h)
if(NOT WIN32)
configure_file(${Anope_SOURCE_DIR}/src/bin/anoperc.cmake ${Anope_BINARY_DIR}/src/bin/anoperc)
endif(NOT WIN32)
# Go into the following directories and run their CMakeLists.txt as well
add_subdirectory(bin)
add_subdirectory(core)
add_subdirectory(modules)
add_subdirectory(protocol)
add_subdirectory(tools)
# Set Anope to be installed to the bin directory
install(TARGETS ${PROGRAM_NAME}
DESTINATION "${BINDIR}"
DESTINATION "${INSTDIR}"
)
+3 -2
View File
@@ -1,9 +1,10 @@
# If not on Windows, generate anoperc and install it along with mydbgen
if(NOT WIN32)
configure_file(${Anope_SOURCE_DIR}/src/bin/anoperc.cmake ${Anope_BINARY_DIR}/src/bin/anoperc)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/anoperc
DESTINATION "${BINDIR}"
DESTINATION "${INSTDIR}"
)
install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/mydbgen
DESTINATION "${DATADIR}"
)
endif(NOT WIN32)
+15 -58
View File
@@ -1,75 +1,32 @@
#if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
#else(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
# file(RELATIVE_PATH DIR ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DIR})
#endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
# Find all the *.c and *.cpp files within the current source directory, and sort the list
file(GLOB CORE_SRCS_C RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c")
file(GLOB CORE_SRCS_CPP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
set(CORE_SRCS ${CORE_SRCS_C} ${CORE_SRCS_CPP})
list(SORT CORE_SRCS)
#add_custom_target(core ALL)
#add_custom_target(core)
#add_dependencies(core build)
# Set all the files to use C++ as well as set their compile flags (use the module-specific compile flags, though)
set_source_files_properties(${CORE_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${MODULE_CXXFLAGS}")
set(cs_set.c_HEADERS encrypt.h)
set(ns_register.c_HEADERS encrypt.h)
set(ns_saset.c_HEADERS encrypt.h)
set(ns_set.c_HEADERS encrypt.h)
# Iterate through all the source files
foreach(SRC ${CORE_SRCS})
string(REGEX REPLACE "\\.cpp$" ".x" SRC_X ${SRC})
string(REGEX REPLACE "\\.c$" ".o" SRC_O ${SRC_X})
string(REGEX REPLACE "\\.x$" ".o" OBJ ${SRC_O})
#string(REGEX REPLACE "\\." "_" OBJ_TARGET ${OBJ})
string(REGEX REPLACE "\\.o" ".so" SO ${OBJ})
#string(REGEX REPLACE "\\.o" "" SO ${OBJ})
#string(REGEX REPLACE "\\." "_" SO_TARGET ${SO})
#add_custom_command(OUTPUT ${BUILD_DIR}/${OBJ}
# COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} -I${Anope_SOURCE_DIR}/include -c ${SRC} -o ${BUILD_DIR}/${OBJ}
# MAIN_DEPENDENCY ${SRC}
#)
#add_custom_target(core_${OBJ_TARGET} DEPENDS ${BUILD_DIR}/${OBJ})
#add_custom_command(OUTPUT ${BUILD_DIR}/${SO}
# COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} ${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} ${BUILD_DIR}/${OBJ} -o ${BUILD_DIR}/${SO}
# MAIN_DEPENDENCY ${BUILD_DIR}/${OBJ}
#)
#add_custom_target(core_${SO_TARGET} DEPENDS ${BUILD_DIR}/${SO})
#add_dependencies(core core_${SO_TARGET})
#set(HEADERS ${Anope_SOURCE_DIR}/include/module.h)
#if(${SRC}_HEADERS)
# foreach(HEADER ${${SRC}_HEADERS})
# string(SUBSTRING ${HEADER} 0 1 FIRST_CHAR)
# string(SUBSTRING ${HEADER} 1 1 SECOND_CHAR)
# if(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
# set(HEADERS ${HEADERS} ${HEADER})
# else(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
# set(HEADERS ${HEADERS} ${Anope_SOURCE_DIR}/include/${HEADER})
# endif(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
# endforeach(HEADER)
#endif(${SRC}_HEADERS)
#if(HEADERS)
# set_source_files_properties(${SRC} PROPERTIES OBJECT_DEPENDS "${HEADERS}")
#endif(HEADERS)
# Convert the source file extension to have a .so extension
string(REGEX REPLACE "\\.(c|cpp)$" ".so" SO ${SRC})
# Calculate the header file dependencies for the given source file
calculate_depends(${SRC})
get_source_file_property(HEADERS ${SRC} OBJECT_DEPENDS)
message(STATUS "${SRC}'s OBJECT_DEPENDS: ${HEADERS}")
set_source_files_properties(${HEADERS} PROPERTIES HEADER_FILE_ONLY TRUE)
if(WIN32 AND MSVC)
set(SRC ${SRC} ${Anope_SOURCE_DIR}/src/win32_memory.cpp)
endif(WIN32 AND MSVC)
# For Visual Studio only, include win32_memory.cpp to the list of sources, required to override Visual Studio's overrides of the new/delete operators
if(MSVC)
list(APPEND SRC ${Anope_SOURCE_DIR}/src/win32_memory.cpp)
endif(MSVC)
# Generate the module and set it's linker flags, also set it to depend on the main Anope executable to be built beforehand
add_library(${SO} MODULE ${SRC})
add_dependencies(${SO} ${PROGRAM_NAME})
#set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "" COMPILE_FLAGS ${CXXFLAGS})
set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "" LINK_FLAGS "${LDFLAGS}")
add_dependencies(${SO} ${PROGRAM_NAME})
# For Windows only, have the module link to the export library of Anope as well as the wsock32 library (most of the modules probably don't need this, but this is to be on the safe side), also set it's version
if(WIN32)
target_link_libraries(${SO} ${PROGRAM_NAME} wsock32)
set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
endif(WIN32)
#set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "")
# Set the module to be installed to the module directory under the data directory
install(TARGETS ${SO}
DESTINATION "${DATADIR}/modules"
)
+3 -3
View File
@@ -256,7 +256,7 @@ static int parse_options(int ac, char **av)
version_flags, version_build);
fprintf(stdout,
"Anope IRC Services (http://www.anope.org)\n");
fprintf(stdout, "Usage ./services [options] ...\n");
fprintf(stdout, "Usage ./" SERVICES_BIN " [options] ...\n");
fprintf(stdout,
"-remote -remote hostname[:port]\n");
fprintf(stdout, "-local -local hostname[:port]\n");
@@ -352,8 +352,8 @@ int init_primary(int ac, char **av)
parse_options(ac, av);
/* Chdir to Services data directory. */
if (chdir(services_dir) < 0) {
fprintf(stderr, "chdir(%s): %s\n", services_dir, strerror(errno));
if (chdir(services_dir.c_str()) < 0) {
fprintf(stderr, "chdir(%s): %s\n", services_dir.c_str(), strerror(errno));
return -1;
}
+46 -31
View File
@@ -35,7 +35,7 @@
/******** Global variables! ********/
/* Command-line options: (note that configuration variables are in config.c) */
const char *services_dir = SERVICES_DIR; /* -dir dirname */
std::string services_dir; /* -dir dirname */
const char *log_filename = LOG_FILENAME; /* -log filename */
int debug = 0; /* -debug */
int readonly = 0; /* -readonly */
@@ -46,8 +46,8 @@ int nothird = 0; /* -nothrid */
int noexpire = 0; /* -noexpire */
int protocoldebug = 0; /* -protocoldebug */
std::string binary_dir; /* Used to store base path for Anope */
#ifdef _WIN32
char *binary_dir; /* Used to store base path for win32 restart */
#include <process.h>
#define execve _execve
#endif
@@ -184,12 +184,7 @@ static void services_restart()
/* First don't unload protocol module, then do so */
modules_unload_all(true, false);
modules_unload_all(true, true);
#ifdef _WIN32
/* This fixes bug #589 - change to binary directory for restart */
/* -- heinz */
if (binary_dir)
chdir(binary_dir);
#endif
chdir(binary_dir.c_str());
execve(SERVICES_BIN, my_av, my_envp);
if (!readonly) {
open_log();
@@ -445,6 +440,45 @@ void sighandler(int signum)
/*************************************************************************/
/** The following comes from InspIRCd to get the full path of the Anope executable
*/
std::string GetFullProgDir(char *argv0)
{
char buffer[PATH_MAX];
#ifdef _WIN32
/* Windows has specific API calls to get the EXE path that never fail.
* For once, Windows has something of use, compared to the POSIX code
* for this, this is positively neato.
*/
if (GetModuleFileName(NULL, buffer, PATH_MAX))
{
std::string fullpath = buffer;
std::string::size_type n = fullpath.rfind("\\" SERVICES_BIN);
return std::string(fullpath, 0, n);
}
#else
// Get the current working directory
if (getcwd(buffer, PATH_MAX))
{
std::string remainder = argv0;
/* Does argv[0] start with /? If so, it's a full path, use it */
if (remainder[0] == '/')
{
std::string::size_type n = remainder.rfind("/" SERVICES_BIN);
return std::string(remainder, 0, n);
}
std::string fullpath = static_cast<std::string>(buffer) + "/" + remainder;
std::string::size_type n = fullpath.rfind("/" SERVICES_BIN);
return std::string(fullpath, 0, n);
}
#endif
return "/";
}
/*************************************************************************/
/* Main routine. (What does it look like? :-) ) */
int main(int ac, char **av, char **envp)
@@ -469,20 +503,11 @@ int main(int ac, char **av, char **envp)
" require root privileges to run, and it is discouraged that you run Anope\n");
fprintf(stderr, " as the root superuser.\n");
}
#else
/*
* We need to know which directory we're in for when restart is called.
* This only affects Windows as a full path is not specified in services_dir.
* This fixes bug #589.
* -- heinz
*/
binary_dir = new char[MAX_PATH];
if (!getcwd(binary_dir, MAX_PATH)) {
fprintf(stderr, "error: getcwd() error\n");
return -1;
}
#endif
binary_dir = GetFullProgDir(av[0]);
services_dir = binary_dir + "/data";
/* General initialization first */
if ((i = init_primary(ac, av)) != 0)
return i;
@@ -590,12 +615,7 @@ int main(int ac, char **av, char **envp)
ircdproto->SendSquit(ServerName, quitmsg);
disconn(servsock);
close_log();
#ifdef _WIN32
/* This fixes bug #589 - change to binary directory for restart */
/* -- heinz */
if (binary_dir)
chdir(binary_dir);
#endif
chdir(binary_dir.c_str());
execve(SERVICES_BIN, av, envp);
if (!readonly) {
open_log();
@@ -612,11 +632,6 @@ int main(int ac, char **av, char **envp)
/* Disconnect and exit */
services_shutdown();
#ifdef _WIN32
if (binary_dir)
delete [] binary_dir;
#endif
return 0;
}
+4 -2
View File
@@ -44,7 +44,9 @@ static int moduleCopyFile(const char *name, const char *output)
char input[4096];
int len;
strncpy(input, MODULE_PATH, 4095); /* Get full path with module extension */
strncpy(input, services_dir.c_str(), 4095);
len = strlen(input);
strncat(input, "/modules/", 4095 - len); /* Get full path with module extension */
len = strlen(input);
strncat(input, name, 4095 - len);
len = strlen(output);
@@ -146,7 +148,7 @@ int ModuleManager::LoadModule(const std::string &modname, User * u)
/* Generate the filename for the temporary copy of the module */
std::string pbuf;
pbuf = MODULE_PATH;
pbuf = services_dir + "/modules/";
#ifndef _WIN32
pbuf += "runtime/";
#else
+1 -6
View File
@@ -1239,12 +1239,7 @@ void ModuleRunTimeDirCleanUp()
char dirbuf[BUFSIZE];
char filebuf[BUFSIZE];
#ifndef _WIN32
snprintf(dirbuf, BUFSIZE, "%s/modules/runtime", services_dir);
#else
snprintf(dirbuf, BUFSIZE, "\\%s", "modules/runtime");
#endif
snprintf(dirbuf, BUFSIZE, "%s/modules/runtime", services_dir.c_str());
if (debug) {
alog("debug: Cleaning out Module run time directory (%s) - this may take a moment please wait", dirbuf);
+15 -52
View File
@@ -1,69 +1,32 @@
#if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
#else(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
# file(RELATIVE_PATH DIR ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DIR})
#endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
# Find all the *.c and *.cpp files within the current source directory, and sort the list
file(GLOB MODULES_SRCS_C RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c")
file(GLOB MODULES_SRCS_CPP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
set(MODULES_SRCS ${MODULES_SRCS_C} ${MODULES_SRCS_CPP})
list(SORT MODULES_SRCS)
#add_custom_target(modules ALL)
#add_custom_target(modules)
#add_dependencies(modules build)
# Set all the files to use C++ as well as set their compile flags (use the module-specific compile flags, though)
set_source_files_properties(${MODULES_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${MODULE_CXXFLAGS}")
# Iterate through all the source files
foreach(SRC ${MODULES_SRCS})
string(REGEX REPLACE "\\.cpp$" ".x" SRC_X ${SRC})
string(REGEX REPLACE "\\.c$" ".o" SRC_O ${SRC_X})
string(REGEX REPLACE "\\.x$" ".o" OBJ ${SRC_O})
#string(REGEX REPLACE "\\." "_" OBJ_TARGET ${OBJ})
string(REGEX REPLACE "\\.o" ".so" SO ${OBJ})
#string(REGEX REPLACE "\\.o" "" SO ${OBJ})
#string(REGEX REPLACE "\\." "_" SO_TARGET ${SO})
#add_custom_command(OUTPUT ${BUILD_DIR}/${OBJ}
# COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} -I${Anope_SOURCE_DIR}/include -c ${SRC} -o ${BUILD_DIR}/${OBJ}
# MAIN_DEPENDENCY ${SRC}
#)
#add_custom_target(modules_${OBJ_TARGET} DEPENDS ${BUILD_DIR}/${OBJ})
#add_custom_command(OUTPUT ${BUILD_DIR}/${SO}
# COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} ${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} ${BUILD_DIR}/${OBJ} -o ${BUILD_DIR}/${SO}
# MAIN_DEPENDENCY ${BUILD_DIR}/${OBJ}
#)
#add_custom_target(modules_${SO_TARGET} DEPENDS ${BUILD_DIR}/${SO})
#add_dependencies(modules modules_${SO_TARGET})
#set(HEADERS ${Anope_SOURCE_DIR}/include/module.h)
#if(${SRC}_HEADERS)
# foreach(HEADER ${${SRC}_HEADERS})
# string(SUBSTRING ${HEADER} 0 1 FIRST_CHAR)
# string(SUBSTRING ${HEADER} 1 1 SECOND_CHAR)
# if(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
# set(HEADERS ${HEADERS} ${HEADER})
# else(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
# set(HEADERS ${HEADERS} ${Anope_SOURCE_DIR}/include/${HEADER})
# endif(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
# endforeach(HEADER)
#endif(${SRC}_HEADERS)
#if(HEADERS)
# set_source_files_properties(${SRC} PROPERTIES OBJECT_DEPENDS "${HEADERS}")
#endif(HEADERS)
# Convert the source file extension to have a .so extension
string(REGEX REPLACE "\\.(c|cpp)$" ".so" SO ${SRC})
# Calculate the header file dependencies for the given source file
calculate_depends(${SRC})
get_source_file_property(HEADERS ${SRC} OBJECT_DEPENDS)
message(STATUS "${SRC}'s OBJECT_DEPENDS: ${HEADERS}")
if(WIN32 AND MSVC)
set(SRC ${SRC} ${Anope_SOURCE_DIR}/src/win32_memory.cpp)
endif(WIN32 AND MSVC)
# For Visual Studio only, include win32_memory.cpp to the list of sources, required to override Visual Studio's overrides of the new/delete operators
if(MSVC)
list(APPEND SRC ${Anope_SOURCE_DIR}/src/win32_memory.cpp)
endif(MSVC)
# Generate the module and set it's linker flags, also set it to depend on the main Anope executable to be built beforehand
add_library(${SO} MODULE ${SRC})
add_dependencies(${SO} ${PROGRAM_NAME})
#set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "" COMPILE_FLAGS ${CXXFLAGS})
set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "" LINK_FLAGS "${LDFLAGS}")
add_dependencies(${SO} ${PROGRAM_NAME})
# For Windows only, have the module link to the export library of Anope as well as the wsock32 library (most of the modules probably don't need this, but this is to be on the safe side), also set it's version
if(WIN32)
target_link_libraries(${SO} ${PROGRAM_NAME} wsock32)
set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
endif(WIN32)
#set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "")
# Set the module to be installed to the module directory under the data directory
install(TARGETS ${SO}
DESTINATION "${DATADIR}/modules"
)
+15 -52
View File
@@ -1,69 +1,32 @@
#if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
#else(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
# file(RELATIVE_PATH DIR ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DIR})
#endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
# Find all the *.c and *.cpp files within the current source directory, and sort the list
file(GLOB PROTOCOL_SRCS_C RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c")
file(GLOB PROTOCOL_SRCS_CPP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
set(PROTOCOL_SRCS ${PROTOCOL_SRCS_C} ${PROTOCOL_SRCS_CPP})
list(SORT PROTOCOL_SRCS)
#add_custom_target(protocol ALL)
#add_custom_target(modules)
#add_dependencies(protocol build)
# Set all the files to use C++ as well as set their compile flags (use the module-specific compile flags, though)
set_source_files_properties(${PROTOCOL_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${MODULE_CXXFLAGS}")
# Iterate through all the source files
foreach(SRC ${PROTOCOL_SRCS})
string(REGEX REPLACE "\\.cpp$" ".x" SRC_X ${SRC})
string(REGEX REPLACE "\\.c$" ".o" SRC_O ${SRC_X})
string(REGEX REPLACE "\\.x$" ".o" OBJ ${SRC_O})
#string(REGEX REPLACE "\\." "_" OBJ_TARGET ${OBJ})
string(REGEX REPLACE "\\.o" ".so" SO ${OBJ})
#string(REGEX REPLACE "\\.o" "" SO ${OBJ})
#string(REGEX REPLACE "\\." "_" SO_TARGET ${SO})
#add_custom_command(OUTPUT ${BUILD_DIR}/${OBJ}
# COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} -I${Anope_SOURCE_DIR}/include -c ${SRC} -o ${BUILD_DIR}/${OBJ}
# MAIN_DEPENDENCY ${SRC}
#)
#add_custom_target(modules_${OBJ_TARGET} DEPENDS ${BUILD_DIR}/${OBJ})
#add_custom_command(OUTPUT ${BUILD_DIR}/${SO}
# COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} ${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} ${BUILD_DIR}/${OBJ} -o ${BUILD_DIR}/${SO}
# MAIN_DEPENDENCY ${BUILD_DIR}/${OBJ}
#)
#add_custom_target(protocol_${SO_TARGET} DEPENDS ${BUILD_DIR}/${SO})
#add_dependencies(protocol protocol_${SO_TARGET})
#set(HEADERS ${Anope_SOURCE_DIR}/include/services.h ${Anope_SOURCE_DIR}/include/pseudo.h)
#if(${SRC}_HEADERS)
# foreach(HEADER ${${SRC}_HEADERS})
# string(SUBSTRING ${HEADER} 0 1 FIRST_CHAR)
# string(SUBSTRING ${HEADER} 1 1 SECOND_CHAR)
# if(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
# set(HEADERS ${HEADERS} ${HEADER})
# else(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
# set(HEADERS ${HEADERS} ${Anope_SOURCE_DIR}/include/${HEADER})
# endif(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
# endforeach(HEADER)
#endif(${SRC}_HEADERS)
#if(HEADERS)
# set_source_files_properties(${SRC} PROPERTIES OBJECT_DEPENDS "${HEADERS}")
#endif(HEADERS)
# Convert the source file extension to have a .so extension
string(REGEX REPLACE "\\.(c|cpp)$" ".so" SO ${SRC})
# Calculate the header file dependencies for the given source file
calculate_depends(${SRC})
get_source_file_property(HEADERS ${SRC} OBJECT_DEPENDS)
message(STATUS "${SRC}'s OBJECT_DEPENDS: ${HEADERS}")
if(WIN32 AND MSVC)
set(SRC ${SRC} ${Anope_SOURCE_DIR}/src/win32_memory.cpp)
endif(WIN32 AND MSVC)
# For Visual Studio only, include win32_memory.cpp to the list of sources, required to override Visual Studio's overrides of the new/delete operators
if(MSVC)
list(APPEND SRC ${Anope_SOURCE_DIR}/src/win32_memory.cpp)
endif(MSVC)
# Generate the module and set it's linker flags, also set it to depend on the main Anope executable to be built beforehand
add_library(${SO} MODULE ${SRC})
add_dependencies(${SO} ${PROGRAM_NAME})
#set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "" COMPILE_FLAGS ${CXXFLAGS})
set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "" LINK_FLAGS "${LDFLAGS}")
add_dependencies(${SO} ${PROGRAM_NAME})
# For Windows only, have the module link to the export library of Anope as well as the wsock32 library (most of the modules probably don't need this, but this is to be on the safe side), also set it's version
if(WIN32)
target_link_libraries(${SO} ${PROGRAM_NAME} wsock32)
set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
endif(WIN32)
#set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "")
# Set the module to be installed to the module directory under the data directory
install(TARGETS ${SO}
DESTINATION "${DATADIR}/modules"
)
+17 -51
View File
@@ -1,68 +1,34 @@
#if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
#else(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
# file(RELATIVE_PATH DIR ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DIR})
#endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
set(TOOLS_SRCS anopesmtp.c db-convert.c db-merger.c)
# Find all the *.c and *.cpp files within the current source directory, and sort the list
file(GLOB TOOLS_SRCS_C RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c")
file(GLOB TOOLS_SRCS_CPP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
set(TOOLS_SRCS ${TOOLS_SRCS_C} ${TOOLS_SRCS_CPP})
list(SORT TOOLS_SRCS)
# Set all the files to use C++ as well as set their compile flags
set_source_files_properties(${TOOLS_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
set(anopesmtp.c_HEADERS ${Anope_BINARY_DIR}/include/sysconf.h ${CMAKE_CURRENT_SOURCE_DIR}/smtp.h)
set(db-convert.c_HEADERS ${Anope_BINARY_DIR}/include/sysconf.h)
set(db-merger.c_HEADERS ${Anope_BINARY_DIR}/include/sysconf.h)
# Iterate through all the source files
foreach(SRC ${TOOLS_SRCS})
#string(REGEX REPLACE "\\." "_" SRC_TARGET ${SRC})
string(REGEX REPLACE "\\.cpp$" ".x" SRC_X ${SRC})
string(REGEX REPLACE "\\.c$" ".o" SRC_O ${SRC_X})
string(REGEX REPLACE "\\.x$" ".o" OBJ ${SRC_O})
string(REGEX REPLACE "\\.o$" "" EXE ${OBJ})
#string(REGEX REPLACE "\\." "_" OBJ_TARGET ${OBJ})
#set(SRC_OBJS ${SRC_OBJS} ${BUILD_DIR}/${OBJ})
set(TOOLS ${TOOLS} ${EXE})
#add_custom_command(OUTPUT ${BUILD_DIR}/${OBJ}
# COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} -I${Anope_SOURCE_DIR}/include -c ${SRC} -o ${BUILD_DIR}/${OBJ}
# MAIN_DEPENDENCY ${SRC}
#)
#add_custom_target(src_${OBJ_TARGET} DEPENDS ${BUILD_DIR}/${OBJ})
#add_custom_target(src_${SRC_TARGET} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${SRC})
#add_dependencies(src_srcs src_${SRC_TARGET})
#set(HEADERS)
#if(${SRC}_HEADERS)
# foreach(HEADER ${${SRC}_HEADERS})
# string(SUBSTRING ${HEADER} 0 1 FIRST_CHAR)
# string(SUBSTRING ${HEADER} 1 1 SECOND_CHAR)
# if(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
# set(HEADERS ${HEADERS} ${HEADER})
# else(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
# set(HEADERS ${HEADERS} ${Anope_SOURCE_DIR}/include/${HEADER})
# endif(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
# endforeach(HEADER)
#endif(${SRC}_HEADERS)
#if(HEADERS)
# set_source_files_properties(${SRC} PROPERTIES OBJECT_DEPENDS "${HEADERS}")
#endif(HEADERS)
# Convert the source file extension to have no extension
string(REGEX REPLACE "\\.(c|cpp)$" "" EXE ${SRC})
# Calculate the header file dependencies for the given source file
calculate_depends(${SRC})
get_source_file_property(HEADERS ${SRC} OBJECT_DEPENDS)
message(STATUS "${SRC}'s OBJECT_DEPENDS: ${HEADERS}")
# Generate the executable and set it's linker flags, also set it to depend on the main Anope executable to be built beforehand
add_executable(${EXE} ${SRC})
set_target_properties(${EXE} PROPERTIES LINK_FLAGS "${LDFLAGS}")
add_dependencies(${EXE} ${PROGRAM_NAME})
#set_target_properties(${EXE} PROPERTIES COMPILE_FLAGS ${CXXFLAGS})
# Set the executable to be installed to the tools directory under the bin directory
install(TARGETS ${EXE}
DESTINATION "${BINDIR}/tools"
DESTINATION "${INSTDIR}/tools"
)
endforeach(SRC)
# Only for Windows, set anopesmtp to require the wsock32 library
if(WIN32)
target_link_libraries(anopesmtp wsock32)
endif(WIN32)
if(NOT WIN32)
if(RUNGROUP)
install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${BINDIR}/tools\")")
endif(RUNGROUP)
endif(NOT WIN32)
# On non-Windows platforms, if RUNGROUP is set, change the permissions of the tools directory
if(NOT WIN32 AND RUNGROUP)
install(CODE "execute_process(COMMAND ${CHMOD} 2770 \"${INSTDIR}/tools\")")
endif(NOT WIN32 AND RUNGROUP)
+5 -1
View File
@@ -37,7 +37,11 @@ VER_ANOPE VERSIONINFO
#ifndef MINGW
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#endif
FILEFLAGS @FILEFLAGS@
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS_NT
FILETYPE VFT_APP
FILESUBTYPE 0x0L