blob: 2b619b1f1c6e1c8201809dfb220fcc83d060ccd6 [file] [log] [blame]
Alec Thileniusf79f52b2017-12-22 12:10:17 -07001project('mosys', 'c')
2
3# Include common. This is passed to all subdir build files as well
4include_common = include_directories(['include'])
5
6# Config data used for creating a config header and including it
7conf_data = configuration_data()
8
9# Set for all platforms
10conf_data.set('PROGRAM', '"mosys"')
11conf_data.set('VERSION', '"1.2.03"')
12conf_data.set('CONFIG_LITTLE_ENDIAN', 1)
13conf_data.set('CONFIG_LOGLEVEL', 4)
14conf_data.set('CONFIG_PLATFORM_EXPERIMENTAL', 1)
Alec Thileniusf79f52b2017-12-22 12:10:17 -070015use_cros_config = get_option('use_cros_config') == 'true'
16if use_cros_config
17 conf_data.set('CONFIG_CROS_CONFIG', 1)
18endif
19
20# Setting on a per-arch basis
21arch = get_option('arch')
22if arch == 'x86' or arch == 'x86_64' or arch == 'amd64'
23 conf_data.set('CONFIG_CHIPSET_INTEL', 1)
24 conf_data.set('CONFIG_CHIPSET_INTEL_LYNXPOINT_LP', 1)
25 conf_data.set('CONFIG_CHIPSET_INTEL_NM10', 1)
26 conf_data.set('CONFIG_CHIPSET_INTEL_SERIES6', 1)
27 conf_data.set('CONFIG_CROS_EC', 1)
28 conf_data.set('CONFIG_CROS_EC_LPC', 1)
29 conf_data.set('CONFIG_EC_ENE_KB932', 1)
30 conf_data.set('CONFIG_EC_ITE_IT8500', 1)
31 conf_data.set('CONFIG_EC_NUVOTON_NPCE781', 1)
32 conf_data.set('CONFIG_EC_SMSC_MEC1308', 1)
33 conf_data.set('CONFIG_EXPERIMENTAL_KIEV', 1)
34 conf_data.set('CONFIG_INTF_PORT_IO', 1)
35 conf_data.set('CONFIG_PLATFORM_ALEX', 1)
36 conf_data.set('CONFIG_PLATFORM_ARCH_X86', 1)
37 conf_data.set('CONFIG_PLATFORM_AURON', 1)
38 conf_data.set('CONFIG_PLATFORM_BELTINO', 1)
39 conf_data.set('CONFIG_PLATFORM_BUTTERFLY', 1)
40 conf_data.set('CONFIG_PLATFORM_CYAN', 1)
41 conf_data.set('CONFIG_PLATFORM_FIZZ', 1)
42 conf_data.set('CONFIG_PLATFORM_GLADOS', 1)
43 conf_data.set('CONFIG_PLATFORM_KAHLEE', 1)
44 conf_data.set('CONFIG_PLATFORM_LINK', 1)
45 conf_data.set('CONFIG_PLATFORM_LUMPY', 1)
46 conf_data.set('CONFIG_PLATFORM_MARIO', 1)
47 conf_data.set('CONFIG_PLATFORM_PARROT', 1)
48 conf_data.set('CONFIG_PLATFORM_RAMBI', 1)
49 conf_data.set('CONFIG_PLATFORM_REEF', 1)
50 conf_data.set('CONFIG_PLATFORM_SAMUS', 1)
51 conf_data.set('CONFIG_PLATFORM_SLIPPY', 1)
52 conf_data.set('CONFIG_PLATFORM_STOUT', 1)
53 conf_data.set('CONFIG_PLATFORM_STRAGO', 1)
54 conf_data.set('CONFIG_PLATFORM_STUMPY', 1)
55 conf_data.set('CONFIG_PLATFORM_ZGB', 1)
56 conf_data.set('CONFIG_SOC_INTEL_BAYTRAIL', 1)
57 conf_data.set('CONFIG_SOC_INTEL_BRASWELL', 1)
58 conf_data.set('CONFIG_STORAGE_SANDISK_U100', 1)
59 conf_data.set('CONFIG_SUPERIO_ITE_IT8772', 1)
Alec Thileniusf79f52b2017-12-22 12:10:17 -070060elif arch == 'mip'
61 conf_data.set('CONFIG_PLATFORM_ARCH_MIPSEL', 1)
62elif arch == 'arm'
63 conf_data.set('CONFIG_CROS_EC', 1)
64 conf_data.set('CONFIG_CROS_EC_I2C', 1)
65 conf_data.set('CONFIG_PLATFORM_ARCH_ARMEL', 1)
66 conf_data.set('CONFIG_PLATFORM_CYCLONE', 1)
67 conf_data.set('CONFIG_PLATFORM_DAISY', 1)
68 conf_data.set('CONFIG_PLATFORM_GRU', 1)
69 conf_data.set('CONFIG_PLATFORM_NYAN', 1)
70 conf_data.set('CONFIG_PLATFORM_OAK', 1)
71 conf_data.set('CONFIG_PLATFORM_PEACH', 1)
72 conf_data.set('CONFIG_PLATFORM_PINKY', 1)
73 conf_data.set('CONFIG_PLATFORM_SKATE', 1)
74 conf_data.set('CONFIG_PLATFORM_SMAUG', 1)
75 conf_data.set('CONFIG_PLATFORM_SPRING', 1)
76 conf_data.set('CONFIG_PLATFORM_STORM', 1)
77 conf_data.set('CONFIG_SOC_NVIDIA', 1)
78 conf_data.set('CONFIG_SOC_NVIDIA_TEGRA124', 1)
79 conf_data.set('CONFIG_SOC_SAMSUNG', 1)
80 conf_data.set('CONFIG_SOC_SAMSUNG_EXYNOS5250', 1)
81 conf_data.set('CONFIG_SOC_SAMSUNG_EXYNOS5420', 1)
82 conf_data.set('CONFIG_TRACKPAD_CYPRESS_APA', 1)
Alec Thileniusf79f52b2017-12-22 12:10:17 -070083endif
84
85# Create the config header file and include it by default while compiling
86configure_file(
87 output : 'config.h',
88 configuration : conf_data,
89)
90add_global_arguments('-include', 'config.h', language: 'c')
91
92# External libs used by Mosys
93fmap_dep = dependency('fmap')
94uuid_dep = dependency('uuid')
95
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -060096libmosys_src = files()
97
Alec Thileniusf79f52b2017-12-22 12:10:17 -070098# Subdirs with source to link against
99subdir('core')
100subdir('drivers')
101subdir('intf')
102subdir('lib')
103subdir('platform')
104
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -0600105deps = [
106 fmap_dep,
107 uuid_dep,
108]
109link_whole = []
110
111# Cros config is a special snowflake.
112if use_cros_config
113 libmosys_src += mosys_lib_cros_config_src
114 fdt_dep = meson.get_compiler('c').find_library('fdt')
115 deps += fdt_dep
116 dtb_lib = static_library(
117 'cros_config_dtb',
118 cros_config_dtb_src,
119 c_args: [
120 '-Itools/vpd_encode',
121 '-D__ASSEMBLY__',
122 '-c',
123 ],
124 link_args: [
125 '-znoexecstack',
126 '-r',
127 ],
128 )
129 link_whole += dtb_lib
130endif
131
Alec Thileniusf79f52b2017-12-22 12:10:17 -0700132# Lib momsys shared library target
133libmosys = static_library(
134 'mosys',
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -0600135 libmosys_src,
136 dependencies: deps,
Alec Thileniusf79f52b2017-12-22 12:10:17 -0700137 include_directories: include_common,
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -0600138 link_whole: link_whole,
139 pic: true,
Alec Thileniusf79f52b2017-12-22 12:10:17 -0700140)
141
142# Add static linking if static is set
143link_args = []
144if get_option('static') == 'true'
145 link_args += '-static'
146endif
147
148# Mosys dynamic executable
149executable(
150 'mosys',
151 ['mosys.c'],
152 include_directories: include_common,
153 link_args: link_args,
154 link_with: [libmosys],
155 install: true,
156 install_dir: '/usr/sbin',
157)
158
159# Mosys static executable. This will be removed by the ebuild if static is not
160# set, but is always built and installed first.
161executable(
162 'mosys_s',
163 ['mosys.c'],
164 include_directories: include_common,
165 link_args: ['-static'],
166 link_with: [libmosys],
167 install: true,
168 install_dir: '/usr/sbin',
169)
170
171# Import tests last, which can link against libmosys
172subdir('tests')