meson.build 4.17 KB
Newer Older
Guido Gunther's avatar
Guido Gunther committed
1
project('phosh', 'c',
Guido Gunther's avatar
Guido Gunther committed
2
          version: '0.0.4',
Guido Gunther's avatar
Guido Gunther committed
3 4 5 6 7
          license: 'GPLv3+',
    meson_version: '>= 0.40.1',
  default_options: [ 'warning_level=1', 'buildtype=debugoptimized', 'c_std=gnu11' ],
)

8 9 10
prefix = get_option('prefix')
bindir = join_paths(prefix, get_option('bindir'))
datadir = join_paths(prefix, get_option('datadir'))
Guido Gunther's avatar
Guido Gunther committed
11
localedir = join_paths(prefix, get_option('localedir'))
Guido Gunther's avatar
Guido Gunther committed
12
libdir = join_paths(prefix, get_option('libdir'))
13
libexecdir = join_paths(prefix, get_option('libexecdir'))
Guido Gunther's avatar
Guido Gunther committed
14
desktopdir = join_paths(datadir, 'applications')
Guido Gunther's avatar
Guido Gunther committed
15
sessiondir = join_paths(datadir, 'gnome-session')
16
pkgdatadir = join_paths(datadir, meson.project_name())
Guido Gunther's avatar
Guido Gunther committed
17
pkglibdir = join_paths(libdir, meson.project_name())
18

Guido Gunther's avatar
Guido Gunther committed
19 20
config_h = configuration_data()
config_h.set_quoted('GETTEXT_PACKAGE', 'phosh')
Guido Gunther's avatar
Guido Gunther committed
21
config_h.set_quoted('LOCALEDIR', localedir)
22
config_h.set_quoted('PHOSH_VERSION', meson.project_version())
Guido Gunther's avatar
Guido Gunther committed
23 24

configure_file(
Guido Gunther's avatar
Guido Gunther committed
25
  input: 'config.h.in',
Guido Gunther's avatar
Guido Gunther committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
  output: 'config.h',
  configuration: config_h,
)

add_project_arguments([
  '-DHAVE_CONFIG_H',
  '-I' + meson.build_root(),
], language: 'c')

root_inc = include_directories('.')

cc = meson.get_compiler('c')

global_c_args = []
test_c_args = [
  '-Wcast-align',
42
  '-Wdate-time',
Guido Gunther's avatar
Guido Gunther committed
43 44
  '-Wdeclaration-after-statement',
  ['-Werror=format-security', '-Werror=format=2'],
45 46
  '-Wendif-labels',
  '-Werror=incompatible-pointer-types',
47
  '-Werror=missing-declarations',
48 49 50 51
  '-Werror=overflow',
  '-Werror=return-type',
  '-Werror=shift-count-overflow',
  '-Werror=shift-overflow=2',
52
  '-Werror=implicit-fallthrough=3',
53
  '-Wfloat-equal',
Guido Gunther's avatar
Guido Gunther committed
54 55
  '-Wformat-nonliteral',
  '-Wformat-security',
56
  '-Winit-self',
57
  '-Wmaybe-uninitialized',
58
  '-Wmissing-field-initializers',
Guido Gunther's avatar
Guido Gunther committed
59
  '-Wmissing-include-dirs',
60
  '-Wmissing-noreturn',
Guido Gunther's avatar
Guido Gunther committed
61 62 63 64 65
  '-Wnested-externs',
  '-Wno-missing-field-initializers',
  '-Wno-sign-compare',
  '-Wno-strict-aliasing',
  '-Wno-unused-parameter',
66
  '-Wold-style-definition',
Guido Gunther's avatar
Guido Gunther committed
67 68 69
  '-Wpointer-arith',
  '-Wredundant-decls',
  '-Wshadow',
70
  '-Wstrict-prototypes',
Guido Gunther's avatar
Guido Gunther committed
71 72
  '-Wswitch-default',
  '-Wswitch-enum',
73
  '-Wtype-limits',
Guido Gunther's avatar
Guido Gunther committed
74
  '-Wundef',
75
  '-Wunused-function',
Guido Gunther's avatar
Guido Gunther committed
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
]
if get_option('buildtype') != 'plain'
  test_c_args += '-fstack-protector-strong'
endif

foreach arg: test_c_args
  if cc.has_multi_arguments(arg)
    global_c_args += arg
  endif
endforeach
add_project_arguments(
  global_c_args,
  language: 'c'
)

91 92
run_data = configuration_data()
run_data.set('ABS_BUILDDIR', meson.current_build_dir())
93
run_data.set('ABS_SRCDIR', meson.current_source_dir())
94 95 96 97 98
configure_file(
  input: 'run.in',
  output: 'run',
  configuration: run_data)

Guido Gunther's avatar
Guido Gunther committed
99
gnome = import('gnome')
Guido Gunther's avatar
Guido Gunther committed
100
i18n  = import('i18n')
Guido Gunther's avatar
Guido Gunther committed
101

102 103 104
gio_dep = dependency('gio-2.0', version: '>=2.56')
gio_unix_dep =  dependency('gio-unix-2.0', version: '>=2.50.0')
glib_dep = dependency('glib-2.0', version: '>=2.50.0')
Guido Gunther's avatar
Guido Gunther committed
105 106 107 108 109 110 111 112 113 114 115
libgvc = subproject('gvc',
  default_options: [
    'package_name=' + meson.project_name(),
    'package_version=' + meson.project_version(),
    'pkgdatadir=' + pkgdatadir,
    'pkglibdir=' + pkglibdir,
    'static=true',
    'introspection=false',
    'alsa=false'
  ])
libgvc_dep = libgvc.get_variable('libgvc_dep')
Guido Gunther's avatar
Guido Gunther committed
116
libnm_dep = dependency('libnm', version: '>= 1.14')
117
libpolkit_agent_dep = dependency('polkit-agent-1', version: '>= 0.105')
Mohammed Sadiq's avatar
Mohammed Sadiq committed
118
network_agent_dep = dependency('libsecret-1')
Guido Gunther's avatar
Guido Gunther committed
119

120
subdir('data')
Guido Gunther's avatar
Guido Gunther committed
121
subdir('po')
122
subdir('protocol')
Guido Gunther's avatar
Guido Gunther committed
123
subdir('src')
Zander Brown's avatar
Zander Brown committed
124
subdir('tools')
125
subdir('tests')
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153

git = find_program('git', required: false)
if git.found()
	all_files = run_command(
		git,
		['--git-dir=@0@/.git'.format(meson.current_source_dir()),
		 'ls-files',
		 ':/*.[ch]'])
	all_files = files(all_files.stdout().split())

	etags = find_program('etags', required: false)
	if etags.found() and all_files.length() > 0
		custom_target('etags',
			build_by_default: true,
			input: all_files,
			output: 'TAGS',
			command: [etags.path(), '-o', 'TAGS'] + all_files)
	endif

	ctags = find_program('ctags', required: false)
	if ctags.found() and all_files.length() > 0
		custom_target('ctags',
			build_by_default: true,
			input: all_files,
			output: 'tags',
			command: [ctags.path(), '-o', 'tags'] + all_files)
	endif
endif
154 155 156

summary = [
  '',
157 158
  '-----------',
  'Phosh @0@'.format(meson.project_version()),
159 160
  '',
  'Tests: @0@'.format(get_option('tests')),
161
  '-----------',
162 163 164
]

message('\n'.join(summary))