summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt58
-rw-r--r--src/main.cpp4
-rw-r--r--src/tools/CMakeLists.txt45
-rw-r--r--src/win32/Config.cs79
-rw-r--r--src/win32/anope_windows.h7
5 files changed, 65 insertions, 128 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index be3f1010f..fd834fc16 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -2,71 +2,41 @@
file(GLOB SRC_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
if(WIN32)
- append_to_list(SRC_SRCS win32/dir/dir.cpp)
- append_to_list(SRC_SRCS win32/socket.cpp)
- append_to_list(SRC_SRCS win32/windows.cpp)
- append_to_list(SRC_SRCS win32/dl/dl.cpp)
- append_to_list(SRC_SRCS win32/pipe/pipe.cpp)
- append_to_list(SRC_SRCS win32/pthread/pthread.cpp)
- append_to_list(SRC_SRCS win32/sigaction/sigaction.cpp)
+ list(APPEND SRC_SRCS win32/dir/dir.cpp)
+ list(APPEND SRC_SRCS win32/socket.cpp)
+ list(APPEND SRC_SRCS win32/windows.cpp)
+ list(APPEND SRC_SRCS win32/dl/dl.cpp)
+ list(APPEND SRC_SRCS win32/pipe/pipe.cpp)
+ list(APPEND SRC_SRCS win32/pthread/pthread.cpp)
+ list(APPEND SRC_SRCS win32/sigaction/sigaction.cpp)
endif(WIN32)
if(HAVE_EPOLL)
- append_to_list(SRC_SRCS socketengines/socketengine_epoll.cpp)
+ list(APPEND SRC_SRCS socketengines/socketengine_epoll.cpp)
else(HAVE_EPOLL)
if(HAVE_KQUEUE)
- append_to_list(SRC_SRCS socketengines/socketengine_kqueue.cpp)
+ list(APPEND SRC_SRCS socketengines/socketengine_kqueue.cpp)
else(HAVE_KQUEUE)
if(HAVE_POLL)
- append_to_list(SRC_SRCS socketengines/socketengine_poll.cpp)
+ list(APPEND SRC_SRCS socketengines/socketengine_poll.cpp)
else(HAVE_POLL)
- append_to_list(SRC_SRCS socketengines/socketengine_select.cpp)
+ list(APPEND SRC_SRCS socketengines/socketengine_select.cpp)
endif(HAVE_POLL)
endif(HAVE_KQUEUE)
endif(HAVE_EPOLL)
-sort_list(SRC_SRCS)
+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}")
-# Create an empty list to store extra include directories
-set(EXTRA_INCLUDES)
-# Iterate through all the source files
-foreach(SRC ${SRC_SRCS})
- # Temporary variable for the current source's include directories
- set(TEMP_INCLUDES)
- # Calculate the header file dependencies for the given source file
- calculate_depends(${SRC} TEMP_INCLUDES)
- # If there were some extra include directories, add them to the list
- if(TEMP_INCLUDES)
- append_to_list(EXTRA_INCLUDES ${TEMP_INCLUDES})
- endif(TEMP_INCLUDES)
-endforeach(SRC)
-# If there were extra include directories, remove the duplicates and add the directories to the include path
-if(EXTRA_INCLUDES)
- remove_list_duplicates(EXTRA_INCLUDES)
- include_directories(${EXTRA_INCLUDES})
-endif(EXTRA_INCLUDES)
-
# 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/win32.rc LANGUAGE RC)
# Add the resource file to the list of sources
- append_to_list(SRC_SRCS ${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc)
- # For MinGW, we have to change the compile flags
- if(MINGW)
- 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/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_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc COMPILE_FLAGS "/i\"${Anope_SOURCE_DIR}/include\"")
- endif(MINGW)
+ list(APPEND SRC_SRCS ${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc)
+ set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc COMPILE_FLAGS "/i\"${Anope_SOURCE_DIR}/include\"")
endif(WIN32)
# If compiling with Visual Studio, create a static library out of win32/win32_memory.cpp to be included with everything else, needed to override its override of new/delete operators
diff --git a/src/main.cpp b/src/main.cpp
index 99054688c..86d135ca8 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -47,7 +47,7 @@ class UpdateTimer : public Timer
public:
UpdateTimer(time_t timeout) : Timer(timeout, Anope::CurTime, true) { }
- void Tick(time_t) anope_override
+ void Tick(time_t) override
{
Anope::SaveDatabases();
}
@@ -58,7 +58,7 @@ class ExpireTimer : public Timer
public:
ExpireTimer(time_t timeout) : Timer(timeout, Anope::CurTime, true) { }
- void Tick(time_t) anope_override
+ void Tick(time_t) override
{
FOREACH_MOD(OnExpireTick, ());
}
diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt
index 200aa2bf3..394d2fc51 100644
--- a/src/tools/CMakeLists.txt
+++ b/src/tools/CMakeLists.txt
@@ -1,6 +1,6 @@
# Find all the *.cpp files within the current source directory, and sort the list
file(GLOB TOOLS_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
-sort_list(TOOLS_SRCS)
+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}")
@@ -9,30 +9,25 @@ set_source_files_properties(${TOOLS_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS
foreach(SRC ${TOOLS_SRCS})
# Convert the source file extension to have no extension
string(REGEX REPLACE "\\.cpp$" "" EXE ${SRC})
- # Calculate the header file dependencies for the given source file
- calculate_depends(${SRC})
- # Only continue if this file isn't skipped
- if(NOT SKIP)
- # Generate the executable and set its 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 LINKER_LANGUAGE CXX LINK_FLAGS "${LDFLAGS}")
- add_dependencies(${EXE} ${PROGRAM_NAME})
- # Only for Windows, set anopesmtp to require the wsock32 library
- if(WIN32 AND ${EXE} STREQUAL anopesmtp)
- target_link_libraries(${EXE} wsock32)
- endif(WIN32 AND ${EXE} STREQUAL anopesmtp)
- if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" AND ${EXE} STREQUAL anopesmtp)
- target_link_libraries(${EXE} socket nsl)
- endif(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" AND ${EXE} STREQUAL anopesmtp)
- # Set the executable to be installed to the bin directory under the main directory
- install(TARGETS ${EXE}
- DESTINATION ${BIN_DIR}
- )
- # Add the executable to the list of files for CPack to ignore
- get_target_property(EXE_BINARY ${EXE} LOCATION)
- get_filename_component(EXE_BINARY ${EXE_BINARY} NAME)
- add_to_cpack_ignored_files("${EXE_BINARY}$" TRUE)
- endif(NOT SKIP)
+ # Generate the executable and set its 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 LINKER_LANGUAGE CXX LINK_FLAGS "${LDFLAGS}")
+ add_dependencies(${EXE} ${PROGRAM_NAME})
+ # Only for Windows, set anopesmtp to require the wsock32 library
+ if(WIN32 AND ${EXE} STREQUAL anopesmtp)
+ target_link_libraries(${EXE} wsock32)
+ endif(WIN32 AND ${EXE} STREQUAL anopesmtp)
+ if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" AND ${EXE} STREQUAL anopesmtp)
+ target_link_libraries(${EXE} socket nsl)
+ endif(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" AND ${EXE} STREQUAL anopesmtp)
+ # Set the executable to be installed to the bin directory under the main directory
+ install(TARGETS ${EXE}
+ DESTINATION ${BIN_DIR}
+ )
+ # Add the executable to the list of files for CPack to ignore
+ get_target_property(EXE_BINARY ${EXE} LOCATION)
+ get_filename_component(EXE_BINARY ${EXE_BINARY} NAME)
+ add_to_cpack_ignored_files("${EXE_BINARY}$" TRUE)
endforeach(SRC)
# If not on Windows, generate anoperc and install it along with mydbgen
diff --git a/src/win32/Config.cs b/src/win32/Config.cs
index 03308fde1..8fbf31a65 100644
--- a/src/win32/Config.cs
+++ b/src/win32/Config.cs
@@ -27,14 +27,12 @@ namespace Config
{
class Config
{
- static string ExecutablePath, InstallDirectory, VSVersion, VSShortVer, ExtraIncludeDirs, ExtraLibDirs, ExtraArguments;
+ static string ExecutablePath, InstallDirectory, ExtraIncludeDirs, ExtraLibDirs, ExtraArguments;
static bool UseNMake = true, BuildDebug = false;
static bool CheckResponse(string InstallerResponse)
{
- if (string.Compare(InstallerResponse, "yes", true) == 0 || string.Compare(InstallerResponse, "y", true) == 0)
- return true;
- return false;
+ return string.Compare(InstallerResponse, "yes", true) == 0 || string.Compare(InstallerResponse, "y", true) == 0;
}
static bool LoadCache()
@@ -62,10 +60,6 @@ namespace Config
ExtraLibDirs = value;
else if (name == "EXTRAARGS")
ExtraArguments = value;
- else if (name == "VSVERSION")
- VSVersion = value;
- else if (name == "VSSHORTVER")
- VSShortVer = value;
}
return true;
@@ -87,8 +81,6 @@ namespace Config
tw.WriteLine("EXTRAINCLUDE={0}", ExtraIncludeDirs);
tw.WriteLine("EXTRALIBS={0}", ExtraLibDirs);
tw.WriteLine("EXTRAARGS={0}", ExtraArguments);
- tw.WriteLine("VSVERSION={0}", VSVersion);
- tw.WriteLine("VSSHORTVER={0}", VSShortVer);
}
}
@@ -103,18 +95,15 @@ namespace Config
Console.Write("[{0}] ", UseNMake ? "yes" : "no");
return UseNMake ? "yes" : "no";
case 2:
- Console.Write("[{0}] ", VSShortVer);
- return VSShortVer;
- case 3:
Console.Write("[{0}] ", BuildDebug ? "yes" : "no");
return BuildDebug ? "yes" : "no";
- case 4:
+ case 3:
Console.Write("[{0}] ", ExtraIncludeDirs);
return ExtraIncludeDirs;
- case 5:
+ case 4:
Console.Write("[{0}] ", ExtraLibDirs);
return ExtraLibDirs;
- case 6:
+ case 5:
Console.Write("[{0}] ", ExtraArguments);
return ExtraArguments;
default:
@@ -247,15 +236,14 @@ namespace Config
if (!DoQuick)
{
List<string> InstallerQuestions = new List<string>()
- {
- "Where do you want Anope to be installed?",
- "Would you like to build using NMake instead of using Visual Studio?\r\nNOTE: If you decide to use NMake, you must be in an environment where\r\nNMake can function, such as the Visual Studio command line. If you say\r\nyes to this while not in an environment that can run NMake, it can\r\ncause the CMake configuration to enter an endless loop. [y/n]",
- "Are you using Visual Studio 2008, 2010, or 2012? You can leave this blank\nand have CMake try and auto detect it, but this usually doesn't\nwork correctly. [2008/2010/2012]",
- "Would you like to build a debug version of Anope? [y/n]",
- "Are there any extra include directories you wish to use?\nYou may only need to do this if CMake is unable to locate missing dependencies without hints.\nSeparate directories with semicolons and use slashes (aka /) instead of backslashes (aka \\).\nIf you need no extra include directories, enter NONE in all caps.",
- "Are there any extra library directories you wish to use?\nYou may only need to do this if CMake is unable to locate missing dependencies without hints.\nSeparate directories with semicolons and use slashes (aka /) instead of backslashes (aka \\).\nIf you need no extra library directories, enter NONE in all caps.",
- "Are there any extra arguments you wish to pass to CMake?\nIf you need no extra arguments to CMake, enter NONE in all caps."
- };
+ {
+ "Where do you want Anope to be installed?",
+ "Would you like to build using NMake instead of using Visual Studio? [y/n]",
+ "Would you like to build a debug version of Anope? [y/n]",
+ "Are there any extra include directories you wish to use?\nYou may only need to do this if CMake is unable to locate missing dependencies without hints.\nSeparate directories with semicolons and use slashes (aka /) instead of backslashes (aka \\).\nIf you need no extra include directories, enter NONE in all caps.",
+ "Are there any extra library directories you wish to use?\nYou may only need to do this if CMake is unable to locate missing dependencies without hints.\nSeparate directories with semicolons and use slashes (aka /) instead of backslashes (aka \\).\nIf you need no extra library directories, enter NONE in all caps.",
+ "Are there any extra arguments you wish to pass to CMake?\nIf you need no extra arguments to CMake, enter NONE in all caps."
+ };
for (int i = 0; i < InstallerQuestions.Count; ++i)
{
@@ -269,8 +257,8 @@ namespace Config
if (!string.IsNullOrWhiteSpace(CacheResponse) && string.IsNullOrWhiteSpace(InstallerResponse))
InstallerResponse = CacheResponse;
- // Question 5-7 are optional
- if (i < 4 && string.IsNullOrWhiteSpace(InstallerResponse))
+ // Question 4-6 are optional
+ if (i < 3 && string.IsNullOrWhiteSpace(InstallerResponse))
{
Console.WriteLine("Invalid option");
--i;
@@ -305,42 +293,23 @@ namespace Config
break;
case 1:
UseNMake = CheckResponse(InstallerResponse);
- if (UseNMake)
- ++i;
break;
case 2:
- if (InstallerResponse == "2012")
- {
- VSVersion = "-G\"Visual Studio 11\" ";
- VSShortVer = "2012";
- }
- else if (InstallerResponse == "2010")
- {
- VSVersion = "-G\"Visual Studio 10\" ";
- VSShortVer = "2010";
- }
- else if (InstallerResponse == "2008")
- {
- VSVersion = "-G\"Visual Studio 9 2008\" ";
- VSShortVer = "2008";
- }
- break;
- case 3:
BuildDebug = CheckResponse(InstallerResponse);
break;
- case 4:
+ case 3:
if (InstallerResponse == "NONE")
ExtraIncludeDirs = null;
else
ExtraIncludeDirs = InstallerResponse;
break;
- case 5:
+ case 4:
if (InstallerResponse == "NONE")
ExtraLibDirs = null;
else
ExtraLibDirs = InstallerResponse;
break;
- case 6:
+ case 5:
if (InstallerResponse == "NONE")
ExtraArguments = null;
else
@@ -354,11 +323,7 @@ namespace Config
Console.WriteLine("Anope will be compiled with the following options:");
Console.WriteLine("Install directory: {0}", InstallDirectory);
- Console.WriteLine("Use NMake: {0}", UseNMake ? "Yes" : "No");
- if (!string.IsNullOrWhiteSpace(VSShortVer))
- Console.WriteLine("Using Visual Studio: {0}", VSShortVer);
- else
- Console.WriteLine("Using Visual Studio: No");
+ Console.WriteLine("Generator: {0}", UseNMake ? "nmake" : "Visual Studio");
Console.WriteLine("Build debug: {0}", BuildDebug ? "Yes" : "No");
Console.WriteLine("Anope Version: {0}", AnopeVersion);
Console.WriteLine("Extra Include Directories: {0}", ExtraIncludeDirs);
@@ -383,9 +348,9 @@ namespace Config
ExtraArguments = "";
InstallDirectory = "-DINSTDIR:STRING=\"" + InstallDirectory.Replace('\\', '/') + "\" ";
- string NMake = UseNMake ? "-G\"NMake Makefiles\" " : "";
- string Debug = BuildDebug ? "-DCMAKE_BUILD_TYPE:STRING=DEBUG " : "-DCMAKE_BUILD_TYPE:STRING=RELEASE ";
- string cMake = InstallDirectory + NMake + Debug + VSVersion + ExtraIncludeDirs + ExtraLibDirs + ExtraArguments + "\"" + ExecutablePath.Replace('\\', '/') + "\"";
+ string Generator = UseNMake ? "-G\"NMake Makefiles\" " : "-G \"Visual Studio 11\" ";
+ string Debug = "-DCMAKE_BUILD_TYPE:STRING=" + (BuildDebug ? "DEBUG" : "RELEASE") + " ";
+ string cMake = InstallDirectory + Generator + Debug + ExtraIncludeDirs + ExtraLibDirs + ExtraArguments + "\"" + ExecutablePath.Replace('\\', '/') + "\"";
RunCMake(cMake);
return 0;
diff --git a/src/win32/anope_windows.h b/src/win32/anope_windows.h
index ad561f9b3..d08969ceb 100644
--- a/src/win32/anope_windows.h
+++ b/src/win32/anope_windows.h
@@ -42,6 +42,13 @@
/* VS2008 hates having this define before its own */
#define vsnprintf _vsnprintf
+#define popen _popen
+#define pclose _pclose
+
+#define PATH_MAX MAX_PATH
+
+#define sleep(x) Sleep(x * 1000)
+
#define anope_close windows_close
#define stat _stat