summaryrefslogtreecommitdiff
path: root/meson.build
blob: 84d13d544dcc24a7f0660a5f54673f3077880651 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
83
84
85
86
87
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
116
117
118
119
120
121
122
123
124
125
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
project(
  'eog', 'c',
  version: '3.27.91',
  license: 'GPL2+',
  default_options: 'buildtype=debugoptimized',
  meson_version: '>= 0.43.0'
)

eog_version = meson.project_version()
version_array = eog_version.split('.')
eog_major_version = version_array[0].to_int()
eog_minor_version = version_array[1].to_int()
eog_micro_version = version_array[2].to_int()

eog_api_version = '@0@.0'.format(eog_major_version)
eog_api_name = '@0@-@1@'.format(meson.project_name(), eog_api_version)

eog_gir_ns = 'Eog'
eog_gir_version = '1.0'

eog_prefix = get_option('prefix')
eog_bindir = join_paths(eog_prefix, get_option('bindir'))
eog_datadir = join_paths(eog_prefix, get_option('datadir'))
eog_includedir = join_paths(eog_prefix, get_option('includedir'))
eog_libdir = join_paths(eog_prefix, get_option('libdir'))
eog_libexecdir = join_paths(eog_prefix, get_option('libexecdir'))
eog_localedir = join_paths(eog_prefix, get_option('localedir'))

eog_pkgdatadir = join_paths(eog_datadir, meson.project_name())
eog_pkglibdir = join_paths(eog_libdir, meson.project_name())
eog_pkglibexecdir = join_paths(eog_libexecdir, meson.project_name())

eog_pluginsdir = join_paths(eog_pkglibdir, 'plugins')
eog_schemadir = join_paths(eog_datadir, 'glib-2.0', 'schemas')

eog_debug = get_option('buildtype').contains('debug')

cc = meson.get_compiler('c')

config_h = configuration_data()

# defines
set_defines = [
  # package
  ['PACKAGE', meson.project_name()],
  ['PACKAGE_BUGREPORT', 'http://bugzilla.gnome.org/enter_bug.cgi?product=' + meson.project_name()],
  ['PACKAGE_URL', 'https://wiki.gnome.org/Apps/EyeOfGnome'],
  ['VERSION', eog_version],
  # i18n
  ['GETTEXT_PACKAGE', meson.project_name()]
]

foreach define: set_defines
  config_h.set_quoted(define[0], define[1])
endforeach

# support for nl_langinfo (_NL_MEASUREMENT_MEASUREMENT) (optional)
langinfo_measurement_src = '''
  #include <langinfo.h>
  int main() {
    char c;
    c = *((unsigned char *)  nl_langinfo(_NL_MEASUREMENT_MEASUREMENT));
  };
'''
config_h.set('HAVE__NL_MEASUREMENT_MEASUREMENT', cc.compiles(langinfo_measurement_src),
             description: 'Define if _NL_MEASUREMENT_MEASUREMENT is available')

# support for strptime
config_h.set('HAVE_STRPTIME', cc.has_function('strptime'))

# compiler flags
common_flags = ['-DHAVE_CONFIG_H']

compiler_flags = []
if eog_debug
  test_cflags = [
    '-Werror=format=2',
    '-Werror=implicit-function-declaration',
    '-Werror=init-self',
    '-Werror=missing-include-dirs',
    '-Werror=missing-prototypes',
    '-Werror=pointer-arith',
    '-Werror=return-type',
    '-Wnested-externs',
    '-Wstrict-prototypes'
  ]

  compiler_flags += cc.get_supported_arguments(test_cflags)
endif

add_project_arguments(common_flags + compiler_flags, language: 'c')

ldflag = '-Wl,--version-script'
have_version_script = host_machine.system().contains('linux') and cc.has_argument(ldflag)

glib_req_version = '>= 2.53.4'
peas_req_version = '>= 0.7.4'

eog_deps = [
  dependency('gtk+-3.0', version: '>= 3.22.0'),
  dependency('glib-2.0', version: glib_req_version),
  dependency('gio-2.0', version: glib_req_version),
  dependency('gio-unix-2.0', version: glib_req_version),
  dependency('gnome-desktop-3.0', version: '>= 2.91.2'),
  dependency('gdk-pixbuf-2.0', version: '>= 2.36.5'),
  dependency('gtk+-unix-print-3.0', version: '>= 3.5.4'),
  dependency('shared-mime-info', version: '>= 0.20'),
  dependency('gsettings-desktop-schemas', version: '>= 2.91.92'),
  dependency('libpeas-1.0', version: peas_req_version),
  dependency('libpeas-gtk-1.0', version: peas_req_version),
  cc.find_library('m')
]

# ZLIB support (required)
have_zlib = false
if cc.has_header('zlib.h')
  zlib_dep = cc.find_library('z', required: false)
  have_zlib =  zlib_dep.found() and (cc.has_function('inflate', dependencies: zlib_dep) or cc.has_function('crc32', dependencies: zlib_dep))

  if have_zlib
    eog_deps += zlib_dep
  endif
endif
assert(have_zlib, 'No sufficient zlib library found on your system')

