Work around strange build error on Ubuntu 18.04
[dcpomatic.git] / src / wx / wscript
1 #
2 #    Copyright (C) 2012-2022 Carl Hetherington <cth@carlh.net>
3 #
4 #    This file is part of DCP-o-matic.
5 #
6 #    DCP-o-matic is free software; you can redistribute it and/or modify
7 #    it under the terms of the GNU General Public License as published by
8 #    the Free Software Foundation; either version 2 of the License, or
9 #    (at your option) any later version.
10 #
11 #    DCP-o-matic is distributed in the hope that it will be useful,
12 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #    GNU General Public License for more details.
15 #
16 #    You should have received a copy of the GNU General Public License
17 #    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18 #
19
20 import os
21 import subprocess
22 import shlex
23 import glob
24 from waflib import Logs
25 import i18n
26
27 sources = """
28           about_dialog.cc
29           audio_dialog.cc
30           audio_gain_dialog.cc
31           audio_mapping_view.cc
32           audio_panel.cc
33           audio_plot.cc
34           auto_crop_dialog.cc
35           barco_alchemy_certificate_panel.cc
36           batch_job_view.cc
37           check_box.cc
38           christie_certificate_panel.cc
39           cinema_dialog.cc
40           closed_captions_dialog.cc
41           colour_conversion_editor.cc
42           config_dialog.cc
43           config_move_dialog.cc
44           confirm_kdm_email_dialog.cc
45           content_advanced_dialog.cc
46           content_colour_conversion_dialog.cc
47           content_menu.cc
48           content_panel.cc
49           content_properties_dialog.cc
50           content_sub_panel.cc
51           content_version_dialog.cc
52           content_view.cc
53           controls.cc
54           credentials_download_certificate_panel.cc
55           custom_scale_dialog.cc
56           dcp_panel.cc
57           dcp_text_track_dialog.cc
58           dcpomatic_button.cc
59           dcpomatic_spin_ctrl.cc
60           dir_picker_ctrl.cc
61           disk_warning_dialog.cc
62           dkdm_dialog.cc
63           dkdm_output_panel.cc
64           dolby_doremi_certificate_panel.cc
65           download_certificate_dialog.cc
66           download_certificate_panel.cc
67           drive_wipe_warning_dialog.cc
68           email_dialog.cc
69           export_subtitles_dialog.cc
70           export_video_file_dialog.cc
71           extra_kdm_email_dialog.cc
72           file_picker_ctrl.cc
73           film_editor.cc
74           film_name_location_dialog.cc
75           film_viewer.cc
76           filter_dialog.cc
77           focus_manager.cc
78           fonts_dialog.cc
79           full_config_dialog.cc
80           full_language_tag_dialog.cc
81           gain_calculator_dialog.cc
82           gdc_certificate_panel.cc
83           gl_video_view.cc
84           hints_dialog.cc
85           html_dialog.cc
86           i18n_hook.cc
87           image_sequence_dialog.cc
88           instant_i18n_dialog.cc
89           interop_metadata_dialog.cc
90           job_manager_view.cc
91           job_view.cc
92           job_view_dialog.cc
93           kdm_advanced_dialog.cc
94           kdm_cpl_panel.cc
95           kdm_dialog.cc
96           kdm_output_panel.cc
97           kdm_timing_panel.cc
98           language_tag_dialog.cc
99           language_tag_widget.cc
100           kdm_choice.cc
101           make_chain_dialog.cc
102           markers.cc
103           markers_dialog.cc
104           markers_panel.cc
105           message_dialog.cc
106           metadata_dialog.cc
107           move_to_dialog.cc
108           nag_dialog.cc
109           name_format_editor.cc
110           new_dkdm_folder_dialog.cc
111           normal_job_view.cc
112           paste_dialog.cc
113           password_entry.cc
114           player_config_dialog.cc
115           player_information.cc
116           player_stress_tester.cc
117           playhead_to_timecode_dialog.cc
118           playhead_to_frame_dialog.cc
119           playlist_controls.cc
120           playlist_editor_config_dialog.cc
121           question_dialog.cc
122           rating_dialog.cc
123           qube_certificate_panel.cc
124           recipients_panel.cc
125           recipient_dialog.cc
126           recreate_chain_dialog.cc
127           repeat_dialog.cc
128           report_problem_dialog.cc
129           rename_template_dialog.cc
130           rgba_colour_picker.cc
131           save_template_dialog.cc
132           screen_dialog.cc
133           screens_panel.cc
134           self_dkdm_dialog.cc
135           send_i18n_dialog.cc
136           send_test_email_dialog.cc
137           server_dialog.cc
138           servers_list_dialog.cc
139           simple_video_view.cc
140           smpte_metadata_dialog.cc
141           standard_controls.cc
142           static_text.cc
143           subtitle_appearance_dialog.cc
144           suspender.cc
145           system_font_dialog.cc
146           system_information_dialog.cc
147           table_dialog.cc
148           templates_dialog.cc
149           text_panel.cc
150           text_view.cc
151           time_picker.cc
152           timer_display.cc
153           timecode.cc
154           timeline.cc
155           timeline_atmos_content_view.cc
156           timeline_content_view.cc
157           timeline_dialog.cc
158           timeline_audio_content_view.cc
159           timeline_labels_view.cc
160           timeline_text_content_view.cc
161           timeline_reels_view.cc
162           timeline_time_axis_view.cc
163           timeline_video_content_view.cc
164           timeline_view.cc
165           timing_panel.cc
166           try_unmount_dialog.cc
167           update_dialog.cc
168           verify_dcp_dialog.cc
169           verify_dcp_progress_dialog.cc
170           video_panel.cc
171           video_view.cc
172           video_waveform_dialog.cc
173           video_waveform_plot.cc
174           wx_util.cc
175           wx_signal_manager.cc
176           """
177
178 def configure(conf):
179
180     wx_libs = 'core,richtext,adv,html,xml,propgrid'
181
182     if conf.options.wx_config is not None:
183         wx_config = conf.options.wx_config
184         conf.check_cfg(msg='Checking for wxWidgets using %s' % wx_config,
185                        package='',
186                        path=wx_config,
187                        args='--cppflags --cxxflags --libs %s --gl-libs' % wx_libs,
188                        uselib_store='WXWIDGETS',
189                        mandatory=True)
190     else:
191         try:
192             wx_config = '/usr/lib64/wx/config/gtk2-unicode-3.0'
193             conf.check_cfg(msg='Checking for wxWidgets using gtk2-unicode-3.0',
194                            package='',
195                            path=wx_config,
196                            args='--cppflags --cxxflags --libs %s --gl-libs' % wx_libs,
197                            uselib_store='WXWIDGETS',
198                            mandatory=True)
199         except:
200             try:
201                 wx_config = 'wx-config-3.0-gtk2'
202                 conf.check_cfg(msg='Checking for wxWidgets using wx-config-3.0-gtk2',
203                                package='',
204                                path=wx_config,
205                                args='--cppflags --cxxflags --libs %s --gl-libs' % wx_libs,
206                                uselib_store='WXWIDGETS',
207                                mandatory=True)
208             except:
209                 wx_config = 'wx-config'
210                 conf.check_cfg(msg='Checking for wxWidgets using wx-config',
211                                package='',
212                                path=wx_config,
213                                args='--cppflags --cxxflags --libs %s --gl-libs' % wx_libs,
214                                uselib_store='WXWIDGETS',
215                                mandatory=True)
216
217     if conf.env.TARGET_LINUX:
218         conf.env.append_value('CXXFLAGS', ['-DGL_GLEXT_PROTOTYPES', '-DGLX_GLXEXT_PROTOTYPES'])
219     if conf.env.TARGET_WINDOWS_64 or conf.env.TARGET_WINDOWS_32:
220         conf.env.append_value('CXXFLAGS', ['-DWGL_WGLEXT_PROTOTYPES'])
221     conf.env.append_value('CXXFLAGS', ['-DwxNO_UNSAFE_WXSTRING_CONV'])
222
223     if conf.options.static_wxwidgets:
224         # wx-config returns its static libraries as full paths, without -l prefixes, which confuses
225         # check_cfg().  It puts the static libraries into LINKFLAGS_WXWIDGETS, so fish them out.
226         stlibs = []
227         new_linkflags = []
228         stlib_paths = []
229         for f in conf.env.LINKFLAGS_WXWIDGETS:
230             if f.startswith('/'):
231                 d = os.path.dirname(f)
232                 if not d in stlib_paths:
233                     stlib_paths.append(d)
234                 stlibs.append(os.path.basename(f)[3:-2])
235             else:
236                 new_linkflags.append(f)
237
238         conf.env.STLIB_WXWIDGETS = stlibs
239         conf.env.LINKFLAGS_WXWIDGETS = new_linkflags
240         conf.env.STLIBPATH_WXWIDGETS = stlib_paths
241
242     conf.in_msg = 1
243     wx_version = conf.check_cfg(package='wxwidgets', path=wx_config, args='--version').strip()
244     conf.in_msg = 0
245     if not wx_version.startswith('3.'):
246         conf.fatal('wxwidgets version 3.x.y is required; %s found' % wx_version)
247
248     config = conf.check_cfg(package='wxwidgets', path=wx_config, args='--selected-config').strip()
249     if config.find('gtk2') != -1:
250         conf.check_cfg(package='gtk+-2.0', args='--cflags --libs', uselib_store='GTK', mandatory=True)
251
252     try:
253         conf.check_cfg(msg='Checking for RtAudio using pkg-config',
254                        package='rtaudio',
255                        args='--cflags --libs',
256                        uselib_store='RTAUDIO',
257                        mandatory=True)
258     except:
259         conf.check_cfg(msg='Checking for RtAudio headers using rtaudio-config',
260                        package='',
261                        path='rtaudio-config',
262                        args='--cppflags',
263                        uselib_store='RTAUDIO',
264                        mandatory=True)
265
266         conf.check_cfg(msg='Checking for RtAudio libraries using rtaudio-config',
267                        package='',
268                        path='rtaudio-config',
269                        args='--libs',
270                        uselib_store='RTAUDIO',
271                        mandatory=True)
272
273     # Some rtaudio-configs don't include rtaudio as a link library.  Go figure.
274     conf.env.LIB_RTAUDIO.append('rtaudio')
275     if conf.env.TARGET_WINDOWS_64 or conf.env.TARGET_WINDOWS_32:
276         # Don't explicitly link with pthread on Windows
277         conf.env.CFLAGS_RTAUDIO.remove('-pthread')
278         conf.env.LINKFLAGS_RTAUDIO.remove('-pthread')
279         # We need some libraries for WASAPI
280         conf.env.LIB_RTAUDIO.append('mfplat')
281         conf.env.LIB_RTAUDIO.append('mfuuid')
282         conf.env.LIB_RTAUDIO.append('wmcodecdspuuid')
283
284     if conf.env.TARGET_WINDOWS_64 or conf.env.TARGET_WINDOWS_32 or conf.env.TARGET_LINUX:
285         conf.check_cfg(package='gl', args='--cflags --libs', uselib_store='GL', mandatory=True)
286         conf.check_cfg(package='glu', args='--cflags --libs', uselib_store='GLU', mandatory=True)
287         if conf.env.TARGET_WINDOWS_64 or conf.env.TARGET_WINDOWS_32:
288             conf.check_cfg(package='glew', args='--cflags --libs', uselib_store='GLEW', mandatory=True)
289     else:
290         conf.env.STLIB_GL = 'gl'
291         conf.env.STLIB_GLU = 'glu'
292
293     if conf.env.TARGET_LINUX:
294         conf.check_cxx(fragment="""
295                                 #include <wx/glcanvas.h>
296                                 #include <GL/glu.h>
297                                 #include <GL/glext.h>
298                                 #include <GL/glxext.h>
299                                 int main() {
300                                     glXSwapIntervalEXT (0, 0, 1);
301                                     return 0;
302                                 }
303                                 """,
304                        msg='Checking for glXSwapIntervalEXT',
305                        okmsg='yes',
306                        uselib='GL WXWIDGETS',
307                        define_name='DCPOMATIC_HAVE_GLX_SWAP_INTERVAL_EXT',
308                        mandatory=False)
309
310
311 def build(bld):
312     if bld.env.STATIC_DCPOMATIC:
313         obj = bld(features='cxx cxxstlib')
314     else:
315         obj = bld(features='cxx cxxshlib')
316
317     obj.name   = 'libdcpomatic2-wx'
318     obj.export_includes = ['..']
319     obj.uselib = 'BOOST_FILESYSTEM BOOST_THREAD BOOST_REGEX WXWIDGETS DCP SUB ZIP CXML RTAUDIO ICU '
320     if bld.env.TARGET_LINUX:
321         obj.uselib += 'GTK GL GLU '
322     if bld.env.TARGET_WINDOWS_64 or bld.env.TARGET_WINDOWS_32:
323         obj.uselib += 'WINSOCK2 OLE32 DSOUND WINMM KSUSER GL GLU GLEW '
324     if bld.env.TARGET_OSX:
325         obj.framework = ['CoreAudio', 'OpenGL']
326     obj.use = 'libdcpomatic2'
327     obj.source = sources
328     obj.target = 'dcpomatic2-wx'
329
330     i18n.po_to_mo(os.path.join('src', 'wx'), 'libdcpomatic2-wx', bld)
331
332 def pot(bld):
333     i18n.pot(os.path.join('src', 'wx'), sources + " editable_list.h content_widget.h", 'libdcpomatic-wx')
334
335 def pot_merge(bld):
336     i18n.pot_merge(os.path.join('src', 'wx'), 'libdcpomatic-wx')