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 #include ''' ) 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: true) 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: true) 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)