################################################################################
# Meson siril file
################################################################################

siril_inc_dir = include_directories('.')

################################################################################
# Generate configuration files

configure_file(
  input : 'git-version.h.in',
  output : 'git-version.h',
  configuration : git_data
)

configure_file(output : 'config.h',
               configuration : conf_data)

################################################################################
# Generate Siril static library with all sources

src_files = [
  'algos/anscombe.c',
  'algos/astrometry_solver.c',
  'algos/background_extraction.c',
  'algos/ccd-inspector.c',
  'algos/colors.c',
  'algos/comparison_stars.c',
  'algos/demosaicing.c',
  'algos/demosaicing_rtp.cpp',
  'algos/extraction.c',
  'algos/fitting.c',
  'algos/fix_xtrans_af.c',
  'algos/geometry.c',
  'algos/io_wave.c',
  'algos/median_fast.c',
  'algos/noise.c',
  'algos/pave.c',
  'algos/photometry.c',
  'algos/photometric_cc.c',
  'algos/spcc.c',
  'algos/PSF.c',
  'algos/quality.c',
  'algos/quality_float.c',
  'algos/quantize.c',
  'algos/reconstr.c',
  'algos/siril_random.cpp',
  'algos/siril_wcs.c',
  'algos/sorting.c',
  'algos/star_finder.c',
  'algos/statistics.c',
  'algos/statistics_float.c',
  'algos/transform.c',
  'algos/search_objects.c',
  'algos/lcms_acceleration/fast_16_tethra.c',
  'algos/lcms_acceleration/fast_8_curves.c',
  'algos/lcms_acceleration/fast_8_matsh.c',
  'algos/lcms_acceleration/fast_8_matsh_sse.c',
  'algos/lcms_acceleration/fast_8_tethra.c',
  'algos/lcms_acceleration/fast_float_15bits.c',
  'algos/lcms_acceleration/fast_float_15mats.c',
  'algos/lcms_acceleration/fast_float_cmyk.c',
  'algos/lcms_acceleration/fast_float_curves.c',
  'algos/lcms_acceleration/fast_float_lab.c',
  'algos/lcms_acceleration/fast_float_matsh.c',
  'algos/lcms_acceleration/fast_float_separate.c',
  'algos/lcms_acceleration/fast_float_sup.c',
  'algos/lcms_acceleration/fast_float_tethra.c',
  'algos/lcms_acceleration/threaded_core.c',
  'algos/lcms_acceleration/threaded_main.c',
  'algos/lcms_acceleration/threaded_scheduler.c',
  'algos/lcms_acceleration/threaded_split.c',

  'compositing/align_rgb.c',
  'compositing/compositing.c',
  'compositing/filters.c',

  'core/arithm.c',
  'core/command.c',
  'core/command_line_processor.c',
  'core/exif.cpp',
  'core/icc_profile.c',
  'core/initfile.c',
  'core/OS_utils.c',
  'core/pipe.c',
  'core/preprocess.c',
  'core/processing.c',
  'core/sequence_filtering.c',
  'core/settings.c',
  'core/signals.c',
  'core/siril.c',
  'core/siril_actions.c',
  'core/siril_alloc.c',
  'core/siril_app_dirs.c',
  'core/siril_cmd_help.c',
  'core/siril_date.c',
  'core/siril_language.c',
  'core/siril_log.c',
  'core/siril_networking.c',
  'core/siril_spawn.c',
  'core/siril_update.c',
  'core/siril_world_cs.c',
  'core/undo.c',
  'core/utils.c',

  'drizzle/cdrizzlebox.c',
  'drizzle/cdrizzlemap.c',
  'drizzle/cdrizzleutil.c',

  'filters/asinh.c',
  'filters/banding.c',
  'filters/clahe.c',
  'filters/cosmetic_correction.c',
  'filters/curve_transform.c',
  'filters/deconvolution.c',
  'filters/epf.c',
  'filters/fft.c',
  'filters/ght.c',
  'filters/linear_match.c',
  'filters/median.c',
  'filters/mtf.c',
  'filters/rgradient.c',
  'filters/saturation.c',
  'filters/scnr.c',
  'filters/starnet.c',
  'filters/synthstar.c',
  'filters/unpurple.c',
  'filters/wavelets.c',

  'filters/da3d/DA3D.cpp',
  'filters/da3d/Utils.cpp',
  'filters/da3d/WeightMap.cpp',
  'filters/nlbayes/call_nlbayes.cpp',
  'filters/nlbayes/LibImages.cpp',
  'filters/nlbayes/LibMatrix.cpp',
  'filters/nlbayes/NlBayes.cpp',
  'filters/nlbayes/Utilities.cpp',

  'filters/deconvolution/angleSet.cpp',
  'filters/deconvolution/better_than_std.hpp',
  'filters/deconvolution/deconvolution.h',
  'filters/deconvolution/deconvolve.cpp',
  'filters/deconvolution/deconvolve.hpp',
  'filters/deconvolution/edgetaper.hpp',
  'filters/deconvolution/estimate_kernel.cpp',
  'filters/deconvolution/fft.hpp',
  'filters/deconvolution/fftw_allocator.hpp',
  'filters/deconvolution/gf_estimate.cpp',
  'filters/deconvolution/image_expr.hpp',
  'filters/deconvolution/image.hpp',
  'filters/deconvolution/labeling.hpp',
  'filters/deconvolution/optimization.hpp',
  'filters/deconvolution/options.hpp',
  'filters/deconvolution/utils.hpp',
  'filters/deconvolution/vec2.hpp',

  'io/aavso_extended.c',
  'io/annotation_catalogues.c',
  'io/Astro-TIFF.c',
  'io/avi_pipp/pipp_avi_write.cpp',
  'io/avi_pipp/pipp_avi_write.h',
  'io/avi_pipp/pipp_avi_write_dib.cpp',
  'io/avi_pipp/pipp_avi_write_dib.h',
  'io/avi_pipp/pipp_utf8.h',
  'io/avi_pipp/pipp_buffer.cpp',
  'io/avi_pipp/pipp_buffer.h',
  'io/avi_pipp/pipp_video_write.h',
  'io/avi_pipp/avi_writer.cpp',
  'io/avi_pipp/avi_writer.h',
  'io/kstars/htmesh_wrapper.cpp',
  'io/conversion.c',
  'io/films.c',
  'io/fits_keywords.c',
  'io/fits_sequence.c',
  'io/FITS_symlink.c',
  'io/healpix/healpix.cpp',
  'io/image_format_fits.c',
  'io/image_formats_internal.c',
  'io/image_formats_libraries.c',
  'io/local_catalogues.c',
  'io/mp4_output.c',
  'io/path_parse.c',
  'io/remote_catalogues.c',
  'io/seqfile.c',
  'io/sequence.c',
  'io/sequence_export.c',
  'io/seqwriter.c',
  'io/ser.c',
  'io/single_image.c',
  'io/siril_catalogues.c',
  'io/siril_git.c',
  'io/siril_plot.c',
  'io/siril_pythoncommands.c',
  'io/siril_pythonmodule.c',
  'io/SirilXISFReader.cpp',
  'io/SirilJpegXLWrapper.cpp',
  'io/spcc_json.c',

  'livestacking/gui.c',
  'livestacking/livestacking.c',

  'opencv/opencv.cpp',
  'opencv/opencv.h',
  'opencv/guidedfilter.cpp',
  'opencv/guidedfilter.h',
  'opencv/kombat/kombat.cpp',
  'opencv/kombat/kombat.h',

  'gui/about_dialog.c',
  'gui/annotate.c',
  'gui/annotations_pref.c',
  'gui/astrometry_solver.c',
  'gui/denoisegui.c',
  'gui/background_extraction.c',
  'gui/callbacks.c',
  'gui/colors.c',
  'gui/compstars.c',
  'gui/conversion.c',
  'gui/curves.c',
  'gui/cut.c',
  'gui/dialog_preview.c',
  'gui/dialogs.c',
  'gui/documentation.c',
  'gui/epf.c',
  'gui/fix_xtrans_af.c',
  'gui/git_gui.c',
  'gui/histogram.c',
  'gui/keywords_tree.c',
  'gui/icc_profile.c',
  'gui/image_display.c',
  'gui/image_interactions.c',
  'gui/linear_match.c',
  'gui/menu_gray_geometry.c',
  'gui/menu_gray_selection.c',
  'gui/merge_cfa.c',
  'gui/message_dialog.c',
  'gui/mouse_action_functions.c',
  'gui/mouse_action_preferences.c',
  'gui/newdeconv.c',
  'gui/nina_light_curve.c',
  'gui/open_dialog.c',
  'gui/photometric_cc.c',
  'gui/plot.c',
  'gui/preferences.c',
  'gui/progress_and_log.c',
  'gui/PSF_list.c',
  'gui/python_gui.c',
  'gui/registration.c',
  'gui/registration_preview.c',
  'gui/remixer.c',
  'gui/save_dialog.c',
  'gui/script_menu.c',
  'gui/sequence_list.c',
  'gui/single_image.c',
  'gui/siril_css.c',
  'gui/siril_intro.c',
  'gui/siril_preview.c',
  'gui/siril_plot.c',
  'gui/siril-window.c',
  'gui/split_cfa.c',
  'gui/stacking.c',
  'gui/star_finder.c',
  'gui/starnetgui.c',
  'gui/statistics_list.c',
  'gui/unpurple.c',
  'gui/user_polygons.c',
  'gui/utils.c',

  'pixelMath/pixel_math_runner.c',
  'pixelMath/tinyexpr.c',

  'registration/3stars.c',
  'registration/comet.c',
  'registration/global.c',
  'registration/matching/match.c',
  'registration/matching/atpmatch.c',
  'registration/matching/misc.c',
  'registration/matching/apply_match.c',
  'registration/astrometric.c',
  'registration/distorsion.c',
  'registration/registration.c',
  'registration/applyreg.c',
  'registration/shift_methods.c',

  'stacking/blending.c',
  'stacking/median_and_mean.c',
  'stacking/normalization.c',
  'stacking/rejection_float.c',
  'stacking/siril_fit_linear.c',
  'stacking/stacking.c',
  'stacking/stackminmax.c',
  'stacking/sum.c',
  'stacking/upscaling.c',

  'rt/boxblur.cc',
  'rt/gauss.cc',
  'rt/rt_algo.cc'
]

