meson.build 6.96 KB
Newer Older
1
project('gnome-software', 'c',
Richard Hughes's avatar
Richard Hughes committed
2
  version : '3.34.0',
3
  license : 'GPL-2.0+',
4
  default_options : ['warning_level=1', 'c_std=c99'],
5
  meson_version : '>=0.46.0'
6 7 8
)

conf = configuration_data()
9 10 11
conf.set_quoted('VERSION', meson.project_version())
conf.set_quoted('PACKAGE_NAME', meson.project_name())
conf.set_quoted('PACKAGE_VERSION', meson.project_version())
12 13 14

# this refers to the gnome-software plugin API version
# this is not in any way related to a package or soname version
15
gs_plugin_api_version = '13'
Iain Lane's avatar
Iain Lane committed
16
conf.set_quoted('GS_PLUGIN_API_VERSION', gs_plugin_api_version)
17 18

# install docs
19
install_data('README.md', install_dir : 'share/doc/gnome-software')
20

21
# get supported warning flags
22 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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
test_args = [
  '-fstack-protector-strong',
  '-Waggregate-return',
  '-Warray-bounds',
  '-Wcast-align',
  '-Wclobbered',
  '-Wdeclaration-after-statement',
  '-Wempty-body',
  '-Wextra',
  '-Wformat=2',
  '-Wformat-nonliteral',
  '-Wformat-security',
  '-Wformat-signedness',
  '-Wignored-qualifiers',
  '-Wimplicit-function-declaration',
  '-Winit-self',
  '-Winline',
  '-Wmissing-declarations',
  '-Wmissing-format-attribute',
  '-Wmissing-include-dirs',
  '-Wmissing-noreturn',
  '-Wmissing-parameter-type',
  '-Wmissing-prototypes',
  '-Wnested-externs',
  '-Wno-discarded-qualifiers',
  '-Wno-missing-field-initializers',
  '-Wno-strict-aliasing',
  '-Wno-suggest-attribute=format',
  '-Wno-unused-parameter',
  '-Wold-style-definition',
  '-Woverride-init',
  '-Wpacked',
  '-Wpointer-arith',
  '-Wredundant-decls',
  '-Wreturn-type',
  '-Wshadow',
  '-Wsign-compare',
  '-Wstrict-aliasing',
  '-Wstrict-prototypes',
  '-Wswitch-default',
  '-Wtype-limits',
  '-Wundef',
  '-Wuninitialized',
  '-Wunused-but-set-variable',
  '-Wwrite-strings'
]
cc = meson.get_compiler('c')
foreach arg: test_args
  if cc.has_argument(arg)
    add_project_arguments(arg, language : 'c')
  endif
endforeach

# enable full RELRO where possible
# FIXME: until https://github.com/mesonbuild/meson/issues/1140 is fixed
global_link_args = []
test_link_args = [
  '-Wl,-z,relro',
  '-Wl,-z,now',
]
foreach arg: test_link_args
83
  if cc.has_link_argument(arg)
84 85 86 87 88 89 90 91
    global_link_args += arg
  endif
endforeach
add_global_link_arguments(
  global_link_args,
  language: 'c'
)

92
# Needed for PATH_MAX and symlink()
93
add_project_arguments('-D_XOPEN_SOURCE=700', language : 'c')
94 95
# Needed for syscall()
add_project_arguments('-D_GNU_SOURCE', language : 'c')
96

97 98
conf.set('HAVE_LINUX_UNISTD_H', cc.has_header('linux/unistd.h'))

99
appstream_glib = dependency('appstream-glib', version : '>= 0.7.14')
100
gdk_pixbuf = dependency('gdk-pixbuf-2.0', version : '>= 2.32.0')
101
libxmlb = dependency('xmlb', version : '>= 0.1.7', fallback : ['libxmlb', 'libxmlb_dep'])
102
gio_unix = dependency('gio-unix-2.0', version : '>= 2.56.0')
103
gmodule = dependency('gmodule-2.0')
104
goa = dependency('goa-1.0')
105
gtk = dependency('gtk+-3.0', version : '>= 3.22.4')
106
json_glib = dependency('json-glib-1.0', version : '>= 1.2.0')
107
libm = cc.find_library('m', required: false)
108
libsoup = dependency('libsoup-2.4', version : '>= 2.52.0')
109

110 111 112 113 114
if get_option('mogwai')
  mogwai_schedule_client = dependency('mogwai-schedule-client-0', version : '>= 0.2.0')
  conf.set('HAVE_MOGWAI', 1)
endif

