meson.build 3.87 KB
Newer Older
1
project('girara', 'c',
Sebastian Ramacher's avatar
Sebastian Ramacher committed
2
  version: '0.3.3',
3
  meson_version: '>=0.48',
4
  default_options: 'c_std=c11',
5 6
)

7 8
version = meson.project_version()
version_array = version.split('.')
9

10 11 12 13 14 15 16
# Rules for so_major and so_minor:
# Before a release perform the following checks against the last release:
# * If a function has been removed or the paramaters of a function have changed
#   bump SOMAJOR and set SOMINOR to 0.
# * If any of the exported datastructures have changed in a incompatible way
#   bump SOMAJOR and set SOMINOR to 0.
# * If a function has been added bump SOMINOR.
17
so_major = '3'
Sebastian Ramacher's avatar
Sebastian Ramacher committed
18
so_minor = '1'
19 20 21
so_version = '@0@.@1@'.format(so_major, so_minor)

conf_data = configuration_data()
22 23 24
conf_data.set('GVMAJOR', version_array[0])
conf_data.set('GVMINOR', version_array[1])
conf_data.set('GVREV', version_array[2])
25 26
conf_data.set('version', version)

Sebastian Ramacher's avatar
Sebastian Ramacher committed
27
cc = meson.get_compiler('c')
28 29 30 31

prefix = get_option('prefix')
localedir = get_option('localedir')

Sebastian Ramacher's avatar
Sebastian Ramacher committed
32
# required dependencies
33
libm = cc.find_library('m', required: false)
34 35
glib = dependency('glib-2.0', version: '>=2.50')
gtk3 = dependency('gtk+-3.0', version: '>=3.20')
36
pango = dependency('pango', version: '>=1.14')
37

38
build_dependencies = [libm, glib, gtk3, pango]
39 40
pc_requires = ['glib-2.0', 'gtk+-3.0']

41 42 43
# supported functions
has_getpwnam_r = cc.has_function('getpwnam_r', prefix: '#define _DEFAULT_SOURCE\n#include <sys/types.h>\n#include <pwd.h>')

Sebastian Ramacher's avatar
Sebastian Ramacher committed
44
# defines
45 46
defines = [
  '-DGETTEXT_PACKAGE="libgirara-gtk3-@0@"'.format(so_major),
Sebastian Ramacher's avatar
Sebastian Ramacher committed
47 48
  '-DLOCALEDIR="@0@"'.format(join_paths(prefix, localedir)),
  '-D_DEFAULT_SOURCE',
49 50
]

51 52 53 54
if has_getpwnam_r
  defines += ['-DHAVE_GETPWNAM_R']
endif

Sebastian Ramacher's avatar
Sebastian Ramacher committed
55
# compile flags
56 57 58 59 60
flags = [
  '-Wall',
  '-Wextra',
  '-pedantic',
  '-Wmissing-declarations',
Sebastian Ramacher's avatar
Sebastian Ramacher committed
61
  '-Werror=implicit-function-declaration',
62
  '-Werror=vla'
63 64 65
]
flags = cc.get_supported_arguments(flags)

Sebastian Ramacher's avatar
Sebastian Ramacher committed
66
# optional dependencies
67
pc_requires_private = ['pango']
68 69
libnotify = dependency('libnotify', version: '>=0.7.0', required: get_option('notify'))
jsonc = dependency('json-c', required: get_option('json'))
Sebastian Ramacher's avatar
Sebastian Ramacher committed
70

71
if libnotify.found()
72 73 74
  build_dependencies += libnotify
  defines += '-DWITH_LIBNOTIFY'
  pc_requires_private += 'libnotify'
75 76
endif

77
if jsonc.found()
78
  build_dependencies += jsonc
79
  defines += '-DWITH_JSON'
80
  pc_requires_private += 'json-c'
81 82
endif

Sebastian Ramacher's avatar
Sebastian Ramacher committed
83
# generate version header file
84 85
version_header = configure_file(
  input: 'girara/version.h.in',
86
  output: 'girara-version.h',
87 88 89 90 91 92 93 94 95
  configuration: conf_data
)
include_directories = [
  include_directories('.')
]

subdir('data')
subdir('po')

Sebastian Ramacher's avatar
Sebastian Ramacher committed
96
# source files
97 98 99
sources = files(
  'girara/callbacks.c',
  'girara/commands.c',
Sebastian Ramacher's avatar
Sebastian Ramacher committed
100
  'girara/completion.c',
101 102
  'girara/config.c',
  'girara/datastructures.c',
Sebastian Ramacher's avatar
Sebastian Ramacher committed
103 104
  'girara/entry.c',
  'girara/input-history-io.c',
105 106
  'girara/input-history.c',
  'girara/log.c',
Sebastian Ramacher's avatar
Sebastian Ramacher committed
107
  'girara/session.c',
108
  'girara/settings.c',
Sebastian Ramacher's avatar
Sebastian Ramacher committed
109
  'girara/shortcuts.c',
110
  'girara/statusbar.c',
Sebastian Ramacher's avatar
Sebastian Ramacher committed
111
  'girara/template.c',
112 113 114 115
  'girara/utils.c'
)
sources += girara_css

Sebastian Ramacher's avatar
Sebastian Ramacher committed
116
# header files to install
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
headers = files(
  'girara/callbacks.h',
  'girara/commands.h',
  'girara/completion.h',
  'girara/config.h',
  'girara/datastructures.h',
  'girara/entry.h',
  'girara/girara.h',
  'girara/input-history.h',
  'girara/log.h',
  'girara/macros.h',
  'girara/session.h',
  'girara/settings.h',
  'girara/shortcuts.h',
  'girara/statusbar.h',
  'girara/template.h',
  'girara/types.h',
  'girara/utils.h'
)
headers += version_header

Sebastian Ramacher's avatar
Sebastian Ramacher committed
138
# girara library
139 140 141 142
girara = library(
  'girara-gtk3',
  sources,
  dependencies: build_dependencies,
Sebastian Ramacher's avatar
Sebastian Ramacher committed
143
  version: so_version,
144 145
  install: true,
  include_directories: include_directories,
146 147
  c_args: defines + flags,
  gnu_symbol_visibility: 'hidden'
148 149 150
)
install_headers(headers, subdir: 'girara')

Sebastian Ramacher's avatar
Sebastian Ramacher committed
151
# pkg-config file
152 153 154 155 156 157 158
pkg = import('pkgconfig')
pkg.generate(
  name: 'girara-gtk3',
  description: 'User interface library',
  url: 'https://pwmt.org/projects/girara',
  version: version,
  libraries: girara,
Sebastian Ramacher's avatar
Sebastian Ramacher committed
159 160
  requires: pc_requires,
  requires_private: pc_requires_private,
161 162
)

163
subdir('doc')
164
subdir('tests')