summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt34
-rw-r--r--src/tools/CMakeLists.txt6
-rw-r--r--src/win32/Config.cs359
3 files changed, 18 insertions, 381 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b32c1d9c0..373677fe7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -8,21 +8,17 @@ if(WIN32)
list(APPEND SRC_SRCS win32/dl/dl.cpp)
list(APPEND SRC_SRCS win32/pipe/pipe.cpp)
list(APPEND SRC_SRCS win32/sigaction/sigaction.cpp)
-endif(WIN32)
+endif()
if(HAVE_EPOLL)
list(APPEND SRC_SRCS socketengines/socketengine_epoll.cpp)
-else(HAVE_EPOLL)
- if(HAVE_KQUEUE)
- list(APPEND SRC_SRCS socketengines/socketengine_kqueue.cpp)
- else(HAVE_KQUEUE)
- if(HAVE_POLL)
- list(APPEND SRC_SRCS socketengines/socketengine_poll.cpp)
- else(HAVE_POLL)
- list(APPEND SRC_SRCS socketengines/socketengine_select.cpp)
- endif(HAVE_POLL)
- endif(HAVE_KQUEUE)
-endif(HAVE_EPOLL)
+elseif(HAVE_KQUEUE)
+ list(APPEND SRC_SRCS socketengines/socketengine_kqueue.cpp)
+elseif(HAVE_POLL)
+ list(APPEND SRC_SRCS socketengines/socketengine_poll.cpp)
+else()
+ list(APPEND SRC_SRCS socketengines/socketengine_select.cpp)
+endif()
list(SORT SRC_SRCS)
@@ -36,7 +32,7 @@ if(WIN32)
# Add the resource file to the list of sources
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)
+endif()
# 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
if(MSVC)
@@ -44,9 +40,9 @@ if(MSVC)
add_library(win32_memory STATIC win32/win32_memory.cpp)
set(WIN32_MEMORY win32_memory)
set(EXTRA_LDFLAGS "/OPT:NOREF") # https://sourceware.org/bugzilla/show_bug.cgi?id=12633
-else(MSVC)
+else()
set(WIN32_MEMORY)
-endif(MSVC)
+endif()
# 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})
@@ -55,15 +51,15 @@ set_target_properties(${PROGRAM_NAME} PROPERTIES LINKER_LANGUAGE CXX LINK_FLAGS
if(WIN32)
target_link_libraries(${PROGRAM_NAME} wsock32 Ws2_32 ${LINK_LIBS} ${GETTEXT_LIBRARIES} ${WIN32_MEMORY})
set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
-else(WIN32)
+else()
target_link_libraries(${PROGRAM_NAME} ${LINK_LIBS} ${GETTEXT_LIBRARIES})
-endif(WIN32)
+endif()
# Building the Anope executable requires the version.h header to be generated
add_dependencies(${PROGRAM_NAME} headers)
# Also require the language files if we have gettext
if(GETTEXT_FOUND)
add_dependencies(${PROGRAM_NAME} language)
-endif(GETTEXT_FOUND)
+endif()
# Get the filename of the Anope executable as it is in on this system
get_target_property(SERVICES_BINARY ${PROGRAM_NAME} LOCATION)
@@ -77,7 +73,7 @@ configure_file(${Anope_SOURCE_DIR}/include/sysconf.h.cmake ${Anope_BINARY_DIR}/i
# Go into the following directories and run their CMakeLists.txt as well
if(NOT DISABLE_TOOLS)
add_subdirectory(tools)
-endif(NOT DISABLE_TOOLS)
+endif()
# Set Anope to be installed to the bin directory
install(TARGETS ${PROGRAM_NAME}
diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt
index d970d93b0..4d64f6fd9 100644
--- a/src/tools/CMakeLists.txt
+++ b/src/tools/CMakeLists.txt
@@ -21,7 +21,7 @@ foreach(SRC ${TOOLS_SRCS})
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)
+endforeach()
# If not on Windows, generate anoperc and install it along with mydbgen
if(NOT WIN32)
@@ -32,9 +32,9 @@ if(NOT WIN32)
install (PROGRAMS geoipupdate.sh
DESTINATION ${BIN_DIR}
)
-endif(NOT WIN32)
+endif()
# 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 \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin\")")
-endif(NOT WIN32 AND RUNGROUP)
+endif()
diff --git a/src/win32/Config.cs b/src/win32/Config.cs
deleted file mode 100644
index ea94e338a..000000000
--- a/src/win32/Config.cs
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
- * Config.cs - Windows Configuration
- *
- * (C) 2003-2014 Anope Team
- * Contact us at team@anope.org
- *
- * This program is free but copyrighted software; see the file COPYING for
- * details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- *
- * Written by Scott <stealtharcher.scott@gmail.com>
- * Written by Adam <Adam@anope.org>
- * Cleaned up by Naram Qashat <cyberbotx@anope.org>
- *
- * Compile with: csc /out:../../Config.exe /win32icon:anope-icon.ico Config.cs
- */
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Reflection;
-
-namespace Config
-{
- class Config
- {
- static string ExecutablePath, InstallDirectory, ExtraIncludeDirs, ExtraLibDirs, ExtraArguments;
- static bool UseNMake = true, BuildDebug = false;
-
- static bool CheckResponse(string InstallerResponse)
- {
- return string.Compare(InstallerResponse, "yes", true) == 0 || string.Compare(InstallerResponse, "y", true) == 0;
- }
-
- static bool LoadCache()
- {
- try
- {
- string[] cache = File.ReadAllLines(string.Format(@"{0}\config.cache", ExecutablePath));
- if (cache.Length > 0)
- Console.WriteLine("Using defaults from config.cache");
- foreach (string line in cache)
- {
- int e = line.IndexOf('=');
- string name = line.Substring(0, e);
- string value = line.Substring(e + 1);
-
- if (name == "INSTDIR")
- InstallDirectory = value;
- else if (name == "DEBUG")
- BuildDebug = CheckResponse(value);
- else if (name == "USENMAKE")
- UseNMake = CheckResponse(value);
- else if (name == "EXTRAINCLUDE")
- ExtraIncludeDirs = value;
- else if (name == "EXTRALIBS")
- ExtraLibDirs = value;
- else if (name == "EXTRAARGS")
- ExtraArguments = value;
- }
-
- return true;
- }
- catch (Exception)
- {
- }
-
- return false;
- }
-
- static void SaveCache()
- {
- using (TextWriter tw = new StreamWriter(string.Format(@"{0}\config.cache", ExecutablePath)))
- {
- tw.WriteLine("INSTDIR={0}", InstallDirectory);
- tw.WriteLine("DEBUG={0}", BuildDebug ? "yes" : "no");
- tw.WriteLine("USENMAKE={0}", UseNMake ? "yes" : "no");
- tw.WriteLine("EXTRAINCLUDE={0}", ExtraIncludeDirs);
- tw.WriteLine("EXTRALIBS={0}", ExtraLibDirs);
- tw.WriteLine("EXTRAARGS={0}", ExtraArguments);
- }
- }
-
- static string HandleCache(int i)
- {
- switch (i)
- {
- case 0:
- Console.Write("[{0}] ", InstallDirectory);
- return InstallDirectory;
- case 1:
- Console.Write("[{0}] ", UseNMake ? "yes" : "no");
- return UseNMake ? "yes" : "no";
- case 2:
- Console.Write("[{0}] ", BuildDebug ? "yes" : "no");
- return BuildDebug ? "yes" : "no";
- case 3:
- Console.Write("[{0}] ", ExtraIncludeDirs);
- return ExtraIncludeDirs;
- case 4:
- Console.Write("[{0}] ", ExtraLibDirs);
- return ExtraLibDirs;
- case 5:
- Console.Write("[{0}] ", ExtraArguments);
- return ExtraArguments;
- default:
- break;
- }
-
- return null;
- }
-
- static string FindAnopeVersion()
- {
- if (!File.Exists(string.Format(@"{0}\src\version.sh", ExecutablePath)))
- return "Unknown";
-
- Dictionary<string, string> versions = new Dictionary<string, string>();
- string[] versionfile = File.ReadAllLines(string.Format(@"{0}\src\version.sh", ExecutablePath));
- foreach (string line in versionfile)
- if (line.StartsWith("VERSION_"))
- {
- string key = line.Split('_')[1].Split('=')[0];
- if (!versions.ContainsKey(key))
- versions.Add(key, line.Split('=')[1].Replace("\"", "").Replace("\'", ""));
- }
-
- try
- {
- if (versions.ContainsKey("BUILD"))
- return string.Format("{0}.{1}.{2}.{3}{4}", versions["MAJOR"], versions["MINOR"], versions["PATCH"], versions["BUILD"], versions["EXTRA"]);
- else
- return string.Format("{0}.{1}.{2}{3}", versions["MAJOR"], versions["MINOR"], versions["PATCH"], versions["EXTRA"]);
- }
- catch (Exception e)
- {
- Console.WriteLine(e.Message);
- return "Unknown";
- }
- }
-
- static void RunCMake(string cMake)
- {
- Console.WriteLine("cmake {0}", cMake);
- try
- {
- ProcessStartInfo processStartInfo = new ProcessStartInfo("cmake")
- {
- RedirectStandardError = true,
- RedirectStandardOutput = true,
- UseShellExecute = false,
- Arguments = cMake
- };
- Process pCMake = Process.Start(processStartInfo);
- StreamReader stdout = pCMake.StandardOutput, stderr = pCMake.StandardError;
- string stdoutr, stderrr;
- List<string> errors = new List<string>();
- while (!pCMake.HasExited)
- {
- if ((stdoutr = stdout.ReadLine()) != null)
- Console.WriteLine(stdoutr);
- if ((stderrr = stderr.ReadLine()) != null)
- errors.Add(stderrr);
- }
- foreach (string error in errors)
- Console.WriteLine(error);
- Console.WriteLine();
- if (pCMake.ExitCode == 0)
- {
- if (UseNMake)
- Console.WriteLine("To compile Anope, run 'nmake'. To install, run 'nmake install'");
- else
- Console.WriteLine("To compile Anope, open Anope.sln and build the solution. To install, do a build on the INSTALL project");
- }
- else
- Console.WriteLine("There was an error attempting to run CMake! Check the above error message, and contact the Anope team if you are unsure how to proceed.");
- }
- catch (Exception e)
- {
- Console.WriteLine();
- Console.WriteLine(DateTime.UtcNow + " UTC: " + e.Message);
- Console.WriteLine("There was an error attempting to run CMake! Check the above error message, and contact the Anope team if you are unsure how to proceed.");
- }
- }
-
- static int Main(string[] args)
- {
- bool IgnoreCache = false, NoIntro = false, DoQuick = false;
-
- if (args.Length > 0)
- {
- if (args[0] == "--help")
- {
- Console.WriteLine("Config utility for Anope");
- Console.WriteLine("------------------------");
- Console.WriteLine("Syntax: .\\Config.exe [options]");
- Console.WriteLine("-nocache Ignore settings saved in config.cache");
- Console.WriteLine("-nointro Skip intro (disclaimer, etc)");
- Console.WriteLine("-quick or -q Skip questions, go straight to cmake");
- return 0;
- }
- else if (args[0] == "-nocache")
- IgnoreCache = true;
- else if (args[0] == "-nointro")
- NoIntro = true;
- else if (args[0] == "-quick" || args[0] == "-q")
- DoQuick = true;
- }
-
- ExecutablePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
-
- string AnopeVersion = FindAnopeVersion();
-
- if (!NoIntro && File.Exists(string.Format(@"{0}\.BANNER", ExecutablePath)))
- Console.WriteLine(File.ReadAllText(string.Format(@"{0}\.BANNER", ExecutablePath)).Replace("CURVER", AnopeVersion).Replace("For more options type SOURCE_DIR/Config --help", ""));
-
- Console.WriteLine("Press Enter to begin");
- Console.WriteLine();
- Console.ReadKey();
-
- bool UseCache = false;
-
- if (DoQuick || !IgnoreCache)
- {
- UseCache = LoadCache();
- if (DoQuick && !UseCache)
- {
- Console.WriteLine("Can't find cache file (config.cache), aborting...");
- return 1;
- }
- }
-
- 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? [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)
- {
- Console.WriteLine(InstallerQuestions[i]);
- string CacheResponse = null;
- if (UseCache)
- CacheResponse = HandleCache(i);
- string InstallerResponse = Console.ReadLine();
- Console.WriteLine();
-
- if (!string.IsNullOrWhiteSpace(CacheResponse) && string.IsNullOrWhiteSpace(InstallerResponse))
- InstallerResponse = CacheResponse;
-
- // Question 4+ are optional
- if (i < 3 && string.IsNullOrWhiteSpace(InstallerResponse))
- {
- Console.WriteLine("Invalid option");
- --i;
- continue;
- }
-
- switch (i)
- {
- case 0:
- if (!Directory.Exists(InstallerResponse))
- {
- Console.WriteLine("Directory does not exist! Creating directory.");
- Console.WriteLine();
- try
- {
- Directory.CreateDirectory(InstallerResponse);
- InstallDirectory = InstallerResponse;
- }
- catch (Exception e)
- {
- Console.WriteLine("Unable to create directory: " + e.Message);
- --i;
- }
- }
- else if (File.Exists(InstallerResponse + @"\include\services.h"))
- {
- Console.WriteLine("You cannot use the Anope source directory as the target directory!");
- --i;
- }
- else
- InstallDirectory = InstallerResponse;
- break;
- case 1:
- UseNMake = CheckResponse(InstallerResponse);
- break;
- case 2:
- BuildDebug = CheckResponse(InstallerResponse);
- break;
- case 3:
- if (InstallerResponse == "NONE")
- ExtraIncludeDirs = null;
- else
- ExtraIncludeDirs = InstallerResponse;
- break;
- case 4:
- if (InstallerResponse == "NONE")
- ExtraLibDirs = null;
- else
- ExtraLibDirs = InstallerResponse;
- break;
- case 5:
- if (InstallerResponse == "NONE")
- ExtraArguments = null;
- else
- ExtraArguments = InstallerResponse;
- break;
- default:
- break;
- }
- }
- }
-
- Console.WriteLine("Anope will be compiled with the following options:");
- Console.WriteLine("Install directory: {0}", InstallDirectory);
- 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);
- Console.WriteLine("Extra Library Directories: {0}", ExtraLibDirs);
- Console.WriteLine("Extra Arguments: {0}", ExtraArguments);
- Console.WriteLine("Press Enter to continue...");
- Console.ReadKey();
-
- SaveCache();
-
- if (!string.IsNullOrWhiteSpace(ExtraIncludeDirs))
- ExtraIncludeDirs = string.Format("-DEXTRA_INCLUDE:STRING={0} ", ExtraIncludeDirs);
- else
- ExtraIncludeDirs = "";
- if (!string.IsNullOrWhiteSpace(ExtraLibDirs))
- ExtraLibDirs = string.Format("-DEXTRA_LIBS:STRING={0} ", ExtraLibDirs);
- else
- ExtraLibDirs = "";
- if (!string.IsNullOrWhiteSpace(ExtraArguments))
- ExtraArguments += " ";
- else
- ExtraArguments = "";
-
- InstallDirectory = "-DINSTDIR:STRING=\"" + InstallDirectory.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;
- }
- }
-}