115
if get_option('valgrind')
116 117 118 119 120 121 122 123 124
  message(meson.version())
  # urgh, meson is broken
  if meson.version().version_compare('>0.41.0')
    valgrind = dependency('valgrind')
    conf.set('USE_VALGRIND', 1)
  else
    message('Valgrind integration disabled to work around a meson bug')
    valgrind = []
  endif
125 126 127 128
else
  message('Valgrind integration disabled')
  valgrind = []
endif
129

130
if get_option('gnome_desktop')
131
  gnome_desktop = dependency('gnome-desktop-3.0', version : '>= 3.18.0')
132
  conf.set('HAVE_GNOME_DESKTOP', 1)
133 134
endif

135
if get_option('gspell')
136 137
  gspell = dependency('gspell-1')
  conf.set('HAVE_GSPELL', 1)
138 139
endif

140
if get_option('polkit')
141
  polkit = dependency('polkit-gobject-1')
142
  conf.set('HAVE_POLKIT', 1)
143 144
endif

145
if get_option('packagekit')
146 147 148 149
  packagekit = dependency('packagekit-glib2', version : '>= 1.1.0')
  conf.set('HAVE_PACKAGEKIT', '1')
  add_project_arguments('-DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE',
                        language : 'c')
150
  if get_option('packagekit_autoremove')
151 152 153 154
      conf.set('GS_PACKAGEKIT_AUTOREMOVE', 'TRUE')
  else
      conf.set('GS_PACKAGEKIT_AUTOREMOVE', 'FALSE')
  endif
155 156
endif

157 158 159 160
if get_option('eos_updater')
  ostree = dependency('ostree-1')
endif

161
if get_option('fwupd')
162
  fwupd = dependency('fwupd', version : '>= 1.0.3')
163 164
endif

165
if get_option('flatpak')
166
  flatpak = dependency('flatpak', version : '>= 1.0.4')
167 168
endif

169
if get_option('rpm_ostree')
170
  libdnf = dependency('libdnf')
171
  ostree = dependency('ostree-1')
172
  rpm = dependency('rpm')
173
  rpm_ostree = dependency('rpm-ostree-1', version : '>= 2019.3')
174 175
endif

176
if get_option('gudev')
177 178 179
  gudev = dependency('gudev-1.0')
endif

180
if get_option('snap')
181
  snap = dependency('snapd-glib', version : '>= 1.49')
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
endif

gnome = import('gnome')
i18n = import('i18n')

conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
conf.set_quoted('LOCALEDIR',
                join_paths(get_option('prefix'),
                           get_option('localedir')))
conf.set_quoted('DATADIR',
                join_paths(get_option('prefix'),
                           get_option('datadir')))
conf.set_quoted('LIBDIR',
                join_paths(get_option('prefix'),
                           get_option('libdir')))
197 198 199
conf.set_quoted('BINDIR',
                join_paths(get_option('prefix'),
                           get_option('bindir')))
200 201 202
conf.set_quoted('SYSCONFDIR',
                join_paths(get_option('prefix'),
                           get_option('sysconfdir')))
203 204 205
conf.set_quoted('LOCALSTATEDIR',
                join_paths(get_option('prefix'),
                           get_option('localstatedir')))
206 207 208
conf.set_quoted('LIBEXECDIR',
                join_paths(get_option('prefix'),
                           get_option('libexecdir')))
209 210 211 212 213 214 215 216
configure_file(
  output : 'config.h',
  configuration : conf
)

add_project_arguments('-DI_KNOW_THE_GNOME_SOFTWARE_API_IS_SUBJECT_TO_CHANGE',
                      language : 'c')

217 218 219 220 221 222 223 224 225
test_env = [
  'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
  'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
  'GSETTINGS_SCHEMA_DIR=@0@/data/'.format(meson.build_root()),
  'GSETTINGS_BACKEND=memory',
  'MALLOC_CHECK_=2',
]

subdir('data')
226 227
subdir('lib')
subdir('plugins')
228 229 230 231
subdir('src')
subdir('po')
subdir('doc')

232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
if meson.version().version_compare('<0.41.0')
  archiver = find_program('git', required : false)
  if archiver.found()
    run_target('dist',
      # git config tar.tar.xz.command "xz -c"
      command: [
        'git', 'archive',
        '--prefix=' + meson.project_name() + '-' + meson.project_version() + '/',
        'HEAD',
        '--format=tar.xz',
        '--output',
        meson.project_name() + '-' + meson.project_version() + '.tar.xz'
      ]
    )
  else
    message('git not found, you will not be able to run `ninja dist`')
  endif
249 250 251 252
endif

# FIXME: remove when https://github.com/mesonbuild/meson/issues/837 fixed
meson.add_install_script('meson_post_install.sh')