Replace functions which called once with their bodies
[pidgin-git.git] / finch / meson.build
blob05ea4fbd13efe091c4a7987473aec4dd4b164cff
1 enable_consoleui = false
2 if get_option('consoleui')
3         libgnt_dep = dependency('gnt3', version : '>= 3.0.0', required : false)
4         if libgnt_dep.found()
5                 if enable_introspection
6                         libgnt_gir = ['Gnt-3.0']
7                 endif
8         else
9                 libgnt_proj = subproject('libgnt',
10                     default_options : [
11                         'doc=' + get_option('doc').to_string(),
12                         'introspection=' + enable_introspection.to_string(),
13                     ]
14                 )
15                 libgnt_dep = libgnt_proj.get_variable('libgnt_dep')
17                 if enable_introspection
18                         libgnt_gir = libgnt_proj.get_variable('libgnt_gir')
19                 endif
20         endif
22         #######################################################################
23         # Check for ncurses and other things used by it
24         # FIXME: This should be temporary until libgnt wraps the functionality.
25         #######################################################################
26         ncurses_available = true
27         ncurses_header = 'ncurses.h'
28         # Some distros put the headers in ncursesw/, some don't. These are ordered to
29         # pick the last available as most-specific version.
30         ncursesw_header_paths = ['', 'ncursesw/']
32         ncurses = dependency('ncursesw', required : false)
33         if ncurses.found()
34                 foreach location : ncursesw_header_paths
35                         f = location + 'ncurses.h'
36                         if compiler.has_header_symbol(f, 'get_wch',
37                             prefix : '#define _XOPEN_SOURCE_EXTENDED')
38                                 ncurses_header = f
39                         endif
40                 endforeach
41         else
42                 ncurses_available = false
43                 ncurses_inc = []
44                 ncurses_libs = compiler.find_library('ncursesw', required : false)
45                 if ncurses_libs.found()
46                         foreach location : ncursesw_header_paths
47                                 f = location + 'ncurses.h'
48                                 if compiler.has_header_symbol(f, 'get_wch',
49                                     prefix : '#define _XOPEN_SOURCE_EXTENDED')
50                                         ncurses_available = true
51                                         ncurses_header = f
52                                 endif
53                         endforeach
55                         if ncurses_available
56                                 ncurses = declare_dependency(
57                                     include_directories : ncurses_inc,
58                                     dependencies : ncurses_libs
59                                 )
60                         endif
61                 endif
62         endif
64         if not ncurses_available
65                 # ncursesw was not found. Look for plain old ncurses
66                 ncurses = dependency('ncurses', required : false)
67                 if ncurses.found()
68                         ncurses_available = true
69                 else
70                         ncurses_libs = compiler.find_library('ncurses', required : false)
71                         ncurses_available = ncurses_libs.found()
72                         ncurses = declare_dependency(dependencies : ncurses_libs)
73                 endif
74         endif
76         if not ncurses_available and host_machine.system() == 'windows'
77                 # Try pdcurses too.
78                 ncurses_header = 'curses.h'
79                 ncurses_libs = compiler.find_library('pdcurses', required : false)
80                 ncurses_available = compiler.has_header(ncurses_header) and ncurses_libs.found()
81                 ncurses = declare_dependency(dependencies : ncurses_libs)
82         endif
84         if not ncurses_available
85                 error('ncurses could not be found!')
86         endif
88         if libgnt_dep.found() and ncurses_available
89                 ncurses_header = '-DNCURSES_HEADER="@0@"'.format(ncurses_header)
90                 enable_consoleui = true
91         else
92                 error('''
94 Finch will not be built. You need to install libgnt (or its requirements) and its development headers.
96 ''')
97         endif
98 endif
101 libfinch_SOURCES = [
102         'gntaccount.c',
103         'gntblist.c',
104         'gntconn.c',
105         'gntconv.c',
106         'gntdebug.c',
107         'gntidle.c',
108         'gntlog.c',
109         'gntmedia.c',
110         'gntmenuutil.c',
111         'gntnotify.c',
112         'gntplugin.c',
113         'gntpounce.c',
114         'gntprefs.c',
115         'gntrequest.c',
116         'gntroomlist.c',
117         'gntsound.c',
118         'gntstatus.c',
119         'gntui.c',
120         'gntxfer.c',
121         package_revision,
122         'libfinch.c'
125 libfinch_headers = [
126         'gntaccount.h',
127         'gntblist.h',
128         'gntconn.h',
129         'gntconv.h',
130         'gntdebug.h',
131         'finch.h',
132         'gntidle.h',
133         'gntlog.h',
134         'gntmedia.h',
135         'gntmenuutil.h',
136         'gntnotify.h',
137         'gntplugin.h',
138         'gntpounce.h',
139         'gntprefs.h',
140         'gntrequest.h',
141         'gntroomlist.h',
142         'gntsound.h',
143         'gntstatus.h',
144         'gntui.h',
145         'gntxfer.h'
148 finch_SOURCES = [
149         'finch.c'
152 if IS_WIN32
153         winmm = compiler.find_library('winmm')
155         finch_winres = configure_file(
156             input : 'finch_winres.rc.in',
157             output : 'finch_winres.rc',
158             configuration : version_conf)
159         finch_SOURCES += windows.compile_resources(finch_winres)
160         libfinch_winres = configure_file(
161             input : 'libfinch_winres.rc.in',
162             output : 'libfinch_winres.rc',
163             configuration : version_conf)
164         libfinch_SOURCES += windows.compile_resources(libfinch_winres)
165 else
166         winmm = []
167 endif
169 if enable_consoleui
170         install_headers(libfinch_headers, subdir : 'finch-3')
172         libfinch_inc = include_directories('.')
173         libfinch = shared_library('finch3',
174             libfinch_SOURCES,
175             c_args : ['-DSTANDALONE', '-DGNTSEAL_ENABLE', ncurses_header],
176             include_directories : [toplevel_inc],
177             version : PURPLE_LIB_VERSION,
178             dependencies : [libpurple_dep, libgnt_dep, ncurses, glib, winmm],
179             install : true)
180         libfinch_dep = declare_dependency(
181             include_directories : [toplevel_inc, libfinch_inc],
182             link_with : libfinch,
183             dependencies : [libpurple_dep, libgnt_dep, glib])
185         finch = executable('finch3',
186             finch_SOURCES,
187             c_args : ['-DSTANDALONE', '-DGNTSEAL_ENABLE'],
188             dependencies : [libpurple_dep, libgnt_dep, libfinch_dep],
189             install : true)
191         pkgconfig.generate(
192             name : 'Finch',
193             description : 'Finch is an instant messenger application that uses libpurple for protocol support and ncurses (libgnt) for the UI.',
194             version : meson.project_version(),
195             filebase : 'finch-3',
196             subdirs : 'finch-3',
197             libraries : [libfinch],
198             requires : ['gnt', 'purple-3'],
199             variables : ['plugindir=${libdir}/finch-@0@'.format(purple_major_version)])
201         if enable_introspection
202                 introspection_sources = libfinch_headers
204                 gnome.generate_gir(libfinch,
205                     sources : introspection_sources,
206                     includes : [libgnt_gir[0], libpurple_gir[0], gplugin_gir],
207                     namespace : 'Finch',
208                     symbol_prefix : 'finch',
209                     identifier_prefix : 'Finch',
210                     export_packages : 'finch',
211                     nsversion : '@0@.@1@'.format(purple_major_version,
212                                                  purple_minor_version),
213                     include_directories : [
214                         gplugin_include_directories,
215                     ],
216                     install : true,
217                     extra_args : ['--quiet'])
218         endif
220         subdir('plugins')
221 endif  # enable_consoleui