diff --git a/SConscript b/SConscript index d2680e21..d3ea7f3c 100644 --- a/SConscript +++ b/SConscript @@ -38,8 +38,8 @@ for x in Glob('libs/*'): if not sys.platform.startswith('linux'): if name in 'netlinkplus': continue - else: - if name in 'mongooseplus': + + if env.mongoose == 'no' and name in 'mongooseplus': continue library, library_includes = SConscript(sconscript_path, exports='env dirs name') diff --git a/SConstruct b/SConstruct index 0c3cb35f..55b0a48c 100644 --- a/SConstruct +++ b/SConstruct @@ -22,6 +22,15 @@ AddOption( default='all', help='The compilation mode.', ) +AddOption( + '--mongoose', + dest='mongoose', + nargs=1, + action='store', + choices=('yes', 'no'), + default='no', + help='Build webserver with mongoose (warning: it will violate GPLv3 license!)', +) class FreelanEnvironment(Environment): @@ -29,7 +38,7 @@ class FreelanEnvironment(Environment): A freelan specific environment class. """ - def __init__(self, mode, prefix, bin_prefix=None, **kwargs): + def __init__(self, mode, prefix, bin_prefix=None, mongoose='no', **kwargs): """ Initialize the environment. @@ -69,6 +78,7 @@ class FreelanEnvironment(Environment): self.prefix = prefix self.bin_prefix = bin_prefix if bin_prefix else prefix self.destdir = self['ENV'].get('DESTDIR', '') + self.mongoose = mongoose if self.destdir: self.install_prefix = os.path.normpath( @@ -115,6 +125,9 @@ class FreelanEnvironment(Environment): else: self.Append(CXXFLAGS='-O3') + if self.mongoose == 'yes': + self.Append(CXXFLAGS=['-DUSE_MONGOOSE']) + self.Append(CPPDEFINES=r'FREELAN_INSTALL_PREFIX="\"%s\""' % self.prefix) def RGlob(self, path, patterns=None): @@ -159,6 +172,7 @@ class FreelanEnvironment(Environment): mode = GetOption('mode') +mongoose = GetOption('mongoose') prefix = os.path.normpath(os.path.abspath(ARGUMENTS.get('prefix', './install'))) if 'bin_prefix' in ARGUMENTS: @@ -167,7 +181,7 @@ else: bin_prefix = None if mode in ('all', 'release'): - env = FreelanEnvironment(mode='release', prefix=prefix, bin_prefix=bin_prefix) + env = FreelanEnvironment(mode='release', prefix=prefix, bin_prefix=bin_prefix, mongoose=mongoose) libraries, includes, apps, samples, configurations = SConscript('SConscript', exports='env', variant_dir=os.path.join('build', env.mode)) install = env.Install(os.path.join(env.bin_install_prefix, 'bin'), apps) install.extend(env.Install(os.path.join(env.install_prefix, 'etc', 'freelan'), configurations)) diff --git a/apps/freelan/SConscript b/apps/freelan/SConscript index b27286b9..e1e057fd 100644 --- a/apps/freelan/SConscript +++ b/apps/freelan/SConscript @@ -1,7 +1,6 @@ import os import sys - Import('env dirs name') libraries = [ @@ -29,10 +28,6 @@ if sys.platform.startswith('linux'): 'netlinkplus', ]) else: - libraries.extend([ - 'mongooseplus', - ]) - if sys.platform.startswith('darwin'): libraries.extend([ 'ldap', @@ -40,6 +35,11 @@ else: 'iconv', ]) +if env.mongoose == 'yes': + libraries.extend([ + 'mongooseplus', + ]) + env = env.Clone() env.Prepend(LIBS=libraries) diff --git a/libs/freelan/include/freelan/server.hpp b/libs/freelan/include/freelan/server.hpp index 575b56e7..db002b6a 100644 --- a/libs/freelan/include/freelan/server.hpp +++ b/libs/freelan/include/freelan/server.hpp @@ -47,7 +47,7 @@ #include "os.hpp" -#ifndef LINUX +#ifdef USE_MONGOOSE #include "configuration.hpp" @@ -113,4 +113,4 @@ namespace freelan }; } -#endif \ No newline at end of file +#endif diff --git a/libs/freelan/src/core.cpp b/libs/freelan/src/core.cpp index 40bcb8ec..0c4c8363 100644 --- a/libs/freelan/src/core.cpp +++ b/libs/freelan/src/core.cpp @@ -2358,8 +2358,9 @@ namespace freelan { if (m_configuration.server.enabled) { -#ifdef LINUX - // Due to GPL licensing issues, we can't include that in the LINUX build without violating the GPLv3 license. +#ifndef USE_MONGOOSE + // Due to GPL licensing issues, we can't include that in the build without violating the GPLv3 license. + // If you still want that support, adds USE_MONGOOSE define to the build options. m_logger(fscp::log_level::warning) << "Web server support is not compiled in this version."; #else if (m_configuration.server.protocol == server_configuration::server_protocol_type::https) @@ -2427,7 +2428,7 @@ namespace freelan void core::close_web_server() { -#ifndef LINUX +#ifdef USE_MONGOOSE if (m_web_server) { m_logger(fscp::log_level::information) << "Closing web server..."; diff --git a/libs/freelan/src/server.cpp b/libs/freelan/src/server.cpp index 101cdbb6..64385adc 100644 --- a/libs/freelan/src/server.cpp +++ b/libs/freelan/src/server.cpp @@ -45,7 +45,7 @@ #include "server.hpp" -#ifndef LINUX +#ifdef USE_MONGOOSE #include "tools.hpp" @@ -471,4 +471,4 @@ namespace freelan } } -#endif \ No newline at end of file +#endif