733107a72f0a80d3fa463e968eb957559f28a706
[geeqie.git] / meson.build
1 # This file is a part of Geeqie project (https://www.geeqie.org/).
2 # Copyright (C) 2008 - 2022 The Geeqie Team
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13
14 # Meson default directories used in this project:
15 # prefix - /usr/local
16 # bindir - bin
17 # datadir - share
18
19 # Meson core options:
20 # buildtype
21 # debug
22
23 # Project expanded default directories:
24 # prefix        /usr/local/
25 # bindir        /usr/local/bin                          geeqie executable
26 # gq_bindir     /usr/local/lib/geeqie               *   plugins scripts
27 # datadir       /usr/local/share/
28 #               /usr/local/share/applications           geeqie.desktop
29 # [gq_]appdir   /usr/local/share/geeqie/            *   template.desktop
30 # desktopdir    /usr/local/share/geeqie/applications    plugin desktop files
31 # appdatadir    /usr/local/share/metainfo               org.geeqie.Geeqie.appdata.xml
32 # icondir       /usr/local/share/pixmaps                geeqie.png icon
33 # [gq_]helpdir  /usr/local/share/doc/geeqie         *   readme files etc.
34 # [gq_]htmldir  /usr/local/share/doc/geeqie/html    *   help files
35 # gq_localedir  /usr/locale/share/locale
36 # mandir1       /usr/local/share/man/man1               man page
37 # podir         project_root/po
38
39 # * See meson_options.txt file
40
41 project(
42     'geeqie',
43     'c',
44     'cpp',
45     version : run_command('./version.sh', check : true).stdout().strip(),
46     license : ['GPL-2.0-or-later'],
47     meson_version : '>= 0.60.0',
48     default_options : ['warning_level=3', 'buildtype=debugoptimized']
49 )
50
51 # To inhibit warnings from the generated files icons_inline.h and ui_icons.h
52 add_global_arguments('-Wno-overlength-strings', language : 'c')
53
54 # Project requirements
55 project_sources = []
56 gnome = import('gnome')
57 thread_dep = dependency('threads')
58 cc = meson.get_compiler('c')
59 i18n = import('i18n')
60 configuration_inc = include_directories('.')
61
62 # External programs
63 gdk_pixbuf_csource = find_program('gdk-pixbuf-csource', required : true)
64 glib_genmarshal = find_program('glib-genmarshal', required : true)
65 gnome_doc_tool = find_program('yelp-build', required : false)
66 if not gnome_doc_tool.found()
67     message('yelp-build not found. Help files not created.')
68 endif
69
70 debug = get_option('debug')
71
72 # Note that main.c sets prefix to the directory above where the executable is run from.
73 # This is to allow AppImages to be used
74
75 # These gq_* variables are paths relative to /prefix/,
76 # and are also used in defines in the source as GQ_*
77 if get_option('gq_appdir') == ''
78     gq_appdir = join_paths(get_option('datadir'), 'geeqie')
79 else
80     gq_appdir = get_option('gq_appdir')
81 endif
82
83 # This is not the same as Meson bindir
84 if get_option('gq_bindir') == ''
85     gq_bindir = 'lib/geeqie'
86 else
87     gq_bindir = get_option('gq_bindir')
88 endif
89
90 if get_option('gq_helpdir') == ''
91     gq_helpdir = join_paths(get_option('datadir'), 'doc/geeqie')
92 else
93     gq_helpdir = get_option('gq_helpdir')
94 endif
95
96 if get_option('gq_htmldir') == ''
97     gq_htmldir = join_paths(get_option('datadir'), 'doc/geeqie/html')
98 else
99     gq_htmldir = get_option('gq_htmldir')
100 endif
101
102 if get_option('gq_localedir') == ''
103     gq_localedir = join_paths(get_option('datadir'), 'locale')
104 else
105     gq_localedir = get_option('gq_localedir')
106 endif
107
108
109 # Set up the absolute directory paths used
110 prefix = get_option('prefix')
111 datadir = join_paths(prefix, get_option('datadir'))
112
113 # Installation paths are absolute
114 appdir = join_paths(prefix, gq_appdir)
115 appdatadir = join_paths(datadir, 'metainfo')
116 desktopdir = join_paths(datadir, meson.project_name(), 'applications')
117 helpdir = join_paths(prefix, gq_helpdir)
118 htmldir = join_paths(prefix, gq_htmldir)
119 icondir = join_paths(datadir, 'pixmaps')
120 mandir1 = join_paths(datadir, 'man', 'man1')
121
122 podir = join_paths(meson.project_source_root(), 'po')
123
124 # Create the define constants used in the sources. Set via config.h.in
125 conf_data = configuration_data()
126 conf_data.set_quoted('VERSION', run_command('./version.sh', check : true).stdout())
127 conf_data.set('DEBUG', debug)
128
129 gtk_dep = dependency('gtk+-3.0', version : '>=3.22', required: true)
130 glib_dep = dependency('glib-2.0', version: '>=2.52', required: true)
131
132 libarchive_dep = []
133 libarchive_dep = dependency('libarchive', version: '>=3.4.0', required : get_option('archive'))
134 if libarchive_dep.found()
135     conf_data.set('HAVE_ARCHIVE', 1)
136 endif
137
138 lcms_dep = []
139 lcms_dep = dependency('lcms2', version: '>=2.0', required : get_option('cms'))
140 if lcms_dep.found()
141     conf_data.set('HAVE_LCMS', 1)
142     conf_data.set('HAVE_LCMS2', 1)
143 endif
144
145 ddjvuapi_dep = []
146 ddjvuapi_dep = dependency('ddjvuapi', version: '>=3.5.27', required : get_option('djvu'))
147 if ddjvuapi_dep.found()
148     conf_data.set('HAVE_DJVU', 1)
149 endif
150
151 exiv2_dep = []
152 exiv2_dep = dependency('exiv2', version: '>=0.11', required : get_option('exiv2'))
153 if exiv2_dep.found()
154     conf_data.set('HAVE_EXIV2', 1)
155 endif
156
157 libffmpegthumbnailer_dep = []
158 libffmpegthumbnailer_dep = dependency('libffmpegthumbnailer',
159     version: '>=2.1.0',
160     required : get_option('ffmpegthumbnailer'))
161
162 if libffmpegthumbnailer_dep.found()
163     conf_data.set('HAVE_FFMPEGTHUMBNAILER', 1)
164
165     if cc.has_member('struct video_thumbnailer_struct', 'prefer_embedded_metadata',
166         prefix : '#include <libffmpegthumbnailer/videothumbnailerc.h>')
167
168         conf_data.set('HAVE_FFMPEGTHUMBNAILER_METADATA', 1)
169     endif
170
171     if cc.has_member('struct image_data_struct', 'image_data_width',
172         prefix : '#include <libffmpegthumbnailer/videothumbnailerc.h>' )
173
174         conf_data.set('HAVE_FFMPEGTHUMBNAILER_RGB', 1)
175     endif
176
177     if cc.has_function('video_thumbnailer_set_size',
178         dependencies : libffmpegthumbnailer_dep)
179
180         conf_data.set('HAVE_FFMPEGTHUMBNAILER_WH', 1)
181     endif 
182 endif
183
184 champlain_dep = []
185 champlain_gtk_dep = []
186 champlain_dep = dependency('champlain-0.12', version: '>=0.12', required : get_option('gps-map'))
187 champlain_gtk_dep = dependency('champlain-gtk-0.12', version: '>=0.12', required : get_option('gps-map'))
188 if champlain_dep.found() and champlain_gtk_dep.found()
189     clutter_dep = []
190     clutter_gtk_dep = []
191     clutter_dep = dependency('clutter-1.0', required : true)
192     clutter_gtk_dep = dependency('clutter-gtk-1.0', required : true)
193     if clutter_dep.found() and clutter_gtk_dep.found()
194         conf_data.set('HAVE_CLUTTER', 1)
195         conf_data.set('HAVE_LIBCHAMPLAIN', 1)
196         conf_data.set('HAVE_LIBCHAMPLAIN_GTK', 1)
197     endif
198 endif
199
200 libheif_dep = []
201 libheif_dep = dependency('libheif', version: '>=1.3.2', required : get_option('heif'))
202 if libheif_dep.found()
203     conf_data.set('HAVE_HEIF', 1)
204 endif
205
206 libopenjp2_dep = []
207 libopenjp2_dep = dependency('libopenjp2', version: '>=2.3.0', required : get_option('j2k'))
208 if libopenjp2_dep.found()
209     conf_data.set('HAVE_J2K', 1)
210 endif
211
212 libjpeg_dep = []
213 libjpeg_dep = dependency('libjpeg', required : get_option('jpeg'))
214 if libjpeg_dep.found()
215     if cc.has_function('jpeg_destroy_decompress',
216         dependencies : libjpeg_dep)
217
218         conf_data.set('HAVE_JPEG', 1)
219     endif
220 endif
221
222 libjxl_dep = []
223 libjxl_dep = dependency('libjxl', version: '>=0.3.7', required : get_option('jpegxl'))
224 if libjxl_dep.found()
225     conf_data.set('HAVE_JPEGXL', 1)
226 endif
227
228 libraw_dep = []
229 libraw_dep = dependency('libraw', version: '>=0.20', required : get_option('libraw'))
230 if libraw_dep.found()
231     conf_data.set('HAVE_RAW', 1)
232 endif
233
234 lua_dep = []
235 lua_dep = dependency('lua5.1', required : get_option('lua'))
236 if lua_dep.found()
237     conf_data.set('HAVE_LUA', 1)
238 endif
239
240 poppler_glib_dep = []
241 poppler_glib_dep = dependency('poppler-glib', version: '>=0.62', required : get_option('pdf'))
242 if poppler_glib_dep.found()
243     conf_data.set('HAVE_PDF', 1)
244 endif
245
246 gspell_dep = []
247 gspell_dep = dependency('gspell-1', required: get_option('spell'))
248 if gspell_dep.found()
249     conf_data.set('HAVE_SPELL', 1)
250 endif
251
252 tiff_dep = []
253 tiff_dep = cc.find_library('tiff', required: get_option('tiff'))
254 if tiff_dep.found()
255     if cc.has_function('TIFFClientOpen',
256         dependencies : tiff_dep)
257
258         conf_data.set('HAVE_TIFF', 1)
259     endif
260 endif
261
262 libwebp_dep = []
263     libwebp_dep = dependency('libwebp', version: '>=0.6.1', required : get_option('webp'))
264     if libwebp_dep.found()
265         conf_data.set('HAVE_WEBP', 1)
266     endif
267
268 # Check for nl_langinfo and _NL_TIME_FIRST_WEEKDAY
269 code = '''#include <langinfo.h>
270 #include<stdio.h>
271 int main (int argc, char ** argv) {
272     char *c;
273     c =  nl_langinfo(_NL_TIME_FIRST_WEEKDAY);
274     return 0;
275 }'''
276 if cc.links(code, name : 'nl_langinfo and _NL_TIME_FIRST_WEEKDAY')
277     conf_data.set('HAVE__NL_TIME_FIRST_WEEKDAY', 1)
278 endif
279
280 conf_data.set_quoted('GETTEXT_PACKAGE', meson.project_name())
281 conf_data.set_quoted('GQ_APPDIR', gq_appdir)
282 conf_data.set_quoted('GQ_BINDIR', gq_bindir)
283 conf_data.set_quoted('GQ_HELPDIR', gq_helpdir)
284 conf_data.set_quoted('GQ_HTMLDIR', gq_htmldir)
285 conf_data.set_quoted('GQ_LOCALEDIR', gq_localedir)
286
287 conf_data.set_quoted('PACKAGE', meson.project_name())
288 conf_data.set_quoted('PACKAGE_NAME', meson.project_name())
289 conf_data.set_quoted('PACKAGE_STRING', meson.project_version())
290 conf_data.set_quoted('PACKAGE_TARNAME', meson.project_name())
291 conf_data.set_quoted('PACKAGE_VERSION', meson.project_version())
292 conf_data.set_quoted('VERSION', meson.project_version())
293
294 configure_file(input : 'config.h.in',
295                output : 'config.h',
296                encoding : 'UTF-8',
297                configuration : conf_data)
298
299 # Process subdirs before the sources
300 subdir('po')
301 subdir('plugins')
302
303 # Generate the executable and the help files
304 subdir('src')
305 subdir('doc')
306
307 # Install other project files
308 run_command(find_program('gen_changelog.sh'), meson.project_source_root(), meson.project_build_root(), check : true)
309
310 run_command(find_program('gen_readme.sh'), meson.project_source_root(), meson.project_build_root(), check : true)
311
312 pandoc = find_program('pandoc')
313 if pandoc.found()
314     install_data('README.md', 'COPYING', join_paths(meson.project_build_root(), 'ChangeLog'), 'TODO', 'AUTHORS', join_paths(meson.project_build_root(), 'README.html'), join_paths(meson.project_build_root(), 'ChangeLog.html'), install_dir : helpdir, install_tag : 'help')
315 else
316     install_data('README.md', 'COPYING', join_paths(meson.project_build_root(), 'ChangeLog'), 'TODO', 'README.lirc', 'AUTHORS', install_dir : helpdir, install_tag : 'help')
317 endif
318
319 install_data('geeqie.png', install_dir : icondir, install_tag : 'icons')
320 install_data('geeqie.1', install_dir : mandir1, install_tag : 'man')
321
322 i18n.merge_file(
323     input : 'geeqie.desktop.in',
324     output : 'geeqie.desktop',
325     type : 'desktop',
326     po_dir : podir,
327     install : true,
328     install_dir : join_paths(datadir, 'applications'))
329
330 i18n.merge_file(
331     input : 'org.geeqie.Geeqie.appdata.xml.in',
332     output : 'org.geeqie.Geeqie.appdata.xml',
333     type : 'xml',
334     po_dir : podir,
335     install : true,
336     install_dir : appdatadir)
337
338 configure_file(input: 'geeqie.spec.in', output: 'geeqie.spec', configuration: conf_data)