blob: c7c3fac2e7687e8ea61f1638c1609dc7e4ef3965 [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)
Jason D. Clintona7fd67d2018-04-17 13:34:08 -060015use_cros_config = get_option('use_cros_config') == true
Alec Thileniusf79f52b2017-12-22 12:10:17 -070016if 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'
Alec Thileniusf79f52b2017-12-22 12:10:17 -070023 conf_data.set('CONFIG_PLATFORM_ARCH_X86', 1)
Alec Thileniusf79f52b2017-12-22 12:10:17 -070024elif arch == 'mip'
25 conf_data.set('CONFIG_PLATFORM_ARCH_MIPSEL', 1)
26elif arch == 'arm'
Alec Thileniusf79f52b2017-12-22 12:10:17 -070027 conf_data.set('CONFIG_PLATFORM_ARCH_ARMEL', 1)
Alec Thileniusf79f52b2017-12-22 12:10:17 -070028endif
29
30# Create the config header file and include it by default while compiling
31configure_file(
32 output : 'config.h',
33 configuration : conf_data,
34)
35add_global_arguments('-include', 'config.h', language: 'c')
Jason D. Clintona7fd67d2018-04-17 13:34:08 -060036add_global_arguments('-std=gnu99', language : 'c')
Alec Thileniusf79f52b2017-12-22 12:10:17 -070037
Brian Norrise11e08f2018-04-30 10:46:48 -070038cc = meson.get_compiler('c')
39if (cc.has_argument('-Wno-address-of-packed-member'))
40 add_global_arguments(['-Wno-address-of-packed-member'], language: 'c')
41endif
42
Alec Thileniusf79f52b2017-12-22 12:10:17 -070043# External libs used by Mosys
44fmap_dep = dependency('fmap')
45uuid_dep = dependency('uuid')
46
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -060047libmosys_src = files()
48
Alec Thileniusf79f52b2017-12-22 12:10:17 -070049# Subdirs with source to link against
50subdir('core')
51subdir('drivers')
52subdir('intf')
53subdir('lib')
54subdir('platform')
55
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -060056deps = [
57 fmap_dep,
58 uuid_dep,
59]
60link_whole = []
Jason D. Clintona236cdf2018-04-22 18:32:02 -060061objects = []
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -060062
63# Cros config is a special snowflake.
64if use_cros_config
65 libmosys_src += mosys_lib_cros_config_src
66 fdt_dep = meson.get_compiler('c').find_library('fdt')
67 deps += fdt_dep
68 dtb_lib = static_library(
69 'cros_config_dtb',
70 cros_config_dtb_src,
71 c_args: [
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -060072 '-D__ASSEMBLY__',
73 '-c',
74 ],
75 link_args: [
76 '-znoexecstack',
77 '-r',
78 ],
79 )
80 link_whole += dtb_lib
Jason D. Clintona236cdf2018-04-22 18:32:02 -060081 objects = dtb_lib.extract_all_objects()
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -060082endif
83
Alec Thileniusf79f52b2017-12-22 12:10:17 -070084# Lib momsys shared library target
85libmosys = static_library(
86 'mosys',
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -060087 libmosys_src,
88 dependencies: deps,
Alec Thileniusf79f52b2017-12-22 12:10:17 -070089 include_directories: include_common,
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -060090 link_whole: link_whole,
Jason D. Clintona236cdf2018-04-22 18:32:02 -060091 objects: objects,
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -060092 pic: true,
Alec Thileniusf79f52b2017-12-22 12:10:17 -070093)
94
95# Add static linking if static is set
96link_args = []
Jason D. Clintona7fd67d2018-04-17 13:34:08 -060097if get_option('static') == true
Alec Thileniusf79f52b2017-12-22 12:10:17 -070098 link_args += '-static'
99endif
100
101# Mosys dynamic executable
102executable(
103 'mosys',
104 ['mosys.c'],
105 include_directories: include_common,
106 link_args: link_args,
107 link_with: [libmosys],
108 install: true,
109 install_dir: '/usr/sbin',
110)
111
112# Mosys static executable. This will be removed by the ebuild if static is not
113# set, but is always built and installed first.
114executable(
115 'mosys_s',
116 ['mosys.c'],
117 include_directories: include_common,
118 link_args: ['-static'],
119 link_with: [libmosys],
120 install: true,
121 install_dir: '/usr/sbin',
122)