# Define the resource file
gnome = import('gnome')
siril_resources = gnome.compile_resources(
  'siril_resource', 'siril_resource.xml',
  source_dir : [ '..', '.' ],
  c_name : 'siril_resource')

siril_lib = static_library('siril',
                           siril_resources[0], src_files,
                           dependencies: externals_dep,
                           include_directories: siril_inc_dir,
                           c_args : siril_c_flag,
                           cpp_args : siril_cpp_flag)

siril_dep = declare_dependency(link_with: siril_lib,
                               dependencies: externals_dep,
                               include_directories: siril_inc_dir)

# Custom target for glib-compile-resources

################################################################################
# Build gui executable

siril_gui = executable('siril', siril_resources[1], 'main.c', win_res,
                       dependencies: siril_dep,
                       link_whole: siril_lib,
                       link_args : siril_link_arg,
                       c_args : siril_c_flag,
                       cpp_args : siril_cpp_flag,
                       install : true,
                       win_subsystem : 'console',
                      )

################################################################################
# Build cli executable

siril_cli = executable('siril-cli', 'main-cli.c', win_res,
                       dependencies: siril_dep,
                       link_whole: siril_lib,
                       link_args : siril_link_arg,
                       c_args : siril_c_flag,
                       cpp_args : siril_cpp_flag,
                       install : true
                      )

################################################################################
# Tests

subdir('tests')
