1# -*-python-*-
2project('fbida', 'c')
3
4# tweak warnings
5add_global_arguments('-Wno-pointer-sign', language : 'c')
6
7# init configuration
8config       = configuration_data()
9version      = run_command('cat', 'VERSION')
10config.set_quoted('VERSION', version.stdout().strip())
11x11resrun    = run_command('scripts/x11resdir.sh', get_option('prefix'))
12x11resdir    = x11resrun.stdout().strip()
13
14# pkg-config deps
15freetype_dep = dependency('freetype2')
16fontconf_dep = dependency('fontconfig')
17pixman_dep   = dependency('pixman-1')
18poppler_dep  = dependency('poppler-glib')
19cairo_dep    = dependency('cairo')
20cairo_gl_dep = dependency('cairo-gl')
21drm_dep      = dependency('libdrm')
22gbm_dep      = dependency('gbm')
23epoxy_dep    = dependency('epoxy')
24exif_dep     = dependency('libexif')
25png_dep      = dependency('libpng')
26tiff_dep     = dependency('libtiff-4')
27webp_dep     = dependency('libwebp', required : false)
28
29# other library deps
30cc           = meson.get_compiler('c')
31jpeg_dep     = cc.find_library('jpeg')
32math_dep     = cc.find_library('m', required : false)
33pcd_dep      = cc.find_library('pcd', required : false)
34gif_dep      = cc.find_library('gif', required : false)
35
36# motif + x11 libs
37motif_dep    = cc.find_library('Xm', required : false)
38xpm_dep      = cc.find_library('Xpm', required : false)
39xt_dep       = cc.find_library('Xt', required : false)
40xext_dep     = cc.find_library('Xext', required : false)
41x11_dep      = cc.find_library('X11', required : false)
42
43# image formats
44read_srcs    = [ 'readers.c', 'rd/read-ppm.c', 'rd/read-bmp.c',
45                 'rd/read-jpeg.c', 'rd/read-png.c', 'rd/read-tiff.c' ]
46write_srcs   = [ 'writers.c', 'wr/write-ppm.c', 'wr/write-ps.c',
47                 'wr/write-jpeg.c', 'wr/write-png.c', 'wr/write-tiff.c' ]
48image_deps   = [ jpeg_dep, png_dep, tiff_dep,
49                 pcd_dep, gif_dep, webp_dep ]
50
51if pcd_dep.found()
52    read_srcs += 'rd/read-pcd.c'
53    config.set('HAVE_LIBPCD', true)
54endif
55if gif_dep.found()
56    read_srcs += 'rd/read-gif.c'
57    config.set('HAVE_LIBGIF', true)
58endif
59if webp_dep.found()
60    read_srcs += 'rd/read-webp.c'
61    config.set('HAVE_LIBWEBP', true)
62endif
63
64# jpeg transformation support
65jpeg_run     = run_command('scripts/jpeg-version.sh')
66jpeg_ver     = jpeg_run.stdout().strip()
67trans_src    = ''.join(['jpeg/', jpeg_ver,  '/transupp.c'])
68trans_inc    = include_directories(''.join(['jpeg/', jpeg_ver]))
69
70# finish & write configuration
71if cairo_gl_dep.found()
72    config.set('HAVE_CAIRO_GL', true)
73endif
74if motif_dep.found()
75    config.set('HAVE_MOTIF', true)
76endif
77configure_file(output : 'config.h', configuration : config)
78add_global_arguments(['-include', 'config.h'], language : 'c')
79
80########################################################################
81
82# build fbi
83fbi_srcs     = [ 'fbi.c', 'fb-gui.c', 'desktop.c',
84                 'parseconfig.c', 'fbiconfig.c',
85                 'vt.c', 'kbd.c', 'fbtools.c', 'drmtools.c',
86                 'dither.c', 'filter.c', 'op.c', 'jpegtools.c',
87                 trans_src, read_srcs ]
88fbi_deps     = [ freetype_dep, fontconf_dep,
89                 drm_dep, pixman_dep,
90                 exif_dep, image_deps,
91                 math_dep ]
92
93executable('fbi',
94           sources             : fbi_srcs,
95           dependencies        : fbi_deps,
96           include_directories : trans_inc,
97           install             : true)
98install_man('man/fbi.1')
99
100# build exiftran
101exiftr_srcs  = [ 'exiftran.c', 'genthumbnail.c', 'jpegtools.c',
102                 'filter.c', 'op.c', 'readers.c', 'rd/read-jpeg.c',
103                 trans_src ]
104exiftr_deps  = [ jpeg_dep, exif_dep, math_dep, pixman_dep ]
105
106executable('exiftran',
107           sources             : exiftr_srcs,
108           dependencies        : exiftr_deps,
109           include_directories : trans_inc,
110           install             : true)
111install_man('man/exiftran.1')
112
113# build thumbnail.cgi
114executable('thumbnail.cgi',
115           sources             : 'thumbnail.cgi.c',
116           dependencies        : exif_dep)
117
118# build fbpdf
119fbpdf_srcs   = [ 'fbpdf.c', 'parseconfig.c', 'fbiconfig.c',
120                 'vt.c', 'kbd.c', 'fbtools.c', 'drmtools.c', 'drmtools-egl.c' ]
121fbpdf_deps   = [ drm_dep, gbm_dep, epoxy_dep,
122                 pixman_dep, poppler_dep, cairo_dep, cairo_gl_dep ]
123
124executable('fbpdf',
125           sources             : fbpdf_srcs,
126           dependencies        : fbpdf_deps,
127           install             : true)
128
129# build kbdtest
130executable('kbdtest', [ 'kbdtest.c', 'kbd.c' ])
131
132# build ida
133mkfallback   = find_program('scripts/fallback.pl')
134hexify       = find_program('scripts/hexify.sh')
135copy         = find_program('cp')
136ida_ad       = custom_target('ida-app-defaults-fallback',
137                             input   : ['Ida.ad'],
138                             output  : ['Ida.ad.h'],
139                             command : [ mkfallback, '@INPUT@', '@OUTPUT@'])
140ida_logo     = custom_target('ida-logo',
141                             input   : ['logo.jpg'],
142                             output  : ['logo.h'],
143                             command : [ hexify, '@INPUT@', '@OUTPUT@'])
144ida_srcs     = [ 'ida.c', 'man.c', 'hex.c', 'x11.c', 'viewer.c',
145                 'dither.c', 'icons.c', 'parseconfig.c', 'idaconfig.c',
146                 'fileops.c', 'desktop.c', 'RegEdit.c', 'selections.c',
147                 'xdnd.c', 'filebutton.c', 'filelist.c', 'browser.c',
148                 'jpegtools.c', 'op.c', 'filter.c', 'lut.c', 'color.c',
149                 trans_src, read_srcs, write_srcs,
150                 'rd/read-xwd.c', 'rd/read-xpm.c',
151                 ida_ad, ida_logo ]
152ida_deps     = [ pixman_dep, exif_dep, image_deps, math_dep,
153                 motif_dep, xpm_dep, xt_dep, xext_dep, x11_dep ]
154
155if motif_dep.found()
156    executable('ida',
157               sources             : ida_srcs,
158               dependencies        : ida_deps,
159               include_directories : trans_inc,
160               install             : true)
161    install_man('man/ida.1')
162    custom_target('ida-app-defaults',
163                  input   : ['Ida.ad'],
164                  output  : ['Ida'],
165                  command : [ copy, '@INPUT@', '@OUTPUT@'],
166                  install : true, install_dir : x11resdir)
167endif
168