From 806e57433a38193ae14942ee60f573fe47f4b643 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Sun, 11 Sep 2016 21:19:28 +0100 Subject: Rewrite the build system directive parser. --- src/modules/extra/m_geoip.cpp | 7 +++++-- src/modules/extra/m_ldap.cpp | 5 +++-- src/modules/extra/m_mysql.cpp | 9 ++++++--- src/modules/extra/m_pgsql.cpp | 17 ++++++----------- src/modules/extra/m_regex_pcre.cpp | 9 ++++++--- src/modules/extra/m_regex_re2.cpp | 8 ++++++-- src/modules/extra/m_regex_stdlib.cpp | 5 +++-- src/modules/extra/m_regex_tre.cpp | 8 +++++--- src/modules/extra/m_sqlite3.cpp | 8 +++++--- src/modules/extra/m_ssl_gnutls.cpp | 12 +++++++++--- src/modules/extra/m_ssl_mbedtls.cpp | 5 ++++- src/modules/extra/m_ssl_openssl.cpp | 9 ++++++--- 12 files changed, 64 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/modules/extra/m_geoip.cpp b/src/modules/extra/m_geoip.cpp index 967c6a761..564599bf8 100644 --- a/src/modules/extra/m_geoip.cpp +++ b/src/modules/extra/m_geoip.cpp @@ -17,6 +17,11 @@ * along with this program. If not, see . */ +/// $CompilerFlags: find_compiler_flags("geoip" "") +/// $LinkerFlags: find_linker_flags("geoip" "-lGeoIP") + +/// $PackageInfo: require_system("darwin") geoip pkg-config +/// $PackageInfo: require_system("ubuntu") libgeoip-dev pkg-config #include "inspircd.h" #include "xline.h" @@ -27,8 +32,6 @@ # pragma comment(lib, "GeoIP.lib") #endif -/* $LinkerFlags: -lGeoIP */ - class ModuleGeoIP : public Module { LocalStringExt ext; diff --git a/src/modules/extra/m_ldap.cpp b/src/modules/extra/m_ldap.cpp index 698738145..67a4e6745 100644 --- a/src/modules/extra/m_ldap.cpp +++ b/src/modules/extra/m_ldap.cpp @@ -17,6 +17,9 @@ * along with this program. If not, see . */ +/// $LinkerFlags: -llber -lldap_r +/// $PackageInfo: require_system("ubuntu") libldap2-dev + #include "inspircd.h" #include "modules/ldap.h" @@ -27,8 +30,6 @@ # pragma comment(lib, "liblber.lib") #endif -/* $LinkerFlags: -lldap_r -llber */ - class LDAPService; class LDAPRequest diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index e65a8de92..d965c88fb 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -19,6 +19,12 @@ * along with this program. If not, see . */ +/// $CompilerFlags: execute("mysql_config --include" "MYSQL_CXXFLAGS") +/// $LinkerFlags: execute("mysql_config --libs_r" "MYSQL_LDFLAGS" "-lmysqlclient") + +/// $PackageInfo: require_system("darwin") mysql-connector-c +/// $PackageInfo: require_system("ubuntu") libmysqlclient-dev + // Fix warnings about the use of `long long` on C++03. #if defined __clang__ @@ -37,9 +43,6 @@ /* VERSION 3 API: With nonblocking (threaded) requests */ -/* $CompileFlags: exec("mysql_config --include") */ -/* $LinkerFlags: exec("mysql_config --libs_r") rpath("mysql_config --libs_r") */ - /* THE NONBLOCKING MYSQL API! * * MySQL provides no nonblocking (asyncronous) API of its own, and its developers recommend diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index ff8c1174c..56455a718 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -21,15 +21,18 @@ * along with this program. If not, see . */ +/// $CompilerFlags: -Iexecute("pg_config --includedir" "POSTGRESQL_INCLUDE_DIR") +/// $LinkerFlags: -Lexecute("pg_config --libdir" "POSTGRESQL_LIBRARY_DIR") -lpq + +/// $PackageInfo: require_system("darwin") postgresql +/// $PackageInfo: require_system("ubuntu") libpq-dev + #include "inspircd.h" #include #include #include "modules/sql.h" -/* $CompileFlags: -Iexec("pg_config --includedir") eval("my $s = `pg_config --version`;$s =~ /^.*?(\d+)\.(\d+)\.(\d+).*?$/;my $v = hex(sprintf("0x%02x%02x%02x", $1, $2, $3));print "-DPGSQL_HAS_ESCAPECONN" if(($v >= 0x080104) || ($v >= 0x07030F && $v < 0x070400) || ($v >= 0x07040D && $v < 0x080000) || ($v >= 0x080008 && $v < 0x080100));") */ -/* $LinkerFlags: -Lexec("pg_config --libdir") -lpq */ - /* SQLConn rewritten by peavey to * use EventHandler instead of * BufferedSocket. This is much neater @@ -412,14 +415,10 @@ restart: { std::string parm = p[param++]; std::vector buffer(parm.length() * 2 + 1); -#ifdef PGSQL_HAS_ESCAPECONN int error; size_t escapedsize = PQescapeStringConn(sql, &buffer[0], parm.data(), parm.length(), &error); if (error) ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "BUG: Apparently PQescapeStringConn() failed"); -#else - size_t escapedsize = PQescapeString(&buffer[0], parm.data(), parm.length()); -#endif res.append(&buffer[0], escapedsize); } } @@ -447,14 +446,10 @@ restart: { std::string parm = it->second; std::vector buffer(parm.length() * 2 + 1); -#ifdef PGSQL_HAS_ESCAPECONN int error; size_t escapedsize = PQescapeStringConn(sql, &buffer[0], parm.data(), parm.length(), &error); if (error) ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "BUG: Apparently PQescapeStringConn() failed"); -#else - size_t escapedsize = PQescapeString(&buffer[0], parm.data(), parm.length()); -#endif res.append(&buffer[0], escapedsize); } } diff --git a/src/modules/extra/m_regex_pcre.cpp b/src/modules/extra/m_regex_pcre.cpp index 9ae6719ba..5ad27858f 100644 --- a/src/modules/extra/m_regex_pcre.cpp +++ b/src/modules/extra/m_regex_pcre.cpp @@ -17,14 +17,17 @@ * along with this program. If not, see . */ +/// $CompilerFlags: execute("pcre-config --cflags" "PCRE_CXXFLAGS") +/// $LinkerFlags: execute("pcre-config --libs" "PCRE_LDFLAGS" "-lpcre") + +/// $PackageInfo: require_system("darwin") pcre pkg-config +/// $PackageInfo: require_system("ubuntu") libpcre3-dev pkg-config + #include "inspircd.h" #include #include "modules/regex.h" -/* $CompileFlags: exec("pcre-config --cflags") */ -/* $LinkerFlags: exec("pcre-config --libs") rpath("pcre-config --libs") -lpcre */ - #ifdef _WIN32 # pragma comment(lib, "libpcre.lib") #endif diff --git a/src/modules/extra/m_regex_re2.cpp b/src/modules/extra/m_regex_re2.cpp index c4657bf8b..2f0ee2998 100644 --- a/src/modules/extra/m_regex_re2.cpp +++ b/src/modules/extra/m_regex_re2.cpp @@ -17,6 +17,12 @@ * along with this program. If not, see . */ +/// $CompilerFlags: find_compiler_flags("re2" "") +/// $LinkerFlags: find_linker_flags("re2" "-lre2") + +/// $PackageInfo: require_system("darwin") pkg-config re2 +/// $PackageInfo: require_system("ubuntu" "15.10") libre2-dev pkg-config + #include "inspircd.h" #include "modules/regex.h" @@ -32,8 +38,6 @@ #include -/* $LinkerFlags: -lre2 */ - class RE2Regex : public Regex { RE2 regexcl; diff --git a/src/modules/extra/m_regex_stdlib.cpp b/src/modules/extra/m_regex_stdlib.cpp index 8e7bd0da2..7a888ed72 100644 --- a/src/modules/extra/m_regex_stdlib.cpp +++ b/src/modules/extra/m_regex_stdlib.cpp @@ -16,12 +16,13 @@ * along with this program. If not, see . */ +/// $CompilerFlags: -std=c++11 + + #include "inspircd.h" #include "modules/regex.h" #include -/* $CompileFlags: -std=c++11 */ - class StdRegex : public Regex { std::regex regexcl; diff --git a/src/modules/extra/m_regex_tre.cpp b/src/modules/extra/m_regex_tre.cpp index 8a1d54248..e2eafcd01 100644 --- a/src/modules/extra/m_regex_tre.cpp +++ b/src/modules/extra/m_regex_tre.cpp @@ -17,15 +17,17 @@ * along with this program. If not, see . */ +/// $CompilerFlags: find_compiler_flags("tre") +/// $LinkerFlags: find_linker_flags("tre" "-ltre") + +/// $PackageInfo: require_system("darwin") pkg-config tre +/// $PackageInfo: require_system("ubuntu") libtre-dev pkg-config #include "inspircd.h" #include "modules/regex.h" #include #include -/* $CompileFlags: pkgconfincludes("tre","tre/regex.h","") */ -/* $LinkerFlags: pkgconflibs("tre","/libtre.so","-ltre") rpath("pkg-config --libs tre") */ - class TRERegex : public Regex { regex_t regbuf; diff --git a/src/modules/extra/m_sqlite3.cpp b/src/modules/extra/m_sqlite3.cpp index 8c07bfc6a..fa88cacc3 100644 --- a/src/modules/extra/m_sqlite3.cpp +++ b/src/modules/extra/m_sqlite3.cpp @@ -19,6 +19,11 @@ * along with this program. If not, see . */ +/// $CompilerFlags: find_compiler_flags("sqlite3") +/// $LinkerFlags: find_linker_flags("sqlite3" "-lsqlite3") + +/// $PackageInfo: require_system("darwin") pkg-config sqlite3 +/// $PackageInfo: require_system("ubuntu") libsqlite3-dev pkg-config #include "inspircd.h" #include "modules/sql.h" @@ -36,9 +41,6 @@ # pragma comment(lib, "sqlite3.lib") #endif -/* $CompileFlags: pkgconfversion("sqlite3","3.3") pkgconfincludes("sqlite3","/sqlite3.h","") */ -/* $LinkerFlags: pkgconflibs("sqlite3","/libsqlite3.so","-lsqlite3") */ - class SQLConn; typedef insp::flat_map ConnMap; diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index e5cb8ee90..a42efa1ab 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -20,6 +20,15 @@ * along with this program. If not, see . */ +/// $CompilerFlags: find_compiler_flags("gnutls") +/// $CompilerFlags: require_version("gnutls" "1.0" "2.12") execute("libgcrypt-config --cflags" "LIBGCRYPT_CXXFLAGS") + +/// $LinkerFlags: find_linker_flags("gnutls" "-lgnutls") +/// $LinkerFlags: require_version("gnutls" "1.0" "2.12") execute("libgcrypt-config --libs" "LIBGCRYPT_LDFLAGS") + +/// $PackageInfo: require_system("darwin") gnutls pkg-config +/// $PackageInfo: require_system("ubuntu" "1.0" "13.10") libgcrypt11-dev +/// $PackageInfo: require_system("ubuntu" "14.04") gnutls-bin libgnutls-dev pkg-config #include "inspircd.h" #include "modules/ssl.h" @@ -62,9 +71,6 @@ # pragma comment(lib, "libgnutls-30.lib") #endif -/* $CompileFlags: pkgconfincludes("gnutls","/gnutls/gnutls.h","") eval("print `libgcrypt-config --cflags | tr -d \r` if `pkg-config --modversion gnutls 2>/dev/null | tr -d \r` lt '2.12'") */ -/* $LinkerFlags: rpath("pkg-config --libs gnutls") pkgconflibs("gnutls","/libgnutls.so","-lgnutls") eval("print `libgcrypt-config --libs | tr -d \r` if `pkg-config --modversion gnutls 2>/dev/null | tr -d \r` lt '2.12'") */ - // These don't exist in older GnuTLS versions #if INSPIRCD_GNUTLS_HAS_VERSION(2, 1, 7) #define GNUTLS_NEW_PRIO_API diff --git a/src/modules/extra/m_ssl_mbedtls.cpp b/src/modules/extra/m_ssl_mbedtls.cpp index 50bf38266..f3b5adfd5 100644 --- a/src/modules/extra/m_ssl_mbedtls.cpp +++ b/src/modules/extra/m_ssl_mbedtls.cpp @@ -16,8 +16,11 @@ * along with this program. If not, see . */ +/// $LinkerFlags: -lmbedtls + +/// $PackageInfo: require_system("darwin") mbedtls +/// $PackageInfo: require_system("ubuntu" "16.04") libmbedtls-dev -/* $LinkerFlags: -lmbedtls */ #include "inspircd.h" #include "modules/ssl.h" diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index 8467cc6d4..8843c34f6 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -21,6 +21,12 @@ * along with this program. If not, see . */ +/// $CompilerFlags: find_compiler_flags("openssl") +/// $LinkerFlags: find_linker_flags("openssl" "-lssl -lcrypto") + +/// $PackageInfo: require_system("darwin") openssl pkg-config +/// $PackageInfo: require_system("ubuntu" "16.04") libssl-dev openssl pkg-config + #include "inspircd.h" #include "iohook.h" @@ -46,9 +52,6 @@ # pragma comment(lib, "libeay32.lib") #endif -/* $CompileFlags: pkgconfversion("openssl","0.9.7") pkgconfincludes("openssl","/openssl/ssl.h","") */ -/* $LinkerFlags: rpath("pkg-config --libs openssl") pkgconflibs("openssl","/libssl.so","-lssl -lcrypto") */ - #if ((OPENSSL_VERSION_NUMBER >= 0x10000000L) && (!(defined(OPENSSL_NO_ECDH)))) // OpenSSL 0.9.8 includes some ECC support, but it's unfinished. Enable only for 1.0.0 and later. #define INSPIRCD_OPENSSL_ENABLE_ECDH -- cgit v1.2.3