summaryrefslogtreecommitdiff
path: root/meson.build
blob: 723f03ab5fd349c8e0e091d21caeeda55ecce6ce (plain)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
project('e-module-weather', 'c',
  version: '0.1',
  license: 'BSD 2 clause',
  default_options: [ 'c_std=gnu99', 'warning_level=2' ],
  meson_version: '>= 0.46.0')

pkgconfig = import('pkgconfig')
cc = meson.get_compiler('c')

config_h = configuration_data()
config_h.set_quoted('GADGET_NAME', meson.project_name())



openweathermap_api_key = get_option('openweathermap-api-key')
config_h.set_quoted('OPENWEATHERMAP_API_KEY', openweathermap_api_key)



if get_option('sandbox')
  if get_option('home-install')
    error('A sandbox gadget can\'t be installed into home directory.')
  endif
else
  if get_option('test')
    error('Test option is attended to be used with sandbox gadget')
  endif
endif


dep_e = dependency('enlightenment')
release = dep_e.get_pkgconfig_variable('release')
host_os = host_machine.system()
if host_os == 'linux'
   if cc.has_header_symbol('features.h', '__UCLIBC__')
	 host_os = 'linux-uclibc'
   elif cc.has_header_symbol('features.h', '__dietlibc__')
	 host_os = 'linux-dietlibc'
   else
	 host_os = 'linux-gnu'
   endif
endif
module_arch = '@0@-@1@-@2@'.format(host_os, host_machine.cpu_family(), release)


desktop_data = configuration_data()
desktop_data.set('GADGET_VERSION', meson.project_version())
dir_prefix = dep_e.get_pkgconfig_variable('prefix')

if get_option('sandbox')
  dir_lib = join_paths(dir_prefix, get_option('libdir'))
  dir_gadgets = join_paths([dir_lib, 'enlightenment/gadgets', module_arch, 'weather'])
  dir_gadgets_e = join_paths([dir_lib, 'enlightenment/gadgets', module_arch])
else
  if get_option('home-install')
	pymodule = import('python')
	python = pymodule.find_installation()
	res = run_command(python, '-c', 'import os; print(os.environ["HOME"],end="")')
	if res.returncode() == 0
	  dir_home = res.stdout()
	  dir_gadgets = join_paths([dir_home, '.e/e/modules/weather'])
	else
	  # not found, do fallback
	endif
  else
	dir_gadgets = join_paths([dep_e.get_pkgconfig_variable('modules'), 'weather'])
  endif
endif

dir_locales = join_paths([dir_gadgets, 'locale'])
if get_option('sandbox')
  config_h.set_quoted('THEMEDIR', dir_gadgets)
  config_h.set('WEATHER_SANDBOX', '1')
  config_h.set_quoted('PACKAGE_LOCALE_DIR', dir_locales)
  if get_option('test')
	config_h.set('WEATHER_TEST', '1')
  endif
  desktop_data.set('E_GADGET_DIR', dir_gadgets_e)
endif

if get_option('sandbox')
  configure_file(input: 'weather.desktop.in',
    output: 'weather.desktop',
    install: true,
    install_dir: dir_gadgets,
    configuration: desktop_data)
  configure_file(input: 'weather_big.desktop.in',
    output: 'weather_big.desktop',
    install: true,
    install_dir: join_paths([dir_gadgets_e, 'weather_big']),
    configuration: desktop_data)
  configure_file(input: 'weather_map.desktop.in',
    output: 'weather_map.desktop',
    install: true,
    install_dir: join_paths([dir_gadgets_e, 'weather_map']),
    configuration: desktop_data)
else
  configure_file(input: 'module.desktop.in',
    output: 'module.desktop',
    install: true,
    install_dir: dir_gadgets,
    configuration: desktop_data)

endif


install_data('e-gadget-weather.edj',
             install_dir: dir_gadgets)

subdir('po')

deps = [
  dep_e,
  dep_intl,
  dependency('elementary')
  ]

configure_file(output       : 'config.h',
               install      : false,
               configuration: config_h)
subdir('src')