# EXIF (optional)
have_exif = false
if get_option('libexif')
  libexif_dep = dependency('libexif', version: '>= 0.6.14', required: false)
  have_exif = libexif_dep.found() and cc.has_header('libexif/exif-data.h', dependencies: libexif_dep)

  if have_exif
    eog_deps += libexif_dep
    config_h.set10('HAVE_EXIF', true,
                   description: 'EXIF Support.')
  endif
endif

# Little CMS (optional)
have_lcms = false
if get_option('cms')
  libcms_dep = dependency('lcms2', required: false)
  have_lcms = libcms_dep.found()

  if have_lcms
    eog_deps += libcms_dep
    config_h.set10('HAVE_LCMS', true,
                   description: 'Little CMS Support.')
  endif
endif

# Exempi (optional)
have_exempi = false
if get_option('xmp')
  libexempi_dep = dependency('exempi-2.0', version: '>= 1.99.5', required: false)
  have_exempi = libexempi_dep.found()

  if have_exempi
    eog_deps += libexempi_dep
    config_h.set10('HAVE_EXEMPI', true,
                   description: 'XMP Support.')
  endif
endif

# Jpeg (semi-optional)
jpeg_deps = []

have_jpeg = false
have_jpeg_80 = false

if get_option('libjpeg')
  libjpeg_dep = dependency('libjpeg', required: false)
  if libjpeg_dep.found()
    have_jpeg = cc.has_function('jpeg_destroy_decompress', dependencies: libjpeg_dep) and cc.has_header('jpeglib.h', dependencies: libjpeg_dep)

    if have_jpeg
      jpeg_deps += libjpeg_dep

      have_progressive = cc.has_function('jpeg_simple_progression', dependencies: libjpeg_dep)
      if not have_progressive
        message('JPEG library does not support progressive saving.')
      endif

      message('Checking libjpeg version is 8 or greater')
      jpeg_80_check_src = '''
        #include <stdio.h>
        #include <jpeglib.h>
        #if JPEG_LIB_VERSION < 80
        #error "wrong version"
        #endif
      '''
      have_jpeg_80 = cc.compiles(jpeg_80_check_src, dependencies: libjpeg_dep)
    else
      error_msg = '*** JPEG loader will not be built (JPEG header file not found) ***\n'
    endif
  else
    error_msg = '*** JPEG loader will not be built (JPEG library not found) ***\n'
  endif

  if not have_jpeg
    error_msg += '*** You can build without it by passing -Dlibjpeg=false to\n'
    error_msg += '*** meson but some programs using GTK+ may not work properly\n'
    error(error_msg)
  endif

  config_h.set10('HAVE_JPEG', true,
                 description: 'Jpeg Support.')
endif
config_h.set('HAVE_LIBJPEG', have_jpeg,
             description: 'libjpeg is Present.')

# introspection support
have_gir = false
if get_option('introspection')
  gir_dep = dependency('gobject-introspection-1.0', version: '>= 0.6.7', required: false)
  have_gir = gir_dep.found()

  if have_gir
    eog_deps += gir_dep
  endif
endif
config_h.set('HAVE_INTROSPECTION', have_gir)

# RSVG (optional for scaling svg image)
have_rsvg = false
if get_option('librsvg')
  librsvg_dep = dependency('librsvg-2.0', version: '>= 2.36.2', required: false)
  have_rsvg = librsvg_dep.found()

  if have_rsvg
    eog_deps += librsvg_dep
  endif
endif
config_h.set('HAVE_RSVG', have_rsvg,
             description: 'RSVG Support.')

# libX11 (required for TotemScrSaver and Color Profiling)
gdk_dep = dependency('gdk-3.0', required: false)

if have_lcms or (gdk_dep.found() and gdk_dep.get_pkgconfig_variable('targets').contains('x11'))
  libx11_dep = dependency('x11', required: false)
  assert(libx11_dep.found(), 'X development libraries (libX11) not found')
  eog_deps += libx11_dep
endif

gnome = import('gnome')
i18n = import('i18n')
pkg = import('pkgconfig')

data_dir = join_paths(meson.source_root(), 'data')
po_dir = join_paths(meson.source_root(), 'po')

top_inc = include_directories('.')

subdir('data')

if have_jpeg
  subdir('jpegutils')
endif

subdir('src')
subdir('plugins')
subdir('help')

if get_option('gtk_doc')
  subdir('doc/reference')
endif

subdir('po')

if get_option('installed_tests')
  subdir('tests')
endif

configure_file(
  output: 'config.h',
  configuration: config_h
)

meson.add_install_script(
  'meson_post_install.py',
  eog_datadir
)

output = 'Configure summary:\n\n'
output += '  Source code location .......:  ' + meson.source_root() + '\n'
output += '  Compiler ...................:  ' + cc.get_id() + '\n'
output += '  Extra Compiler Warnings ....:  ' + ' '.join(compiler_flags) + '\n'
output += '  EXIF support ...............:  ' + have_exif.to_string() + '\n'
output += '  XMP support ................:  ' + have_exempi.to_string() + '\n'
output += '  JPEG support ...............:  ' + have_jpeg.to_string() + '\n'
output += '  Colour management support ..:  ' + have_lcms.to_string() + '\n'
output += '  GObject Introspection.......:  ' + have_gir.to_string() + '\n'
message(output)