X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=meson.build;h=155421986f3e08fbf616e9b9e28db1d22f840f63;hb=refs%2Fheads%2F1.1;hp=f96fb3232bca6ebb79aa74a50044982622f168e5;hpb=34317698b8c024de5c948b6f6058730b1fdbc328;p=tinc diff --git a/meson.build b/meson.build index f96fb323..15542198 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('tinc', 'c', - version: run_command('./src/git_tag.sh', check: true).stdout().strip(), + version: '1.1pre18', license: 'GPL-2.0-or-later', meson_version: '>=0.51', default_options: [ @@ -12,6 +12,7 @@ project('tinc', 'c', dir_run_state = get_option('runstatedir') opt_crypto = get_option('crypto') opt_curses = get_option('curses') +opt_debug = get_option('debug') opt_docs = get_option('docs') opt_harden = get_option('hardening') opt_jumbograms = get_option('jumbograms') @@ -19,6 +20,7 @@ opt_lz4 = get_option('lz4') opt_lzo = get_option('lzo') opt_miniupnpc = get_option('miniupnpc') opt_readline = get_option('readline') +opt_sandbox = get_option('sandbox') opt_static = get_option('static') opt_systemd = get_option('systemd') opt_tests = get_option('tests') @@ -31,8 +33,20 @@ meson_version = meson.version() cc = meson.get_compiler('c') os_name = host_machine.system() +cpu_family = host_machine.cpu_family() cc_name = cc.get_id() +python = find_program('python3', required: false) +if python.found() + if meson_version.version_compare('>=0.55') + python_path = python.full_path() + else + python_path = python.path() + endif +else + python_path = '' +endif + cc_defs = ['-D_GNU_SOURCE'] if os_name == 'sunos' cc_defs += '-D__EXTENSIONS__' @@ -41,39 +55,67 @@ endif cc_flags = [cc_defs] ld_flags = [] +if cc_name != 'msvc' + cc_flags += [ + '-Wbad-function-cast', + '-Wduplicated-branches', + '-Wduplicated-cond', + '-Wformat-overflow=2', + '-Wformat-truncation=1', # 2 prints too much noise + '-Wformat=2', + '-Wlogical-op', + '-Wmissing-declarations', + '-Wmissing-noreturn', + '-Wmissing-prototypes', + '-Wno-embedded-directive', + '-Wold-style-definition', + '-Wredundant-decls', + '-Wreturn-type', + '-Wstrict-prototypes', + '-Wswitch-enum', + '-Wtrampolines', # may require executable stack which is disabled + '-Wvla', # VLAs are not supported by MSVC + '-Wwrite-strings', + '-fdiagnostics-show-option', + '-fno-strict-overflow', + '-fstrict-aliasing', + ] +endif + if opt_static.auto() static = os_name == 'windows' else static = opt_static.enabled() endif -if static +if static and cc_name != 'msvc' ld_flags += '-static' endif if opt_harden - cc_flags += [ - '-D_FORTIFY_SOURCE=2', - '-fwrapv', - '-fno-strict-overflow', - '-Wreturn-type', - '-Wold-style-definition', - '-Wmissing-declarations', - '-Wmissing-prototypes', - '-Wstrict-prototypes', - '-Wredundant-decls', - '-Wbad-function-cast', - '-Wwrite-strings', - '-fdiagnostics-show-option', - '-fstrict-aliasing', - '-Wmissing-noreturn', - ] - if cc_name == 'clang' - cc_flags += '-Qunused-arguments' - endif - ld_flags += ['-Wl,-z,relro', '-Wl,-z,now'] - if os_name == 'windows' - ld_flags += ['-Wl,--dynamicbase', '-Wl,--nxcompat'] + if cc_name == 'msvc' + # Most of these flags are already ON by default in the latest version of MSVC. + # Add anyway in case someone is building using an old toolchain. + cc_flags += ['/guard:cf', '/GS'] + ld_flags += [ + '/guard:cf', + '/NXCOMPAT', + '/DYNAMICBASE', + cpu_family.endswith('64') ? '/HIGHENTROPYVA' : '/SAFESEH', + ] + else + cc_flags += [ + '-D_FORTIFY_SOURCE=2', + '-fcf-protection=full', + '-fstack-protector-strong', + ] + ld_flags += ['-Wl,-z,relro', '-Wl,-z,now', '-Wl,-z,noexecstack'] + if os_name == 'windows' + ld_flags += ['-Wl,--dynamicbase', '-Wl,--nxcompat'] + else + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90458 + cc_flags += '-fstack-clash-protection' + endif endif endif @@ -117,12 +159,23 @@ if os_name == 'linux' and not opt_systemd.disabled() subdir('systemd') endif -prog_reformat = find_program('astyle', native: true, required: false) -if prog_reformat.found() +if python.found() run_target('reformat', command: [ - prog_reformat, - '--options=@SOURCE_ROOT@/.astylerc', - '@SOURCE_ROOT@/*.c', '@SOURCE_ROOT@/*.h', + python, + '@SOURCE_ROOT@/lint.py', + '--fix', + ]) + + run_target('lint', command: [ + python, + '@SOURCE_ROOT@/lint.py', ]) endif +if meson_version.version_compare('>=0.53') + summary({ + 'prefix': prefix, + 'sandbox': cdata.has('HAVE_SANDBOX'), + 'watchdog': cdata.has('HAVE_WATCHDOG'), + }, bool_yn: true, section: 'System') +endif