summaryrefslogtreecommitdiffstats
path: root/meson.build
blob: d34bf7d73964c2bcdfd08a41824df1744a185084 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
project('vaclaunch', 'c', meson_version : '>=1.1')

jansson_dep = dependency('jansson', required : true)
curl_dep = dependency('libcurl', required : true)

proj_inc = include_directories('include', '.')

platform_enum_names = {
  'windows': 'PLATFORM_WINDOWS',
  'osx': 'PLATFORM_OSX',
  'linux': 'PLATFORM_LINUX',
  'unknown': 'PLATFORM_UNKNOWN'
}

plat_os = get_option('launcher_os')
if plat_os == 'detect'
  if host_machine.system() == 'windows' or host_machine.system() == 'cygwin'
    plat_os = 'windows'
  elif host_machine.system() == 'osx'
    plat_os = 'osx'
  elif host_machine.system() == 'linux'
    plat_os = 'linux'
  else
    plat_os = 'unknown'
  endif

  message('Auto-detected launcher OS:', plat_os)
else
  message('Using launcher OS:', plat_os)
endif

plat_arch = get_option('launcher_arch')
if plat_arch == ''
  plat_arch = host_machine.cpu_family()
  if plat_arch == 'x86_64'
    # squash faulty arch regexes like 'x86' for detecting 32-bit systems
    plat_arch = 'amd64'
  endif

  message('Auto-detected launcher architecture:', plat_arch)
else
  message('Using launcher architecture:', plat_arch)
endif

plat_jre_arch = get_option('launcher_jre_arch')
if plat_jre_arch == ''
  plat_jre_arch = 'gamecore'

  if plat_os == 'windows'
    if plat_arch == 'amd64'
      plat_jre_arch = 'windows-x64'
    elif plat_arch == 'x86'
      plat_jre_arch = 'windows-x86'
    elif plat_arch == 'aarch64'
      plat_jre_arch = 'windows-arm64'
    endif
  elif plat_os == 'linux'
    if plat_arch == 'amd64'
      plat_jre_arch = 'linux'
    elif plat_arch == 'x86'
      plat_jre_arch = 'i386'
    endif
  elif plat_os == 'osx'
    if plat_arch == 'amd64'
      plat_jre_arch = 'mac-os'
    elif plat_arch == 'aarch64'
      plat_jre_arch = 'mac-os-arm64'
    endif
  endif

  message('Auto-detected launcher JRE architecture:', plat_jre_arch)
else
  message('Using launcher JRE architecture:', plat_jre_arch)
endif

platform_config = configuration_data()
platform_config.set_quoted('VL_OS_NAME', plat_os)
platform_config.set('VL_OS', platform_enum_names[plat_os])
platform_config.set_quoted('VL_ARCH_NAME', plat_arch)
platform_config.set_quoted('VL_JRE_ARCH', plat_jre_arch)
platform_config.set10('VL_ENDIAN_LITTLE', host_machine.endian() == 'little')
platform_config.set10('VL_ENDIAN_BIG', host_machine.endian() == 'big')

configure_file(
  configuration : platform_config,
  input : 'config.h.in',
  output : 'config.h')

subdir('lib')

executable('vl', files('main.c'),
  link_with : [ vaclaunch_libs.get_shared_lib() ],
  dependencies : [ curl_dep, jansson_dep ],
  include_directories : proj_inc)