diff options
Diffstat (limited to 'src/libs/botan')
-rw-r--r-- | src/libs/botan/botan.pri | 5 | ||||
-rw-r--r-- | src/libs/botan/botan.pro | 55 | ||||
-rw-r--r-- | src/libs/botan/botan.qbs | 117 | ||||
-rw-r--r-- | src/libs/botan/botan_dependencies.pri | 0 | ||||
-rw-r--r-- | src/libs/botan/update-botan.sh | 62 |
5 files changed, 239 insertions, 0 deletions
diff --git a/src/libs/botan/botan.pri b/src/libs/botan/botan.pri new file mode 100644 index 0000000000..b5b28535d1 --- /dev/null +++ b/src/libs/botan/botan.pri @@ -0,0 +1,5 @@ +msvc: BOTAN_LIB_NAME = botan +else: BOTAN_LIB_NAME = botan-2 +BOTAN_BUILD_DIR = build +!msvc: BOTAN_LIB_PREFIX = lib +BOTAN_FULL_NAME = $$BOTAN_LIB_PREFIX$${BOTAN_LIB_NAME}.$$QMAKE_EXTENSION_STATICLIB diff --git a/src/libs/botan/botan.pro b/src/libs/botan/botan.pro new file mode 100644 index 0000000000..48b3b2ea35 --- /dev/null +++ b/src/libs/botan/botan.pro @@ -0,0 +1,55 @@ +TEMPLATE = aux + +DISTFILES = update-botan.sh + +include(botan.pri) +include(../../../qtcreator.pri) +BOTAN_BUILD_DIR = $$OUT_PWD/$$BOTAN_BUILD_DIR +BOTAN_FILE_PATH = $$BOTAN_BUILD_DIR/$$BOTAN_FULL_NAME +BOTAN_BUILD_DIR_FOR_SHELL = $$shell_quote($$shell_path($$BOTAN_BUILD_DIR)) +BOTAN_SOURCE_DIR = $$PWD/../3rdparty/botan + +TARGET = $$BOTAN_LIB_NAME +PRECOMPILED_HEADER = +CONFIG -= qt + +msvc: BOTAN_CC_TYPE = msvc +else: clang: BOTAN_CC_TYPE = clang +else: BOTAN_CC_TYPE = gcc +contains(QT_ARCH, i386): BOTAN_ARCH_SWITCH = "--cpu=x86" +else: contains(QT_ARCH, x86_64): BOTAN_ARCH_SWITCH = "--cpu=x86_64" +BOTAN_MODULES = aes aes_ssse3 auto_rng bigint block cbc ctr des dh dsa ec_group ecdh ecdsa entropy \ + filters hmac mode_pad pubkey rsa sha1 sha1_sse2 sha1_x86 sha2_32 sha2_32_x86 \ + sha2_64 simd system_rng,emsa_pkcs1,pbes2,pbkdf2 +OTHER_FLAGS = --amalgamation --minimized-build --disable-shared \ + --enable-modules=$$join(BOTAN_MODULES,",",,) --without-documentation +mingw { + BOTAN_OS_SWITCH = "--os=mingw" + OTHER_FLAGS += --without-stack-protector +} +BOTAN_CXX_FLAGS = +msvc: BOTAN_CXX_FLAGS += /wd4127 /wd4244 /wd4250 /wd4267 /wd4334 /wd4702 /wd4996 +else: BOTAN_CXX_FLAGS += -Wno-unused-parameter +macos: BOTAN_CXX_FLAGS += -mmacosx-version-min=$$QMAKE_MACOSX_DEPLOYMENT_TARGET -isysroot $$shell_quote($$QMAKE_MAC_SDK.macosx.Path) +unix: BOTAN_CXX_FLAGS += -fPIC +!isEmpty(BOTAN_CXX_FLAGS): OTHER_FLAGS += --cxxflags=$$shell_quote($$BOTAN_CXX_FLAGS) +win32: OTHER_FLAGS += --link-method=hardlink +CONFIG(debug, debug|release): OTHER_FLAGS += --with-debug-info +CONFIGURE_FILE_PATH_FOR_SHELL = $$shell_quote($$shell_path($$BOTAN_SOURCE_DIR/configure.py)) + +configure_inputs = $$BOTAN_SOURCE_DIR/configure.py + +configure.input = configure_inputs +configure.output = $$BOTAN_BUILD_DIR/Makefile +configure.variable_out = BOTAN_MAKEFILE +configure.commands = cd $$BOTAN_BUILD_DIR_FOR_SHELL && \ + python $$CONFIGURE_FILE_PATH_FOR_SHELL \ + --cc=$$BOTAN_CC_TYPE --cc-bin=$$QMAKE_CXX \ + $$BOTAN_ARCH_SWITCH $$BOTAN_OS_SWITCH $$OTHER_FLAGS +QMAKE_EXTRA_COMPILERS += configure + +make.input = BOTAN_MAKEFILE +make.output = $$BOTAN_FILE_PATH +make.CONFIG += target_predeps +make.commands = cd $$BOTAN_BUILD_DIR_FOR_SHELL && $(MAKE) libs +QMAKE_EXTRA_COMPILERS += make diff --git a/src/libs/botan/botan.qbs b/src/libs/botan/botan.qbs new file mode 100644 index 0000000000..3872e900ad --- /dev/null +++ b/src/libs/botan/botan.qbs @@ -0,0 +1,117 @@ +import qbs + +Product { + name: "Botan" + condition: !qtc.useSystemBotan + type: ["staticlibrary", "hpp"] + Depends { name: "cpp" } + Depends { name: "qtc" } + Depends { name: "xcode"; condition: qbs.toolchain.contains("xcode") } + files: "update-botan.sh" + Group { + name: "Botan sources" + prefix: "../3rdparty/botan/" + Group { + name: "Botan configure script" + files: "configure.py" + fileTags: "botan.configure" + } + Group { + name: "Other Botan files" + files: "**/*" + excludeFiles: "configure.py" + fileTags: "botan.sources" + } + } + + Rule { + inputs: "botan.configure" + Artifact { + filePath: "Makefile" + fileTags: "botan.Makefile" + } + Artifact { + filePath: "build/include/botan/build.h" + fileTags: "hpp" + } + prepare: { + var args = [input.filePath, "--amalgamation", "--minimized-build", "--disable-shared", + "--without-documentation"]; + var modules = "aes,aes_ssse3,auto_rng,bigint,block,cbc,ctr,des,dh,dsa,ec_group,ecdh," + + "ecdsa,entropy,filters,hmac,mode_pad,pubkey,rsa,sha1,sha1_sse2,sha1_x86," + + "sha2_32,sha2_32_x86,sha2_64,simd,system_rng,emsa_pkcs1,pbes2,pbkdf2"; + args.push("--enable-modules=" + modules); + var cxxFlags = []; + if (product.qbs.toolchain.contains("msvc")) { + cxxFlags.push("/wd4127", "/wd4244", "/wd4250", "/wd4267", "/wd4334", "/wd4702", + "/wd4996"); + } + else if (product.qbs.toolchain.contains("gcc")) + cxxFlags.push("-Wno-unused-parameter"); + if (product.qbs.targetOS.contains("macos")) { + cxxFlags.push("-mmacosx-version-min=" + project.minimumMacosVersion); + if (product.qbs.toolchain.contains("xcode")) + cxxFlags.push("-isysroot", product.xcode.sdkPath); + } + if (product.qbs.targetOS.contains("unix")) + cxxFlags.push("-fPIC"); + if (cxxFlags.length > 0) + args.push("--cxxflags=" + cxxFlags.join(" ")); + var ccOption = "--cc="; + var tc = product.qbs.toolchain; + if (tc.contains("msvc")) + ccOption += "msvc"; + else if (tc.contains("clang")) + ccOption += "clang"; + else + ccOption += "gcc"; + args.push(ccOption); + if (!tc.contains("msvc")) + args.push("--cc-bin=" + product.cpp.compilerPath); + if (tc.contains("mingw")) { + args.push("--os=mingw", "--without-stack-protector"); + if (product.qbs.targetOS.contains("windows")) + args.push("--link-method=hardlink"); + } + var arch = product.qbs.architecture; + if (arch == "x86" || arch == "x86_64") + args.push("--cpu=" + arch); + if (product.qbs.debugInformation) + args.push("--with-debug-info"); + var cmd = new Command("python", args); + cmd.workingDirectory = product.buildDirectory; + cmd.description = "Configuring Botan"; + return cmd; + } + } + + Rule { + multiplex: true + inputs: ["botan.Makefile", "botan.sources"] + Artifact { + filePath: (product.qbs.toolchain.contains("msvc") ? "botan" : "libbotan-2") + + product.cpp.staticLibrarySuffix; + fileTags: "staticlibrary" + } + + prepare: { + var tc = product.moduleProperty("qbs", "toolchain"); + var make = "make"; + if (tc.contains("msvc")) { + make = "nmake"; + } else if (tc.contains("mingw") + && product.moduleProperty("qbs", "hostOS").contains("windows")) { + make = "mingw32-make"; + } + var cmd = new Command(make, ["libs"]); + cmd.workingDirectory = product.buildDirectory; + cmd.description = "Building Botan"; + return cmd; + } + } + + Export { + Depends { name: "cpp" } + cpp.includePaths: product.buildDirectory + "/build/include" + } +} diff --git a/src/libs/botan/botan_dependencies.pri b/src/libs/botan/botan_dependencies.pri new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/src/libs/botan/botan_dependencies.pri diff --git a/src/libs/botan/update-botan.sh b/src/libs/botan/update-botan.sh new file mode 100644 index 0000000000..f604fe8442 --- /dev/null +++ b/src/libs/botan/update-botan.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +test $# -eq 1 || { echo "This script needs a Botan archive as its sole argument."; exit 1; } + +set -e + +script_dir=$(readlink -f $(dirname $0)) +botan_archive=$1 +botan_extracted_dir_name=$(basename -s .tgz $botan_archive) +botan_parent_dir=$script_dir/../3rdparty + +cd $botan_parent_dir + +echo "Removing old botan sources..." +rm -rf botan + +echo "Extracting new botan sources..." +tar xf $botan_archive +mv $botan_extracted_dir_name botan + +echo "Removing unneeded components..." +cd botan +rm -r doc news.rst +cd src +rm -r build-data/policy/* cli configs fuzzer python scripts tests +cd lib +rm -r codec/base32 compression ffi misc passhash pbkdf/pbkdf1 pbkdf/pgp_s2k pbkdf/scrypt prov \ + psk_db tls +cd block +rm -r aria blowfish camellia cascade cast gost_28147 idea kasumi lion misty1 noekeon seed serpent\ + shacal2 sm4 threefish_512 twofish xtea +cd ../filters +rm -r codec_filt fd_unix +cd ../hash +rm -r blake2 checksum comb4p gost_3411 keccak md4 md5 par_hash rmd160 sha3 shake skein sm3 \ + streebog tiger whirlpool +cd ../kdf +rm -r hkdf kdf1 kdf1_iso18033 kdf2 prf_tls prf_x942 sp800_108 sp800_56a sp800_56c +cd ../mac +rm -r cbc_mac cmac gmac poly1305 siphash x919_mac +cd ../modes +rm -r aead cfb xts +cd ../pk_pad +rm -r eme_oaep eme_pkcs1 eme_raw emsa_raw emsa_x931 iso9796 +cd ../pubkey +rm -r cecpq1 curve25519 dlies ecgdsa ecies eckcdsa ed25519 elgamal gost_3410 mce mceies newhope \ + rfc6979 sm2 xmss +cd ../rng +rm -r chacha_rng +cd ../stream +rm -r chacha ofb rc4 salsa20 shake_cipher +cd ../utils +rm -r boost http_util locking_allocator mem_pool poly_dbl socket sqlite3 thread_utils +cd ../x509 +rm -r certstor_sql certstor_sqlite3 + +echo "Patching..." +# Fix annoying linker warning on macOS +sed -i 's/all!haiku -> "-pthread"/all!haiku,darwin -> "-pthread"/g' \ + "$botan_parent_dir/botan/src/build-data/cc/clang.txt" + +echo "Done." |