subdir('scripts')

configure_file(
  input: 'orca_bin.py.in',
  output: 'orca',
  configuration: {
    'PYTHON': python3.full_path(),
    'prefix': get_option('prefix'),
    'libdir': python3.get_path('purelib').replace(python3.get_path('data'), get_option('prefix')),
  },
  install: true,
  install_dir: get_option('bindir'),
)

orca_i18n_py = configure_file(
  input: 'orca_i18n.py.in',
  output: '@BASENAME@',
  configuration: {
    'GETTEXT_PACKAGE': meson.project_name(),
    'localedir': get_option('localedir'),
    'prefix': get_option('prefix'),
  }
)

git = find_program('git', required: false)
if git.found()
  r = run_command('git', 'rev-parse', '--short', 'HEAD', check: false)
  revision = r.stdout().strip()
else
  revision = ''
endif

liblouis_dep = dependency('liblouis', required: false)
louis_tables_dir = liblouis_dep.get_variable(
  'tablesdir',
  default_value: ''
)

orca_platform_py = configure_file(
  input: 'orca_platform.py.in',
  output: '@BASENAME@',
  configuration: {
    'datadir': get_option('datadir'),
    'prefix': get_option('prefix'),
    'PACKAGE': meson.project_name(),
    'VERSION': meson.project_version(),
    'REVISION': revision,
    'LOUIS_TABLE_DIR': louis_tables_dir,
    'MATHCAT_RULES_DIR': mathcat_rules_dir,
  }
)

lib_sources = [
  '__init__.py',
  'acss.py',
  'action_presenter.py',
  'action_presenter_command_definitions.py',
  'ax_action.py',
  'ax_cache_manager.py',
  'ax_collection.py',
  'ax_component.py',
  'ax_device_manager.py',
  'ax_document.py',
  'ax_event_synthesizer.py',
  'ax_hypertext.py',
  'ax_object.py',
  'ax_selection.py',
  'ax_table.py',
  'ax_text.py',
  'ax_utilities.py',
  'ax_utilities_action.py',
  'ax_utilities_application.py',
  'ax_utilities_collection.py',
  'ax_utilities_component.py',
  'ax_utilities_debugging.py',
  'ax_utilities_document.py',
  'ax_utilities_event.py',
  'ax_utilities_hypertext.py',
  'ax_utilities_math.py',
  'ax_utilities_object.py',
  'ax_utilities_relation.py',
  'ax_utilities_role.py',
  'ax_utilities_selection.py',
  'ax_utilities_state.py',
  'ax_utilities_table.py',
  'ax_utilities_text.py',
  'ax_value.py',
  'braille.py',
  'braille_generator.py',
  'braille_presenter.py',
  'braille_presenter_command_definitions.py',
  'braille_presenter_preferences_grid.py',
  'braille_rolenames.py',
  'braille_monitor.py',
  'brltablenames.py',
  'bypass_mode_manager.py',
  'bypass_mode_manager_command_definitions.py',
  'caret_navigator.py',
  'caret_navigator_command_definitions.py',
  'chat_presenter.py',
  'chat_presenter_command_definitions.py',
  'chat_presenter_preferences_grid.py',
  'clipboard.py',
  'clipboard_command_definitions.py',
  'cmdnames.py',
  'colornames.py',
  'command.py',
  'command_manager.py',
  'command_manager_preferences_grid.py',
  'dbus_service.py',
  'debug.py',
  'debugging_tools_manager.py',
  'debugging_tools_manager_command_definitions.py',
  'document_presenter.py',
  'document_presenter_command_definitions.py',
  'document_presenter_preferences_grid.py',
  'event_manager.py',
  'extension.py',
  'extension_loader.py',
  'extension_loader_preferences_grid.py',
  'extension_preferences.py',
  'extension_preferences_dialog.py',
  'flat_review.py',
  'flat_review_finder.py',
  'flat_review_finder_command_definitions.py',
  'flat_review_presenter.py',
  'flat_review_presenter_command_definitions.py',
  'flat_review_presenter_preferences_grid.py',
  'focus_manager.py',
  'generator.py',
  'gsettings_registry.py',
  'guilabels.py',
  'input_event.py',
  'input_event_manager.py',
  'keybindings.py',
  'keynames.py',
  'label_inference.py',
  'language_utilities.py',
  'learn_mode_presenter.py',
  'learn_mode_presenter_command_definitions.py',
  'live_region_presenter.py',
  'live_region_presenter_command_definitions.py',
  'math_navigator.py',
  'math_navigator_command_definitions.py',
  'math_presenter.py',
  'math_presenter_preferences_grid.py',
  'messages.py',
  'mouse_presenter.py',
  'mouse_presenter_command_definitions.py',
  'mouse_presenter_preferences_grid.py',
  'notification_presenter.py',
  'notification_presenter_command_definitions.py',
  'object_navigator.py',
  'object_navigator_command_definitions.py',
  'object_properties.py',
  'orca.py',
  'orca_gui_helpers.py',
  'orca_gui_navlist.py',
  'orca_modifier_manager.py',
  'output_reader.py',
  'output_recorder.py',
  'phonnames.py',
  'preferences_grid_base.py',
  'preferences_window.py',
  'presentation_manager.py',
  'profile_manager.py',
  'profile_manager_command_definitions.py',
  'profile_manager_preferences_grid.py',
  'pronunciation_dictionary_manager.py',
  'pronunciation_dictionary_manager_preferences_grid.py',
  'say_all_presenter.py',
  'say_all_presenter_command_definitions.py',
  'say_all_presenter_preferences_grid.py',
  'screen_reader_manager.py',
  'screen_reader_manager_command_definitions.py',
  'script.py',
  'script_manager.py',
  'script_utilities.py',
  'sleep_mode_manager.py',
  'sleep_mode_manager_command_definitions.py',
  'sleep_mode_manager_preferences_grid.py',
  'sound.py',
  'sound_generator.py',
  'sound_presenter.py',
  'sound_presenter_preferences_grid.py',
  'speech_manager.py',
  'speech_manager_command_definitions.py',
  'speech_manager_preferences_grid.py',
  'speech_monitor.py',
  'speech_presenter.py',
  'speech_presenter_command_definitions.py',
  'speech_presenter_preferences_grid.py',
  'spellcheck_presenter.py',
  'spellcheck_presenter_preferences_grid.py',
  'speechdispatcherfactory.py',
  'speech_generator.py',
  'speechserver.py',
  'spiel.py',
  'ssml.py',
  'structural_navigator.py',
  'structural_navigator_command_definitions.py',
  'systemd.py',
  'system_information_presenter.py',
  'system_information_presenter_command_definitions.py',
  'system_information_presenter_preferences_grid.py',
  'table_navigator.py',
  'table_navigator_command_definitions.py',
  'text_attribute_manager.py',
  'text_attribute_manager_preferences_grid.py',
  'text_attribute_names.py',
  'typing_echo_presenter.py',
  'typing_echo_presenter_command_definitions.py',
  'typing_echo_presenter_preferences_grid.py',
  'where_am_i_presenter.py',
  'where_am_i_presenter_command_definitions.py',
]

python3.install_sources(
  [ lib_sources, orca_i18n_py, orca_platform_py ],
  subdir: meson.project_name())
