diff options
| author | Joel Klinghed <the_jk@yahoo.com> | 2017-08-12 01:44:03 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@yahoo.com> | 2017-08-12 01:44:17 +0200 |
| commit | 4bc57e1aff741f2bad1884574c8fe29b51ee5f16 (patch) | |
| tree | 69ec3ee7453792168dd22881bd5e7c83bbf38142 | |
| parent | 8b6fdad56758a254c6ce3ba44cc2ca23e88e46f5 (diff) | |
Initial meson build files
| -rw-r--r-- | meson.build | 299 | ||||
| -rw-r--r-- | meson_options.txt | 4 |
2 files changed, 303 insertions, 0 deletions
diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..64deeb6 --- /dev/null +++ b/meson.build @@ -0,0 +1,299 @@ +project('tp', 'cpp', + version: '0.1', + default_options: ['cpp_std=c++11']) + +cpp_optional_flags = ['-fno-rtti', '-fno-exceptions', + '-fvisibility=hidden', + '-Wall', '-Wextra', + '-Wno-missing-field-initializers', + '-Wno-maybe-uninitialized'] +cpp_flags = ['-DHAVE_CONFIG_H'] +if get_option('buildtype') == 'release' + # If asserts are disabled parameters and variables used for only that + # end up causing warnings + cpp_optional_flags += ['-Wno-unused-parameter', '-Wno-unused-variable'] + cpp_flags += '-DNDEBUG' +endif +cpp = meson.get_compiler('cpp') +foreach flag : cpp_optional_flags + if cpp.has_argument(flag) + cpp_flags += flag + endif +endforeach +add_global_arguments(cpp_flags, language: 'cpp') + +conf = configuration_data() +conf.set('VERSION', '"' + meson.project_version() + '"') +conf.set('SYSCONFDIR', '"' + join_paths(get_option('prefix'), + get_option('sysconfdir')) + '"') + +if cpp.has_function('accept4', prefix: ''' +#include <sys/types.h> +#include <sys/socket.h>''' + ) + conf.set('HAVE_ACCEPT4', true) +endif + +if cpp.compiles(''' +void foo(const char* format, ...) + __attribute__((format (printf, 1, 2))) + ; +''', name: 'attribute(format) check') + conf.set('HAVE_FUNC_ATTRIBUTE_FORMAT', true) +endif + +link_args_mbedtls = ['-lmbedtls', '-lmbedx509', '-lmbedcrypto'] + +dep_mbedtls = cpp.find_library('mbedtls', required: false) +dep_mbedx509 = cpp.find_library('mbedx509', required: false) +dep_mbedcrypto = cpp.find_library('mbedcrypto', required: false) +if cpp.has_header('mbedtls/ssl.h') and dep_mbedtls.found() and dep_mbedx509.found() and dep_mbedcrypto.found() + conf.set10('HAVE_SSL', true) + src_mitm = ['src/mitm.cc', 'src/ssl_mbedtls.cc'] + dep_ssl = [dep_mbedtls, dep_mbedx509, dep_mbedcrypto] +else + dep_openssl = dependency('openssl', version : '>= 1.0.2', required: false) + if dep_openssl.found() + conf.set10('HAVE_SSL', true) + src_mitm = ['src/mitm.cc', 'src/ssl_openssl.cc'] + dep_ssl = dep_openssl + else + src_mitm = ['src/mitm_stub.cc'] + dep_ssl = [] + endif +endif + +dep_thread = dependency('threads') + +dep_zlib = dependency('zlib', required: false) +if not dep_zlib.found() and cpp.has_headere('zlib.h') + dep_zlib = cpp.find_library('z', required: false) +endif +conf.set10('HAVE_ZLIB', dep_zlib.found()) + +if cpp.has_header('bzlib.h') + dep_bzip2 = cpp.find_library('bz2', required: false) + conf.set10('HAVE_BZIP2', dep_bzip2.found()) +else + dep_bzip2 = [] +endif + +import('qt5') +dep_qt = dependency('qt5', modules : 'Widgets', version: '>= 5.5.0', + required: false) + +if not dep_qt.found() or get_option('all_gui') + dep_gtk = dependency('gtk+-3.0', version: '>= 3.18', required: false) + have_gtk = dep_gtk.found() +else + have_gtk = false +endif + +if dep_qt.found() or have_gtk + dep_pcap = [] + ret = run_command('pcap-config', '--cflags') + if ret.returncode() == 0 + cflags = ret.stdout().strip().split() + ret = run_command('pcap-config', '--libs') + if ret.returncode() == 0 + dep_pcap = declare_dependency( + compile_args: cflags, + link_args: ret.stdout().strip().split()) + conf.set10('HAVE_PCAP', true) + message('PCAP found') + endif + endif +endif + +configure_file(output: 'config.h', + configuration: conf) + +lib_common = static_library('common', + sources: ['src/args.cc', 'src/xdg.cc', + 'src/terminal.cc', 'src/http.cc', + 'src/url.cc', 'src/paths.cc', + 'src/character.cc', 'src/config.cc', + 'src/strings.cc', 'src/io.cc', + 'src/looper.cc', 'src/buffer.cc', + 'src/chunked.cc', 'src/package.cc', + 'src/utf.cc', 'src/packages.cc']) + +lib_logger = static_library('logger', + sources: ['src/logger.cc']) + +lib_resolver = static_library('resolver', + sources: ['src/resolver.cc']) + +lib_mitm = static_library('mitm', + sources: src_mitm, + dependencies: dep_ssl) + +lib_proxy = static_library('proxy', + sources: ['src/proxy.cc']) + +lib_attrstr = static_library('attrstr', + sources: ['src/gui_attrtext.cc', + 'src/gui_htmlattrtext.cc', + 'src/gui_plainattrtext.cc']) + +lib_hexdump = static_library('hexdump', + sources: ['src/gui_hexdump.cc']) + +lib_monitor = static_library('monitor', + sources: ['src/monitor.cc']) + +lib_protocol = static_library('protocol', + sources: ['src/protocols.cc', + 'src/http_protocol.cc'], + dependencies: [dep_zlib, dep_bzip2]) + +if dep_qt.found() or have_gtk + lib_monitor_gui = static_library('monitor-gui', + sources: ['src/monitor-gui.cc', + 'src/gui_config.cc'], + dependencies: dep_pcap) +endif + +executable('tp', + sources: ['src/main.cc'], + link_with: [lib_proxy, lib_mitm, lib_logger, lib_resolver, + lib_common], + dependencies: dep_thread, + install: true) + +executable('tp-genca', + sources: ['src/genca.cc'], + link_with: [lib_mitm, lib_logger, lib_common], + dependencies: dep_thread, + install: true) + +executable('tp-monitor', + sources: ['src/monitor-cmd.cc'], + link_with: [lib_monitor, lib_resolver, lib_hexdump, lib_attrstr, + lib_common], + dependencies: dep_thread, + install: true) + +executable('protocol', + sources: ['src/protocol-main.cc'], + link_with: [lib_protocol, lib_hexdump, lib_attrstr, lib_common], + dependencies: dep_thread) + +if have_gtk + executable('tp-monitor-gtk', + sources: ['src/gui_gtk.cc'], + link_with: [lib_monitor_gui, lib_protocol, lib_attrstr, + lib_proxy, lib_mitm, lib_monitor, lib_hexdump, + lib_common, lib_resolver, lib_logger], + dependencies: [dep_gtk, dep_thread], + cpp_args: '-Wno-unused-function') + install_data(['data/tp-monitor-gtk.desktop'], + install_dir: join_paths(get_option('datadir'), 'applications')) + install_data(['data/tp-monitor-gtk.gschema.xml'], + install_dir: join_paths(get_option('datadir'), + 'glib-2.0/schemas')) + if get_option('update_mimedb') + meson.add_install_script('gtk-update-icon-cache', + join_paths(get_option('prefix'), + get_option('datadir'), + 'icons/hicolor')) + endif +endif + +if dep_qt.found() + executable('tp-monitor-qt', + sources: ['src/gui_qt.cc'], + link_with: [lib_monitor_gui, lib_protocol, lib_attrstr, + lib_proxy, lib_mitm, lib_monitor, lib_hexdump, + lib_common, lib_resolver, lib_logger], + dependencies: [dep_qt, dep_thread]) + install_data(['data/tp-monitor-qt.desktop'], + install_dir: join_paths(get_option('datadir'), 'applications')) +endif + +if dep_qt.found() or have_gtk + install_data(['data/tp-monitor.png'], + install_dir: join_paths(get_option('datadir'), + 'icons/hicolor/48x48/apps')) + install_data(['data/tp-monitor.xml'], + install_dir: join_paths(get_option('datadir'), + 'mime/packages')) + + if get_option('update_mimedb') + meson.add_install_script('update-mime-database', '-n', + join_paths(get_option('prefix'), + get_option('datadir'), + 'mime')) + meson.add_install_script('update-desktop-database', + join_paths(get_option('prefix'), + get_option('datadir'), + 'applications')) + endif +endif + +inc_src = include_directories('src') + +test_url = executable('test-url', + sources: ['test/test-url.cc'], + link_with: lib_common, + include_directories: inc_src) +test('url', test_url) + +test_http = executable('test-http', + sources: ['test/test-http.cc'], + link_with: lib_common, + include_directories: inc_src) +test('http', test_http) + +test_args = executable('test-args', + sources: ['test/test-args.cc'], + link_with: lib_common, + include_directories: inc_src) +test('args', test_args) + +test_xdg = executable('test-xdg', + sources: ['test/test-xdg.cc'], + link_with: lib_common, + include_directories: inc_src) +test('xdg', test_xdg) + +test_strings = executable('test-strings', + sources: ['test/test-strings.cc'], + link_with: lib_common, + include_directories: inc_src) +test('strings', test_strings) + +test_paths = executable('test-paths', + sources: ['test/test-paths.cc'], + link_with: lib_common, + include_directories: inc_src) +test('paths', test_paths) + +test_observers = executable('test-observers', + sources: ['test/test-observers.cc'], + include_directories: inc_src) +test('observers', test_observers) + +test_htmlattrtext = executable('test-htmlattrtext', + sources: ['test/test-htmlattrtext.cc'], + link_with: lib_attrstr, + include_directories: inc_src) +test('htmlattrtext', test_htmlattrtext) + +test_package = executable('test-package', + sources: ['test/test-package.cc'], + link_with: lib_common, + include_directories: inc_src) +test('package', test_package) + +test_utf = executable('test-utf', + sources: ['test/test-utf.cc'], + link_with: lib_common, + include_directories: inc_src) +test('utf', test_utf) + +test_packages = executable('test-packages', + sources: ['test/test-packages.cc'], + link_with: lib_common, + include_directories: inc_src) +test('packages', test_packages) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..101cbd9 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,4 @@ +option('update_mimedb', type: 'boolean', value: true, + description: 'Call update-mime-database (and similar) after install') +option('all_gui', type: 'boolean', value: false, + description: 'Build all found GUI backends') |
