3 license: 'GPL-2.0-or-later',
4 meson_version: '>=0.51',
8 'buildtype=debugoptimized',
12 dir_run_state = get_option('runstatedir')
13 opt_crypto = get_option('crypto')
14 opt_curses = get_option('curses')
15 opt_debug = get_option('debug')
16 opt_docs = get_option('docs')
17 opt_harden = get_option('hardening')
18 opt_jumbograms = get_option('jumbograms')
19 opt_lz4 = get_option('lz4')
20 opt_lzo = get_option('lzo')
21 opt_miniupnpc = get_option('miniupnpc')
22 opt_readline = get_option('readline')
23 opt_static = get_option('static')
24 opt_systemd = get_option('systemd')
25 opt_tests = get_option('tests')
26 opt_tunemu = get_option('tunemu')
27 opt_uml = get_option('uml')
28 opt_vde = get_option('vde')
29 opt_zlib = get_option('zlib')
31 meson_version = meson.version()
33 cc = meson.get_compiler('c')
34 os_name = host_machine.system()
35 cpu_family = host_machine.cpu_family()
38 cc_defs = ['-D_GNU_SOURCE']
40 cc_defs += '-D__EXTENSIONS__'
47 static = os_name == 'windows'
49 static = opt_static.enabled()
52 if static and cc_name != 'msvc'
58 # Most of these flags are already ON by default in the latest version of MSVC.
59 # Add anyway in case someone is building using an old toolchain.
60 cc_flags += ['/guard:cf', '/GS']
65 cpu_family.endswith('64') ? '/HIGHENTROPYVA' : '/SAFESEH',
69 '-D_FORTIFY_SOURCE=2',
71 '-fno-strict-overflow',
73 '-Wold-style-definition',
74 '-Wmissing-declarations',
75 '-Wmissing-prototypes',
76 '-Wstrict-prototypes',
78 '-Wbad-function-cast',
80 '-fdiagnostics-show-option',
85 cc_flags += '-Qunused-arguments'
87 ld_flags += ['-Wl,-z,relro', '-Wl,-z,now']
88 if os_name == 'windows'
89 ld_flags += ['-Wl,--dynamicbase', '-Wl,--nxcompat']
94 cc_flags = cc.get_supported_arguments(cc_flags)
95 ld_flags = cc.get_supported_link_arguments(ld_flags)
97 add_project_arguments(cc_flags, language: 'c')
98 add_project_link_arguments(ld_flags, language: 'c')
100 build_root = meson.current_build_dir()
101 src_root = meson.current_source_dir()
103 prefix = get_option('prefix')
104 dir_bin = prefix / get_option('bindir')
105 dir_data = prefix / get_option('datadir')
106 dir_info = prefix / get_option('infodir')
107 dir_lib = prefix / get_option('libdir')
108 dir_local_state = prefix / get_option('localstatedir')
109 dir_locale = prefix / get_option('localedir')
110 dir_man = prefix / get_option('mandir')
111 dir_sbin = prefix / get_option('sbindir')
112 dir_sysconf = prefix / get_option('sysconfdir')
114 if dir_run_state == ''
115 dir_run_state = dir_local_state / 'run'
118 if not opt_docs.disabled()
124 if not opt_tests.disabled()
128 subdir('bash_completion.d')
130 if os_name == 'linux' and not opt_systemd.disabled()
134 prog_reformat = find_program('astyle', native: true, required: false)
135 if prog_reformat.found()
136 run_target('reformat', command: [
138 '--options=@SOURCE_ROOT@/.astylerc', '--recursive',
139 '@SOURCE_ROOT@/*.c', '@SOURCE_ROOT@/*.h',