meson.build 2.9 KB
Newer Older
Guido Gunther's avatar
Guido Gunther committed
1 2 3 4 5 6 7
project('phosh', 'c',
          version: '0',
          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'))
12
libexecdir = join_paths(prefix, get_option('libexecdir'))
Guido Gunther's avatar
Guido Gunther committed
13
desktopdir = join_paths(datadir, 'applications')
Guido Gunther's avatar
Guido Gunther committed
14
sessiondir = join_paths(datadir, 'gnome-session')
15 16
pkgdatadir = join_paths(datadir, meson.project_name())

Guido Gunther's avatar
Guido Gunther committed
17 18
config_h = configuration_data()
config_h.set_quoted('GETTEXT_PACKAGE', 'phosh')
Guido Gunther's avatar
Guido Gunther committed
19
config_h.set_quoted('LOCALEDIR', localedir)
Guido Gunther's avatar
Guido Gunther committed
20 21

configure_file(
Guido Gunther's avatar
Guido Gunther committed
22
  input: 'config.h.in',
Guido Gunther's avatar
Guido Gunther committed
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
  output: 'config.h',
  configuration: config_h,
)

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

root_inc = include_directories('.')
src_inc = include_directories('src')

cc = meson.get_compiler('c')

global_c_args = []
test_c_args = [
  '-Wcast-align',
  '-Wdeclaration-after-statement',
  ['-Werror=format-security', '-Werror=format=2'],
  '-Wformat-nonliteral',
  '-Wformat-security',
  '-Wmissing-include-dirs',
  '-Wnested-externs',
  '-Wno-missing-field-initializers',
  '-Wno-sign-compare',
  '-Wno-strict-aliasing',
  '-Wno-uninitialized',
  '-Wno-unused-parameter',
  '-Wpointer-arith',
  '-Wredundant-decls',
  '-Wshadow',
  '-Wswitch-default',
  '-Wswitch-enum',
  '-Wundef',
57
  '-Wmaybe-uninitialized',
Guido Gunther's avatar
Guido Gunther committed
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
]
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'
)

73 74
run_data = configuration_data()
run_data.set('ABS_BUILDDIR', meson.current_build_dir())
75
run_data.set('ABS_SRCDIR', meson.current_source_dir())
76 77 78 79 80
configure_file(
  input: 'run.in',
  output: 'run',
  configuration: run_data)

Guido Gunther's avatar
Guido Gunther committed
81
gnome = import('gnome')
Guido Gunther's avatar
Guido Gunther committed
82
i18n  = import('i18n')
Guido Gunther's avatar
Guido Gunther committed
83

84
subdir('data')
Guido Gunther's avatar
Guido Gunther committed
85 86
subdir('po')
subdir('src')
Guido Gunther's avatar
Guido Gunther committed
87
#subdir('tests')
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115

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
116 117 118 119 120 121 122 123 124 125 126 127

summary = [
  '',
  '-----',
  'Phosh',
  '',
  'Tests: @0@'.format(get_option('tests')),
 '-----',

]

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